babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. /**
  95. * User defined information that will be sent to observers
  96. */
  97. userInfo?: any;
  98. }
  99. /**
  100. * Represent an Observer registered to a given Observable object.
  101. */
  102. export class Observer<T> {
  103. /**
  104. * Defines the callback to call when the observer is notified
  105. */
  106. callback: (eventData: T, eventState: EventState) => void;
  107. /**
  108. * Defines the mask of the observer (used to filter notifications)
  109. */
  110. mask: number;
  111. /**
  112. * Defines the current scope used to restore the JS context
  113. */
  114. scope: any;
  115. /** @hidden */
  116. _willBeUnregistered: boolean;
  117. /**
  118. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  119. */
  120. unregisterOnNextCall: boolean;
  121. /**
  122. * Creates a new observer
  123. * @param callback defines the callback to call when the observer is notified
  124. * @param mask defines the mask of the observer (used to filter notifications)
  125. * @param scope defines the current scope used to restore the JS context
  126. */
  127. constructor(
  128. /**
  129. * Defines the callback to call when the observer is notified
  130. */
  131. callback: (eventData: T, eventState: EventState) => void,
  132. /**
  133. * Defines the mask of the observer (used to filter notifications)
  134. */
  135. mask: number,
  136. /**
  137. * Defines the current scope used to restore the JS context
  138. */
  139. scope?: any);
  140. }
  141. /**
  142. * Represent a list of observers registered to multiple Observables object.
  143. */
  144. export class MultiObserver<T> {
  145. private _observers;
  146. private _observables;
  147. /**
  148. * Release associated resources
  149. */
  150. dispose(): void;
  151. /**
  152. * Raise a callback when one of the observable will notify
  153. * @param observables defines a list of observables to watch
  154. * @param callback defines the callback to call on notification
  155. * @param mask defines the mask used to filter notifications
  156. * @param scope defines the current scope used to restore the JS context
  157. * @returns the new MultiObserver
  158. */
  159. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  160. }
  161. /**
  162. * The Observable class is a simple implementation of the Observable pattern.
  163. *
  164. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  165. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  166. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  167. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  168. */
  169. export class Observable<T> {
  170. private _observers;
  171. private _eventState;
  172. private _onObserverAdded;
  173. /**
  174. * Gets the list of observers
  175. */
  176. get observers(): Array<Observer<T>>;
  177. /**
  178. * Creates a new observable
  179. * @param onObserverAdded defines a callback to call when a new observer is added
  180. */
  181. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  182. /**
  183. * Create a new Observer with the specified callback
  184. * @param callback the callback that will be executed for that Observer
  185. * @param mask the mask used to filter observers
  186. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  187. * @param scope optional scope for the callback to be called from
  188. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  189. * @returns the new observer created for the callback
  190. */
  191. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  192. /**
  193. * Create a new Observer with the specified callback and unregisters after the next notification
  194. * @param callback the callback that will be executed for that Observer
  195. * @returns the new observer created for the callback
  196. */
  197. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  198. /**
  199. * Remove an Observer from the Observable object
  200. * @param observer the instance of the Observer to remove
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. remove(observer: Nullable<Observer<T>>): boolean;
  204. /**
  205. * Remove a callback from the Observable object
  206. * @param callback the callback to remove
  207. * @param scope optional scope. If used only the callbacks with this scope will be removed
  208. * @returns false if it doesn't belong to this Observable
  209. */
  210. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  211. private _deferUnregister;
  212. private _remove;
  213. /**
  214. * Moves the observable to the top of the observer list making it get called first when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverTopPriority(observer: Observer<T>): void;
  218. /**
  219. * Moves the observable to the bottom of the observer list making it get called last when notified
  220. * @param observer the observer to move
  221. */
  222. makeObserverBottomPriority(observer: Observer<T>): void;
  223. /**
  224. * Notify all Observers by calling their respective callback with the given data
  225. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  226. * @param eventData defines the data to send to all observers
  227. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  228. * @param target defines the original target of the state
  229. * @param currentTarget defines the current target of the state
  230. * @param userInfo defines any user info to send to observers
  231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  232. */
  233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  234. /**
  235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  238. * and it is crucial that all callbacks will be executed.
  239. * The order of the callbacks is kept, callbacks are not executed parallel.
  240. *
  241. * @param eventData The data to be sent to each callback
  242. * @param mask is used to filter observers defaults to -1
  243. * @param target defines the callback target (see EventState)
  244. * @param currentTarget defines he current object in the bubbling phase
  245. * @param userInfo defines any user info to send to observers
  246. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  247. */
  248. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  249. /**
  250. * Notify a specific observer
  251. * @param observer defines the observer to notify
  252. * @param eventData defines the data to be sent to each callback
  253. * @param mask is used to filter observers defaults to -1
  254. */
  255. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  256. /**
  257. * Gets a boolean indicating if the observable has at least one observer
  258. * @returns true is the Observable has at least one Observer registered
  259. */
  260. hasObservers(): boolean;
  261. /**
  262. * Clear the list of observers
  263. */
  264. clear(): void;
  265. /**
  266. * Clone the current observable
  267. * @returns a new observable
  268. */
  269. clone(): Observable<T>;
  270. /**
  271. * Does this observable handles observer registered with a given mask
  272. * @param mask defines the mask to be tested
  273. * @return whether or not one observer registered with the given mask is handeled
  274. **/
  275. hasSpecificMask(mask?: number): boolean;
  276. }
  277. }
  278. declare module "babylonjs/Misc/domManagement" {
  279. /**
  280. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  281. * Babylon.js
  282. */
  283. export class DomManagement {
  284. /**
  285. * Checks if the window object exists
  286. * @returns true if the window object exists
  287. */
  288. static IsWindowObjectExist(): boolean;
  289. /**
  290. * Checks if the navigator object exists
  291. * @returns true if the navigator object exists
  292. */
  293. static IsNavigatorAvailable(): boolean;
  294. /**
  295. * Check if the document object exists
  296. * @returns true if the document object exists
  297. */
  298. static IsDocumentAvailable(): boolean;
  299. /**
  300. * Extracts text content from a DOM element hierarchy
  301. * @param element defines the root element
  302. * @returns a string
  303. */
  304. static GetDOMTextContent(element: HTMLElement): string;
  305. }
  306. }
  307. declare module "babylonjs/Misc/logger" {
  308. /**
  309. * Logger used througouht the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. private static _LogCache;
  334. /**
  335. * Gets a value indicating the number of loading errors
  336. * @ignorenaming
  337. */
  338. static errorsCount: number;
  339. /**
  340. * Callback called when a new log is added
  341. */
  342. static OnNewCacheEntry: (entry: string) => void;
  343. private static _AddLogEntry;
  344. private static _FormatMessage;
  345. private static _LogDisabled;
  346. private static _LogEnabled;
  347. private static _WarnDisabled;
  348. private static _WarnEnabled;
  349. private static _ErrorDisabled;
  350. private static _ErrorEnabled;
  351. /**
  352. * Log a message to the console
  353. */
  354. static Log: (message: string) => void;
  355. /**
  356. * Write a warning message to the console
  357. */
  358. static Warn: (message: string) => void;
  359. /**
  360. * Write an error message to the console
  361. */
  362. static Error: (message: string) => void;
  363. /**
  364. * Gets current log cache (list of logs)
  365. */
  366. static get LogCache(): string;
  367. /**
  368. * Clears the log cache
  369. */
  370. static ClearLogCache(): void;
  371. /**
  372. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  373. */
  374. static set LogLevels(level: number);
  375. }
  376. }
  377. declare module "babylonjs/Misc/typeStore" {
  378. /** @hidden */
  379. export class _TypeStore {
  380. /** @hidden */
  381. static RegisteredTypes: {
  382. [key: string]: Object;
  383. };
  384. /** @hidden */
  385. static GetClass(fqdn: string): any;
  386. }
  387. }
  388. declare module "babylonjs/Misc/stringTools" {
  389. /**
  390. * Helper to manipulate strings
  391. */
  392. export class StringTools {
  393. /**
  394. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static EndsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static StartsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Decodes a buffer into a string
  409. * @param buffer The buffer to decode
  410. * @returns The decoded string
  411. */
  412. static Decode(buffer: Uint8Array | Uint16Array): string;
  413. /**
  414. * Encode a buffer to a base64 string
  415. * @param buffer defines the buffer to encode
  416. * @returns the encoded string
  417. */
  418. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  419. /**
  420. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  421. * @param num the number to convert and pad
  422. * @param length the expected length of the string
  423. * @returns the padded string
  424. */
  425. static PadNumber(num: number, length: number): string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/deepCopier" {
  429. /**
  430. * Class containing a set of static utilities functions for deep copy.
  431. */
  432. export class DeepCopier {
  433. /**
  434. * Tries to copy an object by duplicating every property
  435. * @param source defines the source object
  436. * @param destination defines the target object
  437. * @param doNotCopyList defines a list of properties to avoid
  438. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  439. */
  440. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  441. }
  442. }
  443. declare module "babylonjs/Misc/precisionDate" {
  444. /**
  445. * Class containing a set of static utilities functions for precision date
  446. */
  447. export class PrecisionDate {
  448. /**
  449. * Gets either window.performance.now() if supported or Date.now() else
  450. */
  451. static get Now(): number;
  452. }
  453. }
  454. declare module "babylonjs/Misc/devTools" {
  455. /** @hidden */
  456. export class _DevTools {
  457. static WarnImport(name: string): string;
  458. }
  459. }
  460. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  461. /**
  462. * Interface used to define the mechanism to get data from the network
  463. */
  464. export interface IWebRequest {
  465. /**
  466. * Returns client's response url
  467. */
  468. responseURL: string;
  469. /**
  470. * Returns client's status
  471. */
  472. status: number;
  473. /**
  474. * Returns client's status as a text
  475. */
  476. statusText: string;
  477. }
  478. }
  479. declare module "babylonjs/Misc/webRequest" {
  480. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  481. import { Nullable } from "babylonjs/types";
  482. /**
  483. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  484. */
  485. export class WebRequest implements IWebRequest {
  486. private _xhr;
  487. /**
  488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  489. * i.e. when loading files, where the server/service expects an Authorization header
  490. */
  491. static CustomRequestHeaders: {
  492. [key: string]: string;
  493. };
  494. /**
  495. * Add callback functions in this array to update all the requests before they get sent to the network
  496. */
  497. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  498. private _injectCustomRequestHeaders;
  499. /**
  500. * Gets or sets a function to be called when loading progress changes
  501. */
  502. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  503. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  504. /**
  505. * Returns client's state
  506. */
  507. get readyState(): number;
  508. /**
  509. * Returns client's status
  510. */
  511. get status(): number;
  512. /**
  513. * Returns client's status as a text
  514. */
  515. get statusText(): string;
  516. /**
  517. * Returns client's response
  518. */
  519. get response(): any;
  520. /**
  521. * Returns client's response url
  522. */
  523. get responseURL(): string;
  524. /**
  525. * Returns client's response as text
  526. */
  527. get responseText(): string;
  528. /**
  529. * Gets or sets the expected response type
  530. */
  531. get responseType(): XMLHttpRequestResponseType;
  532. set responseType(value: XMLHttpRequestResponseType);
  533. /** @hidden */
  534. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  535. /** @hidden */
  536. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  537. /**
  538. * Cancels any network activity
  539. */
  540. abort(): void;
  541. /**
  542. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  543. * @param body defines an optional request body
  544. */
  545. send(body?: Document | BodyInit | null): void;
  546. /**
  547. * Sets the request method, request URL
  548. * @param method defines the method to use (GET, POST, etc..)
  549. * @param url defines the url to connect with
  550. */
  551. open(method: string, url: string): void;
  552. /**
  553. * Sets the value of a request header.
  554. * @param name The name of the header whose value is to be set
  555. * @param value The value to set as the body of the header
  556. */
  557. setRequestHeader(name: string, value: string): void;
  558. /**
  559. * Get the string containing the text of a particular header's value.
  560. * @param name The name of the header
  561. * @returns The string containing the text of the given header name
  562. */
  563. getResponseHeader(name: string): Nullable<string>;
  564. }
  565. }
  566. declare module "babylonjs/Misc/fileRequest" {
  567. import { Observable } from "babylonjs/Misc/observable";
  568. /**
  569. * File request interface
  570. */
  571. export interface IFileRequest {
  572. /**
  573. * Raised when the request is complete (success or error).
  574. */
  575. onCompleteObservable: Observable<IFileRequest>;
  576. /**
  577. * Aborts the request for a file.
  578. */
  579. abort: () => void;
  580. }
  581. }
  582. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  583. /**
  584. * Define options used to create a render target texture
  585. */
  586. export class RenderTargetCreationOptions {
  587. /**
  588. * Specifies is mipmaps must be generated
  589. */
  590. generateMipMaps?: boolean;
  591. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  592. generateDepthBuffer?: boolean;
  593. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  594. generateStencilBuffer?: boolean;
  595. /** Defines texture type (int by default) */
  596. type?: number;
  597. /** Defines sampling mode (trilinear by default) */
  598. samplingMode?: number;
  599. /** Defines format (RGBA by default) */
  600. format?: number;
  601. }
  602. }
  603. declare module "babylonjs/Engines/constants" {
  604. /** Defines the cross module used constants to avoid circular dependncies */
  605. export class Constants {
  606. /** Defines that alpha blending is disabled */
  607. static readonly ALPHA_DISABLE: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  609. static readonly ALPHA_ADD: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_COMBINE: number;
  612. /** Defines that alpha blending is DEST - SRC * DEST */
  613. static readonly ALPHA_SUBTRACT: number;
  614. /** Defines that alpha blending is SRC * DEST */
  615. static readonly ALPHA_MULTIPLY: number;
  616. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  617. static readonly ALPHA_MAXIMIZED: number;
  618. /** Defines that alpha blending is SRC + DEST */
  619. static readonly ALPHA_ONEONE: number;
  620. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  621. static readonly ALPHA_PREMULTIPLIED: number;
  622. /**
  623. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  624. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  625. */
  626. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  627. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  628. static readonly ALPHA_INTERPOLATE: number;
  629. /**
  630. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  631. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  632. */
  633. static readonly ALPHA_SCREENMODE: number;
  634. /**
  635. * Defines that alpha blending is SRC + DST
  636. * Alpha will be set to SRC ALPHA + DST ALPHA
  637. */
  638. static readonly ALPHA_ONEONE_ONEONE: number;
  639. /**
  640. * Defines that alpha blending is SRC * DST ALPHA + DST
  641. * Alpha will be set to 0
  642. */
  643. static readonly ALPHA_ALPHATOCOLOR: number;
  644. /**
  645. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  646. */
  647. static readonly ALPHA_REVERSEONEMINUS: number;
  648. /**
  649. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  650. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  651. */
  652. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  653. /**
  654. * Defines that alpha blending is SRC + DST
  655. * Alpha will be set to SRC ALPHA
  656. */
  657. static readonly ALPHA_ONEONE_ONEZERO: number;
  658. /**
  659. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  660. * Alpha will be set to DST ALPHA
  661. */
  662. static readonly ALPHA_EXCLUSION: number;
  663. /** Defines that alpha blending equation a SUM */
  664. static readonly ALPHA_EQUATION_ADD: number;
  665. /** Defines that alpha blending equation a SUBSTRACTION */
  666. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  667. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  668. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  669. /** Defines that alpha blending equation a MAX operation */
  670. static readonly ALPHA_EQUATION_MAX: number;
  671. /** Defines that alpha blending equation a MIN operation */
  672. static readonly ALPHA_EQUATION_MIN: number;
  673. /**
  674. * Defines that alpha blending equation a DARKEN operation:
  675. * It takes the min of the src and sums the alpha channels.
  676. */
  677. static readonly ALPHA_EQUATION_DARKEN: number;
  678. /** Defines that the ressource is not delayed*/
  679. static readonly DELAYLOADSTATE_NONE: number;
  680. /** Defines that the ressource was successfully delay loaded */
  681. static readonly DELAYLOADSTATE_LOADED: number;
  682. /** Defines that the ressource is currently delay loading */
  683. static readonly DELAYLOADSTATE_LOADING: number;
  684. /** Defines that the ressource is delayed and has not started loading */
  685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  687. static readonly NEVER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  689. static readonly ALWAYS: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  691. static readonly LESS: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  693. static readonly EQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  695. static readonly LEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  697. static readonly GREATER: number;
  698. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  699. static readonly GEQUAL: number;
  700. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  701. static readonly NOTEQUAL: number;
  702. /** Passed to stencilOperation to specify that stencil value must be kept */
  703. static readonly KEEP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  705. static readonly REPLACE: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  707. static readonly INCR: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  709. static readonly DECR: number;
  710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  711. static readonly INVERT: number;
  712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  713. static readonly INCR_WRAP: number;
  714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  715. static readonly DECR_WRAP: number;
  716. /** Texture is not repeating outside of 0..1 UVs */
  717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  718. /** Texture is repeating outside of 0..1 UVs */
  719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  720. /** Texture is repeating and mirrored */
  721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  722. /** ALPHA */
  723. static readonly TEXTUREFORMAT_ALPHA: number;
  724. /** LUMINANCE */
  725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  726. /** LUMINANCE_ALPHA */
  727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  728. /** RGB */
  729. static readonly TEXTUREFORMAT_RGB: number;
  730. /** RGBA */
  731. static readonly TEXTUREFORMAT_RGBA: number;
  732. /** RED */
  733. static readonly TEXTUREFORMAT_RED: number;
  734. /** RED (2nd reference) */
  735. static readonly TEXTUREFORMAT_R: number;
  736. /** RG */
  737. static readonly TEXTUREFORMAT_RG: number;
  738. /** RED_INTEGER */
  739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  740. /** RED_INTEGER (2nd reference) */
  741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  742. /** RG_INTEGER */
  743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  744. /** RGB_INTEGER */
  745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  746. /** RGBA_INTEGER */
  747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  748. /** UNSIGNED_BYTE */
  749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  750. /** UNSIGNED_BYTE (2nd reference) */
  751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  752. /** FLOAT */
  753. static readonly TEXTURETYPE_FLOAT: number;
  754. /** HALF_FLOAT */
  755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  756. /** BYTE */
  757. static readonly TEXTURETYPE_BYTE: number;
  758. /** SHORT */
  759. static readonly TEXTURETYPE_SHORT: number;
  760. /** UNSIGNED_SHORT */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  762. /** INT */
  763. static readonly TEXTURETYPE_INT: number;
  764. /** UNSIGNED_INT */
  765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  766. /** UNSIGNED_SHORT_4_4_4_4 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  768. /** UNSIGNED_SHORT_5_5_5_1 */
  769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  770. /** UNSIGNED_SHORT_5_6_5 */
  771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  772. /** UNSIGNED_INT_2_10_10_10_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  774. /** UNSIGNED_INT_24_8 */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  776. /** UNSIGNED_INT_10F_11F_11F_REV */
  777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  778. /** UNSIGNED_INT_5_9_9_9_REV */
  779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  782. /** nearest is mag = nearest and min = nearest and no mip */
  783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** Bilinear is mag = linear and min = linear and no mip */
  787. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  788. /** mag = linear and min = linear and mip = none */
  789. static readonly TEXTURE_LINEAR_LINEAR: number;
  790. /** Trilinear is mag = linear and min = linear and mip = linear */
  791. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  792. /** Trilinear is mag = linear and min = linear and mip = linear */
  793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = nearest and mip = nearest */
  795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  796. /** mag = nearest and min = linear and mip = nearest */
  797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  798. /** mag = nearest and min = linear and mip = linear */
  799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  800. /** mag = nearest and min = linear and mip = none */
  801. static readonly TEXTURE_NEAREST_LINEAR: number;
  802. /** nearest is mag = nearest and min = nearest and mip = linear */
  803. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  804. /** mag = linear and min = nearest and mip = nearest */
  805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = linear */
  807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  810. /** mag = linear and min = nearest and mip = none */
  811. static readonly TEXTURE_LINEAR_NEAREST: number;
  812. /** Explicit coordinates mode */
  813. static readonly TEXTURE_EXPLICIT_MODE: number;
  814. /** Spherical coordinates mode */
  815. static readonly TEXTURE_SPHERICAL_MODE: number;
  816. /** Planar coordinates mode */
  817. static readonly TEXTURE_PLANAR_MODE: number;
  818. /** Cubic coordinates mode */
  819. static readonly TEXTURE_CUBIC_MODE: number;
  820. /** Projection coordinates mode */
  821. static readonly TEXTURE_PROJECTION_MODE: number;
  822. /** Skybox coordinates mode */
  823. static readonly TEXTURE_SKYBOX_MODE: number;
  824. /** Inverse Cubic coordinates mode */
  825. static readonly TEXTURE_INVCUBIC_MODE: number;
  826. /** Equirectangular coordinates mode */
  827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  828. /** Equirectangular Fixed coordinates mode */
  829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  830. /** Equirectangular Fixed Mirrored coordinates mode */
  831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  832. /** Offline (baking) quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  834. /** High quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  836. /** Medium quality for texture filtering */
  837. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  838. /** Low quality for texture filtering */
  839. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  840. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  841. static readonly SCALEMODE_FLOOR: number;
  842. /** Defines that texture rescaling will look for the nearest power of 2 size */
  843. static readonly SCALEMODE_NEAREST: number;
  844. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  845. static readonly SCALEMODE_CEILING: number;
  846. /**
  847. * The dirty texture flag value
  848. */
  849. static readonly MATERIAL_TextureDirtyFlag: number;
  850. /**
  851. * The dirty light flag value
  852. */
  853. static readonly MATERIAL_LightDirtyFlag: number;
  854. /**
  855. * The dirty fresnel flag value
  856. */
  857. static readonly MATERIAL_FresnelDirtyFlag: number;
  858. /**
  859. * The dirty attribute flag value
  860. */
  861. static readonly MATERIAL_AttributesDirtyFlag: number;
  862. /**
  863. * The dirty misc flag value
  864. */
  865. static readonly MATERIAL_MiscDirtyFlag: number;
  866. /**
  867. * The dirty prepass flag value
  868. */
  869. static readonly MATERIAL_PrePassDirtyFlag: number;
  870. /**
  871. * The all dirty flag value
  872. */
  873. static readonly MATERIAL_AllDirtyFlag: number;
  874. /**
  875. * Returns the triangle fill mode
  876. */
  877. static readonly MATERIAL_TriangleFillMode: number;
  878. /**
  879. * Returns the wireframe mode
  880. */
  881. static readonly MATERIAL_WireFrameFillMode: number;
  882. /**
  883. * Returns the point fill mode
  884. */
  885. static readonly MATERIAL_PointFillMode: number;
  886. /**
  887. * Returns the point list draw mode
  888. */
  889. static readonly MATERIAL_PointListDrawMode: number;
  890. /**
  891. * Returns the line list draw mode
  892. */
  893. static readonly MATERIAL_LineListDrawMode: number;
  894. /**
  895. * Returns the line loop draw mode
  896. */
  897. static readonly MATERIAL_LineLoopDrawMode: number;
  898. /**
  899. * Returns the line strip draw mode
  900. */
  901. static readonly MATERIAL_LineStripDrawMode: number;
  902. /**
  903. * Returns the triangle strip draw mode
  904. */
  905. static readonly MATERIAL_TriangleStripDrawMode: number;
  906. /**
  907. * Returns the triangle fan draw mode
  908. */
  909. static readonly MATERIAL_TriangleFanDrawMode: number;
  910. /**
  911. * Stores the clock-wise side orientation
  912. */
  913. static readonly MATERIAL_ClockWiseSideOrientation: number;
  914. /**
  915. * Stores the counter clock-wise side orientation
  916. */
  917. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  918. /**
  919. * Nothing
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_NothingTrigger: number;
  923. /**
  924. * On pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickTrigger: number;
  928. /**
  929. * On left pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnLeftPickTrigger: number;
  933. /**
  934. * On right pick
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnRightPickTrigger: number;
  938. /**
  939. * On center pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnCenterPickTrigger: number;
  943. /**
  944. * On pick down
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickDownTrigger: number;
  948. /**
  949. * On double pick
  950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  951. */
  952. static readonly ACTION_OnDoublePickTrigger: number;
  953. /**
  954. * On pick up
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickUpTrigger: number;
  958. /**
  959. * On pick out.
  960. * This trigger will only be raised if you also declared a OnPickDown
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPickOutTrigger: number;
  964. /**
  965. * On long press
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnLongPressTrigger: number;
  969. /**
  970. * On pointer over
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnPointerOverTrigger: number;
  974. /**
  975. * On pointer out
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnPointerOutTrigger: number;
  979. /**
  980. * On every frame
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnEveryFrameTrigger: number;
  984. /**
  985. * On intersection enter
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnIntersectionEnterTrigger: number;
  989. /**
  990. * On intersection exit
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnIntersectionExitTrigger: number;
  994. /**
  995. * On key down
  996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  997. */
  998. static readonly ACTION_OnKeyDownTrigger: number;
  999. /**
  1000. * On key up
  1001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1002. */
  1003. static readonly ACTION_OnKeyUpTrigger: number;
  1004. /**
  1005. * Billboard mode will only apply to Y axis
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1008. /**
  1009. * Billboard mode will apply to all axes
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1012. /**
  1013. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1014. */
  1015. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1017. * Test order :
  1018. * Is the bounding sphere outside the frustum ?
  1019. * If not, are the bounding box vertices outside the frustum ?
  1020. * It not, then the cullable object is in the frustum.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1023. /** Culling strategy : Bounding Sphere Only.
  1024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1025. * It's also less accurate than the standard because some not visible objects can still be selected.
  1026. * Test : is the bounding sphere outside the frustum ?
  1027. * If not, then the cullable object is in the frustum.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1030. /** Culling strategy : Optimistic Inclusion.
  1031. * This in an inclusion test first, then the standard exclusion test.
  1032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1034. * Anyway, it's as accurate as the standard strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the default culling strategy.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1043. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1045. * Test :
  1046. * Is the cullable object bounding sphere center in the frustum ?
  1047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1048. */
  1049. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1050. /**
  1051. * No logging while loading
  1052. */
  1053. static readonly SCENELOADER_NO_LOGGING: number;
  1054. /**
  1055. * Minimal logging while loading
  1056. */
  1057. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1058. /**
  1059. * Summary logging while loading
  1060. */
  1061. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1062. /**
  1063. * Detailled logging while loading
  1064. */
  1065. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1066. /**
  1067. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1069. */
  1070. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the position texture index in the textures array in the prepass
  1073. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1074. */
  1075. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1078. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1079. */
  1080. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1091. /**
  1092. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1093. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1094. */
  1095. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1096. /**
  1097. * Constant used to retrieve albedo index in the textures array in the prepass
  1098. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1099. */
  1100. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1101. }
  1102. }
  1103. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1104. import { Nullable } from "babylonjs/types";
  1105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1106. /**
  1107. * This represents the required contract to create a new type of texture loader.
  1108. */
  1109. export interface IInternalTextureLoader {
  1110. /**
  1111. * Defines wether the loader supports cascade loading the different faces.
  1112. */
  1113. supportCascades: boolean;
  1114. /**
  1115. * This returns if the loader support the current file information.
  1116. * @param extension defines the file extension of the file being loaded
  1117. * @param mimeType defines the optional mime type of the file being loaded
  1118. * @returns true if the loader can load the specified file
  1119. */
  1120. canLoad(extension: string, mimeType?: string): boolean;
  1121. /**
  1122. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1123. * @param data contains the texture data
  1124. * @param texture defines the BabylonJS internal texture
  1125. * @param createPolynomials will be true if polynomials have been requested
  1126. * @param onLoad defines the callback to trigger once the texture is ready
  1127. * @param onError defines the callback to trigger in case of error
  1128. */
  1129. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1130. /**
  1131. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1132. * @param data contains the texture data
  1133. * @param texture defines the BabylonJS internal texture
  1134. * @param callback defines the method to call once ready to upload
  1135. */
  1136. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1137. }
  1138. }
  1139. declare module "babylonjs/Engines/IPipelineContext" {
  1140. /**
  1141. * Class used to store and describe the pipeline context associated with an effect
  1142. */
  1143. export interface IPipelineContext {
  1144. /**
  1145. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1146. */
  1147. isAsync: boolean;
  1148. /**
  1149. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1150. */
  1151. isReady: boolean;
  1152. /** @hidden */
  1153. _getVertexShaderCode(): string | null;
  1154. /** @hidden */
  1155. _getFragmentShaderCode(): string | null;
  1156. /** @hidden */
  1157. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1158. }
  1159. }
  1160. declare module "babylonjs/Meshes/dataBuffer" {
  1161. /**
  1162. * Class used to store gfx data (like WebGLBuffer)
  1163. */
  1164. export class DataBuffer {
  1165. /**
  1166. * Gets or sets the number of objects referencing this buffer
  1167. */
  1168. references: number;
  1169. /** Gets or sets the size of the underlying buffer */
  1170. capacity: number;
  1171. /**
  1172. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1173. */
  1174. is32Bits: boolean;
  1175. /**
  1176. * Gets the underlying buffer
  1177. */
  1178. get underlyingResource(): any;
  1179. }
  1180. }
  1181. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1182. /** @hidden */
  1183. export interface IShaderProcessor {
  1184. attributeProcessor?: (attribute: string) => string;
  1185. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1186. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1187. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1188. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1189. lineProcessor?: (line: string, isFragment: boolean) => string;
  1190. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1191. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1192. }
  1193. }
  1194. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1195. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1196. /** @hidden */
  1197. export interface ProcessingOptions {
  1198. defines: string[];
  1199. indexParameters: any;
  1200. isFragment: boolean;
  1201. shouldUseHighPrecisionShader: boolean;
  1202. supportsUniformBuffers: boolean;
  1203. shadersRepository: string;
  1204. includesShadersStore: {
  1205. [key: string]: string;
  1206. };
  1207. processor?: IShaderProcessor;
  1208. version: string;
  1209. platformName: string;
  1210. lookForClosingBracketForUniformBuffer?: boolean;
  1211. }
  1212. }
  1213. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1214. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1215. /** @hidden */
  1216. export class ShaderCodeNode {
  1217. line: string;
  1218. children: ShaderCodeNode[];
  1219. additionalDefineKey?: string;
  1220. additionalDefineValue?: string;
  1221. isValid(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. process(preprocessors: {
  1225. [key: string]: string;
  1226. }, options: ProcessingOptions): string;
  1227. }
  1228. }
  1229. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1230. /** @hidden */
  1231. export class ShaderCodeCursor {
  1232. private _lines;
  1233. lineIndex: number;
  1234. get currentLine(): string;
  1235. get canRead(): boolean;
  1236. set lines(value: string[]);
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1240. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1241. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1242. /** @hidden */
  1243. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1244. process(preprocessors: {
  1245. [key: string]: string;
  1246. }, options: ProcessingOptions): string;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1250. /** @hidden */
  1251. export class ShaderDefineExpression {
  1252. isTrue(preprocessors: {
  1253. [key: string]: string;
  1254. }): boolean;
  1255. private static _OperatorPriority;
  1256. private static _Stack;
  1257. static postfixToInfix(postfix: string[]): string;
  1258. static infixToPostfix(infix: string): string[];
  1259. }
  1260. }
  1261. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1262. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderCodeTestNode extends ShaderCodeNode {
  1266. testExpression: ShaderDefineExpression;
  1267. isValid(preprocessors: {
  1268. [key: string]: string;
  1269. }): boolean;
  1270. }
  1271. }
  1272. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1273. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1274. /** @hidden */
  1275. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1276. define: string;
  1277. not: boolean;
  1278. constructor(define: string, not?: boolean);
  1279. isTrue(preprocessors: {
  1280. [key: string]: string;
  1281. }): boolean;
  1282. }
  1283. }
  1284. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1285. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1286. /** @hidden */
  1287. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1288. leftOperand: ShaderDefineExpression;
  1289. rightOperand: ShaderDefineExpression;
  1290. isTrue(preprocessors: {
  1291. [key: string]: string;
  1292. }): boolean;
  1293. }
  1294. }
  1295. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1296. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1297. /** @hidden */
  1298. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1299. leftOperand: ShaderDefineExpression;
  1300. rightOperand: ShaderDefineExpression;
  1301. isTrue(preprocessors: {
  1302. [key: string]: string;
  1303. }): boolean;
  1304. }
  1305. }
  1306. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1307. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1308. /** @hidden */
  1309. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1310. define: string;
  1311. operand: string;
  1312. testValue: string;
  1313. constructor(define: string, operand: string, testValue: string);
  1314. isTrue(preprocessors: {
  1315. [key: string]: string;
  1316. }): boolean;
  1317. }
  1318. }
  1319. declare module "babylonjs/Offline/IOfflineProvider" {
  1320. /**
  1321. * Class used to enable access to offline support
  1322. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1323. */
  1324. export interface IOfflineProvider {
  1325. /**
  1326. * Gets a boolean indicating if scene must be saved in the database
  1327. */
  1328. enableSceneOffline: boolean;
  1329. /**
  1330. * Gets a boolean indicating if textures must be saved in the database
  1331. */
  1332. enableTexturesOffline: boolean;
  1333. /**
  1334. * Open the offline support and make it available
  1335. * @param successCallback defines the callback to call on success
  1336. * @param errorCallback defines the callback to call on error
  1337. */
  1338. open(successCallback: () => void, errorCallback: () => void): void;
  1339. /**
  1340. * Loads an image from the offline support
  1341. * @param url defines the url to load from
  1342. * @param image defines the target DOM image
  1343. */
  1344. loadImage(url: string, image: HTMLImageElement): void;
  1345. /**
  1346. * Loads a file from offline support
  1347. * @param url defines the URL to load from
  1348. * @param sceneLoaded defines a callback to call on success
  1349. * @param progressCallBack defines a callback to call when progress changed
  1350. * @param errorCallback defines a callback to call on error
  1351. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1352. */
  1353. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/filesInputStore" {
  1357. /**
  1358. * Class used to help managing file picking and drag'n'drop
  1359. * File Storage
  1360. */
  1361. export class FilesInputStore {
  1362. /**
  1363. * List of files ready to be loaded
  1364. */
  1365. static FilesToLoad: {
  1366. [key: string]: File;
  1367. };
  1368. }
  1369. }
  1370. declare module "babylonjs/Misc/retryStrategy" {
  1371. import { WebRequest } from "babylonjs/Misc/webRequest";
  1372. /**
  1373. * Class used to define a retry strategy when error happens while loading assets
  1374. */
  1375. export class RetryStrategy {
  1376. /**
  1377. * Function used to defines an exponential back off strategy
  1378. * @param maxRetries defines the maximum number of retries (3 by default)
  1379. * @param baseInterval defines the interval between retries
  1380. * @returns the strategy function to use
  1381. */
  1382. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1383. }
  1384. }
  1385. declare module "babylonjs/Misc/baseError" {
  1386. /**
  1387. * @ignore
  1388. * Application error to support additional information when loading a file
  1389. */
  1390. export abstract class BaseError extends Error {
  1391. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1392. }
  1393. }
  1394. declare module "babylonjs/Misc/fileTools" {
  1395. import { WebRequest } from "babylonjs/Misc/webRequest";
  1396. import { Nullable } from "babylonjs/types";
  1397. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1398. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1399. import { BaseError } from "babylonjs/Misc/baseError";
  1400. /** @ignore */
  1401. export class LoadFileError extends BaseError {
  1402. request?: WebRequest;
  1403. file?: File;
  1404. /**
  1405. * Creates a new LoadFileError
  1406. * @param message defines the message of the error
  1407. * @param request defines the optional web request
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, object?: WebRequest | File);
  1411. }
  1412. /** @ignore */
  1413. export class RequestFileError extends BaseError {
  1414. request: WebRequest;
  1415. /**
  1416. * Creates a new LoadFileError
  1417. * @param message defines the message of the error
  1418. * @param request defines the optional web request
  1419. */
  1420. constructor(message: string, request: WebRequest);
  1421. }
  1422. /** @ignore */
  1423. export class ReadFileError extends BaseError {
  1424. file: File;
  1425. /**
  1426. * Creates a new ReadFileError
  1427. * @param message defines the message of the error
  1428. * @param file defines the optional file
  1429. */
  1430. constructor(message: string, file: File);
  1431. }
  1432. /**
  1433. * @hidden
  1434. */
  1435. export class FileTools {
  1436. /**
  1437. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1438. */
  1439. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1440. /**
  1441. * Gets or sets the base URL to use to load assets
  1442. */
  1443. static BaseUrl: string;
  1444. /**
  1445. * Default behaviour for cors in the application.
  1446. * It can be a string if the expected behavior is identical in the entire app.
  1447. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1448. */
  1449. static CorsBehavior: string | ((url: string | string[]) => string);
  1450. /**
  1451. * Gets or sets a function used to pre-process url before using them to load assets
  1452. */
  1453. static PreprocessUrl: (url: string) => string;
  1454. /**
  1455. * Removes unwanted characters from an url
  1456. * @param url defines the url to clean
  1457. * @returns the cleaned url
  1458. */
  1459. private static _CleanUrl;
  1460. /**
  1461. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1462. * @param url define the url we are trying
  1463. * @param element define the dom element where to configure the cors policy
  1464. */
  1465. static SetCorsBehavior(url: string | string[], element: {
  1466. crossOrigin: string | null;
  1467. }): void;
  1468. /**
  1469. * Loads an image as an HTMLImageElement.
  1470. * @param input url string, ArrayBuffer, or Blob to load
  1471. * @param onLoad callback called when the image successfully loads
  1472. * @param onError callback called when the image fails to load
  1473. * @param offlineProvider offline provider for caching
  1474. * @param mimeType optional mime type
  1475. * @returns the HTMLImageElement of the loaded image
  1476. */
  1477. 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>;
  1478. /**
  1479. * Reads a file from a File object
  1480. * @param file defines the file to load
  1481. * @param onSuccess defines the callback to call when data is loaded
  1482. * @param onProgress defines the callback to call during loading process
  1483. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1484. * @param onError defines the callback to call when an error occurs
  1485. * @returns a file request object
  1486. */
  1487. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1488. /**
  1489. * Loads a file from a url
  1490. * @param url url to load
  1491. * @param onSuccess callback called when the file successfully loads
  1492. * @param onProgress callback called while file is loading (if the server supports this mode)
  1493. * @param offlineProvider defines the offline provider for caching
  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. * @returns a file request object
  1497. */
  1498. 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;
  1499. /**
  1500. * Loads a file
  1501. * @param url url to load
  1502. * @param onSuccess callback called when the file successfully loads
  1503. * @param onProgress callback called while file is loading (if the server supports this mode)
  1504. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1505. * @param onError callback called when the file fails to load
  1506. * @param onOpened callback called when the web request is opened
  1507. * @returns a file request object
  1508. */
  1509. 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;
  1510. /**
  1511. * Checks if the loaded document was accessed via `file:`-Protocol.
  1512. * @returns boolean
  1513. */
  1514. static IsFileURL(): boolean;
  1515. }
  1516. }
  1517. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1518. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1519. import { WebRequest } from "babylonjs/Misc/webRequest";
  1520. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1521. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1522. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1523. /** @hidden */
  1524. export class ShaderProcessor {
  1525. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1526. private static _ProcessPrecision;
  1527. private static _ExtractOperation;
  1528. private static _BuildSubExpression;
  1529. private static _BuildExpression;
  1530. private static _MoveCursorWithinIf;
  1531. private static _MoveCursor;
  1532. private static _EvaluatePreProcessors;
  1533. private static _PreparePreProcessors;
  1534. private static _ProcessShaderConversion;
  1535. private static _ProcessIncludes;
  1536. /**
  1537. * Loads a file from a url
  1538. * @param url url to load
  1539. * @param onSuccess callback called when the file successfully loads
  1540. * @param onProgress callback called while file is loading (if the server supports this mode)
  1541. * @param offlineProvider defines the offline provider for caching
  1542. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1543. * @param onError callback called when the file fails to load
  1544. * @returns a file request object
  1545. * @hidden
  1546. */
  1547. 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;
  1548. }
  1549. }
  1550. declare module "babylonjs/Maths/math.like" {
  1551. import { float, int, DeepImmutable } from "babylonjs/types";
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IColor4Like {
  1556. r: float;
  1557. g: float;
  1558. b: float;
  1559. a: float;
  1560. }
  1561. /**
  1562. * @hidden
  1563. */
  1564. export interface IColor3Like {
  1565. r: float;
  1566. g: float;
  1567. b: float;
  1568. }
  1569. /**
  1570. * @hidden
  1571. */
  1572. export interface IVector4Like {
  1573. x: float;
  1574. y: float;
  1575. z: float;
  1576. w: float;
  1577. }
  1578. /**
  1579. * @hidden
  1580. */
  1581. export interface IVector3Like {
  1582. x: float;
  1583. y: float;
  1584. z: float;
  1585. }
  1586. /**
  1587. * @hidden
  1588. */
  1589. export interface IVector2Like {
  1590. x: float;
  1591. y: float;
  1592. }
  1593. /**
  1594. * @hidden
  1595. */
  1596. export interface IMatrixLike {
  1597. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1598. updateFlag: int;
  1599. }
  1600. /**
  1601. * @hidden
  1602. */
  1603. export interface IViewportLike {
  1604. x: float;
  1605. y: float;
  1606. width: float;
  1607. height: float;
  1608. }
  1609. /**
  1610. * @hidden
  1611. */
  1612. export interface IPlaneLike {
  1613. normal: IVector3Like;
  1614. d: float;
  1615. normalize(): void;
  1616. }
  1617. }
  1618. declare module "babylonjs/Materials/iEffectFallbacks" {
  1619. import { Effect } from "babylonjs/Materials/effect";
  1620. /**
  1621. * Interface used to define common properties for effect fallbacks
  1622. */
  1623. export interface IEffectFallbacks {
  1624. /**
  1625. * Removes the defines that should be removed when falling back.
  1626. * @param currentDefines defines the current define statements for the shader.
  1627. * @param effect defines the current effect we try to compile
  1628. * @returns The resulting defines with defines of the current rank removed.
  1629. */
  1630. reduce(currentDefines: string, effect: Effect): string;
  1631. /**
  1632. * Removes the fallback from the bound mesh.
  1633. */
  1634. unBindMesh(): void;
  1635. /**
  1636. * Checks to see if more fallbacks are still availible.
  1637. */
  1638. hasMoreFallbacks: boolean;
  1639. }
  1640. }
  1641. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1642. /**
  1643. * Class used to evalaute queries containing `and` and `or` operators
  1644. */
  1645. export class AndOrNotEvaluator {
  1646. /**
  1647. * Evaluate a query
  1648. * @param query defines the query to evaluate
  1649. * @param evaluateCallback defines the callback used to filter result
  1650. * @returns true if the query matches
  1651. */
  1652. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1653. private static _HandleParenthesisContent;
  1654. private static _SimplifyNegation;
  1655. }
  1656. }
  1657. declare module "babylonjs/Misc/tags" {
  1658. /**
  1659. * Class used to store custom tags
  1660. */
  1661. export class Tags {
  1662. /**
  1663. * Adds support for tags on the given object
  1664. * @param obj defines the object to use
  1665. */
  1666. static EnableFor(obj: any): void;
  1667. /**
  1668. * Removes tags support
  1669. * @param obj defines the object to use
  1670. */
  1671. static DisableFor(obj: any): void;
  1672. /**
  1673. * Gets a boolean indicating if the given object has tags
  1674. * @param obj defines the object to use
  1675. * @returns a boolean
  1676. */
  1677. static HasTags(obj: any): boolean;
  1678. /**
  1679. * Gets the tags available on a given object
  1680. * @param obj defines the object to use
  1681. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1682. * @returns the tags
  1683. */
  1684. static GetTags(obj: any, asString?: boolean): any;
  1685. /**
  1686. * Adds tags to an object
  1687. * @param obj defines the object to use
  1688. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1689. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1690. */
  1691. static AddTagsTo(obj: any, tagsString: string): void;
  1692. /**
  1693. * @hidden
  1694. */
  1695. static _AddTagTo(obj: any, tag: string): void;
  1696. /**
  1697. * Removes specific tags from a specific object
  1698. * @param obj defines the object to use
  1699. * @param tagsString defines the tags to remove
  1700. */
  1701. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1702. /**
  1703. * @hidden
  1704. */
  1705. static _RemoveTagFrom(obj: any, tag: string): void;
  1706. /**
  1707. * Defines if tags hosted on an object match a given query
  1708. * @param obj defines the object to use
  1709. * @param tagsQuery defines the tag query
  1710. * @returns a boolean
  1711. */
  1712. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1713. }
  1714. }
  1715. declare module "babylonjs/Maths/math.scalar" {
  1716. /**
  1717. * Scalar computation library
  1718. */
  1719. export class Scalar {
  1720. /**
  1721. * Two pi constants convenient for computation.
  1722. */
  1723. static TwoPi: number;
  1724. /**
  1725. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1726. * @param a number
  1727. * @param b number
  1728. * @param epsilon (default = 1.401298E-45)
  1729. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1730. */
  1731. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1732. /**
  1733. * Returns a string : the upper case translation of the number i to hexadecimal.
  1734. * @param i number
  1735. * @returns the upper case translation of the number i to hexadecimal.
  1736. */
  1737. static ToHex(i: number): string;
  1738. /**
  1739. * Returns -1 if value is negative and +1 is value is positive.
  1740. * @param value the value
  1741. * @returns the value itself if it's equal to zero.
  1742. */
  1743. static Sign(value: number): number;
  1744. /**
  1745. * Returns the value itself if it's between min and max.
  1746. * Returns min if the value is lower than min.
  1747. * Returns max if the value is greater than max.
  1748. * @param value the value to clmap
  1749. * @param min the min value to clamp to (default: 0)
  1750. * @param max the max value to clamp to (default: 1)
  1751. * @returns the clamped value
  1752. */
  1753. static Clamp(value: number, min?: number, max?: number): number;
  1754. /**
  1755. * the log2 of value.
  1756. * @param value the value to compute log2 of
  1757. * @returns the log2 of value.
  1758. */
  1759. static Log2(value: number): number;
  1760. /**
  1761. * Loops the value, so that it is never larger than length and never smaller than 0.
  1762. *
  1763. * This is similar to the modulo operator but it works with floating point numbers.
  1764. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1765. * With t = 5 and length = 2.5, the result would be 0.0.
  1766. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1767. * @param value the value
  1768. * @param length the length
  1769. * @returns the looped value
  1770. */
  1771. static Repeat(value: number, length: number): number;
  1772. /**
  1773. * Normalize the value between 0.0 and 1.0 using min and max values
  1774. * @param value value to normalize
  1775. * @param min max to normalize between
  1776. * @param max min to normalize between
  1777. * @returns the normalized value
  1778. */
  1779. static Normalize(value: number, min: number, max: number): number;
  1780. /**
  1781. * Denormalize the value from 0.0 and 1.0 using min and max values
  1782. * @param normalized value to denormalize
  1783. * @param min max to denormalize between
  1784. * @param max min to denormalize between
  1785. * @returns the denormalized value
  1786. */
  1787. static Denormalize(normalized: number, min: number, max: number): number;
  1788. /**
  1789. * Calculates the shortest difference between two given angles given in degrees.
  1790. * @param current current angle in degrees
  1791. * @param target target angle in degrees
  1792. * @returns the delta
  1793. */
  1794. static DeltaAngle(current: number, target: number): number;
  1795. /**
  1796. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1797. * @param tx value
  1798. * @param length length
  1799. * @returns The returned value will move back and forth between 0 and length
  1800. */
  1801. static PingPong(tx: number, length: number): number;
  1802. /**
  1803. * Interpolates between min and max with smoothing at the limits.
  1804. *
  1805. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1806. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1807. * @param from from
  1808. * @param to to
  1809. * @param tx value
  1810. * @returns the smooth stepped value
  1811. */
  1812. static SmoothStep(from: number, to: number, tx: number): number;
  1813. /**
  1814. * Moves a value current towards target.
  1815. *
  1816. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1817. * Negative values of maxDelta pushes the value away from target.
  1818. * @param current current value
  1819. * @param target target value
  1820. * @param maxDelta max distance to move
  1821. * @returns resulting value
  1822. */
  1823. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1824. /**
  1825. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1826. *
  1827. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1828. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1829. * @param current current value
  1830. * @param target target value
  1831. * @param maxDelta max distance to move
  1832. * @returns resulting angle
  1833. */
  1834. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1835. /**
  1836. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1837. * @param start start value
  1838. * @param end target value
  1839. * @param amount amount to lerp between
  1840. * @returns the lerped value
  1841. */
  1842. static Lerp(start: number, end: number, amount: number): number;
  1843. /**
  1844. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1845. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1846. * @param start start value
  1847. * @param end target value
  1848. * @param amount amount to lerp between
  1849. * @returns the lerped value
  1850. */
  1851. static LerpAngle(start: number, end: number, amount: number): number;
  1852. /**
  1853. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1854. * @param a start value
  1855. * @param b target value
  1856. * @param value value between a and b
  1857. * @returns the inverseLerp value
  1858. */
  1859. static InverseLerp(a: number, b: number, value: number): number;
  1860. /**
  1861. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1862. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1863. * @param value1 spline value
  1864. * @param tangent1 spline value
  1865. * @param value2 spline value
  1866. * @param tangent2 spline value
  1867. * @param amount input value
  1868. * @returns hermite result
  1869. */
  1870. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1871. /**
  1872. * Returns a random float number between and min and max values
  1873. * @param min min value of random
  1874. * @param max max value of random
  1875. * @returns random value
  1876. */
  1877. static RandomRange(min: number, max: number): number;
  1878. /**
  1879. * This function returns percentage of a number in a given range.
  1880. *
  1881. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1882. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1883. * @param number to convert to percentage
  1884. * @param min min range
  1885. * @param max max range
  1886. * @returns the percentage
  1887. */
  1888. static RangeToPercent(number: number, min: number, max: number): number;
  1889. /**
  1890. * This function returns number that corresponds to the percentage in a given range.
  1891. *
  1892. * PercentToRange(0.34,0,100) will return 34.
  1893. * @param percent to convert to number
  1894. * @param min min range
  1895. * @param max max range
  1896. * @returns the number
  1897. */
  1898. static PercentToRange(percent: number, min: number, max: number): number;
  1899. /**
  1900. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1901. * @param angle The angle to normalize in radian.
  1902. * @return The converted angle.
  1903. */
  1904. static NormalizeRadians(angle: number): number;
  1905. }
  1906. }
  1907. declare module "babylonjs/Maths/math.constants" {
  1908. /**
  1909. * Constant used to convert a value to gamma space
  1910. * @ignorenaming
  1911. */
  1912. export const ToGammaSpace: number;
  1913. /**
  1914. * Constant used to convert a value to linear space
  1915. * @ignorenaming
  1916. */
  1917. export const ToLinearSpace = 2.2;
  1918. /**
  1919. * Constant used to define the minimal number value in Babylon.js
  1920. * @ignorenaming
  1921. */
  1922. let Epsilon: number;
  1923. export { Epsilon };
  1924. }
  1925. declare module "babylonjs/Maths/math.viewport" {
  1926. /**
  1927. * Class used to represent a viewport on screen
  1928. */
  1929. export class Viewport {
  1930. /** viewport left coordinate */
  1931. x: number;
  1932. /** viewport top coordinate */
  1933. y: number;
  1934. /**viewport width */
  1935. width: number;
  1936. /** viewport height */
  1937. height: number;
  1938. /**
  1939. * Creates a Viewport object located at (x, y) and sized (width, height)
  1940. * @param x defines viewport left coordinate
  1941. * @param y defines viewport top coordinate
  1942. * @param width defines the viewport width
  1943. * @param height defines the viewport height
  1944. */
  1945. constructor(
  1946. /** viewport left coordinate */
  1947. x: number,
  1948. /** viewport top coordinate */
  1949. y: number,
  1950. /**viewport width */
  1951. width: number,
  1952. /** viewport height */
  1953. height: number);
  1954. /**
  1955. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1956. * @param renderWidth defines the rendering width
  1957. * @param renderHeight defines the rendering height
  1958. * @returns a new Viewport
  1959. */
  1960. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1961. /**
  1962. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1963. * @param renderWidth defines the rendering width
  1964. * @param renderHeight defines the rendering height
  1965. * @param ref defines the target viewport
  1966. * @returns the current viewport
  1967. */
  1968. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1969. /**
  1970. * Returns a new Viewport copied from the current one
  1971. * @returns a new Viewport
  1972. */
  1973. clone(): Viewport;
  1974. }
  1975. }
  1976. declare module "babylonjs/Misc/arrayTools" {
  1977. /**
  1978. * Class containing a set of static utilities functions for arrays.
  1979. */
  1980. export class ArrayTools {
  1981. /**
  1982. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1983. * @param size the number of element to construct and put in the array
  1984. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1985. * @returns a new array filled with new objects
  1986. */
  1987. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1988. }
  1989. }
  1990. declare module "babylonjs/Maths/math.plane" {
  1991. import { DeepImmutable } from "babylonjs/types";
  1992. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1993. /**
  1994. * Represents a plane by the equation ax + by + cz + d = 0
  1995. */
  1996. export class Plane {
  1997. private static _TmpMatrix;
  1998. /**
  1999. * Normal of the plane (a,b,c)
  2000. */
  2001. normal: Vector3;
  2002. /**
  2003. * d component of the plane
  2004. */
  2005. d: number;
  2006. /**
  2007. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2008. * @param a a component of the plane
  2009. * @param b b component of the plane
  2010. * @param c c component of the plane
  2011. * @param d d component of the plane
  2012. */
  2013. constructor(a: number, b: number, c: number, d: number);
  2014. /**
  2015. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2016. */
  2017. asArray(): number[];
  2018. /**
  2019. * @returns a new plane copied from the current Plane.
  2020. */
  2021. clone(): Plane;
  2022. /**
  2023. * @returns the string "Plane".
  2024. */
  2025. getClassName(): string;
  2026. /**
  2027. * @returns the Plane hash code.
  2028. */
  2029. getHashCode(): number;
  2030. /**
  2031. * Normalize the current Plane in place.
  2032. * @returns the updated Plane.
  2033. */
  2034. normalize(): Plane;
  2035. /**
  2036. * Applies a transformation the plane and returns the result
  2037. * @param transformation the transformation matrix to be applied to the plane
  2038. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2039. */
  2040. transform(transformation: DeepImmutable<Matrix>): Plane;
  2041. /**
  2042. * Compute the dot product between the point and the plane normal
  2043. * @param point point to calculate the dot product with
  2044. * @returns the dot product (float) of the point coordinates and the plane normal.
  2045. */
  2046. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2047. /**
  2048. * Updates the current Plane from the plane defined by the three given points.
  2049. * @param point1 one of the points used to contruct the plane
  2050. * @param point2 one of the points used to contruct the plane
  2051. * @param point3 one of the points used to contruct the plane
  2052. * @returns the updated Plane.
  2053. */
  2054. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2055. /**
  2056. * Checks if the plane is facing a given direction
  2057. * @param direction the direction to check if the plane is facing
  2058. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2059. * @returns True is the vector "direction" is the same side than the plane normal.
  2060. */
  2061. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2062. /**
  2063. * Calculates the distance to a point
  2064. * @param point point to calculate distance to
  2065. * @returns the signed distance (float) from the given point to the Plane.
  2066. */
  2067. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2068. /**
  2069. * Creates a plane from an array
  2070. * @param array the array to create a plane from
  2071. * @returns a new Plane from the given array.
  2072. */
  2073. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2074. /**
  2075. * Creates a plane from three points
  2076. * @param point1 point used to create the plane
  2077. * @param point2 point used to create the plane
  2078. * @param point3 point used to create the plane
  2079. * @returns a new Plane defined by the three given points.
  2080. */
  2081. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2082. /**
  2083. * Creates a plane from an origin point and a normal
  2084. * @param origin origin of the plane to be constructed
  2085. * @param normal normal of the plane to be constructed
  2086. * @returns a new Plane the normal vector to this plane at the given origin point.
  2087. * Note : the vector "normal" is updated because normalized.
  2088. */
  2089. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2090. /**
  2091. * Calculates the distance from a plane and a point
  2092. * @param origin origin of the plane to be constructed
  2093. * @param normal normal of the plane to be constructed
  2094. * @param point point to calculate distance to
  2095. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2096. */
  2097. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2098. }
  2099. }
  2100. declare module "babylonjs/Engines/performanceConfigurator" {
  2101. /** @hidden */
  2102. export class PerformanceConfigurator {
  2103. /** @hidden */
  2104. static MatrixUse64Bits: boolean;
  2105. /** @hidden */
  2106. static MatrixTrackPrecisionChange: boolean;
  2107. /** @hidden */
  2108. static MatrixCurrentType: any;
  2109. /** @hidden */
  2110. static MatrixTrackedMatrices: Array<any> | null;
  2111. /** @hidden */
  2112. static SetMatrixPrecision(use64bits: boolean): void;
  2113. }
  2114. }
  2115. declare module "babylonjs/Maths/math.vector" {
  2116. import { Viewport } from "babylonjs/Maths/math.viewport";
  2117. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2118. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2119. import { Plane } from "babylonjs/Maths/math.plane";
  2120. /**
  2121. * Class representing a vector containing 2 coordinates
  2122. */
  2123. export class Vector2 {
  2124. /** defines the first coordinate */
  2125. x: number;
  2126. /** defines the second coordinate */
  2127. y: number;
  2128. /**
  2129. * Creates a new Vector2 from the given x and y coordinates
  2130. * @param x defines the first coordinate
  2131. * @param y defines the second coordinate
  2132. */
  2133. constructor(
  2134. /** defines the first coordinate */
  2135. x?: number,
  2136. /** defines the second coordinate */
  2137. y?: number);
  2138. /**
  2139. * Gets a string with the Vector2 coordinates
  2140. * @returns a string with the Vector2 coordinates
  2141. */
  2142. toString(): string;
  2143. /**
  2144. * Gets class name
  2145. * @returns the string "Vector2"
  2146. */
  2147. getClassName(): string;
  2148. /**
  2149. * Gets current vector hash code
  2150. * @returns the Vector2 hash code as a number
  2151. */
  2152. getHashCode(): number;
  2153. /**
  2154. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2155. * @param array defines the source array
  2156. * @param index defines the offset in source array
  2157. * @returns the current Vector2
  2158. */
  2159. toArray(array: FloatArray, index?: number): Vector2;
  2160. /**
  2161. * Update the current vector from an array
  2162. * @param array defines the destination array
  2163. * @param index defines the offset in the destination array
  2164. * @returns the current Vector3
  2165. */
  2166. fromArray(array: FloatArray, index?: number): Vector2;
  2167. /**
  2168. * Copy the current vector to an array
  2169. * @returns a new array with 2 elements: the Vector2 coordinates.
  2170. */
  2171. asArray(): number[];
  2172. /**
  2173. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2174. * @param source defines the source Vector2
  2175. * @returns the current updated Vector2
  2176. */
  2177. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2178. /**
  2179. * Sets the Vector2 coordinates with the given floats
  2180. * @param x defines the first coordinate
  2181. * @param y defines the second coordinate
  2182. * @returns the current updated Vector2
  2183. */
  2184. copyFromFloats(x: number, y: number): Vector2;
  2185. /**
  2186. * Sets the Vector2 coordinates with the given floats
  2187. * @param x defines the first coordinate
  2188. * @param y defines the second coordinate
  2189. * @returns the current updated Vector2
  2190. */
  2191. set(x: number, y: number): Vector2;
  2192. /**
  2193. * Add another vector with the current one
  2194. * @param otherVector defines the other vector
  2195. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2196. */
  2197. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2198. /**
  2199. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2200. * @param otherVector defines the other vector
  2201. * @param result defines the target vector
  2202. * @returns the unmodified current Vector2
  2203. */
  2204. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2205. /**
  2206. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2207. * @param otherVector defines the other vector
  2208. * @returns the current updated Vector2
  2209. */
  2210. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2211. /**
  2212. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2213. * @param otherVector defines the other vector
  2214. * @returns a new Vector2
  2215. */
  2216. addVector3(otherVector: Vector3): Vector2;
  2217. /**
  2218. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2219. * @param otherVector defines the other vector
  2220. * @returns a new Vector2
  2221. */
  2222. subtract(otherVector: Vector2): Vector2;
  2223. /**
  2224. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2225. * @param otherVector defines the other vector
  2226. * @param result defines the target vector
  2227. * @returns the unmodified current Vector2
  2228. */
  2229. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2230. /**
  2231. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2232. * @param otherVector defines the other vector
  2233. * @returns the current updated Vector2
  2234. */
  2235. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2236. /**
  2237. * Multiplies in place the current Vector2 coordinates by the given ones
  2238. * @param otherVector defines the other vector
  2239. * @returns the current updated Vector2
  2240. */
  2241. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2242. /**
  2243. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2244. * @param otherVector defines the other vector
  2245. * @returns a new Vector2
  2246. */
  2247. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2248. /**
  2249. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2250. * @param otherVector defines the other vector
  2251. * @param result defines the target vector
  2252. * @returns the unmodified current Vector2
  2253. */
  2254. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2255. /**
  2256. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2257. * @param x defines the first coordinate
  2258. * @param y defines the second coordinate
  2259. * @returns a new Vector2
  2260. */
  2261. multiplyByFloats(x: number, y: number): Vector2;
  2262. /**
  2263. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2264. * @param otherVector defines the other vector
  2265. * @returns a new Vector2
  2266. */
  2267. divide(otherVector: Vector2): Vector2;
  2268. /**
  2269. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2270. * @param otherVector defines the other vector
  2271. * @param result defines the target vector
  2272. * @returns the unmodified current Vector2
  2273. */
  2274. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2275. /**
  2276. * Divides the current Vector2 coordinates by the given ones
  2277. * @param otherVector defines the other vector
  2278. * @returns the current updated Vector2
  2279. */
  2280. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2281. /**
  2282. * Gets a new Vector2 with current Vector2 negated coordinates
  2283. * @returns a new Vector2
  2284. */
  2285. negate(): Vector2;
  2286. /**
  2287. * Negate this vector in place
  2288. * @returns this
  2289. */
  2290. negateInPlace(): Vector2;
  2291. /**
  2292. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2293. * @param result defines the Vector3 object where to store the result
  2294. * @returns the current Vector2
  2295. */
  2296. negateToRef(result: Vector2): Vector2;
  2297. /**
  2298. * Multiply the Vector2 coordinates by scale
  2299. * @param scale defines the scaling factor
  2300. * @returns the current updated Vector2
  2301. */
  2302. scaleInPlace(scale: number): Vector2;
  2303. /**
  2304. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2305. * @param scale defines the scaling factor
  2306. * @returns a new Vector2
  2307. */
  2308. scale(scale: number): Vector2;
  2309. /**
  2310. * Scale the current Vector2 values by a factor to a given Vector2
  2311. * @param scale defines the scale factor
  2312. * @param result defines the Vector2 object where to store the result
  2313. * @returns the unmodified current Vector2
  2314. */
  2315. scaleToRef(scale: number, result: Vector2): Vector2;
  2316. /**
  2317. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2318. * @param scale defines the scale factor
  2319. * @param result defines the Vector2 object where to store the result
  2320. * @returns the unmodified current Vector2
  2321. */
  2322. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2323. /**
  2324. * Gets a boolean if two vectors are equals
  2325. * @param otherVector defines the other vector
  2326. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2327. */
  2328. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2329. /**
  2330. * Gets a boolean if two vectors are equals (using an epsilon value)
  2331. * @param otherVector defines the other vector
  2332. * @param epsilon defines the minimal distance to consider equality
  2333. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2334. */
  2335. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2336. /**
  2337. * Gets a new Vector2 from current Vector2 floored values
  2338. * @returns a new Vector2
  2339. */
  2340. floor(): Vector2;
  2341. /**
  2342. * Gets a new Vector2 from current Vector2 floored values
  2343. * @returns a new Vector2
  2344. */
  2345. fract(): Vector2;
  2346. /**
  2347. * Gets the length of the vector
  2348. * @returns the vector length (float)
  2349. */
  2350. length(): number;
  2351. /**
  2352. * Gets the vector squared length
  2353. * @returns the vector squared length (float)
  2354. */
  2355. lengthSquared(): number;
  2356. /**
  2357. * Normalize the vector
  2358. * @returns the current updated Vector2
  2359. */
  2360. normalize(): Vector2;
  2361. /**
  2362. * Gets a new Vector2 copied from the Vector2
  2363. * @returns a new Vector2
  2364. */
  2365. clone(): Vector2;
  2366. /**
  2367. * Gets a new Vector2(0, 0)
  2368. * @returns a new Vector2
  2369. */
  2370. static Zero(): Vector2;
  2371. /**
  2372. * Gets a new Vector2(1, 1)
  2373. * @returns a new Vector2
  2374. */
  2375. static One(): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set from the given index element of the given array
  2378. * @param array defines the data source
  2379. * @param offset defines the offset in the data source
  2380. * @returns a new Vector2
  2381. */
  2382. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2383. /**
  2384. * Sets "result" from the given index element of the given array
  2385. * @param array defines the data source
  2386. * @param offset defines the offset in the data source
  2387. * @param result defines the target vector
  2388. */
  2389. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2390. /**
  2391. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2392. * @param value1 defines 1st point of control
  2393. * @param value2 defines 2nd point of control
  2394. * @param value3 defines 3rd point of control
  2395. * @param value4 defines 4th point of control
  2396. * @param amount defines the interpolation factor
  2397. * @returns a new Vector2
  2398. */
  2399. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2400. /**
  2401. * 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".
  2402. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2403. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2404. * @param value defines the value to clamp
  2405. * @param min defines the lower limit
  2406. * @param max defines the upper limit
  2407. * @returns a new Vector2
  2408. */
  2409. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2410. /**
  2411. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2412. * @param value1 defines the 1st control point
  2413. * @param tangent1 defines the outgoing tangent
  2414. * @param value2 defines the 2nd control point
  2415. * @param tangent2 defines the incoming tangent
  2416. * @param amount defines the interpolation factor
  2417. * @returns a new Vector2
  2418. */
  2419. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2420. /**
  2421. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2422. * @param start defines the start vector
  2423. * @param end defines the end vector
  2424. * @param amount defines the interpolation factor
  2425. * @returns a new Vector2
  2426. */
  2427. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2428. /**
  2429. * Gets the dot product of the vector "left" and the vector "right"
  2430. * @param left defines first vector
  2431. * @param right defines second vector
  2432. * @returns the dot product (float)
  2433. */
  2434. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2435. /**
  2436. * Returns a new Vector2 equal to the normalized given vector
  2437. * @param vector defines the vector to normalize
  2438. * @returns a new Vector2
  2439. */
  2440. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2441. /**
  2442. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2443. * @param left defines 1st vector
  2444. * @param right defines 2nd vector
  2445. * @returns a new Vector2
  2446. */
  2447. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2448. /**
  2449. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2450. * @param left defines 1st vector
  2451. * @param right defines 2nd vector
  2452. * @returns a new Vector2
  2453. */
  2454. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2455. /**
  2456. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2457. * @param vector defines the vector to transform
  2458. * @param transformation defines the matrix to apply
  2459. * @returns a new Vector2
  2460. */
  2461. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2462. /**
  2463. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2464. * @param vector defines the vector to transform
  2465. * @param transformation defines the matrix to apply
  2466. * @param result defines the target vector
  2467. */
  2468. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2469. /**
  2470. * Determines if a given vector is included in a triangle
  2471. * @param p defines the vector to test
  2472. * @param p0 defines 1st triangle point
  2473. * @param p1 defines 2nd triangle point
  2474. * @param p2 defines 3rd triangle point
  2475. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2476. */
  2477. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2478. /**
  2479. * Gets the distance between the vectors "value1" and "value2"
  2480. * @param value1 defines first vector
  2481. * @param value2 defines second vector
  2482. * @returns the distance between vectors
  2483. */
  2484. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2485. /**
  2486. * Returns the squared distance between the vectors "value1" and "value2"
  2487. * @param value1 defines first vector
  2488. * @param value2 defines second vector
  2489. * @returns the squared distance between vectors
  2490. */
  2491. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2492. /**
  2493. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2494. * @param value1 defines first vector
  2495. * @param value2 defines second vector
  2496. * @returns a new Vector2
  2497. */
  2498. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2499. /**
  2500. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2501. * @param p defines the middle point
  2502. * @param segA defines one point of the segment
  2503. * @param segB defines the other point of the segment
  2504. * @returns the shortest distance
  2505. */
  2506. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2507. }
  2508. /**
  2509. * Class used to store (x,y,z) vector representation
  2510. * A Vector3 is the main object used in 3D geometry
  2511. * It can represent etiher the coordinates of a point the space, either a direction
  2512. * Reminder: js uses a left handed forward facing system
  2513. */
  2514. export class Vector3 {
  2515. private static _UpReadOnly;
  2516. private static _ZeroReadOnly;
  2517. /** @hidden */
  2518. _x: number;
  2519. /** @hidden */
  2520. _y: number;
  2521. /** @hidden */
  2522. _z: number;
  2523. /** @hidden */
  2524. _isDirty: boolean;
  2525. /** Gets or sets the x coordinate */
  2526. get x(): number;
  2527. set x(value: number);
  2528. /** Gets or sets the y coordinate */
  2529. get y(): number;
  2530. set y(value: number);
  2531. /** Gets or sets the z coordinate */
  2532. get z(): number;
  2533. set z(value: number);
  2534. /**
  2535. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2536. * @param x defines the first coordinates (on X axis)
  2537. * @param y defines the second coordinates (on Y axis)
  2538. * @param z defines the third coordinates (on Z axis)
  2539. */
  2540. constructor(x?: number, y?: number, z?: number);
  2541. /**
  2542. * Creates a string representation of the Vector3
  2543. * @returns a string with the Vector3 coordinates.
  2544. */
  2545. toString(): string;
  2546. /**
  2547. * Gets the class name
  2548. * @returns the string "Vector3"
  2549. */
  2550. getClassName(): string;
  2551. /**
  2552. * Creates the Vector3 hash code
  2553. * @returns a number which tends to be unique between Vector3 instances
  2554. */
  2555. getHashCode(): number;
  2556. /**
  2557. * Creates an array containing three elements : the coordinates of the Vector3
  2558. * @returns a new array of numbers
  2559. */
  2560. asArray(): number[];
  2561. /**
  2562. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2563. * @param array defines the destination array
  2564. * @param index defines the offset in the destination array
  2565. * @returns the current Vector3
  2566. */
  2567. toArray(array: FloatArray, index?: number): Vector3;
  2568. /**
  2569. * Update the current vector from an array
  2570. * @param array defines the destination array
  2571. * @param index defines the offset in the destination array
  2572. * @returns the current Vector3
  2573. */
  2574. fromArray(array: FloatArray, index?: number): Vector3;
  2575. /**
  2576. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2577. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2578. */
  2579. toQuaternion(): Quaternion;
  2580. /**
  2581. * Adds the given vector to the current Vector3
  2582. * @param otherVector defines the second operand
  2583. * @returns the current updated Vector3
  2584. */
  2585. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2586. /**
  2587. * Adds the given coordinates to the current Vector3
  2588. * @param x defines the x coordinate of the operand
  2589. * @param y defines the y coordinate of the operand
  2590. * @param z defines the z coordinate of the operand
  2591. * @returns the current updated Vector3
  2592. */
  2593. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2594. /**
  2595. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2596. * @param otherVector defines the second operand
  2597. * @returns the resulting Vector3
  2598. */
  2599. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2600. /**
  2601. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2602. * @param otherVector defines the second operand
  2603. * @param result defines the Vector3 object where to store the result
  2604. * @returns the current Vector3
  2605. */
  2606. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2607. /**
  2608. * Subtract the given vector from the current Vector3
  2609. * @param otherVector defines the second operand
  2610. * @returns the current updated Vector3
  2611. */
  2612. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2613. /**
  2614. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2615. * @param otherVector defines the second operand
  2616. * @returns the resulting Vector3
  2617. */
  2618. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2619. /**
  2620. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2621. * @param otherVector defines the second operand
  2622. * @param result defines the Vector3 object where to store the result
  2623. * @returns the current Vector3
  2624. */
  2625. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2626. /**
  2627. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2628. * @param x defines the x coordinate of the operand
  2629. * @param y defines the y coordinate of the operand
  2630. * @param z defines the z coordinate of the operand
  2631. * @returns the resulting Vector3
  2632. */
  2633. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2634. /**
  2635. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2636. * @param x defines the x coordinate of the operand
  2637. * @param y defines the y coordinate of the operand
  2638. * @param z defines the z coordinate of the operand
  2639. * @param result defines the Vector3 object where to store the result
  2640. * @returns the current Vector3
  2641. */
  2642. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2643. /**
  2644. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2645. * @returns a new Vector3
  2646. */
  2647. negate(): Vector3;
  2648. /**
  2649. * Negate this vector in place
  2650. * @returns this
  2651. */
  2652. negateInPlace(): Vector3;
  2653. /**
  2654. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2655. * @param result defines the Vector3 object where to store the result
  2656. * @returns the current Vector3
  2657. */
  2658. negateToRef(result: Vector3): Vector3;
  2659. /**
  2660. * Multiplies the Vector3 coordinates by the float "scale"
  2661. * @param scale defines the multiplier factor
  2662. * @returns the current updated Vector3
  2663. */
  2664. scaleInPlace(scale: number): Vector3;
  2665. /**
  2666. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2667. * @param scale defines the multiplier factor
  2668. * @returns a new Vector3
  2669. */
  2670. scale(scale: number): Vector3;
  2671. /**
  2672. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2673. * @param scale defines the multiplier factor
  2674. * @param result defines the Vector3 object where to store the result
  2675. * @returns the current Vector3
  2676. */
  2677. scaleToRef(scale: number, result: Vector3): Vector3;
  2678. /**
  2679. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2680. * @param scale defines the scale factor
  2681. * @param result defines the Vector3 object where to store the result
  2682. * @returns the unmodified current Vector3
  2683. */
  2684. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2685. /**
  2686. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2687. * @param origin defines the origin of the projection ray
  2688. * @param plane defines the plane to project to
  2689. * @returns the projected vector3
  2690. */
  2691. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2692. /**
  2693. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2694. * @param origin defines the origin of the projection ray
  2695. * @param plane defines the plane to project to
  2696. * @param result defines the Vector3 where to store the result
  2697. */
  2698. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2699. /**
  2700. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2701. * @param otherVector defines the second operand
  2702. * @returns true if both vectors are equals
  2703. */
  2704. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2705. /**
  2706. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2707. * @param otherVector defines the second operand
  2708. * @param epsilon defines the minimal distance to define values as equals
  2709. * @returns true if both vectors are distant less than epsilon
  2710. */
  2711. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2712. /**
  2713. * Returns true if the current Vector3 coordinates equals the given floats
  2714. * @param x defines the x coordinate of the operand
  2715. * @param y defines the y coordinate of the operand
  2716. * @param z defines the z coordinate of the operand
  2717. * @returns true if both vectors are equals
  2718. */
  2719. equalsToFloats(x: number, y: number, z: number): boolean;
  2720. /**
  2721. * Multiplies the current Vector3 coordinates by the given ones
  2722. * @param otherVector defines the second operand
  2723. * @returns the current updated Vector3
  2724. */
  2725. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2726. /**
  2727. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2728. * @param otherVector defines the second operand
  2729. * @returns the new Vector3
  2730. */
  2731. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2732. /**
  2733. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2734. * @param otherVector defines the second operand
  2735. * @param result defines the Vector3 object where to store the result
  2736. * @returns the current Vector3
  2737. */
  2738. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2741. * @param x defines the x coordinate of the operand
  2742. * @param y defines the y coordinate of the operand
  2743. * @param z defines the z coordinate of the operand
  2744. * @returns the new Vector3
  2745. */
  2746. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2749. * @param otherVector defines the second operand
  2750. * @returns the new Vector3
  2751. */
  2752. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2753. /**
  2754. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2755. * @param otherVector defines the second operand
  2756. * @param result defines the Vector3 object where to store the result
  2757. * @returns the current Vector3
  2758. */
  2759. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2760. /**
  2761. * Divides the current Vector3 coordinates by the given ones.
  2762. * @param otherVector defines the second operand
  2763. * @returns the current updated Vector3
  2764. */
  2765. divideInPlace(otherVector: Vector3): Vector3;
  2766. /**
  2767. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2768. * @param other defines the second operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2772. /**
  2773. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2774. * @param other defines the second operand
  2775. * @returns the current updated Vector3
  2776. */
  2777. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2778. /**
  2779. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2780. * @param x defines the x coordinate of the operand
  2781. * @param y defines the y coordinate of the operand
  2782. * @param z defines the z coordinate of the operand
  2783. * @returns the current updated Vector3
  2784. */
  2785. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2786. /**
  2787. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2788. * @param x defines the x coordinate of the operand
  2789. * @param y defines the y coordinate of the operand
  2790. * @param z defines the z coordinate of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2794. /**
  2795. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2796. * Check if is non uniform within a certain amount of decimal places to account for this
  2797. * @param epsilon the amount the values can differ
  2798. * @returns if the the vector is non uniform to a certain number of decimal places
  2799. */
  2800. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2801. /**
  2802. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2803. */
  2804. get isNonUniform(): boolean;
  2805. /**
  2806. * Gets a new Vector3 from current Vector3 floored values
  2807. * @returns a new Vector3
  2808. */
  2809. floor(): Vector3;
  2810. /**
  2811. * Gets a new Vector3 from current Vector3 floored values
  2812. * @returns a new Vector3
  2813. */
  2814. fract(): Vector3;
  2815. /**
  2816. * Gets the length of the Vector3
  2817. * @returns the length of the Vector3
  2818. */
  2819. length(): number;
  2820. /**
  2821. * Gets the squared length of the Vector3
  2822. * @returns squared length of the Vector3
  2823. */
  2824. lengthSquared(): number;
  2825. /**
  2826. * Normalize the current Vector3.
  2827. * Please note that this is an in place operation.
  2828. * @returns the current updated Vector3
  2829. */
  2830. normalize(): Vector3;
  2831. /**
  2832. * Reorders the x y z properties of the vector in place
  2833. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2834. * @returns the current updated vector
  2835. */
  2836. reorderInPlace(order: string): this;
  2837. /**
  2838. * Rotates the vector around 0,0,0 by a quaternion
  2839. * @param quaternion the rotation quaternion
  2840. * @param result vector to store the result
  2841. * @returns the resulting vector
  2842. */
  2843. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2844. /**
  2845. * Rotates a vector around a given point
  2846. * @param quaternion the rotation quaternion
  2847. * @param point the point to rotate around
  2848. * @param result vector to store the result
  2849. * @returns the resulting vector
  2850. */
  2851. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2852. /**
  2853. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2854. * The cross product is then orthogonal to both current and "other"
  2855. * @param other defines the right operand
  2856. * @returns the cross product
  2857. */
  2858. cross(other: Vector3): Vector3;
  2859. /**
  2860. * Normalize the current Vector3 with the given input length.
  2861. * Please note that this is an in place operation.
  2862. * @param len the length of the vector
  2863. * @returns the current updated Vector3
  2864. */
  2865. normalizeFromLength(len: number): Vector3;
  2866. /**
  2867. * Normalize the current Vector3 to a new vector
  2868. * @returns the new Vector3
  2869. */
  2870. normalizeToNew(): Vector3;
  2871. /**
  2872. * Normalize the current Vector3 to the reference
  2873. * @param reference define the Vector3 to update
  2874. * @returns the updated Vector3
  2875. */
  2876. normalizeToRef(reference: Vector3): Vector3;
  2877. /**
  2878. * Creates a new Vector3 copied from the current Vector3
  2879. * @returns the new Vector3
  2880. */
  2881. clone(): Vector3;
  2882. /**
  2883. * Copies the given vector coordinates to the current Vector3 ones
  2884. * @param source defines the source Vector3
  2885. * @returns the current updated Vector3
  2886. */
  2887. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2888. /**
  2889. * Copies the given floats to the current Vector3 coordinates
  2890. * @param x defines the x coordinate of the operand
  2891. * @param y defines the y coordinate of the operand
  2892. * @param z defines the z coordinate of the operand
  2893. * @returns the current updated Vector3
  2894. */
  2895. copyFromFloats(x: number, y: number, z: number): Vector3;
  2896. /**
  2897. * Copies the given floats to the current Vector3 coordinates
  2898. * @param x defines the x coordinate of the operand
  2899. * @param y defines the y coordinate of the operand
  2900. * @param z defines the z coordinate of the operand
  2901. * @returns the current updated Vector3
  2902. */
  2903. set(x: number, y: number, z: number): Vector3;
  2904. /**
  2905. * Copies the given float to the current Vector3 coordinates
  2906. * @param v defines the x, y and z coordinates of the operand
  2907. * @returns the current updated Vector3
  2908. */
  2909. setAll(v: number): Vector3;
  2910. /**
  2911. * Get the clip factor between two vectors
  2912. * @param vector0 defines the first operand
  2913. * @param vector1 defines the second operand
  2914. * @param axis defines the axis to use
  2915. * @param size defines the size along the axis
  2916. * @returns the clip factor
  2917. */
  2918. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2919. /**
  2920. * Get angle between two vectors
  2921. * @param vector0 angle between vector0 and vector1
  2922. * @param vector1 angle between vector0 and vector1
  2923. * @param normal direction of the normal
  2924. * @return the angle between vector0 and vector1
  2925. */
  2926. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2927. /**
  2928. * Returns a new Vector3 set from the index "offset" of the given array
  2929. * @param array defines the source array
  2930. * @param offset defines the offset in the source array
  2931. * @returns the new Vector3
  2932. */
  2933. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2936. * @param array defines the source array
  2937. * @param offset defines the offset in the source array
  2938. * @returns the new Vector3
  2939. * @deprecated Please use FromArray instead.
  2940. */
  2941. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2942. /**
  2943. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2944. * @param array defines the source array
  2945. * @param offset defines the offset in the source array
  2946. * @param result defines the Vector3 where to store the result
  2947. */
  2948. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2949. /**
  2950. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2951. * @param array defines the source array
  2952. * @param offset defines the offset in the source array
  2953. * @param result defines the Vector3 where to store the result
  2954. * @deprecated Please use FromArrayToRef instead.
  2955. */
  2956. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2957. /**
  2958. * Sets the given vector "result" with the given floats.
  2959. * @param x defines the x coordinate of the source
  2960. * @param y defines the y coordinate of the source
  2961. * @param z defines the z coordinate of the source
  2962. * @param result defines the Vector3 where to store the result
  2963. */
  2964. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2967. * @returns a new empty Vector3
  2968. */
  2969. static Zero(): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2972. * @returns a new unit Vector3
  2973. */
  2974. static One(): Vector3;
  2975. /**
  2976. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2977. * @returns a new up Vector3
  2978. */
  2979. static Up(): Vector3;
  2980. /**
  2981. * Gets a up Vector3 that must not be updated
  2982. */
  2983. static get UpReadOnly(): DeepImmutable<Vector3>;
  2984. /**
  2985. * Gets a zero Vector3 that must not be updated
  2986. */
  2987. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2988. /**
  2989. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2990. * @returns a new down Vector3
  2991. */
  2992. static Down(): Vector3;
  2993. /**
  2994. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2995. * @param rightHandedSystem is the scene right-handed (negative z)
  2996. * @returns a new forward Vector3
  2997. */
  2998. static Forward(rightHandedSystem?: boolean): Vector3;
  2999. /**
  3000. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3001. * @param rightHandedSystem is the scene right-handed (negative-z)
  3002. * @returns a new forward Vector3
  3003. */
  3004. static Backward(rightHandedSystem?: boolean): Vector3;
  3005. /**
  3006. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3007. * @returns a new right Vector3
  3008. */
  3009. static Right(): Vector3;
  3010. /**
  3011. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3012. * @returns a new left Vector3
  3013. */
  3014. static Left(): Vector3;
  3015. /**
  3016. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3017. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3018. * @param vector defines the Vector3 to transform
  3019. * @param transformation defines the transformation matrix
  3020. * @returns the transformed Vector3
  3021. */
  3022. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3023. /**
  3024. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3025. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3026. * @param vector defines the Vector3 to transform
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3033. * This method computes tranformed coordinates only, not transformed direction vectors
  3034. * @param x define the x coordinate of the source vector
  3035. * @param y define the y coordinate of the source vector
  3036. * @param z define the z coordinate of the source vector
  3037. * @param transformation defines the transformation matrix
  3038. * @param result defines the Vector3 where to store the result
  3039. */
  3040. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3041. /**
  3042. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3043. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3044. * @param vector defines the Vector3 to transform
  3045. * @param transformation defines the transformation matrix
  3046. * @returns the new Vector3
  3047. */
  3048. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3049. /**
  3050. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3051. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3052. * @param vector defines the Vector3 to transform
  3053. * @param transformation defines the transformation matrix
  3054. * @param result defines the Vector3 where to store the result
  3055. */
  3056. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3057. /**
  3058. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3059. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3060. * @param x define the x coordinate of the source vector
  3061. * @param y define the y coordinate of the source vector
  3062. * @param z define the z coordinate of the source vector
  3063. * @param transformation defines the transformation matrix
  3064. * @param result defines the Vector3 where to store the result
  3065. */
  3066. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3067. /**
  3068. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3069. * @param value1 defines the first control point
  3070. * @param value2 defines the second control point
  3071. * @param value3 defines the third control point
  3072. * @param value4 defines the fourth control point
  3073. * @param amount defines the amount on the spline to use
  3074. * @returns the new Vector3
  3075. */
  3076. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3077. /**
  3078. * 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"
  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. * @returns the new Vector3
  3085. */
  3086. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3087. /**
  3088. * 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"
  3089. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3090. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3091. * @param value defines the current value
  3092. * @param min defines the lower range value
  3093. * @param max defines the upper range value
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3097. /**
  3098. * Checks if a given vector is inside a specific range
  3099. * @param v defines the vector to test
  3100. * @param min defines the minimum range
  3101. * @param max defines the maximum range
  3102. */
  3103. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3104. /**
  3105. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3106. * @param value1 defines the first control point
  3107. * @param tangent1 defines the first tangent vector
  3108. * @param value2 defines the second control point
  3109. * @param tangent2 defines the second tangent vector
  3110. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3111. * @returns the new Vector3
  3112. */
  3113. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3114. /**
  3115. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3116. * @param start defines the start value
  3117. * @param end defines the end value
  3118. * @param amount max defines amount between both (between 0 and 1)
  3119. * @returns the new Vector3
  3120. */
  3121. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3122. /**
  3123. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3124. * @param start defines the start value
  3125. * @param end defines the end value
  3126. * @param amount max defines amount between both (between 0 and 1)
  3127. * @param result defines the Vector3 where to store the result
  3128. */
  3129. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3130. /**
  3131. * Returns the dot product (float) between the vectors "left" and "right"
  3132. * @param left defines the left operand
  3133. * @param right defines the right operand
  3134. * @returns the dot product
  3135. */
  3136. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3137. /**
  3138. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3139. * The cross product is then orthogonal to both "left" and "right"
  3140. * @param left defines the left operand
  3141. * @param right defines the right operand
  3142. * @returns the cross product
  3143. */
  3144. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3145. /**
  3146. * Sets the given vector "result" with the cross product of "left" and "right"
  3147. * The cross product is then orthogonal to both "left" and "right"
  3148. * @param left defines the left operand
  3149. * @param right defines the right operand
  3150. * @param result defines the Vector3 where to store the result
  3151. */
  3152. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3153. /**
  3154. * Returns a new Vector3 as the normalization of the given vector
  3155. * @param vector defines the Vector3 to normalize
  3156. * @returns the new Vector3
  3157. */
  3158. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3159. /**
  3160. * Sets the given vector "result" with the normalization of the given first vector
  3161. * @param vector defines the Vector3 to normalize
  3162. * @param result defines the Vector3 where to store the result
  3163. */
  3164. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3165. /**
  3166. * Project a Vector3 onto screen space
  3167. * @param vector defines the Vector3 to project
  3168. * @param world defines the world matrix to use
  3169. * @param transform defines the transform (view x projection) matrix to use
  3170. * @param viewport defines the screen viewport to use
  3171. * @returns the new Vector3
  3172. */
  3173. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3174. /** @hidden */
  3175. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  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 transform defines the transform (view x projection) matrix to use
  3183. * @returns the new Vector3
  3184. */
  3185. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3186. /**
  3187. * Unproject from screen space to object space
  3188. * @param source defines the screen space Vector3 to use
  3189. * @param viewportWidth defines the current width of the viewport
  3190. * @param viewportHeight defines the current height of the viewport
  3191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3192. * @param view defines the view matrix to use
  3193. * @param projection defines the projection matrix to use
  3194. * @returns the new Vector3
  3195. */
  3196. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3197. /**
  3198. * Unproject from screen space to object space
  3199. * @param source defines the screen space Vector3 to use
  3200. * @param viewportWidth defines the current width of the viewport
  3201. * @param viewportHeight defines the current height of the viewport
  3202. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3203. * @param view defines the view matrix to use
  3204. * @param projection defines the projection matrix to use
  3205. * @param result defines the Vector3 where to store the result
  3206. */
  3207. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3208. /**
  3209. * Unproject from screen space to object space
  3210. * @param sourceX defines the screen space x coordinate to use
  3211. * @param sourceY defines the screen space y coordinate to use
  3212. * @param sourceZ defines the screen space z coordinate to use
  3213. * @param viewportWidth defines the current width of the viewport
  3214. * @param viewportHeight defines the current height of the viewport
  3215. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3216. * @param view defines the view matrix to use
  3217. * @param projection defines the projection matrix to use
  3218. * @param result defines the Vector3 where to store the result
  3219. */
  3220. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3221. /**
  3222. * Gets the minimal coordinate values between two Vector3
  3223. * @param left defines the first operand
  3224. * @param right defines the second operand
  3225. * @returns the new Vector3
  3226. */
  3227. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3228. /**
  3229. * Gets the maximal coordinate values between two Vector3
  3230. * @param left defines the first operand
  3231. * @param right defines the second operand
  3232. * @returns the new Vector3
  3233. */
  3234. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3235. /**
  3236. * Returns the distance between the vectors "value1" and "value2"
  3237. * @param value1 defines the first operand
  3238. * @param value2 defines the second operand
  3239. * @returns the distance
  3240. */
  3241. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3242. /**
  3243. * Returns the squared distance between the vectors "value1" and "value2"
  3244. * @param value1 defines the first operand
  3245. * @param value2 defines the second operand
  3246. * @returns the squared distance
  3247. */
  3248. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3249. /**
  3250. * Returns a new Vector3 located at the center between "value1" and "value2"
  3251. * @param value1 defines the first operand
  3252. * @param value2 defines the second operand
  3253. * @returns the new Vector3
  3254. */
  3255. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3256. /**
  3257. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3258. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3259. * to something in order to rotate it from its local system to the given target system
  3260. * Note: axis1, axis2 and axis3 are normalized during this operation
  3261. * @param axis1 defines the first axis
  3262. * @param axis2 defines the second axis
  3263. * @param axis3 defines the third axis
  3264. * @returns a new Vector3
  3265. */
  3266. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3267. /**
  3268. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3269. * @param axis1 defines the first axis
  3270. * @param axis2 defines the second axis
  3271. * @param axis3 defines the third axis
  3272. * @param ref defines the Vector3 where to store the result
  3273. */
  3274. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3275. }
  3276. /**
  3277. * Vector4 class created for EulerAngle class conversion to Quaternion
  3278. */
  3279. export class Vector4 {
  3280. /** x value of the vector */
  3281. x: number;
  3282. /** y value of the vector */
  3283. y: number;
  3284. /** z value of the vector */
  3285. z: number;
  3286. /** w value of the vector */
  3287. w: number;
  3288. /**
  3289. * Creates a Vector4 object from the given floats.
  3290. * @param x x value of the vector
  3291. * @param y y value of the vector
  3292. * @param z z value of the vector
  3293. * @param w w value of the vector
  3294. */
  3295. constructor(
  3296. /** x value of the vector */
  3297. x: number,
  3298. /** y value of the vector */
  3299. y: number,
  3300. /** z value of the vector */
  3301. z: number,
  3302. /** w value of the vector */
  3303. w: number);
  3304. /**
  3305. * Returns the string with the Vector4 coordinates.
  3306. * @returns a string containing all the vector values
  3307. */
  3308. toString(): string;
  3309. /**
  3310. * Returns the string "Vector4".
  3311. * @returns "Vector4"
  3312. */
  3313. getClassName(): string;
  3314. /**
  3315. * Returns the Vector4 hash code.
  3316. * @returns a unique hash code
  3317. */
  3318. getHashCode(): number;
  3319. /**
  3320. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3321. * @returns the resulting array
  3322. */
  3323. asArray(): number[];
  3324. /**
  3325. * Populates the given array from the given index with the Vector4 coordinates.
  3326. * @param array array to populate
  3327. * @param index index of the array to start at (default: 0)
  3328. * @returns the Vector4.
  3329. */
  3330. toArray(array: FloatArray, index?: number): Vector4;
  3331. /**
  3332. * Update the current vector from an array
  3333. * @param array defines the destination array
  3334. * @param index defines the offset in the destination array
  3335. * @returns the current Vector3
  3336. */
  3337. fromArray(array: FloatArray, index?: number): Vector4;
  3338. /**
  3339. * Adds the given vector to the current Vector4.
  3340. * @param otherVector the vector to add
  3341. * @returns the updated Vector4.
  3342. */
  3343. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3344. /**
  3345. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3346. * @param otherVector the vector to add
  3347. * @returns the resulting vector
  3348. */
  3349. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3350. /**
  3351. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3352. * @param otherVector the vector to add
  3353. * @param result the vector to store the result
  3354. * @returns the current Vector4.
  3355. */
  3356. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3357. /**
  3358. * Subtract in place the given vector from the current Vector4.
  3359. * @param otherVector the vector to subtract
  3360. * @returns the updated Vector4.
  3361. */
  3362. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3365. * @param otherVector the vector to add
  3366. * @returns the new vector with the result
  3367. */
  3368. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3369. /**
  3370. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3371. * @param otherVector the vector to subtract
  3372. * @param result the vector to store the result
  3373. * @returns the current Vector4.
  3374. */
  3375. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3376. /**
  3377. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3378. */
  3379. /**
  3380. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3381. * @param x value to subtract
  3382. * @param y value to subtract
  3383. * @param z value to subtract
  3384. * @param w value to subtract
  3385. * @returns new vector containing the result
  3386. */
  3387. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3388. /**
  3389. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3390. * @param x value to subtract
  3391. * @param y value to subtract
  3392. * @param z value to subtract
  3393. * @param w value to subtract
  3394. * @param result the vector to store the result in
  3395. * @returns the current Vector4.
  3396. */
  3397. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3398. /**
  3399. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3400. * @returns a new vector with the negated values
  3401. */
  3402. negate(): Vector4;
  3403. /**
  3404. * Negate this vector in place
  3405. * @returns this
  3406. */
  3407. negateInPlace(): Vector4;
  3408. /**
  3409. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3410. * @param result defines the Vector3 object where to store the result
  3411. * @returns the current Vector4
  3412. */
  3413. negateToRef(result: Vector4): Vector4;
  3414. /**
  3415. * Multiplies the current Vector4 coordinates by scale (float).
  3416. * @param scale the number to scale with
  3417. * @returns the updated Vector4.
  3418. */
  3419. scaleInPlace(scale: number): Vector4;
  3420. /**
  3421. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3422. * @param scale the number to scale with
  3423. * @returns a new vector with the result
  3424. */
  3425. scale(scale: number): Vector4;
  3426. /**
  3427. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3428. * @param scale the number to scale with
  3429. * @param result a vector to store the result in
  3430. * @returns the current Vector4.
  3431. */
  3432. scaleToRef(scale: number, result: Vector4): Vector4;
  3433. /**
  3434. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3435. * @param scale defines the scale factor
  3436. * @param result defines the Vector4 object where to store the result
  3437. * @returns the unmodified current Vector4
  3438. */
  3439. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3440. /**
  3441. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3442. * @param otherVector the vector to compare against
  3443. * @returns true if they are equal
  3444. */
  3445. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3446. /**
  3447. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3448. * @param otherVector vector to compare against
  3449. * @param epsilon (Default: very small number)
  3450. * @returns true if they are equal
  3451. */
  3452. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3453. /**
  3454. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3455. * @param x x value to compare against
  3456. * @param y y value to compare against
  3457. * @param z z value to compare against
  3458. * @param w w value to compare against
  3459. * @returns true if equal
  3460. */
  3461. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3462. /**
  3463. * Multiplies in place the current Vector4 by the given one.
  3464. * @param otherVector vector to multiple with
  3465. * @returns the updated Vector4.
  3466. */
  3467. multiplyInPlace(otherVector: Vector4): Vector4;
  3468. /**
  3469. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3470. * @param otherVector vector to multiple with
  3471. * @returns resulting new vector
  3472. */
  3473. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3474. /**
  3475. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3476. * @param otherVector vector to multiple with
  3477. * @param result vector to store the result
  3478. * @returns the current Vector4.
  3479. */
  3480. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3481. /**
  3482. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3483. * @param x x value multiply with
  3484. * @param y y value multiply with
  3485. * @param z z value multiply with
  3486. * @param w w value multiply with
  3487. * @returns resulting new vector
  3488. */
  3489. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3490. /**
  3491. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3492. * @param otherVector vector to devide with
  3493. * @returns resulting new vector
  3494. */
  3495. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3496. /**
  3497. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3498. * @param otherVector vector to devide with
  3499. * @param result vector to store the result
  3500. * @returns the current Vector4.
  3501. */
  3502. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3503. /**
  3504. * Divides the current Vector3 coordinates by the given ones.
  3505. * @param otherVector vector to devide with
  3506. * @returns the updated Vector3.
  3507. */
  3508. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3509. /**
  3510. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3511. * @param other defines the second operand
  3512. * @returns the current updated Vector4
  3513. */
  3514. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3515. /**
  3516. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3517. * @param other defines the second operand
  3518. * @returns the current updated Vector4
  3519. */
  3520. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3521. /**
  3522. * Gets a new Vector4 from current Vector4 floored values
  3523. * @returns a new Vector4
  3524. */
  3525. floor(): Vector4;
  3526. /**
  3527. * Gets a new Vector4 from current Vector3 floored values
  3528. * @returns a new Vector4
  3529. */
  3530. fract(): Vector4;
  3531. /**
  3532. * Returns the Vector4 length (float).
  3533. * @returns the length
  3534. */
  3535. length(): number;
  3536. /**
  3537. * Returns the Vector4 squared length (float).
  3538. * @returns the length squared
  3539. */
  3540. lengthSquared(): number;
  3541. /**
  3542. * Normalizes in place the Vector4.
  3543. * @returns the updated Vector4.
  3544. */
  3545. normalize(): Vector4;
  3546. /**
  3547. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3548. * @returns this converted to a new vector3
  3549. */
  3550. toVector3(): Vector3;
  3551. /**
  3552. * Returns a new Vector4 copied from the current one.
  3553. * @returns the new cloned vector
  3554. */
  3555. clone(): Vector4;
  3556. /**
  3557. * Updates the current Vector4 with the given one coordinates.
  3558. * @param source the source vector to copy from
  3559. * @returns the updated Vector4.
  3560. */
  3561. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Updates the current Vector4 coordinates with the given floats.
  3564. * @param x float to copy from
  3565. * @param y float to copy from
  3566. * @param z float to copy from
  3567. * @param w float to copy from
  3568. * @returns the updated Vector4.
  3569. */
  3570. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3571. /**
  3572. * Updates the current Vector4 coordinates with the given floats.
  3573. * @param x float to set from
  3574. * @param y float to set from
  3575. * @param z float to set from
  3576. * @param w float to set from
  3577. * @returns the updated Vector4.
  3578. */
  3579. set(x: number, y: number, z: number, w: number): Vector4;
  3580. /**
  3581. * Copies the given float to the current Vector3 coordinates
  3582. * @param v defines the x, y, z and w coordinates of the operand
  3583. * @returns the current updated Vector3
  3584. */
  3585. setAll(v: number): Vector4;
  3586. /**
  3587. * Returns a new Vector4 set from the starting index of the given array.
  3588. * @param array the array to pull values from
  3589. * @param offset the offset into the array to start at
  3590. * @returns the new vector
  3591. */
  3592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3593. /**
  3594. * Updates the given vector "result" from the starting index of the given array.
  3595. * @param array the array to pull values from
  3596. * @param offset the offset into the array to start at
  3597. * @param result the vector to store the result in
  3598. */
  3599. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3600. /**
  3601. * Updates the given vector "result" from the starting index of the given Float32Array.
  3602. * @param array the array to pull values from
  3603. * @param offset the offset into the array to start at
  3604. * @param result the vector to store the result in
  3605. */
  3606. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3607. /**
  3608. * Updates the given vector "result" coordinates from the given floats.
  3609. * @param x float to set from
  3610. * @param y float to set from
  3611. * @param z float to set from
  3612. * @param w float to set from
  3613. * @param result the vector to the floats in
  3614. */
  3615. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3616. /**
  3617. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3618. * @returns the new vector
  3619. */
  3620. static Zero(): Vector4;
  3621. /**
  3622. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3623. * @returns the new vector
  3624. */
  3625. static One(): Vector4;
  3626. /**
  3627. * Returns a new normalized Vector4 from the given one.
  3628. * @param vector the vector to normalize
  3629. * @returns the vector
  3630. */
  3631. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3632. /**
  3633. * Updates the given vector "result" from the normalization of the given one.
  3634. * @param vector the vector to normalize
  3635. * @param result the vector to store the result in
  3636. */
  3637. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3638. /**
  3639. * Returns a vector with the minimum values from the left and right vectors
  3640. * @param left left vector to minimize
  3641. * @param right right vector to minimize
  3642. * @returns a new vector with the minimum of the left and right vector values
  3643. */
  3644. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3645. /**
  3646. * Returns a vector with the maximum values from the left and right vectors
  3647. * @param left left vector to maximize
  3648. * @param right right vector to maximize
  3649. * @returns a new vector with the maximum of the left and right vector values
  3650. */
  3651. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3652. /**
  3653. * Returns the distance (float) between the vectors "value1" and "value2".
  3654. * @param value1 value to calulate the distance between
  3655. * @param value2 value to calulate the distance between
  3656. * @return the distance between the two vectors
  3657. */
  3658. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3659. /**
  3660. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3661. * @param value1 value to calulate the distance between
  3662. * @param value2 value to calulate the distance between
  3663. * @return the distance between the two vectors squared
  3664. */
  3665. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3666. /**
  3667. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3668. * @param value1 value to calulate the center between
  3669. * @param value2 value to calulate the center between
  3670. * @return the center between the two vectors
  3671. */
  3672. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3673. /**
  3674. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3675. * This methods computes transformed normalized direction vectors only.
  3676. * @param vector the vector to transform
  3677. * @param transformation the transformation matrix to apply
  3678. * @returns the new vector
  3679. */
  3680. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3681. /**
  3682. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3683. * This methods computes transformed normalized direction vectors only.
  3684. * @param vector the vector to transform
  3685. * @param transformation the transformation matrix to apply
  3686. * @param result the vector to store the result in
  3687. */
  3688. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3689. /**
  3690. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3691. * This methods computes transformed normalized direction vectors only.
  3692. * @param x value to transform
  3693. * @param y value to transform
  3694. * @param z value to transform
  3695. * @param w value to transform
  3696. * @param transformation the transformation matrix to apply
  3697. * @param result the vector to store the results in
  3698. */
  3699. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3700. /**
  3701. * Creates a new Vector4 from a Vector3
  3702. * @param source defines the source data
  3703. * @param w defines the 4th component (default is 0)
  3704. * @returns a new Vector4
  3705. */
  3706. static FromVector3(source: Vector3, w?: number): Vector4;
  3707. }
  3708. /**
  3709. * Class used to store quaternion data
  3710. * @see https://en.wikipedia.org/wiki/Quaternion
  3711. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3712. */
  3713. export class Quaternion {
  3714. /** @hidden */
  3715. _x: number;
  3716. /** @hidden */
  3717. _y: number;
  3718. /** @hidden */
  3719. _z: number;
  3720. /** @hidden */
  3721. _w: number;
  3722. /** @hidden */
  3723. _isDirty: boolean;
  3724. /** Gets or sets the x coordinate */
  3725. get x(): number;
  3726. set x(value: number);
  3727. /** Gets or sets the y coordinate */
  3728. get y(): number;
  3729. set y(value: number);
  3730. /** Gets or sets the z coordinate */
  3731. get z(): number;
  3732. set z(value: number);
  3733. /** Gets or sets the w coordinate */
  3734. get w(): number;
  3735. set w(value: number);
  3736. /**
  3737. * Creates a new Quaternion from the given floats
  3738. * @param x defines the first component (0 by default)
  3739. * @param y defines the second component (0 by default)
  3740. * @param z defines the third component (0 by default)
  3741. * @param w defines the fourth component (1.0 by default)
  3742. */
  3743. constructor(x?: number, y?: number, z?: number, w?: number);
  3744. /**
  3745. * Gets a string representation for the current quaternion
  3746. * @returns a string with the Quaternion coordinates
  3747. */
  3748. toString(): string;
  3749. /**
  3750. * Gets the class name of the quaternion
  3751. * @returns the string "Quaternion"
  3752. */
  3753. getClassName(): string;
  3754. /**
  3755. * Gets a hash code for this quaternion
  3756. * @returns the quaternion hash code
  3757. */
  3758. getHashCode(): number;
  3759. /**
  3760. * Copy the quaternion to an array
  3761. * @returns a new array populated with 4 elements from the quaternion coordinates
  3762. */
  3763. asArray(): number[];
  3764. /**
  3765. * Check if two quaternions are equals
  3766. * @param otherQuaternion defines the second operand
  3767. * @return true if the current quaternion and the given one coordinates are strictly equals
  3768. */
  3769. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3770. /**
  3771. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3772. * @param otherQuaternion defines the other quaternion
  3773. * @param epsilon defines the minimal distance to consider equality
  3774. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3775. */
  3776. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3777. /**
  3778. * Clone the current quaternion
  3779. * @returns a new quaternion copied from the current one
  3780. */
  3781. clone(): Quaternion;
  3782. /**
  3783. * Copy a quaternion to the current one
  3784. * @param other defines the other quaternion
  3785. * @returns the updated current quaternion
  3786. */
  3787. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Updates the current quaternion with the given float coordinates
  3790. * @param x defines the x coordinate
  3791. * @param y defines the y coordinate
  3792. * @param z defines the z coordinate
  3793. * @param w defines the w coordinate
  3794. * @returns the updated current quaternion
  3795. */
  3796. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3797. /**
  3798. * Updates the current quaternion from the given float coordinates
  3799. * @param x defines the x coordinate
  3800. * @param y defines the y coordinate
  3801. * @param z defines the z coordinate
  3802. * @param w defines the w coordinate
  3803. * @returns the updated current quaternion
  3804. */
  3805. set(x: number, y: number, z: number, w: number): Quaternion;
  3806. /**
  3807. * Adds two quaternions
  3808. * @param other defines the second operand
  3809. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3810. */
  3811. add(other: DeepImmutable<Quaternion>): Quaternion;
  3812. /**
  3813. * Add a quaternion to the current one
  3814. * @param other defines the quaternion to add
  3815. * @returns the current quaternion
  3816. */
  3817. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3818. /**
  3819. * Subtract two quaternions
  3820. * @param other defines the second operand
  3821. * @returns a new quaternion as the subtraction result of the given one from the current one
  3822. */
  3823. subtract(other: Quaternion): Quaternion;
  3824. /**
  3825. * Multiplies the current quaternion by a scale factor
  3826. * @param value defines the scale factor
  3827. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3828. */
  3829. scale(value: number): Quaternion;
  3830. /**
  3831. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3832. * @param scale defines the scale factor
  3833. * @param result defines the Quaternion object where to store the result
  3834. * @returns the unmodified current quaternion
  3835. */
  3836. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3837. /**
  3838. * Multiplies in place the current quaternion by a scale factor
  3839. * @param value defines the scale factor
  3840. * @returns the current modified quaternion
  3841. */
  3842. scaleInPlace(value: number): Quaternion;
  3843. /**
  3844. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3845. * @param scale defines the scale factor
  3846. * @param result defines the Quaternion object where to store the result
  3847. * @returns the unmodified current quaternion
  3848. */
  3849. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3850. /**
  3851. * Multiplies two quaternions
  3852. * @param q1 defines the second operand
  3853. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3854. */
  3855. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3856. /**
  3857. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3858. * @param q1 defines the second operand
  3859. * @param result defines the target quaternion
  3860. * @returns the current quaternion
  3861. */
  3862. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3863. /**
  3864. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3865. * @param q1 defines the second operand
  3866. * @returns the currentupdated quaternion
  3867. */
  3868. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3869. /**
  3870. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3871. * @param ref defines the target quaternion
  3872. * @returns the current quaternion
  3873. */
  3874. conjugateToRef(ref: Quaternion): Quaternion;
  3875. /**
  3876. * Conjugates in place (1-q) the current quaternion
  3877. * @returns the current updated quaternion
  3878. */
  3879. conjugateInPlace(): Quaternion;
  3880. /**
  3881. * Conjugates in place (1-q) the current quaternion
  3882. * @returns a new quaternion
  3883. */
  3884. conjugate(): Quaternion;
  3885. /**
  3886. * Gets length of current quaternion
  3887. * @returns the quaternion length (float)
  3888. */
  3889. length(): number;
  3890. /**
  3891. * Normalize in place the current quaternion
  3892. * @returns the current updated quaternion
  3893. */
  3894. normalize(): Quaternion;
  3895. /**
  3896. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3897. * @param order is a reserved parameter and is ignored for now
  3898. * @returns a new Vector3 containing the Euler angles
  3899. */
  3900. toEulerAngles(order?: string): Vector3;
  3901. /**
  3902. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3903. * @param result defines the vector which will be filled with the Euler angles
  3904. * @returns the current unchanged quaternion
  3905. */
  3906. toEulerAnglesToRef(result: Vector3): Quaternion;
  3907. /**
  3908. * Updates the given rotation matrix with the current quaternion values
  3909. * @param result defines the target matrix
  3910. * @returns the current unchanged quaternion
  3911. */
  3912. toRotationMatrix(result: Matrix): Quaternion;
  3913. /**
  3914. * Updates the current quaternion from the given rotation matrix values
  3915. * @param matrix defines the source matrix
  3916. * @returns the current updated quaternion
  3917. */
  3918. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3919. /**
  3920. * Creates a new quaternion from a rotation matrix
  3921. * @param matrix defines the source matrix
  3922. * @returns a new quaternion created from the given rotation matrix values
  3923. */
  3924. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3925. /**
  3926. * Updates the given quaternion with the given rotation matrix values
  3927. * @param matrix defines the source matrix
  3928. * @param result defines the target quaternion
  3929. */
  3930. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3931. /**
  3932. * Returns the dot product (float) between the quaternions "left" and "right"
  3933. * @param left defines the left operand
  3934. * @param right defines the right operand
  3935. * @returns the dot product
  3936. */
  3937. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3938. /**
  3939. * Checks if the two quaternions are close to each other
  3940. * @param quat0 defines the first quaternion to check
  3941. * @param quat1 defines the second quaternion to check
  3942. * @returns true if the two quaternions are close to each other
  3943. */
  3944. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3945. /**
  3946. * Creates an empty quaternion
  3947. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3948. */
  3949. static Zero(): Quaternion;
  3950. /**
  3951. * Inverse a given quaternion
  3952. * @param q defines the source quaternion
  3953. * @returns a new quaternion as the inverted current quaternion
  3954. */
  3955. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3956. /**
  3957. * Inverse a given quaternion
  3958. * @param q defines the source quaternion
  3959. * @param result the quaternion the result will be stored in
  3960. * @returns the result quaternion
  3961. */
  3962. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3963. /**
  3964. * Creates an identity quaternion
  3965. * @returns the identity quaternion
  3966. */
  3967. static Identity(): Quaternion;
  3968. /**
  3969. * Gets a boolean indicating if the given quaternion is identity
  3970. * @param quaternion defines the quaternion to check
  3971. * @returns true if the quaternion is identity
  3972. */
  3973. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3974. /**
  3975. * Creates a quaternion from a rotation around an axis
  3976. * @param axis defines the axis to use
  3977. * @param angle defines the angle to use
  3978. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3979. */
  3980. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3981. /**
  3982. * Creates a rotation around an axis and stores it into the given quaternion
  3983. * @param axis defines the axis to use
  3984. * @param angle defines the angle to use
  3985. * @param result defines the target quaternion
  3986. * @returns the target quaternion
  3987. */
  3988. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3989. /**
  3990. * Creates a new quaternion from data stored into an array
  3991. * @param array defines the data source
  3992. * @param offset defines the offset in the source array where the data starts
  3993. * @returns a new quaternion
  3994. */
  3995. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3996. /**
  3997. * Updates the given quaternion "result" from the starting index of the given array.
  3998. * @param array the array to pull values from
  3999. * @param offset the offset into the array to start at
  4000. * @param result the quaternion to store the result in
  4001. */
  4002. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4003. /**
  4004. * Create a quaternion from Euler rotation angles
  4005. * @param x Pitch
  4006. * @param y Yaw
  4007. * @param z Roll
  4008. * @returns the new Quaternion
  4009. */
  4010. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4011. /**
  4012. * Updates a quaternion from Euler rotation angles
  4013. * @param x Pitch
  4014. * @param y Yaw
  4015. * @param z Roll
  4016. * @param result the quaternion to store the result
  4017. * @returns the updated quaternion
  4018. */
  4019. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4020. /**
  4021. * Create a quaternion from Euler rotation vector
  4022. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4023. * @returns the new Quaternion
  4024. */
  4025. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4026. /**
  4027. * Updates a quaternion from Euler rotation vector
  4028. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4029. * @param result the quaternion to store the result
  4030. * @returns the updated quaternion
  4031. */
  4032. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4033. /**
  4034. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4035. * @param yaw defines the rotation around Y axis
  4036. * @param pitch defines the rotation around X axis
  4037. * @param roll defines the rotation around Z axis
  4038. * @returns the new quaternion
  4039. */
  4040. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4041. /**
  4042. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4043. * @param yaw defines the rotation around Y axis
  4044. * @param pitch defines the rotation around X axis
  4045. * @param roll defines the rotation around Z axis
  4046. * @param result defines the target quaternion
  4047. */
  4048. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4049. /**
  4050. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4051. * @param alpha defines the rotation around first axis
  4052. * @param beta defines the rotation around second axis
  4053. * @param gamma defines the rotation around third axis
  4054. * @returns the new quaternion
  4055. */
  4056. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4057. /**
  4058. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4059. * @param alpha defines the rotation around first axis
  4060. * @param beta defines the rotation around second axis
  4061. * @param gamma defines the rotation around third axis
  4062. * @param result defines the target quaternion
  4063. */
  4064. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4065. /**
  4066. * 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)
  4067. * @param axis1 defines the first axis
  4068. * @param axis2 defines the second axis
  4069. * @param axis3 defines the third axis
  4070. * @returns the new quaternion
  4071. */
  4072. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4073. /**
  4074. * 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
  4075. * @param axis1 defines the first axis
  4076. * @param axis2 defines the second axis
  4077. * @param axis3 defines the third axis
  4078. * @param ref defines the target quaternion
  4079. */
  4080. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4081. /**
  4082. * Interpolates between two quaternions
  4083. * @param left defines first quaternion
  4084. * @param right defines second quaternion
  4085. * @param amount defines the gradient to use
  4086. * @returns the new interpolated quaternion
  4087. */
  4088. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4089. /**
  4090. * Interpolates between two quaternions and stores it into a target quaternion
  4091. * @param left defines first quaternion
  4092. * @param right defines second quaternion
  4093. * @param amount defines the gradient to use
  4094. * @param result defines the target quaternion
  4095. */
  4096. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4097. /**
  4098. * Interpolate between two quaternions using Hermite interpolation
  4099. * @param value1 defines first quaternion
  4100. * @param tangent1 defines the incoming tangent
  4101. * @param value2 defines second quaternion
  4102. * @param tangent2 defines the outgoing tangent
  4103. * @param amount defines the target quaternion
  4104. * @returns the new interpolated quaternion
  4105. */
  4106. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4107. }
  4108. /**
  4109. * Class used to store matrix data (4x4)
  4110. */
  4111. export class Matrix {
  4112. /**
  4113. * Gets the precision of matrix computations
  4114. */
  4115. static get Use64Bits(): boolean;
  4116. private static _updateFlagSeed;
  4117. private static _identityReadOnly;
  4118. private _isIdentity;
  4119. private _isIdentityDirty;
  4120. private _isIdentity3x2;
  4121. private _isIdentity3x2Dirty;
  4122. /**
  4123. * Gets the update flag of the matrix which is an unique number for the matrix.
  4124. * It will be incremented every time the matrix data change.
  4125. * You can use it to speed the comparison between two versions of the same matrix.
  4126. */
  4127. updateFlag: number;
  4128. private readonly _m;
  4129. /**
  4130. * Gets the internal data of the matrix
  4131. */
  4132. get m(): DeepImmutable<Float32Array | Array<number>>;
  4133. /** @hidden */
  4134. _markAsUpdated(): void;
  4135. /** @hidden */
  4136. private _updateIdentityStatus;
  4137. /**
  4138. * Creates an empty matrix (filled with zeros)
  4139. */
  4140. constructor();
  4141. /**
  4142. * Check if the current matrix is identity
  4143. * @returns true is the matrix is the identity matrix
  4144. */
  4145. isIdentity(): boolean;
  4146. /**
  4147. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4148. * @returns true is the matrix is the identity matrix
  4149. */
  4150. isIdentityAs3x2(): boolean;
  4151. /**
  4152. * Gets the determinant of the matrix
  4153. * @returns the matrix determinant
  4154. */
  4155. determinant(): number;
  4156. /**
  4157. * Returns the matrix as a Float32Array or Array<number>
  4158. * @returns the matrix underlying array
  4159. */
  4160. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4161. /**
  4162. * Returns the matrix as a Float32Array or Array<number>
  4163. * @returns the matrix underlying array.
  4164. */
  4165. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4166. /**
  4167. * Inverts the current matrix in place
  4168. * @returns the current inverted matrix
  4169. */
  4170. invert(): Matrix;
  4171. /**
  4172. * Sets all the matrix elements to zero
  4173. * @returns the current matrix
  4174. */
  4175. reset(): Matrix;
  4176. /**
  4177. * Adds the current matrix with a second one
  4178. * @param other defines the matrix to add
  4179. * @returns a new matrix as the addition of the current matrix and the given one
  4180. */
  4181. add(other: DeepImmutable<Matrix>): Matrix;
  4182. /**
  4183. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4184. * @param other defines the matrix to add
  4185. * @param result defines the target matrix
  4186. * @returns the current matrix
  4187. */
  4188. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4189. /**
  4190. * Adds in place the given matrix to the current matrix
  4191. * @param other defines the second operand
  4192. * @returns the current updated matrix
  4193. */
  4194. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Sets the given matrix to the current inverted Matrix
  4197. * @param other defines the target matrix
  4198. * @returns the unmodified current matrix
  4199. */
  4200. invertToRef(other: Matrix): Matrix;
  4201. /**
  4202. * add a value at the specified position in the current Matrix
  4203. * @param index the index of the value within the matrix. between 0 and 15.
  4204. * @param value the value to be added
  4205. * @returns the current updated matrix
  4206. */
  4207. addAtIndex(index: number, value: number): Matrix;
  4208. /**
  4209. * mutiply the specified position in the current Matrix by a value
  4210. * @param index the index of the value within the matrix. between 0 and 15.
  4211. * @param value the value to be added
  4212. * @returns the current updated matrix
  4213. */
  4214. multiplyAtIndex(index: number, value: number): Matrix;
  4215. /**
  4216. * Inserts the translation vector (using 3 floats) in the current matrix
  4217. * @param x defines the 1st component of the translation
  4218. * @param y defines the 2nd component of the translation
  4219. * @param z defines the 3rd component of the translation
  4220. * @returns the current updated matrix
  4221. */
  4222. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4223. /**
  4224. * Adds the translation vector (using 3 floats) in the current matrix
  4225. * @param x defines the 1st component of the translation
  4226. * @param y defines the 2nd component of the translation
  4227. * @param z defines the 3rd component of the translation
  4228. * @returns the current updated matrix
  4229. */
  4230. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4231. /**
  4232. * Inserts the translation vector in the current matrix
  4233. * @param vector3 defines the translation to insert
  4234. * @returns the current updated matrix
  4235. */
  4236. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4237. /**
  4238. * Gets the translation value of the current matrix
  4239. * @returns a new Vector3 as the extracted translation from the matrix
  4240. */
  4241. getTranslation(): Vector3;
  4242. /**
  4243. * Fill a Vector3 with the extracted translation from the matrix
  4244. * @param result defines the Vector3 where to store the translation
  4245. * @returns the current matrix
  4246. */
  4247. getTranslationToRef(result: Vector3): Matrix;
  4248. /**
  4249. * Remove rotation and scaling part from the matrix
  4250. * @returns the updated matrix
  4251. */
  4252. removeRotationAndScaling(): Matrix;
  4253. /**
  4254. * Multiply two matrices
  4255. * @param other defines the second operand
  4256. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4257. */
  4258. multiply(other: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Copy the current matrix from the given one
  4261. * @param other defines the source matrix
  4262. * @returns the current updated matrix
  4263. */
  4264. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4265. /**
  4266. * Populates the given array from the starting index with the current matrix values
  4267. * @param array defines the target array
  4268. * @param offset defines the offset in the target array where to start storing values
  4269. * @returns the current matrix
  4270. */
  4271. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4272. /**
  4273. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4274. * @param other defines the second operand
  4275. * @param result defines the matrix where to store the multiplication
  4276. * @returns the current matrix
  4277. */
  4278. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4279. /**
  4280. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4281. * @param other defines the second operand
  4282. * @param result defines the array where to store the multiplication
  4283. * @param offset defines the offset in the target array where to start storing values
  4284. * @returns the current matrix
  4285. */
  4286. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4287. /**
  4288. * Check equality between this matrix and a second one
  4289. * @param value defines the second matrix to compare
  4290. * @returns true is the current matrix and the given one values are strictly equal
  4291. */
  4292. equals(value: DeepImmutable<Matrix>): boolean;
  4293. /**
  4294. * Clone the current matrix
  4295. * @returns a new matrix from the current matrix
  4296. */
  4297. clone(): Matrix;
  4298. /**
  4299. * Returns the name of the current matrix class
  4300. * @returns the string "Matrix"
  4301. */
  4302. getClassName(): string;
  4303. /**
  4304. * Gets the hash code of the current matrix
  4305. * @returns the hash code
  4306. */
  4307. getHashCode(): number;
  4308. /**
  4309. * Decomposes the current Matrix into a translation, rotation and scaling components
  4310. * @param scale defines the scale vector3 given as a reference to update
  4311. * @param rotation defines the rotation quaternion given as a reference to update
  4312. * @param translation defines the translation vector3 given as a reference to update
  4313. * @returns true if operation was successful
  4314. */
  4315. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4316. /**
  4317. * Gets specific row of the matrix
  4318. * @param index defines the number of the row to get
  4319. * @returns the index-th row of the current matrix as a new Vector4
  4320. */
  4321. getRow(index: number): Nullable<Vector4>;
  4322. /**
  4323. * Sets the index-th row of the current matrix to the vector4 values
  4324. * @param index defines the number of the row to set
  4325. * @param row defines the target vector4
  4326. * @returns the updated current matrix
  4327. */
  4328. setRow(index: number, row: Vector4): Matrix;
  4329. /**
  4330. * Compute the transpose of the matrix
  4331. * @returns the new transposed matrix
  4332. */
  4333. transpose(): Matrix;
  4334. /**
  4335. * Compute the transpose of the matrix and store it in a given matrix
  4336. * @param result defines the target matrix
  4337. * @returns the current matrix
  4338. */
  4339. transposeToRef(result: Matrix): Matrix;
  4340. /**
  4341. * Sets the index-th row of the current matrix with the given 4 x float values
  4342. * @param index defines the row index
  4343. * @param x defines the x component to set
  4344. * @param y defines the y component to set
  4345. * @param z defines the z component to set
  4346. * @param w defines the w component to set
  4347. * @returns the updated current matrix
  4348. */
  4349. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4350. /**
  4351. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4352. * @param scale defines the scale factor
  4353. * @returns a new matrix
  4354. */
  4355. scale(scale: number): Matrix;
  4356. /**
  4357. * Scale the current matrix values by a factor to a given result matrix
  4358. * @param scale defines the scale factor
  4359. * @param result defines the matrix to store the result
  4360. * @returns the current matrix
  4361. */
  4362. scaleToRef(scale: number, result: Matrix): Matrix;
  4363. /**
  4364. * Scale the current matrix values by a factor and add the result to a given matrix
  4365. * @param scale defines the scale factor
  4366. * @param result defines the Matrix to store the result
  4367. * @returns the current matrix
  4368. */
  4369. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4370. /**
  4371. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4372. * @param ref matrix to store the result
  4373. */
  4374. toNormalMatrix(ref: Matrix): void;
  4375. /**
  4376. * Gets only rotation part of the current matrix
  4377. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4378. */
  4379. getRotationMatrix(): Matrix;
  4380. /**
  4381. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4382. * @param result defines the target matrix to store data to
  4383. * @returns the current matrix
  4384. */
  4385. getRotationMatrixToRef(result: Matrix): Matrix;
  4386. /**
  4387. * Toggles model matrix from being right handed to left handed in place and vice versa
  4388. */
  4389. toggleModelMatrixHandInPlace(): void;
  4390. /**
  4391. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4392. */
  4393. toggleProjectionMatrixHandInPlace(): void;
  4394. /**
  4395. * Creates a matrix from an array
  4396. * @param array defines the source array
  4397. * @param offset defines an offset in the source array
  4398. * @returns a new Matrix set from the starting index of the given array
  4399. */
  4400. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4401. /**
  4402. * Copy the content of an array into a given matrix
  4403. * @param array defines the source array
  4404. * @param offset defines an offset in the source array
  4405. * @param result defines the target matrix
  4406. */
  4407. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4408. /**
  4409. * Stores an array into a matrix after having multiplied each component by a given factor
  4410. * @param array defines the source array
  4411. * @param offset defines the offset in the source array
  4412. * @param scale defines the scaling factor
  4413. * @param result defines the target matrix
  4414. */
  4415. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4416. /**
  4417. * Gets an identity matrix that must not be updated
  4418. */
  4419. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4420. /**
  4421. * Stores a list of values (16) inside a given matrix
  4422. * @param initialM11 defines 1st value of 1st row
  4423. * @param initialM12 defines 2nd value of 1st row
  4424. * @param initialM13 defines 3rd value of 1st row
  4425. * @param initialM14 defines 4th value of 1st row
  4426. * @param initialM21 defines 1st value of 2nd row
  4427. * @param initialM22 defines 2nd value of 2nd row
  4428. * @param initialM23 defines 3rd value of 2nd row
  4429. * @param initialM24 defines 4th value of 2nd row
  4430. * @param initialM31 defines 1st value of 3rd row
  4431. * @param initialM32 defines 2nd value of 3rd row
  4432. * @param initialM33 defines 3rd value of 3rd row
  4433. * @param initialM34 defines 4th value of 3rd row
  4434. * @param initialM41 defines 1st value of 4th row
  4435. * @param initialM42 defines 2nd value of 4th row
  4436. * @param initialM43 defines 3rd value of 4th row
  4437. * @param initialM44 defines 4th value of 4th row
  4438. * @param result defines the target matrix
  4439. */
  4440. 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;
  4441. /**
  4442. * Creates new matrix from a list of values (16)
  4443. * @param initialM11 defines 1st value of 1st row
  4444. * @param initialM12 defines 2nd value of 1st row
  4445. * @param initialM13 defines 3rd value of 1st row
  4446. * @param initialM14 defines 4th value of 1st row
  4447. * @param initialM21 defines 1st value of 2nd row
  4448. * @param initialM22 defines 2nd value of 2nd row
  4449. * @param initialM23 defines 3rd value of 2nd row
  4450. * @param initialM24 defines 4th value of 2nd row
  4451. * @param initialM31 defines 1st value of 3rd row
  4452. * @param initialM32 defines 2nd value of 3rd row
  4453. * @param initialM33 defines 3rd value of 3rd row
  4454. * @param initialM34 defines 4th value of 3rd row
  4455. * @param initialM41 defines 1st value of 4th row
  4456. * @param initialM42 defines 2nd value of 4th row
  4457. * @param initialM43 defines 3rd value of 4th row
  4458. * @param initialM44 defines 4th value of 4th row
  4459. * @returns the new matrix
  4460. */
  4461. 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;
  4462. /**
  4463. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4464. * @param scale defines the scale vector3
  4465. * @param rotation defines the rotation quaternion
  4466. * @param translation defines the translation vector3
  4467. * @returns a new matrix
  4468. */
  4469. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4470. /**
  4471. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4472. * @param scale defines the scale vector3
  4473. * @param rotation defines the rotation quaternion
  4474. * @param translation defines the translation vector3
  4475. * @param result defines the target matrix
  4476. */
  4477. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4478. /**
  4479. * Creates a new identity matrix
  4480. * @returns a new identity matrix
  4481. */
  4482. static Identity(): Matrix;
  4483. /**
  4484. * Creates a new identity matrix and stores the result in a given matrix
  4485. * @param result defines the target matrix
  4486. */
  4487. static IdentityToRef(result: Matrix): void;
  4488. /**
  4489. * Creates a new zero matrix
  4490. * @returns a new zero matrix
  4491. */
  4492. static Zero(): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the X axis
  4495. * @param angle defines the angle (in radians) to use
  4496. * @return the new matrix
  4497. */
  4498. static RotationX(angle: number): Matrix;
  4499. /**
  4500. * Creates a new matrix as the invert of a given matrix
  4501. * @param source defines the source matrix
  4502. * @returns the new matrix
  4503. */
  4504. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4507. * @param angle defines the angle (in radians) to use
  4508. * @param result defines the target matrix
  4509. */
  4510. static RotationXToRef(angle: number, result: Matrix): void;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the Y axis
  4513. * @param angle defines the angle (in radians) to use
  4514. * @return the new matrix
  4515. */
  4516. static RotationY(angle: number): Matrix;
  4517. /**
  4518. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4519. * @param angle defines the angle (in radians) to use
  4520. * @param result defines the target matrix
  4521. */
  4522. static RotationYToRef(angle: number, result: Matrix): void;
  4523. /**
  4524. * Creates a new rotation matrix for "angle" radians around the Z axis
  4525. * @param angle defines the angle (in radians) to use
  4526. * @return the new matrix
  4527. */
  4528. static RotationZ(angle: number): Matrix;
  4529. /**
  4530. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4531. * @param angle defines the angle (in radians) to use
  4532. * @param result defines the target matrix
  4533. */
  4534. static RotationZToRef(angle: number, result: Matrix): void;
  4535. /**
  4536. * Creates a new rotation matrix for "angle" radians around the given axis
  4537. * @param axis defines the axis to use
  4538. * @param angle defines the angle (in radians) to use
  4539. * @return the new matrix
  4540. */
  4541. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4542. /**
  4543. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4544. * @param axis defines the axis to use
  4545. * @param angle defines the angle (in radians) to use
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4549. /**
  4550. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4551. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4552. * @param from defines the vector to align
  4553. * @param to defines the vector to align to
  4554. * @param result defines the target matrix
  4555. */
  4556. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4557. /**
  4558. * Creates a rotation matrix
  4559. * @param yaw defines the yaw angle in radians (Y axis)
  4560. * @param pitch defines the pitch angle in radians (X axis)
  4561. * @param roll defines the roll angle in radians (Z axis)
  4562. * @returns the new rotation matrix
  4563. */
  4564. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4565. /**
  4566. * Creates a rotation matrix and stores it in a given matrix
  4567. * @param yaw defines the yaw angle in radians (Y axis)
  4568. * @param pitch defines the pitch angle in radians (X axis)
  4569. * @param roll defines the roll angle in radians (Z axis)
  4570. * @param result defines the target matrix
  4571. */
  4572. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4573. /**
  4574. * Creates a scaling matrix
  4575. * @param x defines the scale factor on X axis
  4576. * @param y defines the scale factor on Y axis
  4577. * @param z defines the scale factor on Z axis
  4578. * @returns the new matrix
  4579. */
  4580. static Scaling(x: number, y: number, z: number): Matrix;
  4581. /**
  4582. * Creates a scaling matrix and stores it in a given matrix
  4583. * @param x defines the scale factor on X axis
  4584. * @param y defines the scale factor on Y axis
  4585. * @param z defines the scale factor on Z axis
  4586. * @param result defines the target matrix
  4587. */
  4588. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4589. /**
  4590. * Creates a translation matrix
  4591. * @param x defines the translation on X axis
  4592. * @param y defines the translation on Y axis
  4593. * @param z defines the translationon Z axis
  4594. * @returns the new matrix
  4595. */
  4596. static Translation(x: number, y: number, z: number): Matrix;
  4597. /**
  4598. * Creates a translation matrix and stores it in a given matrix
  4599. * @param x defines the translation on X axis
  4600. * @param y defines the translation on Y axis
  4601. * @param z defines the translationon Z axis
  4602. * @param result defines the target matrix
  4603. */
  4604. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4605. /**
  4606. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4607. * @param startValue defines the start value
  4608. * @param endValue defines the end value
  4609. * @param gradient defines the gradient factor
  4610. * @returns the new matrix
  4611. */
  4612. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4613. /**
  4614. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4615. * @param startValue defines the start value
  4616. * @param endValue defines the end value
  4617. * @param gradient defines the gradient factor
  4618. * @param result defines the Matrix object where to store data
  4619. */
  4620. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4621. /**
  4622. * Builds a new matrix whose values are computed by:
  4623. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4624. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4625. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4626. * @param startValue defines the first matrix
  4627. * @param endValue defines the second matrix
  4628. * @param gradient defines the gradient between the two matrices
  4629. * @returns the new matrix
  4630. */
  4631. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4632. /**
  4633. * Update a matrix to values which are computed by:
  4634. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4635. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4636. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4637. * @param startValue defines the first matrix
  4638. * @param endValue defines the second matrix
  4639. * @param gradient defines the gradient between the two matrices
  4640. * @param result defines the target matrix
  4641. */
  4642. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4643. /**
  4644. * 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"
  4645. * This function works in left handed mode
  4646. * @param eye defines the final position of the entity
  4647. * @param target defines where the entity should look at
  4648. * @param up defines the up vector for the entity
  4649. * @returns the new matrix
  4650. */
  4651. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4652. /**
  4653. * 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".
  4654. * This function works in left handed mode
  4655. * @param eye defines the final position of the entity
  4656. * @param target defines where the entity should look at
  4657. * @param up defines the up vector for the entity
  4658. * @param result defines the target matrix
  4659. */
  4660. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4661. /**
  4662. * 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"
  4663. * This function works in right handed mode
  4664. * @param eye defines the final position of the entity
  4665. * @param target defines where the entity should look at
  4666. * @param up defines the up vector for the entity
  4667. * @returns the new matrix
  4668. */
  4669. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4670. /**
  4671. * 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".
  4672. * This function works in right handed mode
  4673. * @param eye defines the final position of the entity
  4674. * @param target defines where the entity should look at
  4675. * @param up defines the up vector for the entity
  4676. * @param result defines the target matrix
  4677. */
  4678. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4679. /**
  4680. * Create a left-handed orthographic projection matrix
  4681. * @param width defines the viewport width
  4682. * @param height defines the viewport height
  4683. * @param znear defines the near clip plane
  4684. * @param zfar defines the far clip plane
  4685. * @returns a new matrix as a left-handed orthographic projection matrix
  4686. */
  4687. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4688. /**
  4689. * Store a left-handed orthographic projection to a given matrix
  4690. * @param width defines the viewport width
  4691. * @param height defines the viewport height
  4692. * @param znear defines the near clip plane
  4693. * @param zfar defines the far clip plane
  4694. * @param result defines the target matrix
  4695. */
  4696. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4697. /**
  4698. * Create a left-handed orthographic projection matrix
  4699. * @param left defines the viewport left coordinate
  4700. * @param right defines the viewport right coordinate
  4701. * @param bottom defines the viewport bottom coordinate
  4702. * @param top defines the viewport top coordinate
  4703. * @param znear defines the near clip plane
  4704. * @param zfar defines the far clip plane
  4705. * @returns a new matrix as a left-handed orthographic projection matrix
  4706. */
  4707. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4708. /**
  4709. * Stores a left-handed orthographic projection into a given matrix
  4710. * @param left defines the viewport left coordinate
  4711. * @param right defines the viewport right coordinate
  4712. * @param bottom defines the viewport bottom coordinate
  4713. * @param top defines the viewport top coordinate
  4714. * @param znear defines the near clip plane
  4715. * @param zfar defines the far clip plane
  4716. * @param result defines the target matrix
  4717. */
  4718. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4719. /**
  4720. * Creates a right-handed orthographic projection matrix
  4721. * @param left defines the viewport left coordinate
  4722. * @param right defines the viewport right coordinate
  4723. * @param bottom defines the viewport bottom coordinate
  4724. * @param top defines the viewport top coordinate
  4725. * @param znear defines the near clip plane
  4726. * @param zfar defines the far clip plane
  4727. * @returns a new matrix as a right-handed orthographic projection matrix
  4728. */
  4729. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4730. /**
  4731. * Stores a right-handed orthographic projection into a given matrix
  4732. * @param left defines the viewport left coordinate
  4733. * @param right defines the viewport right coordinate
  4734. * @param bottom defines the viewport bottom coordinate
  4735. * @param top defines the viewport top coordinate
  4736. * @param znear defines the near clip plane
  4737. * @param zfar defines the far clip plane
  4738. * @param result defines the target matrix
  4739. */
  4740. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4741. /**
  4742. * Creates a left-handed perspective projection matrix
  4743. * @param width defines the viewport width
  4744. * @param height defines the viewport height
  4745. * @param znear defines the near clip plane
  4746. * @param zfar defines the far clip plane
  4747. * @returns a new matrix as a left-handed perspective projection matrix
  4748. */
  4749. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4750. /**
  4751. * Creates a left-handed perspective projection matrix
  4752. * @param fov defines the horizontal field of view
  4753. * @param aspect defines the aspect ratio
  4754. * @param znear defines the near clip plane
  4755. * @param zfar defines the far clip plane
  4756. * @returns a new matrix as a left-handed perspective projection matrix
  4757. */
  4758. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4759. /**
  4760. * Stores a left-handed perspective projection into a given matrix
  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 defines the far clip plane
  4765. * @param result defines the target matrix
  4766. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4767. */
  4768. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4769. /**
  4770. * Stores a left-handed perspective projection into a given matrix with depth reversed
  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 not used as infinity is used as far clip
  4775. * @param result defines the target matrix
  4776. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4777. */
  4778. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4779. /**
  4780. * Creates a right-handed perspective projection matrix
  4781. * @param fov defines the horizontal field of view
  4782. * @param aspect defines the aspect ratio
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @returns a new matrix as a right-handed perspective projection matrix
  4786. */
  4787. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  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 defines the far clip plane
  4794. * @param result defines the target matrix
  4795. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4796. */
  4797. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4798. /**
  4799. * Stores a right-handed perspective projection into a given matrix
  4800. * @param fov defines the horizontal field of view
  4801. * @param aspect defines the aspect ratio
  4802. * @param znear defines the near clip plane
  4803. * @param zfar not used as infinity is used as far clip
  4804. * @param result defines the target matrix
  4805. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4806. */
  4807. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4808. /**
  4809. * Stores a perspective projection for WebVR info a given matrix
  4810. * @param fov defines the field of view
  4811. * @param znear defines the near clip plane
  4812. * @param zfar defines the far clip plane
  4813. * @param result defines the target matrix
  4814. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4815. */
  4816. static PerspectiveFovWebVRToRef(fov: {
  4817. upDegrees: number;
  4818. downDegrees: number;
  4819. leftDegrees: number;
  4820. rightDegrees: number;
  4821. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4822. /**
  4823. * Computes a complete transformation matrix
  4824. * @param viewport defines the viewport to use
  4825. * @param world defines the world matrix
  4826. * @param view defines the view matrix
  4827. * @param projection defines the projection matrix
  4828. * @param zmin defines the near clip plane
  4829. * @param zmax defines the far clip plane
  4830. * @returns the transformation matrix
  4831. */
  4832. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4833. /**
  4834. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4835. * @param matrix defines the matrix to use
  4836. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4837. */
  4838. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4839. /**
  4840. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4841. * @param matrix defines the matrix to use
  4842. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4843. */
  4844. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4845. /**
  4846. * Compute the transpose of a given matrix
  4847. * @param matrix defines the matrix to transpose
  4848. * @returns the new matrix
  4849. */
  4850. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4851. /**
  4852. * Compute the transpose of a matrix and store it in a target matrix
  4853. * @param matrix defines the matrix to transpose
  4854. * @param result defines the target matrix
  4855. */
  4856. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4857. /**
  4858. * Computes a reflection matrix from a plane
  4859. * @param plane defines the reflection plane
  4860. * @returns a new matrix
  4861. */
  4862. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4863. /**
  4864. * Computes a reflection matrix from a plane
  4865. * @param plane defines the reflection plane
  4866. * @param result defines the target matrix
  4867. */
  4868. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4869. /**
  4870. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4871. * @param xaxis defines the value of the 1st axis
  4872. * @param yaxis defines the value of the 2nd axis
  4873. * @param zaxis defines the value of the 3rd axis
  4874. * @param result defines the target matrix
  4875. */
  4876. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4877. /**
  4878. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4879. * @param quat defines the quaternion to use
  4880. * @param result defines the target matrix
  4881. */
  4882. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4883. }
  4884. /**
  4885. * @hidden
  4886. */
  4887. export class TmpVectors {
  4888. static Vector2: Vector2[];
  4889. static Vector3: Vector3[];
  4890. static Vector4: Vector4[];
  4891. static Quaternion: Quaternion[];
  4892. static Matrix: Matrix[];
  4893. }
  4894. }
  4895. declare module "babylonjs/Maths/math.path" {
  4896. import { DeepImmutable, Nullable } from "babylonjs/types";
  4897. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4898. /**
  4899. * Defines potential orientation for back face culling
  4900. */
  4901. export enum Orientation {
  4902. /**
  4903. * Clockwise
  4904. */
  4905. CW = 0,
  4906. /** Counter clockwise */
  4907. CCW = 1
  4908. }
  4909. /** Class used to represent a Bezier curve */
  4910. export class BezierCurve {
  4911. /**
  4912. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4913. * @param t defines the time
  4914. * @param x1 defines the left coordinate on X axis
  4915. * @param y1 defines the left coordinate on Y axis
  4916. * @param x2 defines the right coordinate on X axis
  4917. * @param y2 defines the right coordinate on Y axis
  4918. * @returns the interpolated value
  4919. */
  4920. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4921. }
  4922. /**
  4923. * Defines angle representation
  4924. */
  4925. export class Angle {
  4926. private _radians;
  4927. /**
  4928. * Creates an Angle object of "radians" radians (float).
  4929. * @param radians the angle in radians
  4930. */
  4931. constructor(radians: number);
  4932. /**
  4933. * Get value in degrees
  4934. * @returns the Angle value in degrees (float)
  4935. */
  4936. degrees(): number;
  4937. /**
  4938. * Get value in radians
  4939. * @returns the Angle value in radians (float)
  4940. */
  4941. radians(): number;
  4942. /**
  4943. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4944. * @param a defines first point as the origin
  4945. * @param b defines point
  4946. * @returns a new Angle
  4947. */
  4948. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4949. /**
  4950. * Gets a new Angle object from the given float in radians
  4951. * @param radians defines the angle value in radians
  4952. * @returns a new Angle
  4953. */
  4954. static FromRadians(radians: number): Angle;
  4955. /**
  4956. * Gets a new Angle object from the given float in degrees
  4957. * @param degrees defines the angle value in degrees
  4958. * @returns a new Angle
  4959. */
  4960. static FromDegrees(degrees: number): Angle;
  4961. }
  4962. /**
  4963. * This represents an arc in a 2d space.
  4964. */
  4965. export class Arc2 {
  4966. /** Defines the start point of the arc */
  4967. startPoint: Vector2;
  4968. /** Defines the mid point of the arc */
  4969. midPoint: Vector2;
  4970. /** Defines the end point of the arc */
  4971. endPoint: Vector2;
  4972. /**
  4973. * Defines the center point of the arc.
  4974. */
  4975. centerPoint: Vector2;
  4976. /**
  4977. * Defines the radius of the arc.
  4978. */
  4979. radius: number;
  4980. /**
  4981. * Defines the angle of the arc (from mid point to end point).
  4982. */
  4983. angle: Angle;
  4984. /**
  4985. * Defines the start angle of the arc (from start point to middle point).
  4986. */
  4987. startAngle: Angle;
  4988. /**
  4989. * Defines the orientation of the arc (clock wise/counter clock wise).
  4990. */
  4991. orientation: Orientation;
  4992. /**
  4993. * Creates an Arc object from the three given points : start, middle and end.
  4994. * @param startPoint Defines the start point of the arc
  4995. * @param midPoint Defines the midlle point of the arc
  4996. * @param endPoint Defines the end point of the arc
  4997. */
  4998. constructor(
  4999. /** Defines the start point of the arc */
  5000. startPoint: Vector2,
  5001. /** Defines the mid point of the arc */
  5002. midPoint: Vector2,
  5003. /** Defines the end point of the arc */
  5004. endPoint: Vector2);
  5005. }
  5006. /**
  5007. * Represents a 2D path made up of multiple 2D points
  5008. */
  5009. export class Path2 {
  5010. private _points;
  5011. private _length;
  5012. /**
  5013. * If the path start and end point are the same
  5014. */
  5015. closed: boolean;
  5016. /**
  5017. * Creates a Path2 object from the starting 2D coordinates x and y.
  5018. * @param x the starting points x value
  5019. * @param y the starting points y value
  5020. */
  5021. constructor(x: number, y: number);
  5022. /**
  5023. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5024. * @param x the added points x value
  5025. * @param y the added points y value
  5026. * @returns the updated Path2.
  5027. */
  5028. addLineTo(x: number, y: number): Path2;
  5029. /**
  5030. * 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.
  5031. * @param midX middle point x value
  5032. * @param midY middle point y value
  5033. * @param endX end point x value
  5034. * @param endY end point y value
  5035. * @param numberOfSegments (default: 36)
  5036. * @returns the updated Path2.
  5037. */
  5038. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5039. /**
  5040. * Closes the Path2.
  5041. * @returns the Path2.
  5042. */
  5043. close(): Path2;
  5044. /**
  5045. * Gets the sum of the distance between each sequential point in the path
  5046. * @returns the Path2 total length (float).
  5047. */
  5048. length(): number;
  5049. /**
  5050. * Gets the points which construct the path
  5051. * @returns the Path2 internal array of points.
  5052. */
  5053. getPoints(): Vector2[];
  5054. /**
  5055. * Retreives the point at the distance aways from the starting point
  5056. * @param normalizedLengthPosition the length along the path to retreive the point from
  5057. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5058. */
  5059. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5060. /**
  5061. * Creates a new path starting from an x and y position
  5062. * @param x starting x value
  5063. * @param y starting y value
  5064. * @returns a new Path2 starting at the coordinates (x, y).
  5065. */
  5066. static StartingAt(x: number, y: number): Path2;
  5067. }
  5068. /**
  5069. * Represents a 3D path made up of multiple 3D points
  5070. */
  5071. export class Path3D {
  5072. /**
  5073. * an array of Vector3, the curve axis of the Path3D
  5074. */
  5075. path: Vector3[];
  5076. private _curve;
  5077. private _distances;
  5078. private _tangents;
  5079. private _normals;
  5080. private _binormals;
  5081. private _raw;
  5082. private _alignTangentsWithPath;
  5083. private readonly _pointAtData;
  5084. /**
  5085. * new Path3D(path, normal, raw)
  5086. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5087. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5088. * @param path an array of Vector3, the curve axis of the Path3D
  5089. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5090. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5091. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5092. */
  5093. constructor(
  5094. /**
  5095. * an array of Vector3, the curve axis of the Path3D
  5096. */
  5097. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5098. /**
  5099. * Returns the Path3D array of successive Vector3 designing its curve.
  5100. * @returns the Path3D array of successive Vector3 designing its curve.
  5101. */
  5102. getCurve(): Vector3[];
  5103. /**
  5104. * Returns the Path3D array of successive Vector3 designing its curve.
  5105. * @returns the Path3D array of successive Vector3 designing its curve.
  5106. */
  5107. getPoints(): Vector3[];
  5108. /**
  5109. * @returns the computed length (float) of the path.
  5110. */
  5111. length(): number;
  5112. /**
  5113. * Returns an array populated with tangent vectors on each Path3D curve point.
  5114. * @returns an array populated with tangent vectors on each Path3D curve point.
  5115. */
  5116. getTangents(): Vector3[];
  5117. /**
  5118. * Returns an array populated with normal vectors on each Path3D curve point.
  5119. * @returns an array populated with normal vectors on each Path3D curve point.
  5120. */
  5121. getNormals(): Vector3[];
  5122. /**
  5123. * Returns an array populated with binormal vectors on each Path3D curve point.
  5124. * @returns an array populated with binormal vectors on each Path3D curve point.
  5125. */
  5126. getBinormals(): Vector3[];
  5127. /**
  5128. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5129. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5130. */
  5131. getDistances(): number[];
  5132. /**
  5133. * Returns an interpolated point along this path
  5134. * @param position the position of the point along this path, from 0.0 to 1.0
  5135. * @returns a new Vector3 as the point
  5136. */
  5137. getPointAt(position: number): Vector3;
  5138. /**
  5139. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5140. * @param position the position of the point along this path, from 0.0 to 1.0
  5141. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5142. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5143. */
  5144. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5145. /**
  5146. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5147. * @param position the position of the point along this path, from 0.0 to 1.0
  5148. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5149. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5150. */
  5151. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5152. /**
  5153. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5154. * @param position the position of the point along this path, from 0.0 to 1.0
  5155. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5156. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5157. */
  5158. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5159. /**
  5160. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5161. * @param position the position of the point along this path, from 0.0 to 1.0
  5162. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5163. */
  5164. getDistanceAt(position: number): number;
  5165. /**
  5166. * Returns the array index of the previous point of an interpolated point along this path
  5167. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5168. * @returns the array index
  5169. */
  5170. getPreviousPointIndexAt(position: number): number;
  5171. /**
  5172. * 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)
  5173. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5174. * @returns the sub position
  5175. */
  5176. getSubPositionAt(position: number): number;
  5177. /**
  5178. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5179. * @param target the vector of which to get the closest position to
  5180. * @returns the position of the closest virtual point on this path to the target vector
  5181. */
  5182. getClosestPositionTo(target: Vector3): number;
  5183. /**
  5184. * Returns a sub path (slice) of this path
  5185. * @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
  5186. * @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
  5187. * @returns a sub path (slice) of this path
  5188. */
  5189. slice(start?: number, end?: number): Path3D;
  5190. /**
  5191. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5192. * @param path path which all values are copied into the curves points
  5193. * @param firstNormal which should be projected onto the curve
  5194. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5195. * @returns the same object updated.
  5196. */
  5197. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5198. private _compute;
  5199. private _getFirstNonNullVector;
  5200. private _getLastNonNullVector;
  5201. private _normalVector;
  5202. /**
  5203. * Updates the point at data for an interpolated point along this curve
  5204. * @param position the position of the point along this curve, from 0.0 to 1.0
  5205. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5206. * @returns the (updated) point at data
  5207. */
  5208. private _updatePointAtData;
  5209. /**
  5210. * Updates the point at data from the specified parameters
  5211. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5212. * @param point the interpolated point
  5213. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5214. */
  5215. private _setPointAtData;
  5216. /**
  5217. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5218. */
  5219. private _updateInterpolationMatrix;
  5220. }
  5221. /**
  5222. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5223. * A Curve3 is designed from a series of successive Vector3.
  5224. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5225. */
  5226. export class Curve3 {
  5227. private _points;
  5228. private _length;
  5229. /**
  5230. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5231. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5232. * @param v1 (Vector3) the control point
  5233. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5234. * @param nbPoints (integer) the wanted number of points in the curve
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5238. /**
  5239. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5240. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5241. * @param v1 (Vector3) the first control point
  5242. * @param v2 (Vector3) the second control point
  5243. * @param v3 (Vector3) the end point of the Cubic Bezier
  5244. * @param nbPoints (integer) the wanted number of points in the curve
  5245. * @returns the created Curve3
  5246. */
  5247. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5248. /**
  5249. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5250. * @param p1 (Vector3) the origin point of the Hermite Spline
  5251. * @param t1 (Vector3) the tangent vector at the origin point
  5252. * @param p2 (Vector3) the end point of the Hermite Spline
  5253. * @param t2 (Vector3) the tangent vector at the end point
  5254. * @param nbPoints (integer) the wanted number of points in the curve
  5255. * @returns the created Curve3
  5256. */
  5257. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5258. /**
  5259. * Returns a Curve3 object along a CatmullRom Spline curve :
  5260. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5261. * @param nbPoints (integer) the wanted number of points between each curve control points
  5262. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5263. * @returns the created Curve3
  5264. */
  5265. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5266. /**
  5267. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5268. * A Curve3 is designed from a series of successive Vector3.
  5269. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5270. * @param points points which make up the curve
  5271. */
  5272. constructor(points: Vector3[]);
  5273. /**
  5274. * @returns the Curve3 stored array of successive Vector3
  5275. */
  5276. getPoints(): Vector3[];
  5277. /**
  5278. * @returns the computed length (float) of the curve.
  5279. */
  5280. length(): number;
  5281. /**
  5282. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5283. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5284. * curveA and curveB keep unchanged.
  5285. * @param curve the curve to continue from this curve
  5286. * @returns the newly constructed curve
  5287. */
  5288. continue(curve: DeepImmutable<Curve3>): Curve3;
  5289. private _computeLength;
  5290. }
  5291. }
  5292. declare module "babylonjs/Animations/easing" {
  5293. /**
  5294. * This represents the main contract an easing function should follow.
  5295. * Easing functions are used throughout the animation system.
  5296. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5297. */
  5298. export interface IEasingFunction {
  5299. /**
  5300. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5301. * of the easing function.
  5302. * The link below provides some of the most common examples of easing functions.
  5303. * @see https://easings.net/
  5304. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5305. * @returns the corresponding value on the curve defined by the easing function
  5306. */
  5307. ease(gradient: number): number;
  5308. }
  5309. /**
  5310. * Base class used for every default easing function.
  5311. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5312. */
  5313. export class EasingFunction implements IEasingFunction {
  5314. /**
  5315. * Interpolation follows the mathematical formula associated with the easing function.
  5316. */
  5317. static readonly EASINGMODE_EASEIN: number;
  5318. /**
  5319. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5320. */
  5321. static readonly EASINGMODE_EASEOUT: number;
  5322. /**
  5323. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5324. */
  5325. static readonly EASINGMODE_EASEINOUT: number;
  5326. private _easingMode;
  5327. /**
  5328. * Sets the easing mode of the current function.
  5329. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5330. */
  5331. setEasingMode(easingMode: number): void;
  5332. /**
  5333. * Gets the current easing mode.
  5334. * @returns the easing mode
  5335. */
  5336. getEasingMode(): number;
  5337. /**
  5338. * @hidden
  5339. */
  5340. easeInCore(gradient: number): number;
  5341. /**
  5342. * Given an input gradient between 0 and 1, this returns the corresponding value
  5343. * of the easing function.
  5344. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5345. * @returns the corresponding value on the curve defined by the easing function
  5346. */
  5347. ease(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a circle shape (see link below).
  5351. * @see https://easings.net/#easeInCirc
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class CircleEase extends EasingFunction implements IEasingFunction {
  5355. /** @hidden */
  5356. easeInCore(gradient: number): number;
  5357. }
  5358. /**
  5359. * Easing function with a ease back shape (see link below).
  5360. * @see https://easings.net/#easeInBack
  5361. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5362. */
  5363. export class BackEase extends EasingFunction implements IEasingFunction {
  5364. /** Defines the amplitude of the function */
  5365. amplitude: number;
  5366. /**
  5367. * Instantiates a back ease easing
  5368. * @see https://easings.net/#easeInBack
  5369. * @param amplitude Defines the amplitude of the function
  5370. */
  5371. constructor(
  5372. /** Defines the amplitude of the function */
  5373. amplitude?: number);
  5374. /** @hidden */
  5375. easeInCore(gradient: number): number;
  5376. }
  5377. /**
  5378. * Easing function with a bouncing shape (see link below).
  5379. * @see https://easings.net/#easeInBounce
  5380. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5381. */
  5382. export class BounceEase extends EasingFunction implements IEasingFunction {
  5383. /** Defines the number of bounces */
  5384. bounces: number;
  5385. /** Defines the amplitude of the bounce */
  5386. bounciness: number;
  5387. /**
  5388. * Instantiates a bounce easing
  5389. * @see https://easings.net/#easeInBounce
  5390. * @param bounces Defines the number of bounces
  5391. * @param bounciness Defines the amplitude of the bounce
  5392. */
  5393. constructor(
  5394. /** Defines the number of bounces */
  5395. bounces?: number,
  5396. /** Defines the amplitude of the bounce */
  5397. bounciness?: number);
  5398. /** @hidden */
  5399. easeInCore(gradient: number): number;
  5400. }
  5401. /**
  5402. * Easing function with a power of 3 shape (see link below).
  5403. * @see https://easings.net/#easeInCubic
  5404. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5405. */
  5406. export class CubicEase extends EasingFunction implements IEasingFunction {
  5407. /** @hidden */
  5408. easeInCore(gradient: number): number;
  5409. }
  5410. /**
  5411. * Easing function with an elastic shape (see link below).
  5412. * @see https://easings.net/#easeInElastic
  5413. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5414. */
  5415. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5416. /** Defines the number of oscillations*/
  5417. oscillations: number;
  5418. /** Defines the amplitude of the oscillations*/
  5419. springiness: number;
  5420. /**
  5421. * Instantiates an elastic easing function
  5422. * @see https://easings.net/#easeInElastic
  5423. * @param oscillations Defines the number of oscillations
  5424. * @param springiness Defines the amplitude of the oscillations
  5425. */
  5426. constructor(
  5427. /** Defines the number of oscillations*/
  5428. oscillations?: number,
  5429. /** Defines the amplitude of the oscillations*/
  5430. springiness?: number);
  5431. /** @hidden */
  5432. easeInCore(gradient: number): number;
  5433. }
  5434. /**
  5435. * Easing function with an exponential shape (see link below).
  5436. * @see https://easings.net/#easeInExpo
  5437. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5438. */
  5439. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5440. /** Defines the exponent of the function */
  5441. exponent: number;
  5442. /**
  5443. * Instantiates an exponential easing function
  5444. * @see https://easings.net/#easeInExpo
  5445. * @param exponent Defines the exponent of the function
  5446. */
  5447. constructor(
  5448. /** Defines the exponent of the function */
  5449. exponent?: number);
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power shape (see link below).
  5455. * @see https://easings.net/#easeInQuad
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class PowerEase extends EasingFunction implements IEasingFunction {
  5459. /** Defines the power of the function */
  5460. power: number;
  5461. /**
  5462. * Instantiates an power base easing function
  5463. * @see https://easings.net/#easeInQuad
  5464. * @param power Defines the power of the function
  5465. */
  5466. constructor(
  5467. /** Defines the power of the function */
  5468. power?: number);
  5469. /** @hidden */
  5470. easeInCore(gradient: number): number;
  5471. }
  5472. /**
  5473. * Easing function with a power of 2 shape (see link below).
  5474. * @see https://easings.net/#easeInQuad
  5475. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5476. */
  5477. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5478. /** @hidden */
  5479. easeInCore(gradient: number): number;
  5480. }
  5481. /**
  5482. * Easing function with a power of 4 shape (see link below).
  5483. * @see https://easings.net/#easeInQuart
  5484. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5485. */
  5486. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5487. /** @hidden */
  5488. easeInCore(gradient: number): number;
  5489. }
  5490. /**
  5491. * Easing function with a power of 5 shape (see link below).
  5492. * @see https://easings.net/#easeInQuint
  5493. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5494. */
  5495. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5496. /** @hidden */
  5497. easeInCore(gradient: number): number;
  5498. }
  5499. /**
  5500. * Easing function with a sin shape (see link below).
  5501. * @see https://easings.net/#easeInSine
  5502. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5503. */
  5504. export class SineEase extends EasingFunction implements IEasingFunction {
  5505. /** @hidden */
  5506. easeInCore(gradient: number): number;
  5507. }
  5508. /**
  5509. * Easing function with a bezier shape (see link below).
  5510. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5511. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5512. */
  5513. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5514. /** Defines the x component of the start tangent in the bezier curve */
  5515. x1: number;
  5516. /** Defines the y component of the start tangent in the bezier curve */
  5517. y1: number;
  5518. /** Defines the x component of the end tangent in the bezier curve */
  5519. x2: number;
  5520. /** Defines the y component of the end tangent in the bezier curve */
  5521. y2: number;
  5522. /**
  5523. * Instantiates a bezier function
  5524. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5525. * @param x1 Defines the x component of the start tangent in the bezier curve
  5526. * @param y1 Defines the y component of the start tangent in the bezier curve
  5527. * @param x2 Defines the x component of the end tangent in the bezier curve
  5528. * @param y2 Defines the y component of the end tangent in the bezier curve
  5529. */
  5530. constructor(
  5531. /** Defines the x component of the start tangent in the bezier curve */
  5532. x1?: number,
  5533. /** Defines the y component of the start tangent in the bezier curve */
  5534. y1?: number,
  5535. /** Defines the x component of the end tangent in the bezier curve */
  5536. x2?: number,
  5537. /** Defines the y component of the end tangent in the bezier curve */
  5538. y2?: number);
  5539. /** @hidden */
  5540. easeInCore(gradient: number): number;
  5541. }
  5542. }
  5543. declare module "babylonjs/Maths/math.color" {
  5544. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5545. /**
  5546. * Class used to hold a RBG color
  5547. */
  5548. export class Color3 {
  5549. /**
  5550. * Defines the red component (between 0 and 1, default is 0)
  5551. */
  5552. r: number;
  5553. /**
  5554. * Defines the green component (between 0 and 1, default is 0)
  5555. */
  5556. g: number;
  5557. /**
  5558. * Defines the blue component (between 0 and 1, default is 0)
  5559. */
  5560. b: number;
  5561. /**
  5562. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5563. * @param r defines the red component (between 0 and 1, default is 0)
  5564. * @param g defines the green component (between 0 and 1, default is 0)
  5565. * @param b defines the blue component (between 0 and 1, default is 0)
  5566. */
  5567. constructor(
  5568. /**
  5569. * Defines the red component (between 0 and 1, default is 0)
  5570. */
  5571. r?: number,
  5572. /**
  5573. * Defines the green component (between 0 and 1, default is 0)
  5574. */
  5575. g?: number,
  5576. /**
  5577. * Defines the blue component (between 0 and 1, default is 0)
  5578. */
  5579. b?: number);
  5580. /**
  5581. * Creates a string with the Color3 current values
  5582. * @returns the string representation of the Color3 object
  5583. */
  5584. toString(): string;
  5585. /**
  5586. * Returns the string "Color3"
  5587. * @returns "Color3"
  5588. */
  5589. getClassName(): string;
  5590. /**
  5591. * Compute the Color3 hash code
  5592. * @returns an unique number that can be used to hash Color3 objects
  5593. */
  5594. getHashCode(): number;
  5595. /**
  5596. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5597. * @param array defines the array where to store the r,g,b components
  5598. * @param index defines an optional index in the target array to define where to start storing values
  5599. * @returns the current Color3 object
  5600. */
  5601. toArray(array: FloatArray, index?: number): Color3;
  5602. /**
  5603. * Update the current color with values stored in an array from the starting index of the given array
  5604. * @param array defines the source array
  5605. * @param offset defines an offset in the source array
  5606. * @returns the current Color3 object
  5607. */
  5608. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5609. /**
  5610. * Returns a new Color4 object from the current Color3 and the given alpha
  5611. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5612. * @returns a new Color4 object
  5613. */
  5614. toColor4(alpha?: number): Color4;
  5615. /**
  5616. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5617. * @returns the new array
  5618. */
  5619. asArray(): number[];
  5620. /**
  5621. * Returns the luminance value
  5622. * @returns a float value
  5623. */
  5624. toLuminance(): number;
  5625. /**
  5626. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5627. * @param otherColor defines the second operand
  5628. * @returns the new Color3 object
  5629. */
  5630. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5631. /**
  5632. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5633. * @param otherColor defines the second operand
  5634. * @param result defines the Color3 object where to store the result
  5635. * @returns the current Color3
  5636. */
  5637. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5638. /**
  5639. * Determines equality between Color3 objects
  5640. * @param otherColor defines the second operand
  5641. * @returns true if the rgb values are equal to the given ones
  5642. */
  5643. equals(otherColor: DeepImmutable<Color3>): boolean;
  5644. /**
  5645. * Determines equality between the current Color3 object and a set of r,b,g values
  5646. * @param r defines the red component to check
  5647. * @param g defines the green component to check
  5648. * @param b defines the blue component to check
  5649. * @returns true if the rgb values are equal to the given ones
  5650. */
  5651. equalsFloats(r: number, g: number, b: number): boolean;
  5652. /**
  5653. * Multiplies in place each rgb value by scale
  5654. * @param scale defines the scaling factor
  5655. * @returns the updated Color3
  5656. */
  5657. scale(scale: number): Color3;
  5658. /**
  5659. * Multiplies the rgb values by scale and stores the result into "result"
  5660. * @param scale defines the scaling factor
  5661. * @param result defines the Color3 object where to store the result
  5662. * @returns the unmodified current Color3
  5663. */
  5664. scaleToRef(scale: number, result: Color3): Color3;
  5665. /**
  5666. * Scale the current Color3 values by a factor and add the result to a given Color3
  5667. * @param scale defines the scale factor
  5668. * @param result defines color to store the result into
  5669. * @returns the unmodified current Color3
  5670. */
  5671. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5672. /**
  5673. * Clamps the rgb values by the min and max values and stores the result into "result"
  5674. * @param min defines minimum clamping value (default is 0)
  5675. * @param max defines maximum clamping value (default is 1)
  5676. * @param result defines color to store the result into
  5677. * @returns the original Color3
  5678. */
  5679. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5680. /**
  5681. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5682. * @param otherColor defines the second operand
  5683. * @returns the new Color3
  5684. */
  5685. add(otherColor: DeepImmutable<Color3>): Color3;
  5686. /**
  5687. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5688. * @param otherColor defines the second operand
  5689. * @param result defines Color3 object to store the result into
  5690. * @returns the unmodified current Color3
  5691. */
  5692. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5693. /**
  5694. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5695. * @param otherColor defines the second operand
  5696. * @returns the new Color3
  5697. */
  5698. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5699. /**
  5700. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5701. * @param otherColor defines the second operand
  5702. * @param result defines Color3 object to store the result into
  5703. * @returns the unmodified current Color3
  5704. */
  5705. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5706. /**
  5707. * Copy the current object
  5708. * @returns a new Color3 copied the current one
  5709. */
  5710. clone(): Color3;
  5711. /**
  5712. * Copies the rgb values from the source in the current Color3
  5713. * @param source defines the source Color3 object
  5714. * @returns the updated Color3 object
  5715. */
  5716. copyFrom(source: DeepImmutable<Color3>): Color3;
  5717. /**
  5718. * Updates the Color3 rgb values from the given floats
  5719. * @param r defines the red component to read from
  5720. * @param g defines the green component to read from
  5721. * @param b defines the blue component to read from
  5722. * @returns the current Color3 object
  5723. */
  5724. copyFromFloats(r: number, g: number, b: number): Color3;
  5725. /**
  5726. * Updates the Color3 rgb values from the given floats
  5727. * @param r defines the red component to read from
  5728. * @param g defines the green component to read from
  5729. * @param b defines the blue component to read from
  5730. * @returns the current Color3 object
  5731. */
  5732. set(r: number, g: number, b: number): Color3;
  5733. /**
  5734. * Compute the Color3 hexadecimal code as a string
  5735. * @returns a string containing the hexadecimal representation of the Color3 object
  5736. */
  5737. toHexString(): string;
  5738. /**
  5739. * Computes a new Color3 converted from the current one to linear space
  5740. * @returns a new Color3 object
  5741. */
  5742. toLinearSpace(): Color3;
  5743. /**
  5744. * Converts current color in rgb space to HSV values
  5745. * @returns a new color3 representing the HSV values
  5746. */
  5747. toHSV(): Color3;
  5748. /**
  5749. * Converts current color in rgb space to HSV values
  5750. * @param result defines the Color3 where to store the HSV values
  5751. */
  5752. toHSVToRef(result: Color3): void;
  5753. /**
  5754. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5755. * @param convertedColor defines the Color3 object where to store the linear space version
  5756. * @returns the unmodified Color3
  5757. */
  5758. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5759. /**
  5760. * Computes a new Color3 converted from the current one to gamma space
  5761. * @returns a new Color3 object
  5762. */
  5763. toGammaSpace(): Color3;
  5764. /**
  5765. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5766. * @param convertedColor defines the Color3 object where to store the gamma space version
  5767. * @returns the unmodified Color3
  5768. */
  5769. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5770. private static _BlackReadOnly;
  5771. /**
  5772. * Convert Hue, saturation and value to a Color3 (RGB)
  5773. * @param hue defines the hue
  5774. * @param saturation defines the saturation
  5775. * @param value defines the value
  5776. * @param result defines the Color3 where to store the RGB values
  5777. */
  5778. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5779. /**
  5780. * Creates a new Color3 from the string containing valid hexadecimal values
  5781. * @param hex defines a string containing valid hexadecimal values
  5782. * @returns a new Color3 object
  5783. */
  5784. static FromHexString(hex: string): Color3;
  5785. /**
  5786. * Creates a new Color3 from the starting index of the given array
  5787. * @param array defines the source array
  5788. * @param offset defines an offset in the source array
  5789. * @returns a new Color3 object
  5790. */
  5791. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5792. /**
  5793. * Creates a new Color3 from the starting index element of the given array
  5794. * @param array defines the source array to read from
  5795. * @param offset defines the offset in the source array
  5796. * @param result defines the target Color3 object
  5797. */
  5798. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5799. /**
  5800. * Creates a new Color3 from integer values (< 256)
  5801. * @param r defines the red component to read from (value between 0 and 255)
  5802. * @param g defines the green component to read from (value between 0 and 255)
  5803. * @param b defines the blue component to read from (value between 0 and 255)
  5804. * @returns a new Color3 object
  5805. */
  5806. static FromInts(r: number, g: number, b: number): Color3;
  5807. /**
  5808. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5809. * @param start defines the start Color3 value
  5810. * @param end defines the end Color3 value
  5811. * @param amount defines the gradient value between start and end
  5812. * @returns a new Color3 object
  5813. */
  5814. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5815. /**
  5816. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5817. * @param left defines the start value
  5818. * @param right defines the end value
  5819. * @param amount defines the gradient factor
  5820. * @param result defines the Color3 object where to store the result
  5821. */
  5822. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5823. /**
  5824. * Returns a Color3 value containing a red color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Red(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a green color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Green(): Color3;
  5833. /**
  5834. * Returns a Color3 value containing a blue color
  5835. * @returns a new Color3 object
  5836. */
  5837. static Blue(): Color3;
  5838. /**
  5839. * Returns a Color3 value containing a black color
  5840. * @returns a new Color3 object
  5841. */
  5842. static Black(): Color3;
  5843. /**
  5844. * Gets a Color3 value containing a black color that must not be updated
  5845. */
  5846. static get BlackReadOnly(): DeepImmutable<Color3>;
  5847. /**
  5848. * Returns a Color3 value containing a white color
  5849. * @returns a new Color3 object
  5850. */
  5851. static White(): Color3;
  5852. /**
  5853. * Returns a Color3 value containing a purple color
  5854. * @returns a new Color3 object
  5855. */
  5856. static Purple(): Color3;
  5857. /**
  5858. * Returns a Color3 value containing a magenta color
  5859. * @returns a new Color3 object
  5860. */
  5861. static Magenta(): Color3;
  5862. /**
  5863. * Returns a Color3 value containing a yellow color
  5864. * @returns a new Color3 object
  5865. */
  5866. static Yellow(): Color3;
  5867. /**
  5868. * Returns a Color3 value containing a gray color
  5869. * @returns a new Color3 object
  5870. */
  5871. static Gray(): Color3;
  5872. /**
  5873. * Returns a Color3 value containing a teal color
  5874. * @returns a new Color3 object
  5875. */
  5876. static Teal(): Color3;
  5877. /**
  5878. * Returns a Color3 value containing a random color
  5879. * @returns a new Color3 object
  5880. */
  5881. static Random(): Color3;
  5882. }
  5883. /**
  5884. * Class used to hold a RBGA color
  5885. */
  5886. export class Color4 {
  5887. /**
  5888. * Defines the red component (between 0 and 1, default is 0)
  5889. */
  5890. r: number;
  5891. /**
  5892. * Defines the green component (between 0 and 1, default is 0)
  5893. */
  5894. g: number;
  5895. /**
  5896. * Defines the blue component (between 0 and 1, default is 0)
  5897. */
  5898. b: number;
  5899. /**
  5900. * Defines the alpha component (between 0 and 1, default is 1)
  5901. */
  5902. a: number;
  5903. /**
  5904. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5905. * @param r defines the red component (between 0 and 1, default is 0)
  5906. * @param g defines the green component (between 0 and 1, default is 0)
  5907. * @param b defines the blue component (between 0 and 1, default is 0)
  5908. * @param a defines the alpha component (between 0 and 1, default is 1)
  5909. */
  5910. constructor(
  5911. /**
  5912. * Defines the red component (between 0 and 1, default is 0)
  5913. */
  5914. r?: number,
  5915. /**
  5916. * Defines the green component (between 0 and 1, default is 0)
  5917. */
  5918. g?: number,
  5919. /**
  5920. * Defines the blue component (between 0 and 1, default is 0)
  5921. */
  5922. b?: number,
  5923. /**
  5924. * Defines the alpha component (between 0 and 1, default is 1)
  5925. */
  5926. a?: number);
  5927. /**
  5928. * Adds in place the given Color4 values to the current Color4 object
  5929. * @param right defines the second operand
  5930. * @returns the current updated Color4 object
  5931. */
  5932. addInPlace(right: DeepImmutable<Color4>): Color4;
  5933. /**
  5934. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5935. * @returns the new array
  5936. */
  5937. asArray(): number[];
  5938. /**
  5939. * Stores from the starting index in the given array the Color4 successive values
  5940. * @param array defines the array where to store the r,g,b components
  5941. * @param index defines an optional index in the target array to define where to start storing values
  5942. * @returns the current Color4 object
  5943. */
  5944. toArray(array: number[], index?: number): Color4;
  5945. /**
  5946. * Update the current color with values stored in an array from the starting index of the given array
  5947. * @param array defines the source array
  5948. * @param offset defines an offset in the source array
  5949. * @returns the current Color4 object
  5950. */
  5951. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5952. /**
  5953. * Determines equality between Color4 objects
  5954. * @param otherColor defines the second operand
  5955. * @returns true if the rgba values are equal to the given ones
  5956. */
  5957. equals(otherColor: DeepImmutable<Color4>): boolean;
  5958. /**
  5959. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5960. * @param right defines the second operand
  5961. * @returns a new Color4 object
  5962. */
  5963. add(right: DeepImmutable<Color4>): Color4;
  5964. /**
  5965. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5966. * @param right defines the second operand
  5967. * @returns a new Color4 object
  5968. */
  5969. subtract(right: DeepImmutable<Color4>): Color4;
  5970. /**
  5971. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5972. * @param right defines the second operand
  5973. * @param result defines the Color4 object where to store the result
  5974. * @returns the current Color4 object
  5975. */
  5976. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5977. /**
  5978. * Creates a new Color4 with the current Color4 values multiplied by scale
  5979. * @param scale defines the scaling factor to apply
  5980. * @returns a new Color4 object
  5981. */
  5982. scale(scale: number): Color4;
  5983. /**
  5984. * Multiplies the current Color4 values by scale and stores the result in "result"
  5985. * @param scale defines the scaling factor to apply
  5986. * @param result defines the Color4 object where to store the result
  5987. * @returns the current unmodified Color4
  5988. */
  5989. scaleToRef(scale: number, result: Color4): Color4;
  5990. /**
  5991. * Scale the current Color4 values by a factor and add the result to a given Color4
  5992. * @param scale defines the scale factor
  5993. * @param result defines the Color4 object where to store the result
  5994. * @returns the unmodified current Color4
  5995. */
  5996. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5997. /**
  5998. * Clamps the rgb values by the min and max values and stores the result into "result"
  5999. * @param min defines minimum clamping value (default is 0)
  6000. * @param max defines maximum clamping value (default is 1)
  6001. * @param result defines color to store the result into.
  6002. * @returns the cuurent Color4
  6003. */
  6004. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6005. /**
  6006. * Multipy an Color4 value by another and return a new Color4 object
  6007. * @param color defines the Color4 value to multiply by
  6008. * @returns a new Color4 object
  6009. */
  6010. multiply(color: Color4): Color4;
  6011. /**
  6012. * Multipy a Color4 value by another and push the result in a reference value
  6013. * @param color defines the Color4 value to multiply by
  6014. * @param result defines the Color4 to fill the result in
  6015. * @returns the result Color4
  6016. */
  6017. multiplyToRef(color: Color4, result: Color4): Color4;
  6018. /**
  6019. * Creates a string with the Color4 current values
  6020. * @returns the string representation of the Color4 object
  6021. */
  6022. toString(): string;
  6023. /**
  6024. * Returns the string "Color4"
  6025. * @returns "Color4"
  6026. */
  6027. getClassName(): string;
  6028. /**
  6029. * Compute the Color4 hash code
  6030. * @returns an unique number that can be used to hash Color4 objects
  6031. */
  6032. getHashCode(): number;
  6033. /**
  6034. * Creates a new Color4 copied from the current one
  6035. * @returns a new Color4 object
  6036. */
  6037. clone(): Color4;
  6038. /**
  6039. * Copies the given Color4 values into the current one
  6040. * @param source defines the source Color4 object
  6041. * @returns the current updated Color4 object
  6042. */
  6043. copyFrom(source: Color4): Color4;
  6044. /**
  6045. * Copies the given float values into the current one
  6046. * @param r defines the red component to read from
  6047. * @param g defines the green component to read from
  6048. * @param b defines the blue component to read from
  6049. * @param a defines the alpha component to read from
  6050. * @returns the current updated Color4 object
  6051. */
  6052. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6053. /**
  6054. * Copies the given float values into the current one
  6055. * @param r defines the red component to read from
  6056. * @param g defines the green component to read from
  6057. * @param b defines the blue component to read from
  6058. * @param a defines the alpha component to read from
  6059. * @returns the current updated Color4 object
  6060. */
  6061. set(r: number, g: number, b: number, a: number): Color4;
  6062. /**
  6063. * Compute the Color4 hexadecimal code as a string
  6064. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6065. * @returns a string containing the hexadecimal representation of the Color4 object
  6066. */
  6067. toHexString(returnAsColor3?: boolean): string;
  6068. /**
  6069. * Computes a new Color4 converted from the current one to linear space
  6070. * @returns a new Color4 object
  6071. */
  6072. toLinearSpace(): Color4;
  6073. /**
  6074. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6075. * @param convertedColor defines the Color4 object where to store the linear space version
  6076. * @returns the unmodified Color4
  6077. */
  6078. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6079. /**
  6080. * Computes a new Color4 converted from the current one to gamma space
  6081. * @returns a new Color4 object
  6082. */
  6083. toGammaSpace(): Color4;
  6084. /**
  6085. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6086. * @param convertedColor defines the Color4 object where to store the gamma space version
  6087. * @returns the unmodified Color4
  6088. */
  6089. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6090. /**
  6091. * Creates a new Color4 from the string containing valid hexadecimal values
  6092. * @param hex defines a string containing valid hexadecimal values
  6093. * @returns a new Color4 object
  6094. */
  6095. static FromHexString(hex: string): Color4;
  6096. /**
  6097. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6098. * @param left defines the start value
  6099. * @param right defines the end value
  6100. * @param amount defines the gradient factor
  6101. * @returns a new Color4 object
  6102. */
  6103. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6104. /**
  6105. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6106. * @param left defines the start value
  6107. * @param right defines the end value
  6108. * @param amount defines the gradient factor
  6109. * @param result defines the Color4 object where to store data
  6110. */
  6111. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6112. /**
  6113. * Creates a new Color4 from a Color3 and an alpha value
  6114. * @param color3 defines the source Color3 to read from
  6115. * @param alpha defines the alpha component (1.0 by default)
  6116. * @returns a new Color4 object
  6117. */
  6118. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6119. /**
  6120. * Creates a new Color4 from the starting index element of the given array
  6121. * @param array defines the source array to read from
  6122. * @param offset defines the offset in the source array
  6123. * @returns a new Color4 object
  6124. */
  6125. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6126. /**
  6127. * Creates a new Color4 from the starting index element of the given array
  6128. * @param array defines the source array to read from
  6129. * @param offset defines the offset in the source array
  6130. * @param result defines the target Color4 object
  6131. */
  6132. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6133. /**
  6134. * Creates a new Color3 from integer values (< 256)
  6135. * @param r defines the red component to read from (value between 0 and 255)
  6136. * @param g defines the green component to read from (value between 0 and 255)
  6137. * @param b defines the blue component to read from (value between 0 and 255)
  6138. * @param a defines the alpha component to read from (value between 0 and 255)
  6139. * @returns a new Color3 object
  6140. */
  6141. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6142. /**
  6143. * Check the content of a given array and convert it to an array containing RGBA data
  6144. * If the original array was already containing count * 4 values then it is returned directly
  6145. * @param colors defines the array to check
  6146. * @param count defines the number of RGBA data to expect
  6147. * @returns an array containing count * 4 values (RGBA)
  6148. */
  6149. static CheckColors4(colors: number[], count: number): number[];
  6150. }
  6151. /**
  6152. * @hidden
  6153. */
  6154. export class TmpColors {
  6155. static Color3: Color3[];
  6156. static Color4: Color4[];
  6157. }
  6158. }
  6159. declare module "babylonjs/Animations/animationKey" {
  6160. /**
  6161. * Defines an interface which represents an animation key frame
  6162. */
  6163. export interface IAnimationKey {
  6164. /**
  6165. * Frame of the key frame
  6166. */
  6167. frame: number;
  6168. /**
  6169. * Value at the specifies key frame
  6170. */
  6171. value: any;
  6172. /**
  6173. * The input tangent for the cubic hermite spline
  6174. */
  6175. inTangent?: any;
  6176. /**
  6177. * The output tangent for the cubic hermite spline
  6178. */
  6179. outTangent?: any;
  6180. /**
  6181. * The animation interpolation type
  6182. */
  6183. interpolation?: AnimationKeyInterpolation;
  6184. }
  6185. /**
  6186. * Enum for the animation key frame interpolation type
  6187. */
  6188. export enum AnimationKeyInterpolation {
  6189. /**
  6190. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6191. */
  6192. STEP = 1
  6193. }
  6194. }
  6195. declare module "babylonjs/Animations/animationRange" {
  6196. /**
  6197. * Represents the range of an animation
  6198. */
  6199. export class AnimationRange {
  6200. /**The name of the animation range**/
  6201. name: string;
  6202. /**The starting frame of the animation */
  6203. from: number;
  6204. /**The ending frame of the animation*/
  6205. to: number;
  6206. /**
  6207. * Initializes the range of an animation
  6208. * @param name The name of the animation range
  6209. * @param from The starting frame of the animation
  6210. * @param to The ending frame of the animation
  6211. */
  6212. constructor(
  6213. /**The name of the animation range**/
  6214. name: string,
  6215. /**The starting frame of the animation */
  6216. from: number,
  6217. /**The ending frame of the animation*/
  6218. to: number);
  6219. /**
  6220. * Makes a copy of the animation range
  6221. * @returns A copy of the animation range
  6222. */
  6223. clone(): AnimationRange;
  6224. }
  6225. }
  6226. declare module "babylonjs/Animations/animationEvent" {
  6227. /**
  6228. * Composed of a frame, and an action function
  6229. */
  6230. export class AnimationEvent {
  6231. /** The frame for which the event is triggered **/
  6232. frame: number;
  6233. /** The event to perform when triggered **/
  6234. action: (currentFrame: number) => void;
  6235. /** Specifies if the event should be triggered only once**/
  6236. onlyOnce?: boolean | undefined;
  6237. /**
  6238. * Specifies if the animation event is done
  6239. */
  6240. isDone: boolean;
  6241. /**
  6242. * Initializes the animation event
  6243. * @param frame The frame for which the event is triggered
  6244. * @param action The event to perform when triggered
  6245. * @param onlyOnce Specifies if the event should be triggered only once
  6246. */
  6247. constructor(
  6248. /** The frame for which the event is triggered **/
  6249. frame: number,
  6250. /** The event to perform when triggered **/
  6251. action: (currentFrame: number) => void,
  6252. /** Specifies if the event should be triggered only once**/
  6253. onlyOnce?: boolean | undefined);
  6254. /** @hidden */
  6255. _clone(): AnimationEvent;
  6256. }
  6257. }
  6258. declare module "babylonjs/Behaviors/behavior" {
  6259. import { Nullable } from "babylonjs/types";
  6260. /**
  6261. * Interface used to define a behavior
  6262. */
  6263. export interface Behavior<T> {
  6264. /** gets or sets behavior's name */
  6265. name: string;
  6266. /**
  6267. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6268. */
  6269. init(): void;
  6270. /**
  6271. * Called when the behavior is attached to a target
  6272. * @param target defines the target where the behavior is attached to
  6273. */
  6274. attach(target: T): void;
  6275. /**
  6276. * Called when the behavior is detached from its target
  6277. */
  6278. detach(): void;
  6279. }
  6280. /**
  6281. * Interface implemented by classes supporting behaviors
  6282. */
  6283. export interface IBehaviorAware<T> {
  6284. /**
  6285. * Attach a behavior
  6286. * @param behavior defines the behavior to attach
  6287. * @returns the current host
  6288. */
  6289. addBehavior(behavior: Behavior<T>): T;
  6290. /**
  6291. * Remove a behavior from the current object
  6292. * @param behavior defines the behavior to detach
  6293. * @returns the current host
  6294. */
  6295. removeBehavior(behavior: Behavior<T>): T;
  6296. /**
  6297. * Gets a behavior using its name to search
  6298. * @param name defines the name to search
  6299. * @returns the behavior or null if not found
  6300. */
  6301. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6302. }
  6303. }
  6304. declare module "babylonjs/Misc/smartArray" {
  6305. /**
  6306. * Defines an array and its length.
  6307. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6308. */
  6309. export interface ISmartArrayLike<T> {
  6310. /**
  6311. * The data of the array.
  6312. */
  6313. data: Array<T>;
  6314. /**
  6315. * The active length of the array.
  6316. */
  6317. length: number;
  6318. }
  6319. /**
  6320. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6321. */
  6322. export class SmartArray<T> implements ISmartArrayLike<T> {
  6323. /**
  6324. * The full set of data from the array.
  6325. */
  6326. data: Array<T>;
  6327. /**
  6328. * The active length of the array.
  6329. */
  6330. length: number;
  6331. protected _id: number;
  6332. /**
  6333. * Instantiates a Smart Array.
  6334. * @param capacity defines the default capacity of the array.
  6335. */
  6336. constructor(capacity: number);
  6337. /**
  6338. * Pushes a value at the end of the active data.
  6339. * @param value defines the object to push in the array.
  6340. */
  6341. push(value: T): void;
  6342. /**
  6343. * Iterates over the active data and apply the lambda to them.
  6344. * @param func defines the action to apply on each value.
  6345. */
  6346. forEach(func: (content: T) => void): void;
  6347. /**
  6348. * Sorts the full sets of data.
  6349. * @param compareFn defines the comparison function to apply.
  6350. */
  6351. sort(compareFn: (a: T, b: T) => number): void;
  6352. /**
  6353. * Resets the active data to an empty array.
  6354. */
  6355. reset(): void;
  6356. /**
  6357. * Releases all the data from the array as well as the array.
  6358. */
  6359. dispose(): void;
  6360. /**
  6361. * Concats the active data with a given array.
  6362. * @param array defines the data to concatenate with.
  6363. */
  6364. concat(array: any): void;
  6365. /**
  6366. * Returns the position of a value in the active data.
  6367. * @param value defines the value to find the index for
  6368. * @returns the index if found in the active data otherwise -1
  6369. */
  6370. indexOf(value: T): number;
  6371. /**
  6372. * Returns whether an element is part of the active data.
  6373. * @param value defines the value to look for
  6374. * @returns true if found in the active data otherwise false
  6375. */
  6376. contains(value: T): boolean;
  6377. private static _GlobalId;
  6378. }
  6379. /**
  6380. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6381. * The data in this array can only be present once
  6382. */
  6383. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6384. private _duplicateId;
  6385. /**
  6386. * Pushes a value at the end of the active data.
  6387. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6388. * @param value defines the object to push in the array.
  6389. */
  6390. push(value: T): void;
  6391. /**
  6392. * Pushes a value at the end of the active data.
  6393. * If the data is already present, it won t be added again
  6394. * @param value defines the object to push in the array.
  6395. * @returns true if added false if it was already present
  6396. */
  6397. pushNoDuplicate(value: T): boolean;
  6398. /**
  6399. * Resets the active data to an empty array.
  6400. */
  6401. reset(): void;
  6402. /**
  6403. * Concats the active data with a given array.
  6404. * This ensures no dupplicate will be present in the result.
  6405. * @param array defines the data to concatenate with.
  6406. */
  6407. concatWithNoDuplicate(array: any): void;
  6408. }
  6409. }
  6410. declare module "babylonjs/Cameras/cameraInputsManager" {
  6411. import { Nullable } from "babylonjs/types";
  6412. import { Camera } from "babylonjs/Cameras/camera";
  6413. /**
  6414. * @ignore
  6415. * This is a list of all the different input types that are available in the application.
  6416. * Fo instance: ArcRotateCameraGamepadInput...
  6417. */
  6418. export var CameraInputTypes: {};
  6419. /**
  6420. * This is the contract to implement in order to create a new input class.
  6421. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6422. */
  6423. export interface ICameraInput<TCamera extends Camera> {
  6424. /**
  6425. * Defines the camera the input is attached to.
  6426. */
  6427. camera: Nullable<TCamera>;
  6428. /**
  6429. * Gets the class name of the current intput.
  6430. * @returns the class name
  6431. */
  6432. getClassName(): string;
  6433. /**
  6434. * Get the friendly name associated with the input class.
  6435. * @returns the input friendly name
  6436. */
  6437. getSimpleName(): string;
  6438. /**
  6439. * Attach the input controls to a specific dom element to get the input from.
  6440. * @param element Defines the element the controls should be listened from
  6441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6442. */
  6443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6444. /**
  6445. * Detach the current controls from the specified dom element.
  6446. * @param element Defines the element to stop listening the inputs from
  6447. */
  6448. detachControl(element: Nullable<HTMLElement>): void;
  6449. /**
  6450. * Update the current camera state depending on the inputs that have been used this frame.
  6451. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6452. */
  6453. checkInputs?: () => void;
  6454. }
  6455. /**
  6456. * Represents a map of input types to input instance or input index to input instance.
  6457. */
  6458. export interface CameraInputsMap<TCamera extends Camera> {
  6459. /**
  6460. * Accessor to the input by input type.
  6461. */
  6462. [name: string]: ICameraInput<TCamera>;
  6463. /**
  6464. * Accessor to the input by input index.
  6465. */
  6466. [idx: number]: ICameraInput<TCamera>;
  6467. }
  6468. /**
  6469. * This represents the input manager used within a camera.
  6470. * It helps dealing with all the different kind of input attached to a camera.
  6471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6472. */
  6473. export class CameraInputsManager<TCamera extends Camera> {
  6474. /**
  6475. * Defines the list of inputs attahed to the camera.
  6476. */
  6477. attached: CameraInputsMap<TCamera>;
  6478. /**
  6479. * Defines the dom element the camera is collecting inputs from.
  6480. * This is null if the controls have not been attached.
  6481. */
  6482. attachedElement: Nullable<HTMLElement>;
  6483. /**
  6484. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6485. */
  6486. noPreventDefault: boolean;
  6487. /**
  6488. * Defined the camera the input manager belongs to.
  6489. */
  6490. camera: TCamera;
  6491. /**
  6492. * Update the current camera state depending on the inputs that have been used this frame.
  6493. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6494. */
  6495. checkInputs: () => void;
  6496. /**
  6497. * Instantiate a new Camera Input Manager.
  6498. * @param camera Defines the camera the input manager blongs to
  6499. */
  6500. constructor(camera: TCamera);
  6501. /**
  6502. * Add an input method to a camera
  6503. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6504. * @param input camera input method
  6505. */
  6506. add(input: ICameraInput<TCamera>): void;
  6507. /**
  6508. * Remove a specific input method from a camera
  6509. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6510. * @param inputToRemove camera input method
  6511. */
  6512. remove(inputToRemove: ICameraInput<TCamera>): void;
  6513. /**
  6514. * Remove a specific input type from a camera
  6515. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6516. * @param inputType the type of the input to remove
  6517. */
  6518. removeByType(inputType: string): void;
  6519. private _addCheckInputs;
  6520. /**
  6521. * Attach the input controls to the currently attached dom element to listen the events from.
  6522. * @param input Defines the input to attach
  6523. */
  6524. attachInput(input: ICameraInput<TCamera>): void;
  6525. /**
  6526. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6527. * @param element Defines the dom element to collect the events from
  6528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6529. */
  6530. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6531. /**
  6532. * Detach the current manager inputs controls from a specific dom element.
  6533. * @param element Defines the dom element to collect the events from
  6534. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6535. */
  6536. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6537. /**
  6538. * Rebuild the dynamic inputCheck function from the current list of
  6539. * defined inputs in the manager.
  6540. */
  6541. rebuildInputCheck(): void;
  6542. /**
  6543. * Remove all attached input methods from a camera
  6544. */
  6545. clear(): void;
  6546. /**
  6547. * Serialize the current input manager attached to a camera.
  6548. * This ensures than once parsed,
  6549. * the input associated to the camera will be identical to the current ones
  6550. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6551. */
  6552. serialize(serializedCamera: any): void;
  6553. /**
  6554. * Parses an input manager serialized JSON to restore the previous list of inputs
  6555. * and states associated to a camera.
  6556. * @param parsedCamera Defines the JSON to parse
  6557. */
  6558. parse(parsedCamera: any): void;
  6559. }
  6560. }
  6561. declare module "babylonjs/Meshes/buffer" {
  6562. import { Nullable, DataArray } from "babylonjs/types";
  6563. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6564. /**
  6565. * Class used to store data that will be store in GPU memory
  6566. */
  6567. export class Buffer {
  6568. private _engine;
  6569. private _buffer;
  6570. /** @hidden */
  6571. _data: Nullable<DataArray>;
  6572. private _updatable;
  6573. private _instanced;
  6574. private _divisor;
  6575. /**
  6576. * Gets the byte stride.
  6577. */
  6578. readonly byteStride: number;
  6579. /**
  6580. * Constructor
  6581. * @param engine the engine
  6582. * @param data the data to use for this buffer
  6583. * @param updatable whether the data is updatable
  6584. * @param stride the stride (optional)
  6585. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6586. * @param instanced whether the buffer is instanced (optional)
  6587. * @param useBytes set to true if the stride in in bytes (optional)
  6588. * @param divisor sets an optional divisor for instances (1 by default)
  6589. */
  6590. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6591. /**
  6592. * Create a new VertexBuffer based on the current buffer
  6593. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6594. * @param offset defines offset in the buffer (0 by default)
  6595. * @param size defines the size in floats of attributes (position is 3 for instance)
  6596. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6597. * @param instanced defines if the vertex buffer contains indexed data
  6598. * @param useBytes defines if the offset and stride are in bytes *
  6599. * @param divisor sets an optional divisor for instances (1 by default)
  6600. * @returns the new vertex buffer
  6601. */
  6602. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6603. /**
  6604. * Gets a boolean indicating if the Buffer is updatable?
  6605. * @returns true if the buffer is updatable
  6606. */
  6607. isUpdatable(): boolean;
  6608. /**
  6609. * Gets current buffer's data
  6610. * @returns a DataArray or null
  6611. */
  6612. getData(): Nullable<DataArray>;
  6613. /**
  6614. * Gets underlying native buffer
  6615. * @returns underlying native buffer
  6616. */
  6617. getBuffer(): Nullable<DataBuffer>;
  6618. /**
  6619. * Gets the stride in float32 units (i.e. byte stride / 4).
  6620. * May not be an integer if the byte stride is not divisible by 4.
  6621. * @returns the stride in float32 units
  6622. * @deprecated Please use byteStride instead.
  6623. */
  6624. getStrideSize(): number;
  6625. /**
  6626. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6627. * @param data defines the data to store
  6628. */
  6629. create(data?: Nullable<DataArray>): void;
  6630. /** @hidden */
  6631. _rebuild(): void;
  6632. /**
  6633. * Update current buffer data
  6634. * @param data defines the data to store
  6635. */
  6636. update(data: DataArray): void;
  6637. /**
  6638. * Updates the data directly.
  6639. * @param data the new data
  6640. * @param offset the new offset
  6641. * @param vertexCount the vertex count (optional)
  6642. * @param useBytes set to true if the offset is in bytes
  6643. */
  6644. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6645. /**
  6646. * Release all resources
  6647. */
  6648. dispose(): void;
  6649. }
  6650. /**
  6651. * Specialized buffer used to store vertex data
  6652. */
  6653. export class VertexBuffer {
  6654. /** @hidden */
  6655. _buffer: Buffer;
  6656. private _kind;
  6657. private _size;
  6658. private _ownsBuffer;
  6659. private _instanced;
  6660. private _instanceDivisor;
  6661. /**
  6662. * The byte type.
  6663. */
  6664. static readonly BYTE: number;
  6665. /**
  6666. * The unsigned byte type.
  6667. */
  6668. static readonly UNSIGNED_BYTE: number;
  6669. /**
  6670. * The short type.
  6671. */
  6672. static readonly SHORT: number;
  6673. /**
  6674. * The unsigned short type.
  6675. */
  6676. static readonly UNSIGNED_SHORT: number;
  6677. /**
  6678. * The integer type.
  6679. */
  6680. static readonly INT: number;
  6681. /**
  6682. * The unsigned integer type.
  6683. */
  6684. static readonly UNSIGNED_INT: number;
  6685. /**
  6686. * The float type.
  6687. */
  6688. static readonly FLOAT: number;
  6689. /**
  6690. * Gets or sets the instance divisor when in instanced mode
  6691. */
  6692. get instanceDivisor(): number;
  6693. set instanceDivisor(value: number);
  6694. /**
  6695. * Gets the byte stride.
  6696. */
  6697. readonly byteStride: number;
  6698. /**
  6699. * Gets the byte offset.
  6700. */
  6701. readonly byteOffset: number;
  6702. /**
  6703. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6704. */
  6705. readonly normalized: boolean;
  6706. /**
  6707. * Gets the data type of each component in the array.
  6708. */
  6709. readonly type: number;
  6710. /**
  6711. * Constructor
  6712. * @param engine the engine
  6713. * @param data the data to use for this vertex buffer
  6714. * @param kind the vertex buffer kind
  6715. * @param updatable whether the data is updatable
  6716. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6717. * @param stride the stride (optional)
  6718. * @param instanced whether the buffer is instanced (optional)
  6719. * @param offset the offset of the data (optional)
  6720. * @param size the number of components (optional)
  6721. * @param type the type of the component (optional)
  6722. * @param normalized whether the data contains normalized data (optional)
  6723. * @param useBytes set to true if stride and offset are in bytes (optional)
  6724. * @param divisor defines the instance divisor to use (1 by default)
  6725. */
  6726. 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);
  6727. /** @hidden */
  6728. _rebuild(): void;
  6729. /**
  6730. * Returns the kind of the VertexBuffer (string)
  6731. * @returns a string
  6732. */
  6733. getKind(): string;
  6734. /**
  6735. * Gets a boolean indicating if the VertexBuffer is updatable?
  6736. * @returns true if the buffer is updatable
  6737. */
  6738. isUpdatable(): boolean;
  6739. /**
  6740. * Gets current buffer's data
  6741. * @returns a DataArray or null
  6742. */
  6743. getData(): Nullable<DataArray>;
  6744. /**
  6745. * Gets underlying native buffer
  6746. * @returns underlying native buffer
  6747. */
  6748. getBuffer(): Nullable<DataBuffer>;
  6749. /**
  6750. * Gets the stride in float32 units (i.e. byte stride / 4).
  6751. * May not be an integer if the byte stride is not divisible by 4.
  6752. * @returns the stride in float32 units
  6753. * @deprecated Please use byteStride instead.
  6754. */
  6755. getStrideSize(): number;
  6756. /**
  6757. * Returns the offset as a multiple of the type byte length.
  6758. * @returns the offset in bytes
  6759. * @deprecated Please use byteOffset instead.
  6760. */
  6761. getOffset(): number;
  6762. /**
  6763. * Returns the number of components per vertex attribute (integer)
  6764. * @returns the size in float
  6765. */
  6766. getSize(): number;
  6767. /**
  6768. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6769. * @returns true if this buffer is instanced
  6770. */
  6771. getIsInstanced(): boolean;
  6772. /**
  6773. * Returns the instancing divisor, zero for non-instanced (integer).
  6774. * @returns a number
  6775. */
  6776. getInstanceDivisor(): number;
  6777. /**
  6778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6779. * @param data defines the data to store
  6780. */
  6781. create(data?: DataArray): void;
  6782. /**
  6783. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6784. * This function will create a new buffer if the current one is not updatable
  6785. * @param data defines the data to store
  6786. */
  6787. update(data: DataArray): void;
  6788. /**
  6789. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6790. * Returns the directly updated WebGLBuffer.
  6791. * @param data the new data
  6792. * @param offset the new offset
  6793. * @param useBytes set to true if the offset is in bytes
  6794. */
  6795. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6796. /**
  6797. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6798. */
  6799. dispose(): void;
  6800. /**
  6801. * Enumerates each value of this vertex buffer as numbers.
  6802. * @param count the number of values to enumerate
  6803. * @param callback the callback function called for each value
  6804. */
  6805. forEach(count: number, callback: (value: number, index: number) => void): void;
  6806. /**
  6807. * Positions
  6808. */
  6809. static readonly PositionKind: string;
  6810. /**
  6811. * Normals
  6812. */
  6813. static readonly NormalKind: string;
  6814. /**
  6815. * Tangents
  6816. */
  6817. static readonly TangentKind: string;
  6818. /**
  6819. * Texture coordinates
  6820. */
  6821. static readonly UVKind: string;
  6822. /**
  6823. * Texture coordinates 2
  6824. */
  6825. static readonly UV2Kind: string;
  6826. /**
  6827. * Texture coordinates 3
  6828. */
  6829. static readonly UV3Kind: string;
  6830. /**
  6831. * Texture coordinates 4
  6832. */
  6833. static readonly UV4Kind: string;
  6834. /**
  6835. * Texture coordinates 5
  6836. */
  6837. static readonly UV5Kind: string;
  6838. /**
  6839. * Texture coordinates 6
  6840. */
  6841. static readonly UV6Kind: string;
  6842. /**
  6843. * Colors
  6844. */
  6845. static readonly ColorKind: string;
  6846. /**
  6847. * Matrix indices (for bones)
  6848. */
  6849. static readonly MatricesIndicesKind: string;
  6850. /**
  6851. * Matrix weights (for bones)
  6852. */
  6853. static readonly MatricesWeightsKind: string;
  6854. /**
  6855. * Additional matrix indices (for bones)
  6856. */
  6857. static readonly MatricesIndicesExtraKind: string;
  6858. /**
  6859. * Additional matrix weights (for bones)
  6860. */
  6861. static readonly MatricesWeightsExtraKind: string;
  6862. /**
  6863. * Deduces the stride given a kind.
  6864. * @param kind The kind string to deduce
  6865. * @returns The deduced stride
  6866. */
  6867. static DeduceStride(kind: string): number;
  6868. /**
  6869. * Gets the byte length of the given type.
  6870. * @param type the type
  6871. * @returns the number of bytes
  6872. */
  6873. static GetTypeByteLength(type: number): number;
  6874. /**
  6875. * Enumerates each value of the given parameters as numbers.
  6876. * @param data the data to enumerate
  6877. * @param byteOffset the byte offset of the data
  6878. * @param byteStride the byte stride of the data
  6879. * @param componentCount the number of components per element
  6880. * @param componentType the type of the component
  6881. * @param count the number of values to enumerate
  6882. * @param normalized whether the data is normalized
  6883. * @param callback the callback function called for each value
  6884. */
  6885. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6886. private static _GetFloatValue;
  6887. }
  6888. }
  6889. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6890. import { Vector3 } from "babylonjs/Maths/math.vector";
  6891. import { Mesh } from "babylonjs/Meshes/mesh";
  6892. /**
  6893. * The options Interface for creating a Capsule Mesh
  6894. */
  6895. export interface ICreateCapsuleOptions {
  6896. /** The Orientation of the capsule. Default : Vector3.Up() */
  6897. orientation?: Vector3;
  6898. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6899. subdivisions: number;
  6900. /** Number of cylindrical segments on the capsule. */
  6901. tessellation: number;
  6902. /** Height or Length of the capsule. */
  6903. height: number;
  6904. /** Radius of the capsule. */
  6905. radius: number;
  6906. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6907. capSubdivisions: number;
  6908. /** Overwrite for the top radius. */
  6909. radiusTop?: number;
  6910. /** Overwrite for the bottom radius. */
  6911. radiusBottom?: number;
  6912. /** Overwrite for the top capSubdivisions. */
  6913. topCapSubdivisions?: number;
  6914. /** Overwrite for the bottom capSubdivisions. */
  6915. bottomCapSubdivisions?: number;
  6916. }
  6917. /**
  6918. * Class containing static functions to help procedurally build meshes
  6919. */
  6920. export class CapsuleBuilder {
  6921. /**
  6922. * Creates a capsule or a pill mesh
  6923. * @param name defines the name of the mesh
  6924. * @param options The constructors options.
  6925. * @param scene The scene the mesh is scoped to.
  6926. * @returns Capsule Mesh
  6927. */
  6928. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6929. }
  6930. }
  6931. declare module "babylonjs/Collisions/intersectionInfo" {
  6932. import { Nullable } from "babylonjs/types";
  6933. /**
  6934. * @hidden
  6935. */
  6936. export class IntersectionInfo {
  6937. bu: Nullable<number>;
  6938. bv: Nullable<number>;
  6939. distance: number;
  6940. faceId: number;
  6941. subMeshId: number;
  6942. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6943. }
  6944. }
  6945. declare module "babylonjs/Culling/boundingSphere" {
  6946. import { DeepImmutable } from "babylonjs/types";
  6947. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6948. import { Plane } from "babylonjs/Maths/math.plane";
  6949. /**
  6950. * Class used to store bounding sphere information
  6951. */
  6952. export class BoundingSphere {
  6953. /**
  6954. * Gets the center of the bounding sphere in local space
  6955. */
  6956. readonly center: Vector3;
  6957. /**
  6958. * Radius of the bounding sphere in local space
  6959. */
  6960. radius: number;
  6961. /**
  6962. * Gets the center of the bounding sphere in world space
  6963. */
  6964. readonly centerWorld: Vector3;
  6965. /**
  6966. * Radius of the bounding sphere in world space
  6967. */
  6968. radiusWorld: number;
  6969. /**
  6970. * Gets the minimum vector in local space
  6971. */
  6972. readonly minimum: Vector3;
  6973. /**
  6974. * Gets the maximum vector in local space
  6975. */
  6976. readonly maximum: Vector3;
  6977. private _worldMatrix;
  6978. private static readonly TmpVector3;
  6979. /**
  6980. * Creates a new bounding sphere
  6981. * @param min defines the minimum vector (in local space)
  6982. * @param max defines the maximum vector (in local space)
  6983. * @param worldMatrix defines the new world matrix
  6984. */
  6985. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6986. /**
  6987. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6988. * @param min defines the new minimum vector (in local space)
  6989. * @param max defines the new maximum vector (in local space)
  6990. * @param worldMatrix defines the new world matrix
  6991. */
  6992. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6993. /**
  6994. * Scale the current bounding sphere by applying a scale factor
  6995. * @param factor defines the scale factor to apply
  6996. * @returns the current bounding box
  6997. */
  6998. scale(factor: number): BoundingSphere;
  6999. /**
  7000. * Gets the world matrix of the bounding box
  7001. * @returns a matrix
  7002. */
  7003. getWorldMatrix(): DeepImmutable<Matrix>;
  7004. /** @hidden */
  7005. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7006. /**
  7007. * Tests if the bounding sphere is intersecting the frustum planes
  7008. * @param frustumPlanes defines the frustum planes to test
  7009. * @returns true if there is an intersection
  7010. */
  7011. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7012. /**
  7013. * Tests if the bounding sphere center is in between the frustum planes.
  7014. * Used for optimistic fast inclusion.
  7015. * @param frustumPlanes defines the frustum planes to test
  7016. * @returns true if the sphere center is in between the frustum planes
  7017. */
  7018. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7019. /**
  7020. * Tests if a point is inside the bounding sphere
  7021. * @param point defines the point to test
  7022. * @returns true if the point is inside the bounding sphere
  7023. */
  7024. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7025. /**
  7026. * Checks if two sphere intersct
  7027. * @param sphere0 sphere 0
  7028. * @param sphere1 sphere 1
  7029. * @returns true if the speres intersect
  7030. */
  7031. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7032. }
  7033. }
  7034. declare module "babylonjs/Culling/boundingBox" {
  7035. import { DeepImmutable } from "babylonjs/types";
  7036. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7037. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7038. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7039. import { Plane } from "babylonjs/Maths/math.plane";
  7040. /**
  7041. * Class used to store bounding box information
  7042. */
  7043. export class BoundingBox implements ICullable {
  7044. /**
  7045. * Gets the 8 vectors representing the bounding box in local space
  7046. */
  7047. readonly vectors: Vector3[];
  7048. /**
  7049. * Gets the center of the bounding box in local space
  7050. */
  7051. readonly center: Vector3;
  7052. /**
  7053. * Gets the center of the bounding box in world space
  7054. */
  7055. readonly centerWorld: Vector3;
  7056. /**
  7057. * Gets the extend size in local space
  7058. */
  7059. readonly extendSize: Vector3;
  7060. /**
  7061. * Gets the extend size in world space
  7062. */
  7063. readonly extendSizeWorld: Vector3;
  7064. /**
  7065. * Gets the OBB (object bounding box) directions
  7066. */
  7067. readonly directions: Vector3[];
  7068. /**
  7069. * Gets the 8 vectors representing the bounding box in world space
  7070. */
  7071. readonly vectorsWorld: Vector3[];
  7072. /**
  7073. * Gets the minimum vector in world space
  7074. */
  7075. readonly minimumWorld: Vector3;
  7076. /**
  7077. * Gets the maximum vector in world space
  7078. */
  7079. readonly maximumWorld: Vector3;
  7080. /**
  7081. * Gets the minimum vector in local space
  7082. */
  7083. readonly minimum: Vector3;
  7084. /**
  7085. * Gets the maximum vector in local space
  7086. */
  7087. readonly maximum: Vector3;
  7088. private _worldMatrix;
  7089. private static readonly TmpVector3;
  7090. /**
  7091. * @hidden
  7092. */
  7093. _tag: number;
  7094. /**
  7095. * Creates a new bounding box
  7096. * @param min defines the minimum vector (in local space)
  7097. * @param max defines the maximum vector (in local space)
  7098. * @param worldMatrix defines the new world matrix
  7099. */
  7100. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7101. /**
  7102. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7103. * @param min defines the new minimum vector (in local space)
  7104. * @param max defines the new maximum vector (in local space)
  7105. * @param worldMatrix defines the new world matrix
  7106. */
  7107. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7108. /**
  7109. * Scale the current bounding box by applying a scale factor
  7110. * @param factor defines the scale factor to apply
  7111. * @returns the current bounding box
  7112. */
  7113. scale(factor: number): BoundingBox;
  7114. /**
  7115. * Gets the world matrix of the bounding box
  7116. * @returns a matrix
  7117. */
  7118. getWorldMatrix(): DeepImmutable<Matrix>;
  7119. /** @hidden */
  7120. _update(world: DeepImmutable<Matrix>): void;
  7121. /**
  7122. * Tests if the bounding box is intersecting the frustum planes
  7123. * @param frustumPlanes defines the frustum planes to test
  7124. * @returns true if there is an intersection
  7125. */
  7126. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7127. /**
  7128. * Tests if the bounding box is entirely inside the frustum planes
  7129. * @param frustumPlanes defines the frustum planes to test
  7130. * @returns true if there is an inclusion
  7131. */
  7132. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7133. /**
  7134. * Tests if a point is inside the bounding box
  7135. * @param point defines the point to test
  7136. * @returns true if the point is inside the bounding box
  7137. */
  7138. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7139. /**
  7140. * Tests if the bounding box intersects with a bounding sphere
  7141. * @param sphere defines the sphere to test
  7142. * @returns true if there is an intersection
  7143. */
  7144. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7145. /**
  7146. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7147. * @param min defines the min vector to use
  7148. * @param max defines the max vector to use
  7149. * @returns true if there is an intersection
  7150. */
  7151. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7152. /**
  7153. * Tests if two bounding boxes are intersections
  7154. * @param box0 defines the first box to test
  7155. * @param box1 defines the second box to test
  7156. * @returns true if there is an intersection
  7157. */
  7158. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7159. /**
  7160. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7161. * @param minPoint defines the minimum vector of the bounding box
  7162. * @param maxPoint defines the maximum vector of the bounding box
  7163. * @param sphereCenter defines the sphere center
  7164. * @param sphereRadius defines the sphere radius
  7165. * @returns true if there is an intersection
  7166. */
  7167. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7168. /**
  7169. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7170. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7171. * @param frustumPlanes defines the frustum planes to test
  7172. * @return true if there is an inclusion
  7173. */
  7174. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7175. /**
  7176. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7177. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7178. * @param frustumPlanes defines the frustum planes to test
  7179. * @return true if there is an intersection
  7180. */
  7181. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7182. }
  7183. }
  7184. declare module "babylonjs/Collisions/collider" {
  7185. import { Nullable, IndicesArray } from "babylonjs/types";
  7186. import { Vector3 } from "babylonjs/Maths/math.vector";
  7187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7188. import { Plane } from "babylonjs/Maths/math.plane";
  7189. /** @hidden */
  7190. export class Collider {
  7191. /** Define if a collision was found */
  7192. collisionFound: boolean;
  7193. /**
  7194. * Define last intersection point in local space
  7195. */
  7196. intersectionPoint: Vector3;
  7197. /**
  7198. * Define last collided mesh
  7199. */
  7200. collidedMesh: Nullable<AbstractMesh>;
  7201. private _collisionPoint;
  7202. private _planeIntersectionPoint;
  7203. private _tempVector;
  7204. private _tempVector2;
  7205. private _tempVector3;
  7206. private _tempVector4;
  7207. private _edge;
  7208. private _baseToVertex;
  7209. private _destinationPoint;
  7210. private _slidePlaneNormal;
  7211. private _displacementVector;
  7212. /** @hidden */
  7213. _radius: Vector3;
  7214. /** @hidden */
  7215. _retry: number;
  7216. private _velocity;
  7217. private _basePoint;
  7218. private _epsilon;
  7219. /** @hidden */
  7220. _velocityWorldLength: number;
  7221. /** @hidden */
  7222. _basePointWorld: Vector3;
  7223. private _velocityWorld;
  7224. private _normalizedVelocity;
  7225. /** @hidden */
  7226. _initialVelocity: Vector3;
  7227. /** @hidden */
  7228. _initialPosition: Vector3;
  7229. private _nearestDistance;
  7230. private _collisionMask;
  7231. get collisionMask(): number;
  7232. set collisionMask(mask: number);
  7233. /**
  7234. * Gets the plane normal used to compute the sliding response (in local space)
  7235. */
  7236. get slidePlaneNormal(): Vector3;
  7237. /** @hidden */
  7238. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7239. /** @hidden */
  7240. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7241. /** @hidden */
  7242. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7243. /** @hidden */
  7244. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7245. /** @hidden */
  7246. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7247. /** @hidden */
  7248. _getResponse(pos: Vector3, vel: Vector3): void;
  7249. }
  7250. }
  7251. declare module "babylonjs/Culling/boundingInfo" {
  7252. import { DeepImmutable } from "babylonjs/types";
  7253. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7254. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7255. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7256. import { Plane } from "babylonjs/Maths/math.plane";
  7257. import { Collider } from "babylonjs/Collisions/collider";
  7258. /**
  7259. * Interface for cullable objects
  7260. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7261. */
  7262. export interface ICullable {
  7263. /**
  7264. * Checks if the object or part of the object is in the frustum
  7265. * @param frustumPlanes Camera near/planes
  7266. * @returns true if the object is in frustum otherwise false
  7267. */
  7268. isInFrustum(frustumPlanes: Plane[]): boolean;
  7269. /**
  7270. * Checks if a cullable object (mesh...) is in the camera frustum
  7271. * Unlike isInFrustum this cheks the full bounding box
  7272. * @param frustumPlanes Camera near/planes
  7273. * @returns true if the object is in frustum otherwise false
  7274. */
  7275. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7276. }
  7277. /**
  7278. * Info for a bounding data of a mesh
  7279. */
  7280. export class BoundingInfo implements ICullable {
  7281. /**
  7282. * Bounding box for the mesh
  7283. */
  7284. readonly boundingBox: BoundingBox;
  7285. /**
  7286. * Bounding sphere for the mesh
  7287. */
  7288. readonly boundingSphere: BoundingSphere;
  7289. private _isLocked;
  7290. private static readonly TmpVector3;
  7291. /**
  7292. * Constructs bounding info
  7293. * @param minimum min vector of the bounding box/sphere
  7294. * @param maximum max vector of the bounding box/sphere
  7295. * @param worldMatrix defines the new world matrix
  7296. */
  7297. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7298. /**
  7299. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7300. * @param min defines the new minimum vector (in local space)
  7301. * @param max defines the new maximum vector (in local space)
  7302. * @param worldMatrix defines the new world matrix
  7303. */
  7304. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7305. /**
  7306. * min vector of the bounding box/sphere
  7307. */
  7308. get minimum(): Vector3;
  7309. /**
  7310. * max vector of the bounding box/sphere
  7311. */
  7312. get maximum(): Vector3;
  7313. /**
  7314. * If the info is locked and won't be updated to avoid perf overhead
  7315. */
  7316. get isLocked(): boolean;
  7317. set isLocked(value: boolean);
  7318. /**
  7319. * Updates the bounding sphere and box
  7320. * @param world world matrix to be used to update
  7321. */
  7322. update(world: DeepImmutable<Matrix>): void;
  7323. /**
  7324. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7325. * @param center New center of the bounding info
  7326. * @param extend New extend of the bounding info
  7327. * @returns the current bounding info
  7328. */
  7329. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7330. /**
  7331. * Scale the current bounding info by applying a scale factor
  7332. * @param factor defines the scale factor to apply
  7333. * @returns the current bounding info
  7334. */
  7335. scale(factor: number): BoundingInfo;
  7336. /**
  7337. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7338. * @param frustumPlanes defines the frustum to test
  7339. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7340. * @returns true if the bounding info is in the frustum planes
  7341. */
  7342. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7343. /**
  7344. * Gets the world distance between the min and max points of the bounding box
  7345. */
  7346. get diagonalLength(): number;
  7347. /**
  7348. * Checks if a cullable object (mesh...) is in the camera frustum
  7349. * Unlike isInFrustum this cheks the full bounding box
  7350. * @param frustumPlanes Camera near/planes
  7351. * @returns true if the object is in frustum otherwise false
  7352. */
  7353. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7354. /** @hidden */
  7355. _checkCollision(collider: Collider): boolean;
  7356. /**
  7357. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7358. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7359. * @param point the point to check intersection with
  7360. * @returns if the point intersects
  7361. */
  7362. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7363. /**
  7364. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7365. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7366. * @param boundingInfo the bounding info to check intersection with
  7367. * @param precise if the intersection should be done using OBB
  7368. * @returns if the bounding info intersects
  7369. */
  7370. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7371. }
  7372. }
  7373. declare module "babylonjs/Maths/math.functions" {
  7374. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7375. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7376. /**
  7377. * Extracts minimum and maximum values from a list of indexed positions
  7378. * @param positions defines the positions to use
  7379. * @param indices defines the indices to the positions
  7380. * @param indexStart defines the start index
  7381. * @param indexCount defines the end index
  7382. * @param bias defines bias value to add to the result
  7383. * @return minimum and maximum values
  7384. */
  7385. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7386. minimum: Vector3;
  7387. maximum: Vector3;
  7388. };
  7389. /**
  7390. * Extracts minimum and maximum values from a list of positions
  7391. * @param positions defines the positions to use
  7392. * @param start defines the start index in the positions array
  7393. * @param count defines the number of positions to handle
  7394. * @param bias defines bias value to add to the result
  7395. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7396. * @return minimum and maximum values
  7397. */
  7398. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7399. minimum: Vector3;
  7400. maximum: Vector3;
  7401. };
  7402. }
  7403. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7404. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7405. /** @hidden */
  7406. export class WebGLDataBuffer extends DataBuffer {
  7407. private _buffer;
  7408. constructor(resource: WebGLBuffer);
  7409. get underlyingResource(): any;
  7410. }
  7411. }
  7412. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7413. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7414. import { Nullable } from "babylonjs/types";
  7415. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7416. /** @hidden */
  7417. export class WebGLPipelineContext implements IPipelineContext {
  7418. engine: ThinEngine;
  7419. program: Nullable<WebGLProgram>;
  7420. context?: WebGLRenderingContext;
  7421. vertexShader?: WebGLShader;
  7422. fragmentShader?: WebGLShader;
  7423. isParallelCompiled: boolean;
  7424. onCompiled?: () => void;
  7425. transformFeedback?: WebGLTransformFeedback | null;
  7426. vertexCompilationError: Nullable<string>;
  7427. fragmentCompilationError: Nullable<string>;
  7428. programLinkError: Nullable<string>;
  7429. programValidationError: Nullable<string>;
  7430. get isAsync(): boolean;
  7431. get isReady(): boolean;
  7432. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7433. _getVertexShaderCode(): string | null;
  7434. _getFragmentShaderCode(): string | null;
  7435. }
  7436. }
  7437. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7438. import { FloatArray, Nullable } from "babylonjs/types";
  7439. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7440. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7441. module "babylonjs/Engines/thinEngine" {
  7442. interface ThinEngine {
  7443. /**
  7444. * Create an uniform buffer
  7445. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7446. * @param elements defines the content of the uniform buffer
  7447. * @returns the webGL uniform buffer
  7448. */
  7449. createUniformBuffer(elements: FloatArray): DataBuffer;
  7450. /**
  7451. * Create a dynamic uniform buffer
  7452. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7453. * @param elements defines the content of the uniform buffer
  7454. * @returns the webGL uniform buffer
  7455. */
  7456. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7457. /**
  7458. * Update an existing uniform buffer
  7459. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7460. * @param uniformBuffer defines the target uniform buffer
  7461. * @param elements defines the content to update
  7462. * @param offset defines the offset in the uniform buffer where update should start
  7463. * @param count defines the size of the data to update
  7464. */
  7465. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7466. /**
  7467. * Bind an uniform buffer to the current webGL context
  7468. * @param buffer defines the buffer to bind
  7469. */
  7470. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7471. /**
  7472. * Bind a buffer to the current webGL context at a given location
  7473. * @param buffer defines the buffer to bind
  7474. * @param location defines the index where to bind the buffer
  7475. */
  7476. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7477. /**
  7478. * Bind a specific block at a given index in a specific shader program
  7479. * @param pipelineContext defines the pipeline context to use
  7480. * @param blockName defines the block name
  7481. * @param index defines the index where to bind the block
  7482. */
  7483. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7484. }
  7485. }
  7486. }
  7487. declare module "babylonjs/Materials/uniformBuffer" {
  7488. import { Nullable, FloatArray } from "babylonjs/types";
  7489. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7490. import { Engine } from "babylonjs/Engines/engine";
  7491. import { Effect } from "babylonjs/Materials/effect";
  7492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7493. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7494. import { Color3 } from "babylonjs/Maths/math.color";
  7495. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7496. /**
  7497. * Uniform buffer objects.
  7498. *
  7499. * Handles blocks of uniform on the GPU.
  7500. *
  7501. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7502. *
  7503. * For more information, please refer to :
  7504. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7505. */
  7506. export class UniformBuffer {
  7507. private _engine;
  7508. private _buffer;
  7509. private _data;
  7510. private _bufferData;
  7511. private _dynamic?;
  7512. private _uniformLocations;
  7513. private _uniformSizes;
  7514. private _uniformLocationPointer;
  7515. private _needSync;
  7516. private _noUBO;
  7517. private _currentEffect;
  7518. /** @hidden */
  7519. _alreadyBound: boolean;
  7520. private static _MAX_UNIFORM_SIZE;
  7521. private static _tempBuffer;
  7522. /**
  7523. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7524. * This is dynamic to allow compat with webgl 1 and 2.
  7525. * You will need to pass the name of the uniform as well as the value.
  7526. */
  7527. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7528. /**
  7529. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7530. * This is dynamic to allow compat with webgl 1 and 2.
  7531. * You will need to pass the name of the uniform as well as the value.
  7532. */
  7533. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7534. /**
  7535. * Lambda to Update a single float in a uniform buffer.
  7536. * This is dynamic to allow compat with webgl 1 and 2.
  7537. * You will need to pass the name of the uniform as well as the value.
  7538. */
  7539. updateFloat: (name: string, x: number) => void;
  7540. /**
  7541. * Lambda to Update a vec2 of float in a uniform buffer.
  7542. * This is dynamic to allow compat with webgl 1 and 2.
  7543. * You will need to pass the name of the uniform as well as the value.
  7544. */
  7545. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7546. /**
  7547. * Lambda to Update a vec3 of float in a uniform buffer.
  7548. * This is dynamic to allow compat with webgl 1 and 2.
  7549. * You will need to pass the name of the uniform as well as the value.
  7550. */
  7551. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7552. /**
  7553. * Lambda to Update a vec4 of float in a uniform buffer.
  7554. * This is dynamic to allow compat with webgl 1 and 2.
  7555. * You will need to pass the name of the uniform as well as the value.
  7556. */
  7557. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7558. /**
  7559. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7560. * This is dynamic to allow compat with webgl 1 and 2.
  7561. * You will need to pass the name of the uniform as well as the value.
  7562. */
  7563. updateMatrix: (name: string, mat: Matrix) => void;
  7564. /**
  7565. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7566. * This is dynamic to allow compat with webgl 1 and 2.
  7567. * You will need to pass the name of the uniform as well as the value.
  7568. */
  7569. updateVector3: (name: string, vector: Vector3) => void;
  7570. /**
  7571. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7572. * This is dynamic to allow compat with webgl 1 and 2.
  7573. * You will need to pass the name of the uniform as well as the value.
  7574. */
  7575. updateVector4: (name: string, vector: Vector4) => void;
  7576. /**
  7577. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7578. * This is dynamic to allow compat with webgl 1 and 2.
  7579. * You will need to pass the name of the uniform as well as the value.
  7580. */
  7581. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7582. /**
  7583. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7584. * This is dynamic to allow compat with webgl 1 and 2.
  7585. * You will need to pass the name of the uniform as well as the value.
  7586. */
  7587. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7588. /**
  7589. * Instantiates a new Uniform buffer objects.
  7590. *
  7591. * Handles blocks of uniform on the GPU.
  7592. *
  7593. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7594. *
  7595. * For more information, please refer to :
  7596. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7597. * @param engine Define the engine the buffer is associated with
  7598. * @param data Define the data contained in the buffer
  7599. * @param dynamic Define if the buffer is updatable
  7600. */
  7601. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7602. /**
  7603. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7604. * or just falling back on setUniformXXX calls.
  7605. */
  7606. get useUbo(): boolean;
  7607. /**
  7608. * Indicates if the WebGL underlying uniform buffer is in sync
  7609. * with the javascript cache data.
  7610. */
  7611. get isSync(): boolean;
  7612. /**
  7613. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7614. * Also, a dynamic UniformBuffer will disable cache verification and always
  7615. * update the underlying WebGL uniform buffer to the GPU.
  7616. * @returns if Dynamic, otherwise false
  7617. */
  7618. isDynamic(): boolean;
  7619. /**
  7620. * The data cache on JS side.
  7621. * @returns the underlying data as a float array
  7622. */
  7623. getData(): Float32Array;
  7624. /**
  7625. * The underlying WebGL Uniform buffer.
  7626. * @returns the webgl buffer
  7627. */
  7628. getBuffer(): Nullable<DataBuffer>;
  7629. /**
  7630. * std140 layout specifies how to align data within an UBO structure.
  7631. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7632. * for specs.
  7633. */
  7634. private _fillAlignment;
  7635. /**
  7636. * Adds an uniform in the buffer.
  7637. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7638. * for the layout to be correct !
  7639. * @param name Name of the uniform, as used in the uniform block in the shader.
  7640. * @param size Data size, or data directly.
  7641. */
  7642. addUniform(name: string, size: number | number[]): void;
  7643. /**
  7644. * Adds a Matrix 4x4 to the uniform buffer.
  7645. * @param name Name of the uniform, as used in the uniform block in the shader.
  7646. * @param mat A 4x4 matrix.
  7647. */
  7648. addMatrix(name: string, mat: Matrix): void;
  7649. /**
  7650. * Adds a vec2 to the uniform buffer.
  7651. * @param name Name of the uniform, as used in the uniform block in the shader.
  7652. * @param x Define the x component value of the vec2
  7653. * @param y Define the y component value of the vec2
  7654. */
  7655. addFloat2(name: string, x: number, y: number): void;
  7656. /**
  7657. * Adds a vec3 to the uniform buffer.
  7658. * @param name Name of the uniform, as used in the uniform block in the shader.
  7659. * @param x Define the x component value of the vec3
  7660. * @param y Define the y component value of the vec3
  7661. * @param z Define the z component value of the vec3
  7662. */
  7663. addFloat3(name: string, x: number, y: number, z: number): void;
  7664. /**
  7665. * Adds a vec3 to the uniform buffer.
  7666. * @param name Name of the uniform, as used in the uniform block in the shader.
  7667. * @param color Define the vec3 from a Color
  7668. */
  7669. addColor3(name: string, color: Color3): void;
  7670. /**
  7671. * Adds a vec4 to the uniform buffer.
  7672. * @param name Name of the uniform, as used in the uniform block in the shader.
  7673. * @param color Define the rgb components from a Color
  7674. * @param alpha Define the a component of the vec4
  7675. */
  7676. addColor4(name: string, color: Color3, alpha: number): void;
  7677. /**
  7678. * Adds a vec3 to the uniform buffer.
  7679. * @param name Name of the uniform, as used in the uniform block in the shader.
  7680. * @param vector Define the vec3 components from a Vector
  7681. */
  7682. addVector3(name: string, vector: Vector3): void;
  7683. /**
  7684. * Adds a Matrix 3x3 to the uniform buffer.
  7685. * @param name Name of the uniform, as used in the uniform block in the shader.
  7686. */
  7687. addMatrix3x3(name: string): void;
  7688. /**
  7689. * Adds a Matrix 2x2 to the uniform buffer.
  7690. * @param name Name of the uniform, as used in the uniform block in the shader.
  7691. */
  7692. addMatrix2x2(name: string): void;
  7693. /**
  7694. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7695. */
  7696. create(): void;
  7697. /** @hidden */
  7698. _rebuild(): void;
  7699. /**
  7700. * Updates the WebGL Uniform Buffer on the GPU.
  7701. * If the `dynamic` flag is set to true, no cache comparison is done.
  7702. * Otherwise, the buffer will be updated only if the cache differs.
  7703. */
  7704. update(): void;
  7705. /**
  7706. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7707. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7708. * @param data Define the flattened data
  7709. * @param size Define the size of the data.
  7710. */
  7711. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7712. private _valueCache;
  7713. private _cacheMatrix;
  7714. private _updateMatrix3x3ForUniform;
  7715. private _updateMatrix3x3ForEffect;
  7716. private _updateMatrix2x2ForEffect;
  7717. private _updateMatrix2x2ForUniform;
  7718. private _updateFloatForEffect;
  7719. private _updateFloatForUniform;
  7720. private _updateFloat2ForEffect;
  7721. private _updateFloat2ForUniform;
  7722. private _updateFloat3ForEffect;
  7723. private _updateFloat3ForUniform;
  7724. private _updateFloat4ForEffect;
  7725. private _updateFloat4ForUniform;
  7726. private _updateMatrixForEffect;
  7727. private _updateMatrixForUniform;
  7728. private _updateVector3ForEffect;
  7729. private _updateVector3ForUniform;
  7730. private _updateVector4ForEffect;
  7731. private _updateVector4ForUniform;
  7732. private _updateColor3ForEffect;
  7733. private _updateColor3ForUniform;
  7734. private _updateColor4ForEffect;
  7735. private _updateColor4ForUniform;
  7736. /**
  7737. * Sets a sampler uniform on the effect.
  7738. * @param name Define the name of the sampler.
  7739. * @param texture Define the texture to set in the sampler
  7740. */
  7741. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7742. /**
  7743. * Directly updates the value of the uniform in the cache AND on the GPU.
  7744. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7745. * @param data Define the flattened data
  7746. */
  7747. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7748. /**
  7749. * Binds this uniform buffer to an effect.
  7750. * @param effect Define the effect to bind the buffer to
  7751. * @param name Name of the uniform block in the shader.
  7752. */
  7753. bindToEffect(effect: Effect, name: string): void;
  7754. /**
  7755. * Disposes the uniform buffer.
  7756. */
  7757. dispose(): void;
  7758. }
  7759. }
  7760. declare module "babylonjs/Misc/iInspectable" {
  7761. /**
  7762. * Enum that determines the text-wrapping mode to use.
  7763. */
  7764. export enum InspectableType {
  7765. /**
  7766. * Checkbox for booleans
  7767. */
  7768. Checkbox = 0,
  7769. /**
  7770. * Sliders for numbers
  7771. */
  7772. Slider = 1,
  7773. /**
  7774. * Vector3
  7775. */
  7776. Vector3 = 2,
  7777. /**
  7778. * Quaternions
  7779. */
  7780. Quaternion = 3,
  7781. /**
  7782. * Color3
  7783. */
  7784. Color3 = 4,
  7785. /**
  7786. * String
  7787. */
  7788. String = 5
  7789. }
  7790. /**
  7791. * Interface used to define custom inspectable properties.
  7792. * This interface is used by the inspector to display custom property grids
  7793. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7794. */
  7795. export interface IInspectable {
  7796. /**
  7797. * Gets the label to display
  7798. */
  7799. label: string;
  7800. /**
  7801. * Gets the name of the property to edit
  7802. */
  7803. propertyName: string;
  7804. /**
  7805. * Gets the type of the editor to use
  7806. */
  7807. type: InspectableType;
  7808. /**
  7809. * Gets the minimum value of the property when using in "slider" mode
  7810. */
  7811. min?: number;
  7812. /**
  7813. * Gets the maximum value of the property when using in "slider" mode
  7814. */
  7815. max?: number;
  7816. /**
  7817. * Gets the setp to use when using in "slider" mode
  7818. */
  7819. step?: number;
  7820. }
  7821. }
  7822. declare module "babylonjs/Misc/timingTools" {
  7823. /**
  7824. * Class used to provide helper for timing
  7825. */
  7826. export class TimingTools {
  7827. /**
  7828. * Polyfill for setImmediate
  7829. * @param action defines the action to execute after the current execution block
  7830. */
  7831. static SetImmediate(action: () => void): void;
  7832. }
  7833. }
  7834. declare module "babylonjs/Misc/instantiationTools" {
  7835. /**
  7836. * Class used to enable instatition of objects by class name
  7837. */
  7838. export class InstantiationTools {
  7839. /**
  7840. * Use this object to register external classes like custom textures or material
  7841. * to allow the laoders to instantiate them
  7842. */
  7843. static RegisteredExternalClasses: {
  7844. [key: string]: Object;
  7845. };
  7846. /**
  7847. * Tries to instantiate a new object from a given class name
  7848. * @param className defines the class name to instantiate
  7849. * @returns the new object or null if the system was not able to do the instantiation
  7850. */
  7851. static Instantiate(className: string): any;
  7852. }
  7853. }
  7854. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7855. /**
  7856. * Define options used to create a depth texture
  7857. */
  7858. export class DepthTextureCreationOptions {
  7859. /** Specifies whether or not a stencil should be allocated in the texture */
  7860. generateStencil?: boolean;
  7861. /** Specifies whether or not bilinear filtering is enable on the texture */
  7862. bilinearFiltering?: boolean;
  7863. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7864. comparisonFunction?: number;
  7865. /** Specifies if the created texture is a cube texture */
  7866. isCube?: boolean;
  7867. }
  7868. }
  7869. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7871. import { Nullable } from "babylonjs/types";
  7872. import { Scene } from "babylonjs/scene";
  7873. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7874. module "babylonjs/Engines/thinEngine" {
  7875. interface ThinEngine {
  7876. /**
  7877. * Creates a depth stencil cube texture.
  7878. * This is only available in WebGL 2.
  7879. * @param size The size of face edge in the cube texture.
  7880. * @param options The options defining the cube texture.
  7881. * @returns The cube texture
  7882. */
  7883. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7884. /**
  7885. * Creates a cube texture
  7886. * @param rootUrl defines the url where the files to load is located
  7887. * @param scene defines the current scene
  7888. * @param files defines the list of files to load (1 per face)
  7889. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7890. * @param onLoad defines an optional callback raised when the texture is loaded
  7891. * @param onError defines an optional callback raised if there is an issue to load the texture
  7892. * @param format defines the format of the data
  7893. * @param forcedExtension defines the extension to use to pick the right loader
  7894. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7895. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7896. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7897. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7898. * @returns the cube texture as an InternalTexture
  7899. */
  7900. 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;
  7901. /**
  7902. * Creates a cube texture
  7903. * @param rootUrl defines the url where the files to load is located
  7904. * @param scene defines the current scene
  7905. * @param files defines the list of files to load (1 per face)
  7906. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7907. * @param onLoad defines an optional callback raised when the texture is loaded
  7908. * @param onError defines an optional callback raised if there is an issue to load the texture
  7909. * @param format defines the format of the data
  7910. * @param forcedExtension defines the extension to use to pick the right loader
  7911. * @returns the cube texture as an InternalTexture
  7912. */
  7913. 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;
  7914. /**
  7915. * Creates a cube texture
  7916. * @param rootUrl defines the url where the files to load is located
  7917. * @param scene defines the current scene
  7918. * @param files defines the list of files to load (1 per face)
  7919. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7920. * @param onLoad defines an optional callback raised when the texture is loaded
  7921. * @param onError defines an optional callback raised if there is an issue to load the texture
  7922. * @param format defines the format of the data
  7923. * @param forcedExtension defines the extension to use to pick the right loader
  7924. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7925. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7926. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7927. * @returns the cube texture as an InternalTexture
  7928. */
  7929. 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;
  7930. /** @hidden */
  7931. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7932. /** @hidden */
  7933. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7934. /** @hidden */
  7935. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7936. /** @hidden */
  7937. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7938. /**
  7939. * @hidden
  7940. */
  7941. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7942. }
  7943. }
  7944. }
  7945. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7946. import { Nullable } from "babylonjs/types";
  7947. import { Scene } from "babylonjs/scene";
  7948. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7950. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7951. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7952. import { Observable } from "babylonjs/Misc/observable";
  7953. /**
  7954. * Class for creating a cube texture
  7955. */
  7956. export class CubeTexture extends BaseTexture {
  7957. private _delayedOnLoad;
  7958. /**
  7959. * Observable triggered once the texture has been loaded.
  7960. */
  7961. onLoadObservable: Observable<CubeTexture>;
  7962. /**
  7963. * The url of the texture
  7964. */
  7965. url: string;
  7966. /**
  7967. * Gets or sets the center of the bounding box associated with the cube texture.
  7968. * It must define where the camera used to render the texture was set
  7969. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7970. */
  7971. boundingBoxPosition: Vector3;
  7972. private _boundingBoxSize;
  7973. /**
  7974. * Gets or sets the size of the bounding box associated with the cube texture
  7975. * When defined, the cubemap will switch to local mode
  7976. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7977. * @example https://www.babylonjs-playground.com/#RNASML
  7978. */
  7979. set boundingBoxSize(value: Vector3);
  7980. /**
  7981. * Returns the bounding box size
  7982. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7983. */
  7984. get boundingBoxSize(): Vector3;
  7985. protected _rotationY: number;
  7986. /**
  7987. * Sets texture matrix rotation angle around Y axis in radians.
  7988. */
  7989. set rotationY(value: number);
  7990. /**
  7991. * Gets texture matrix rotation angle around Y axis radians.
  7992. */
  7993. get rotationY(): number;
  7994. /**
  7995. * Are mip maps generated for this texture or not.
  7996. */
  7997. get noMipmap(): boolean;
  7998. private _noMipmap;
  7999. private _files;
  8000. protected _forcedExtension: Nullable<string>;
  8001. private _extensions;
  8002. private _textureMatrix;
  8003. private _format;
  8004. private _createPolynomials;
  8005. /**
  8006. * Creates a cube texture from an array of image urls
  8007. * @param files defines an array of image urls
  8008. * @param scene defines the hosting scene
  8009. * @param noMipmap specifies if mip maps are not used
  8010. * @returns a cube texture
  8011. */
  8012. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8013. /**
  8014. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8015. * @param url defines the url of the prefiltered texture
  8016. * @param scene defines the scene the texture is attached to
  8017. * @param forcedExtension defines the extension of the file if different from the url
  8018. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8019. * @return the prefiltered texture
  8020. */
  8021. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8022. /**
  8023. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8024. * as prefiltered data.
  8025. * @param rootUrl defines the url of the texture or the root name of the six images
  8026. * @param null defines the scene or engine the texture is attached to
  8027. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8028. * @param noMipmap defines if mipmaps should be created or not
  8029. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8030. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8031. * @param onError defines a callback triggered in case of error during load
  8032. * @param format defines the internal format to use for the texture once loaded
  8033. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8034. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8035. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8036. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8037. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8038. * @return the cube texture
  8039. */
  8040. 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);
  8041. /**
  8042. * Get the current class name of the texture useful for serialization or dynamic coding.
  8043. * @returns "CubeTexture"
  8044. */
  8045. getClassName(): string;
  8046. /**
  8047. * Update the url (and optional buffer) of this texture if url was null during construction.
  8048. * @param url the url of the texture
  8049. * @param forcedExtension defines the extension to use
  8050. * @param onLoad callback called when the texture is loaded (defaults to null)
  8051. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8052. */
  8053. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8054. /**
  8055. * Delays loading of the cube texture
  8056. * @param forcedExtension defines the extension to use
  8057. */
  8058. delayLoad(forcedExtension?: string): void;
  8059. /**
  8060. * Returns the reflection texture matrix
  8061. * @returns the reflection texture matrix
  8062. */
  8063. getReflectionTextureMatrix(): Matrix;
  8064. /**
  8065. * Sets the reflection texture matrix
  8066. * @param value Reflection texture matrix
  8067. */
  8068. setReflectionTextureMatrix(value: Matrix): void;
  8069. /**
  8070. * Parses text to create a cube texture
  8071. * @param parsedTexture define the serialized text to read from
  8072. * @param scene defines the hosting scene
  8073. * @param rootUrl defines the root url of the cube texture
  8074. * @returns a cube texture
  8075. */
  8076. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8077. /**
  8078. * Makes a clone, or deep copy, of the cube texture
  8079. * @returns a new cube texture
  8080. */
  8081. clone(): CubeTexture;
  8082. }
  8083. }
  8084. declare module "babylonjs/Materials/materialDefines" {
  8085. /**
  8086. * Manages the defines for the Material
  8087. */
  8088. export class MaterialDefines {
  8089. /** @hidden */
  8090. protected _keys: string[];
  8091. private _isDirty;
  8092. /** @hidden */
  8093. _renderId: number;
  8094. /** @hidden */
  8095. _areLightsDirty: boolean;
  8096. /** @hidden */
  8097. _areLightsDisposed: boolean;
  8098. /** @hidden */
  8099. _areAttributesDirty: boolean;
  8100. /** @hidden */
  8101. _areTexturesDirty: boolean;
  8102. /** @hidden */
  8103. _areFresnelDirty: boolean;
  8104. /** @hidden */
  8105. _areMiscDirty: boolean;
  8106. /** @hidden */
  8107. _arePrePassDirty: boolean;
  8108. /** @hidden */
  8109. _areImageProcessingDirty: boolean;
  8110. /** @hidden */
  8111. _normals: boolean;
  8112. /** @hidden */
  8113. _uvs: boolean;
  8114. /** @hidden */
  8115. _needNormals: boolean;
  8116. /** @hidden */
  8117. _needUVs: boolean;
  8118. [id: string]: any;
  8119. /**
  8120. * Specifies if the material needs to be re-calculated
  8121. */
  8122. get isDirty(): boolean;
  8123. /**
  8124. * Marks the material to indicate that it has been re-calculated
  8125. */
  8126. markAsProcessed(): void;
  8127. /**
  8128. * Marks the material to indicate that it needs to be re-calculated
  8129. */
  8130. markAsUnprocessed(): void;
  8131. /**
  8132. * Marks the material to indicate all of its defines need to be re-calculated
  8133. */
  8134. markAllAsDirty(): void;
  8135. /**
  8136. * Marks the material to indicate that image processing needs to be re-calculated
  8137. */
  8138. markAsImageProcessingDirty(): void;
  8139. /**
  8140. * Marks the material to indicate the lights need to be re-calculated
  8141. * @param disposed Defines whether the light is dirty due to dispose or not
  8142. */
  8143. markAsLightDirty(disposed?: boolean): void;
  8144. /**
  8145. * Marks the attribute state as changed
  8146. */
  8147. markAsAttributesDirty(): void;
  8148. /**
  8149. * Marks the texture state as changed
  8150. */
  8151. markAsTexturesDirty(): void;
  8152. /**
  8153. * Marks the fresnel state as changed
  8154. */
  8155. markAsFresnelDirty(): void;
  8156. /**
  8157. * Marks the misc state as changed
  8158. */
  8159. markAsMiscDirty(): void;
  8160. /**
  8161. * Marks the prepass state as changed
  8162. */
  8163. markAsPrePassDirty(): void;
  8164. /**
  8165. * Rebuilds the material defines
  8166. */
  8167. rebuild(): void;
  8168. /**
  8169. * Specifies if two material defines are equal
  8170. * @param other - A material define instance to compare to
  8171. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8172. */
  8173. isEqual(other: MaterialDefines): boolean;
  8174. /**
  8175. * Clones this instance's defines to another instance
  8176. * @param other - material defines to clone values to
  8177. */
  8178. cloneTo(other: MaterialDefines): void;
  8179. /**
  8180. * Resets the material define values
  8181. */
  8182. reset(): void;
  8183. /**
  8184. * Converts the material define values to a string
  8185. * @returns - String of material define information
  8186. */
  8187. toString(): string;
  8188. }
  8189. }
  8190. declare module "babylonjs/Materials/colorCurves" {
  8191. import { Effect } from "babylonjs/Materials/effect";
  8192. /**
  8193. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8194. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8195. * 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;
  8196. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8197. */
  8198. export class ColorCurves {
  8199. private _dirty;
  8200. private _tempColor;
  8201. private _globalCurve;
  8202. private _highlightsCurve;
  8203. private _midtonesCurve;
  8204. private _shadowsCurve;
  8205. private _positiveCurve;
  8206. private _negativeCurve;
  8207. private _globalHue;
  8208. private _globalDensity;
  8209. private _globalSaturation;
  8210. private _globalExposure;
  8211. /**
  8212. * Gets the global Hue value.
  8213. * 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).
  8214. */
  8215. get globalHue(): number;
  8216. /**
  8217. * Sets the global Hue value.
  8218. * 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).
  8219. */
  8220. set globalHue(value: number);
  8221. /**
  8222. * Gets the global Density value.
  8223. * 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.
  8224. * Values less than zero provide a filter of opposite hue.
  8225. */
  8226. get globalDensity(): number;
  8227. /**
  8228. * Sets the global Density value.
  8229. * 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.
  8230. * Values less than zero provide a filter of opposite hue.
  8231. */
  8232. set globalDensity(value: number);
  8233. /**
  8234. * Gets the global Saturation value.
  8235. * 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.
  8236. */
  8237. get globalSaturation(): number;
  8238. /**
  8239. * Sets the global Saturation value.
  8240. * 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.
  8241. */
  8242. set globalSaturation(value: number);
  8243. /**
  8244. * Gets the global Exposure value.
  8245. * 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.
  8246. */
  8247. get globalExposure(): number;
  8248. /**
  8249. * Sets the global Exposure value.
  8250. * 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.
  8251. */
  8252. set globalExposure(value: number);
  8253. private _highlightsHue;
  8254. private _highlightsDensity;
  8255. private _highlightsSaturation;
  8256. private _highlightsExposure;
  8257. /**
  8258. * Gets the highlights Hue value.
  8259. * 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).
  8260. */
  8261. get highlightsHue(): number;
  8262. /**
  8263. * Sets the highlights Hue value.
  8264. * 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).
  8265. */
  8266. set highlightsHue(value: number);
  8267. /**
  8268. * Gets the highlights Density value.
  8269. * 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.
  8270. * Values less than zero provide a filter of opposite hue.
  8271. */
  8272. get highlightsDensity(): number;
  8273. /**
  8274. * Sets the highlights Density value.
  8275. * 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.
  8276. * Values less than zero provide a filter of opposite hue.
  8277. */
  8278. set highlightsDensity(value: number);
  8279. /**
  8280. * Gets the highlights Saturation value.
  8281. * 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.
  8282. */
  8283. get highlightsSaturation(): number;
  8284. /**
  8285. * Sets the highlights Saturation value.
  8286. * 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.
  8287. */
  8288. set highlightsSaturation(value: number);
  8289. /**
  8290. * Gets the highlights Exposure value.
  8291. * 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.
  8292. */
  8293. get highlightsExposure(): number;
  8294. /**
  8295. * Sets the highlights Exposure value.
  8296. * 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.
  8297. */
  8298. set highlightsExposure(value: number);
  8299. private _midtonesHue;
  8300. private _midtonesDensity;
  8301. private _midtonesSaturation;
  8302. private _midtonesExposure;
  8303. /**
  8304. * Gets the midtones Hue value.
  8305. * 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).
  8306. */
  8307. get midtonesHue(): number;
  8308. /**
  8309. * Sets the midtones Hue value.
  8310. * 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).
  8311. */
  8312. set midtonesHue(value: number);
  8313. /**
  8314. * Gets the midtones Density value.
  8315. * 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.
  8316. * Values less than zero provide a filter of opposite hue.
  8317. */
  8318. get midtonesDensity(): number;
  8319. /**
  8320. * Sets the midtones Density value.
  8321. * 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.
  8322. * Values less than zero provide a filter of opposite hue.
  8323. */
  8324. set midtonesDensity(value: number);
  8325. /**
  8326. * Gets the midtones Saturation value.
  8327. * 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.
  8328. */
  8329. get midtonesSaturation(): number;
  8330. /**
  8331. * Sets the midtones Saturation value.
  8332. * 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.
  8333. */
  8334. set midtonesSaturation(value: number);
  8335. /**
  8336. * Gets the midtones Exposure value.
  8337. * 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.
  8338. */
  8339. get midtonesExposure(): number;
  8340. /**
  8341. * Sets the midtones Exposure value.
  8342. * 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.
  8343. */
  8344. set midtonesExposure(value: number);
  8345. private _shadowsHue;
  8346. private _shadowsDensity;
  8347. private _shadowsSaturation;
  8348. private _shadowsExposure;
  8349. /**
  8350. * Gets the shadows Hue value.
  8351. * 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).
  8352. */
  8353. get shadowsHue(): number;
  8354. /**
  8355. * Sets the shadows Hue value.
  8356. * 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).
  8357. */
  8358. set shadowsHue(value: number);
  8359. /**
  8360. * Gets the shadows Density value.
  8361. * 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.
  8362. * Values less than zero provide a filter of opposite hue.
  8363. */
  8364. get shadowsDensity(): number;
  8365. /**
  8366. * Sets the shadows Density value.
  8367. * 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.
  8368. * Values less than zero provide a filter of opposite hue.
  8369. */
  8370. set shadowsDensity(value: number);
  8371. /**
  8372. * Gets the shadows Saturation value.
  8373. * 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.
  8374. */
  8375. get shadowsSaturation(): number;
  8376. /**
  8377. * Sets the shadows Saturation value.
  8378. * 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.
  8379. */
  8380. set shadowsSaturation(value: number);
  8381. /**
  8382. * Gets the shadows Exposure value.
  8383. * 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.
  8384. */
  8385. get shadowsExposure(): number;
  8386. /**
  8387. * Sets the shadows Exposure value.
  8388. * 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.
  8389. */
  8390. set shadowsExposure(value: number);
  8391. /**
  8392. * Returns the class name
  8393. * @returns The class name
  8394. */
  8395. getClassName(): string;
  8396. /**
  8397. * Binds the color curves to the shader.
  8398. * @param colorCurves The color curve to bind
  8399. * @param effect The effect to bind to
  8400. * @param positiveUniform The positive uniform shader parameter
  8401. * @param neutralUniform The neutral uniform shader parameter
  8402. * @param negativeUniform The negative uniform shader parameter
  8403. */
  8404. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8405. /**
  8406. * Prepare the list of uniforms associated with the ColorCurves effects.
  8407. * @param uniformsList The list of uniforms used in the effect
  8408. */
  8409. static PrepareUniforms(uniformsList: string[]): void;
  8410. /**
  8411. * Returns color grading data based on a hue, density, saturation and exposure value.
  8412. * @param filterHue The hue of the color filter.
  8413. * @param filterDensity The density of the color filter.
  8414. * @param saturation The saturation.
  8415. * @param exposure The exposure.
  8416. * @param result The result data container.
  8417. */
  8418. private getColorGradingDataToRef;
  8419. /**
  8420. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8421. * @param value The input slider value in range [-100,100].
  8422. * @returns Adjusted value.
  8423. */
  8424. private static applyColorGradingSliderNonlinear;
  8425. /**
  8426. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8427. * @param hue The hue (H) input.
  8428. * @param saturation The saturation (S) input.
  8429. * @param brightness The brightness (B) input.
  8430. * @result An RGBA color represented as Vector4.
  8431. */
  8432. private static fromHSBToRef;
  8433. /**
  8434. * Returns a value clamped between min and max
  8435. * @param value The value to clamp
  8436. * @param min The minimum of value
  8437. * @param max The maximum of value
  8438. * @returns The clamped value.
  8439. */
  8440. private static clamp;
  8441. /**
  8442. * Clones the current color curve instance.
  8443. * @return The cloned curves
  8444. */
  8445. clone(): ColorCurves;
  8446. /**
  8447. * Serializes the current color curve instance to a json representation.
  8448. * @return a JSON representation
  8449. */
  8450. serialize(): any;
  8451. /**
  8452. * Parses the color curve from a json representation.
  8453. * @param source the JSON source to parse
  8454. * @return The parsed curves
  8455. */
  8456. static Parse(source: any): ColorCurves;
  8457. }
  8458. }
  8459. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8460. import { Observable } from "babylonjs/Misc/observable";
  8461. import { Nullable } from "babylonjs/types";
  8462. import { Color4 } from "babylonjs/Maths/math.color";
  8463. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8464. import { Effect } from "babylonjs/Materials/effect";
  8465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8466. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8467. /**
  8468. * Interface to follow in your material defines to integrate easily the
  8469. * Image proccessing functions.
  8470. * @hidden
  8471. */
  8472. export interface IImageProcessingConfigurationDefines {
  8473. IMAGEPROCESSING: boolean;
  8474. VIGNETTE: boolean;
  8475. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8476. VIGNETTEBLENDMODEOPAQUE: boolean;
  8477. TONEMAPPING: boolean;
  8478. TONEMAPPING_ACES: boolean;
  8479. CONTRAST: boolean;
  8480. EXPOSURE: boolean;
  8481. COLORCURVES: boolean;
  8482. COLORGRADING: boolean;
  8483. COLORGRADING3D: boolean;
  8484. SAMPLER3DGREENDEPTH: boolean;
  8485. SAMPLER3DBGRMAP: boolean;
  8486. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8487. }
  8488. /**
  8489. * @hidden
  8490. */
  8491. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8492. IMAGEPROCESSING: boolean;
  8493. VIGNETTE: boolean;
  8494. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8495. VIGNETTEBLENDMODEOPAQUE: boolean;
  8496. TONEMAPPING: boolean;
  8497. TONEMAPPING_ACES: boolean;
  8498. CONTRAST: boolean;
  8499. COLORCURVES: boolean;
  8500. COLORGRADING: boolean;
  8501. COLORGRADING3D: boolean;
  8502. SAMPLER3DGREENDEPTH: boolean;
  8503. SAMPLER3DBGRMAP: boolean;
  8504. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8505. EXPOSURE: boolean;
  8506. constructor();
  8507. }
  8508. /**
  8509. * This groups together the common properties used for image processing either in direct forward pass
  8510. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8511. * or not.
  8512. */
  8513. export class ImageProcessingConfiguration {
  8514. /**
  8515. * Default tone mapping applied in BabylonJS.
  8516. */
  8517. static readonly TONEMAPPING_STANDARD: number;
  8518. /**
  8519. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8520. * to other engines rendering to increase portability.
  8521. */
  8522. static readonly TONEMAPPING_ACES: number;
  8523. /**
  8524. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8525. */
  8526. colorCurves: Nullable<ColorCurves>;
  8527. private _colorCurvesEnabled;
  8528. /**
  8529. * Gets wether the color curves effect is enabled.
  8530. */
  8531. get colorCurvesEnabled(): boolean;
  8532. /**
  8533. * Sets wether the color curves effect is enabled.
  8534. */
  8535. set colorCurvesEnabled(value: boolean);
  8536. private _colorGradingTexture;
  8537. /**
  8538. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8539. */
  8540. get colorGradingTexture(): Nullable<BaseTexture>;
  8541. /**
  8542. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8543. */
  8544. set colorGradingTexture(value: Nullable<BaseTexture>);
  8545. private _colorGradingEnabled;
  8546. /**
  8547. * Gets wether the color grading effect is enabled.
  8548. */
  8549. get colorGradingEnabled(): boolean;
  8550. /**
  8551. * Sets wether the color grading effect is enabled.
  8552. */
  8553. set colorGradingEnabled(value: boolean);
  8554. private _colorGradingWithGreenDepth;
  8555. /**
  8556. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8557. */
  8558. get colorGradingWithGreenDepth(): boolean;
  8559. /**
  8560. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8561. */
  8562. set colorGradingWithGreenDepth(value: boolean);
  8563. private _colorGradingBGR;
  8564. /**
  8565. * Gets wether the color grading texture contains BGR values.
  8566. */
  8567. get colorGradingBGR(): boolean;
  8568. /**
  8569. * Sets wether the color grading texture contains BGR values.
  8570. */
  8571. set colorGradingBGR(value: boolean);
  8572. /** @hidden */
  8573. _exposure: number;
  8574. /**
  8575. * Gets the Exposure used in the effect.
  8576. */
  8577. get exposure(): number;
  8578. /**
  8579. * Sets the Exposure used in the effect.
  8580. */
  8581. set exposure(value: number);
  8582. private _toneMappingEnabled;
  8583. /**
  8584. * Gets wether the tone mapping effect is enabled.
  8585. */
  8586. get toneMappingEnabled(): boolean;
  8587. /**
  8588. * Sets wether the tone mapping effect is enabled.
  8589. */
  8590. set toneMappingEnabled(value: boolean);
  8591. private _toneMappingType;
  8592. /**
  8593. * Gets the type of tone mapping effect.
  8594. */
  8595. get toneMappingType(): number;
  8596. /**
  8597. * Sets the type of tone mapping effect used in BabylonJS.
  8598. */
  8599. set toneMappingType(value: number);
  8600. protected _contrast: number;
  8601. /**
  8602. * Gets the contrast used in the effect.
  8603. */
  8604. get contrast(): number;
  8605. /**
  8606. * Sets the contrast used in the effect.
  8607. */
  8608. set contrast(value: number);
  8609. /**
  8610. * Vignette stretch size.
  8611. */
  8612. vignetteStretch: number;
  8613. /**
  8614. * Vignette centre X Offset.
  8615. */
  8616. vignetteCentreX: number;
  8617. /**
  8618. * Vignette centre Y Offset.
  8619. */
  8620. vignetteCentreY: number;
  8621. /**
  8622. * Vignette weight or intensity of the vignette effect.
  8623. */
  8624. vignetteWeight: number;
  8625. /**
  8626. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8627. * if vignetteEnabled is set to true.
  8628. */
  8629. vignetteColor: Color4;
  8630. /**
  8631. * Camera field of view used by the Vignette effect.
  8632. */
  8633. vignetteCameraFov: number;
  8634. private _vignetteBlendMode;
  8635. /**
  8636. * Gets the vignette blend mode allowing different kind of effect.
  8637. */
  8638. get vignetteBlendMode(): number;
  8639. /**
  8640. * Sets the vignette blend mode allowing different kind of effect.
  8641. */
  8642. set vignetteBlendMode(value: number);
  8643. private _vignetteEnabled;
  8644. /**
  8645. * Gets wether the vignette effect is enabled.
  8646. */
  8647. get vignetteEnabled(): boolean;
  8648. /**
  8649. * Sets wether the vignette effect is enabled.
  8650. */
  8651. set vignetteEnabled(value: boolean);
  8652. private _applyByPostProcess;
  8653. /**
  8654. * Gets wether the image processing is applied through a post process or not.
  8655. */
  8656. get applyByPostProcess(): boolean;
  8657. /**
  8658. * Sets wether the image processing is applied through a post process or not.
  8659. */
  8660. set applyByPostProcess(value: boolean);
  8661. private _isEnabled;
  8662. /**
  8663. * Gets wether the image processing is enabled or not.
  8664. */
  8665. get isEnabled(): boolean;
  8666. /**
  8667. * Sets wether the image processing is enabled or not.
  8668. */
  8669. set isEnabled(value: boolean);
  8670. /**
  8671. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8672. */
  8673. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8674. /**
  8675. * Method called each time the image processing information changes requires to recompile the effect.
  8676. */
  8677. protected _updateParameters(): void;
  8678. /**
  8679. * Gets the current class name.
  8680. * @return "ImageProcessingConfiguration"
  8681. */
  8682. getClassName(): string;
  8683. /**
  8684. * Prepare the list of uniforms associated with the Image Processing effects.
  8685. * @param uniforms The list of uniforms used in the effect
  8686. * @param defines the list of defines currently in use
  8687. */
  8688. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8689. /**
  8690. * Prepare the list of samplers associated with the Image Processing effects.
  8691. * @param samplersList The list of uniforms used in the effect
  8692. * @param defines the list of defines currently in use
  8693. */
  8694. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8695. /**
  8696. * Prepare the list of defines associated to the shader.
  8697. * @param defines the list of defines to complete
  8698. * @param forPostProcess Define if we are currently in post process mode or not
  8699. */
  8700. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8701. /**
  8702. * Returns true if all the image processing information are ready.
  8703. * @returns True if ready, otherwise, false
  8704. */
  8705. isReady(): boolean;
  8706. /**
  8707. * Binds the image processing to the shader.
  8708. * @param effect The effect to bind to
  8709. * @param overrideAspectRatio Override the aspect ratio of the effect
  8710. */
  8711. bind(effect: Effect, overrideAspectRatio?: number): void;
  8712. /**
  8713. * Clones the current image processing instance.
  8714. * @return The cloned image processing
  8715. */
  8716. clone(): ImageProcessingConfiguration;
  8717. /**
  8718. * Serializes the current image processing instance to a json representation.
  8719. * @return a JSON representation
  8720. */
  8721. serialize(): any;
  8722. /**
  8723. * Parses the image processing from a json representation.
  8724. * @param source the JSON source to parse
  8725. * @return The parsed image processing
  8726. */
  8727. static Parse(source: any): ImageProcessingConfiguration;
  8728. private static _VIGNETTEMODE_MULTIPLY;
  8729. private static _VIGNETTEMODE_OPAQUE;
  8730. /**
  8731. * Used to apply the vignette as a mix with the pixel color.
  8732. */
  8733. static get VIGNETTEMODE_MULTIPLY(): number;
  8734. /**
  8735. * Used to apply the vignette as a replacement of the pixel color.
  8736. */
  8737. static get VIGNETTEMODE_OPAQUE(): number;
  8738. }
  8739. }
  8740. declare module "babylonjs/Shaders/postprocess.vertex" {
  8741. /** @hidden */
  8742. export var postprocessVertexShader: {
  8743. name: string;
  8744. shader: string;
  8745. };
  8746. }
  8747. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8748. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8749. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8750. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8751. /**
  8752. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8753. */
  8754. export type RenderTargetTextureSize = number | {
  8755. width: number;
  8756. height: number;
  8757. layers?: number;
  8758. };
  8759. module "babylonjs/Engines/thinEngine" {
  8760. interface ThinEngine {
  8761. /**
  8762. * Creates a new render target texture
  8763. * @param size defines the size of the texture
  8764. * @param options defines the options used to create the texture
  8765. * @returns a new render target texture stored in an InternalTexture
  8766. */
  8767. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8768. /**
  8769. * Creates a depth stencil texture.
  8770. * This is only available in WebGL 2 or with the depth texture extension available.
  8771. * @param size The size of face edge in the texture.
  8772. * @param options The options defining the texture.
  8773. * @returns The texture
  8774. */
  8775. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8776. /** @hidden */
  8777. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8778. }
  8779. }
  8780. }
  8781. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8782. /**
  8783. * Defines the kind of connection point for node based material
  8784. */
  8785. export enum NodeMaterialBlockConnectionPointTypes {
  8786. /** Float */
  8787. Float = 1,
  8788. /** Int */
  8789. Int = 2,
  8790. /** Vector2 */
  8791. Vector2 = 4,
  8792. /** Vector3 */
  8793. Vector3 = 8,
  8794. /** Vector4 */
  8795. Vector4 = 16,
  8796. /** Color3 */
  8797. Color3 = 32,
  8798. /** Color4 */
  8799. Color4 = 64,
  8800. /** Matrix */
  8801. Matrix = 128,
  8802. /** Custom object */
  8803. Object = 256,
  8804. /** Detect type based on connection */
  8805. AutoDetect = 1024,
  8806. /** Output type that will be defined by input type */
  8807. BasedOnInput = 2048
  8808. }
  8809. }
  8810. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8811. /**
  8812. * Enum used to define the target of a block
  8813. */
  8814. export enum NodeMaterialBlockTargets {
  8815. /** Vertex shader */
  8816. Vertex = 1,
  8817. /** Fragment shader */
  8818. Fragment = 2,
  8819. /** Neutral */
  8820. Neutral = 4,
  8821. /** Vertex and Fragment */
  8822. VertexAndFragment = 3
  8823. }
  8824. }
  8825. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8826. /**
  8827. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8828. */
  8829. export enum NodeMaterialBlockConnectionPointMode {
  8830. /** Value is an uniform */
  8831. Uniform = 0,
  8832. /** Value is a mesh attribute */
  8833. Attribute = 1,
  8834. /** Value is a varying between vertex and fragment shaders */
  8835. Varying = 2,
  8836. /** Mode is undefined */
  8837. Undefined = 3
  8838. }
  8839. }
  8840. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8841. /**
  8842. * Enum used to define system values e.g. values automatically provided by the system
  8843. */
  8844. export enum NodeMaterialSystemValues {
  8845. /** World */
  8846. World = 1,
  8847. /** View */
  8848. View = 2,
  8849. /** Projection */
  8850. Projection = 3,
  8851. /** ViewProjection */
  8852. ViewProjection = 4,
  8853. /** WorldView */
  8854. WorldView = 5,
  8855. /** WorldViewProjection */
  8856. WorldViewProjection = 6,
  8857. /** CameraPosition */
  8858. CameraPosition = 7,
  8859. /** Fog Color */
  8860. FogColor = 8,
  8861. /** Delta time */
  8862. DeltaTime = 9
  8863. }
  8864. }
  8865. declare module "babylonjs/Maths/math.axis" {
  8866. import { Vector3 } from "babylonjs/Maths/math.vector";
  8867. /** Defines supported spaces */
  8868. export enum Space {
  8869. /** Local (object) space */
  8870. LOCAL = 0,
  8871. /** World space */
  8872. WORLD = 1,
  8873. /** Bone space */
  8874. BONE = 2
  8875. }
  8876. /** Defines the 3 main axes */
  8877. export class Axis {
  8878. /** X axis */
  8879. static X: Vector3;
  8880. /** Y axis */
  8881. static Y: Vector3;
  8882. /** Z axis */
  8883. static Z: Vector3;
  8884. }
  8885. }
  8886. declare module "babylonjs/Maths/math.frustum" {
  8887. import { Matrix } from "babylonjs/Maths/math.vector";
  8888. import { DeepImmutable } from "babylonjs/types";
  8889. import { Plane } from "babylonjs/Maths/math.plane";
  8890. /**
  8891. * Represents a camera frustum
  8892. */
  8893. export class Frustum {
  8894. /**
  8895. * Gets the planes representing the frustum
  8896. * @param transform matrix to be applied to the returned planes
  8897. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8898. */
  8899. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8900. /**
  8901. * Gets the near frustum plane transformed by the transform matrix
  8902. * @param transform transformation matrix to be applied to the resulting frustum plane
  8903. * @param frustumPlane the resuling frustum plane
  8904. */
  8905. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8906. /**
  8907. * Gets the far frustum plane transformed by the transform matrix
  8908. * @param transform transformation matrix to be applied to the resulting frustum plane
  8909. * @param frustumPlane the resuling frustum plane
  8910. */
  8911. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8912. /**
  8913. * Gets the left frustum plane transformed by the transform matrix
  8914. * @param transform transformation matrix to be applied to the resulting frustum plane
  8915. * @param frustumPlane the resuling frustum plane
  8916. */
  8917. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8918. /**
  8919. * Gets the right frustum plane transformed by the transform matrix
  8920. * @param transform transformation matrix to be applied to the resulting frustum plane
  8921. * @param frustumPlane the resuling frustum plane
  8922. */
  8923. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8924. /**
  8925. * Gets the top frustum plane transformed by the transform matrix
  8926. * @param transform transformation matrix to be applied to the resulting frustum plane
  8927. * @param frustumPlane the resuling frustum plane
  8928. */
  8929. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8930. /**
  8931. * Gets the bottom frustum plane transformed by the transform matrix
  8932. * @param transform transformation matrix to be applied to the resulting frustum plane
  8933. * @param frustumPlane the resuling frustum plane
  8934. */
  8935. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8936. /**
  8937. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8938. * @param transform transformation matrix to be applied to the resulting frustum planes
  8939. * @param frustumPlanes the resuling frustum planes
  8940. */
  8941. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8942. }
  8943. }
  8944. declare module "babylonjs/Maths/math.size" {
  8945. /**
  8946. * Interface for the size containing width and height
  8947. */
  8948. export interface ISize {
  8949. /**
  8950. * Width
  8951. */
  8952. width: number;
  8953. /**
  8954. * Heighht
  8955. */
  8956. height: number;
  8957. }
  8958. /**
  8959. * Size containing widht and height
  8960. */
  8961. export class Size implements ISize {
  8962. /**
  8963. * Width
  8964. */
  8965. width: number;
  8966. /**
  8967. * Height
  8968. */
  8969. height: number;
  8970. /**
  8971. * Creates a Size object from the given width and height (floats).
  8972. * @param width width of the new size
  8973. * @param height height of the new size
  8974. */
  8975. constructor(width: number, height: number);
  8976. /**
  8977. * Returns a string with the Size width and height
  8978. * @returns a string with the Size width and height
  8979. */
  8980. toString(): string;
  8981. /**
  8982. * "Size"
  8983. * @returns the string "Size"
  8984. */
  8985. getClassName(): string;
  8986. /**
  8987. * Returns the Size hash code.
  8988. * @returns a hash code for a unique width and height
  8989. */
  8990. getHashCode(): number;
  8991. /**
  8992. * Updates the current size from the given one.
  8993. * @param src the given size
  8994. */
  8995. copyFrom(src: Size): void;
  8996. /**
  8997. * Updates in place the current Size from the given floats.
  8998. * @param width width of the new size
  8999. * @param height height of the new size
  9000. * @returns the updated Size.
  9001. */
  9002. copyFromFloats(width: number, height: number): Size;
  9003. /**
  9004. * Updates in place the current Size from the given floats.
  9005. * @param width width to set
  9006. * @param height height to set
  9007. * @returns the updated Size.
  9008. */
  9009. set(width: number, height: number): Size;
  9010. /**
  9011. * Multiplies the width and height by numbers
  9012. * @param w factor to multiple the width by
  9013. * @param h factor to multiple the height by
  9014. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9015. */
  9016. multiplyByFloats(w: number, h: number): Size;
  9017. /**
  9018. * Clones the size
  9019. * @returns a new Size copied from the given one.
  9020. */
  9021. clone(): Size;
  9022. /**
  9023. * True if the current Size and the given one width and height are strictly equal.
  9024. * @param other the other size to compare against
  9025. * @returns True if the current Size and the given one width and height are strictly equal.
  9026. */
  9027. equals(other: Size): boolean;
  9028. /**
  9029. * The surface of the Size : width * height (float).
  9030. */
  9031. get surface(): number;
  9032. /**
  9033. * Create a new size of zero
  9034. * @returns a new Size set to (0.0, 0.0)
  9035. */
  9036. static Zero(): Size;
  9037. /**
  9038. * Sums the width and height of two sizes
  9039. * @param otherSize size to add to this size
  9040. * @returns a new Size set as the addition result of the current Size and the given one.
  9041. */
  9042. add(otherSize: Size): Size;
  9043. /**
  9044. * Subtracts the width and height of two
  9045. * @param otherSize size to subtract to this size
  9046. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9047. */
  9048. subtract(otherSize: Size): Size;
  9049. /**
  9050. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9051. * @param start starting size to lerp between
  9052. * @param end end size to lerp between
  9053. * @param amount amount to lerp between the start and end values
  9054. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9055. */
  9056. static Lerp(start: Size, end: Size, amount: number): Size;
  9057. }
  9058. }
  9059. declare module "babylonjs/Maths/math.vertexFormat" {
  9060. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9061. /**
  9062. * Contains position and normal vectors for a vertex
  9063. */
  9064. export class PositionNormalVertex {
  9065. /** the position of the vertex (defaut: 0,0,0) */
  9066. position: Vector3;
  9067. /** the normal of the vertex (defaut: 0,1,0) */
  9068. normal: Vector3;
  9069. /**
  9070. * Creates a PositionNormalVertex
  9071. * @param position the position of the vertex (defaut: 0,0,0)
  9072. * @param normal the normal of the vertex (defaut: 0,1,0)
  9073. */
  9074. constructor(
  9075. /** the position of the vertex (defaut: 0,0,0) */
  9076. position?: Vector3,
  9077. /** the normal of the vertex (defaut: 0,1,0) */
  9078. normal?: Vector3);
  9079. /**
  9080. * Clones the PositionNormalVertex
  9081. * @returns the cloned PositionNormalVertex
  9082. */
  9083. clone(): PositionNormalVertex;
  9084. }
  9085. /**
  9086. * Contains position, normal and uv vectors for a vertex
  9087. */
  9088. export class PositionNormalTextureVertex {
  9089. /** the position of the vertex (defaut: 0,0,0) */
  9090. position: Vector3;
  9091. /** the normal of the vertex (defaut: 0,1,0) */
  9092. normal: Vector3;
  9093. /** the uv of the vertex (default: 0,0) */
  9094. uv: Vector2;
  9095. /**
  9096. * Creates a PositionNormalTextureVertex
  9097. * @param position the position of the vertex (defaut: 0,0,0)
  9098. * @param normal the normal of the vertex (defaut: 0,1,0)
  9099. * @param uv the uv of the vertex (default: 0,0)
  9100. */
  9101. constructor(
  9102. /** the position of the vertex (defaut: 0,0,0) */
  9103. position?: Vector3,
  9104. /** the normal of the vertex (defaut: 0,1,0) */
  9105. normal?: Vector3,
  9106. /** the uv of the vertex (default: 0,0) */
  9107. uv?: Vector2);
  9108. /**
  9109. * Clones the PositionNormalTextureVertex
  9110. * @returns the cloned PositionNormalTextureVertex
  9111. */
  9112. clone(): PositionNormalTextureVertex;
  9113. }
  9114. }
  9115. declare module "babylonjs/Maths/math" {
  9116. export * from "babylonjs/Maths/math.axis";
  9117. export * from "babylonjs/Maths/math.color";
  9118. export * from "babylonjs/Maths/math.constants";
  9119. export * from "babylonjs/Maths/math.frustum";
  9120. export * from "babylonjs/Maths/math.path";
  9121. export * from "babylonjs/Maths/math.plane";
  9122. export * from "babylonjs/Maths/math.size";
  9123. export * from "babylonjs/Maths/math.vector";
  9124. export * from "babylonjs/Maths/math.vertexFormat";
  9125. export * from "babylonjs/Maths/math.viewport";
  9126. }
  9127. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9128. /**
  9129. * Enum defining the type of animations supported by InputBlock
  9130. */
  9131. export enum AnimatedInputBlockTypes {
  9132. /** No animation */
  9133. None = 0,
  9134. /** Time based animation. Will only work for floats */
  9135. Time = 1
  9136. }
  9137. }
  9138. declare module "babylonjs/Lights/shadowLight" {
  9139. import { Camera } from "babylonjs/Cameras/camera";
  9140. import { Scene } from "babylonjs/scene";
  9141. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9143. import { Light } from "babylonjs/Lights/light";
  9144. /**
  9145. * Interface describing all the common properties and methods a shadow light needs to implement.
  9146. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9147. * as well as binding the different shadow properties to the effects.
  9148. */
  9149. export interface IShadowLight extends Light {
  9150. /**
  9151. * The light id in the scene (used in scene.findLighById for instance)
  9152. */
  9153. id: string;
  9154. /**
  9155. * The position the shdow will be casted from.
  9156. */
  9157. position: Vector3;
  9158. /**
  9159. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9160. */
  9161. direction: Vector3;
  9162. /**
  9163. * The transformed position. Position of the light in world space taking parenting in account.
  9164. */
  9165. transformedPosition: Vector3;
  9166. /**
  9167. * The transformed direction. Direction of the light in world space taking parenting in account.
  9168. */
  9169. transformedDirection: Vector3;
  9170. /**
  9171. * The friendly name of the light in the scene.
  9172. */
  9173. name: string;
  9174. /**
  9175. * Defines the shadow projection clipping minimum z value.
  9176. */
  9177. shadowMinZ: number;
  9178. /**
  9179. * Defines the shadow projection clipping maximum z value.
  9180. */
  9181. shadowMaxZ: number;
  9182. /**
  9183. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9184. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9185. */
  9186. computeTransformedInformation(): boolean;
  9187. /**
  9188. * Gets the scene the light belongs to.
  9189. * @returns The scene
  9190. */
  9191. getScene(): Scene;
  9192. /**
  9193. * Callback defining a custom Projection Matrix Builder.
  9194. * This can be used to override the default projection matrix computation.
  9195. */
  9196. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9197. /**
  9198. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9199. * @param matrix The materix to updated with the projection information
  9200. * @param viewMatrix The transform matrix of the light
  9201. * @param renderList The list of mesh to render in the map
  9202. * @returns The current light
  9203. */
  9204. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9205. /**
  9206. * Gets the current depth scale used in ESM.
  9207. * @returns The scale
  9208. */
  9209. getDepthScale(): number;
  9210. /**
  9211. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9212. * @returns true if a cube texture needs to be use
  9213. */
  9214. needCube(): boolean;
  9215. /**
  9216. * Detects if the projection matrix requires to be recomputed this frame.
  9217. * @returns true if it requires to be recomputed otherwise, false.
  9218. */
  9219. needProjectionMatrixCompute(): boolean;
  9220. /**
  9221. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9222. */
  9223. forceProjectionMatrixCompute(): void;
  9224. /**
  9225. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9226. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9227. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9228. */
  9229. getShadowDirection(faceIndex?: number): Vector3;
  9230. /**
  9231. * Gets the minZ used for shadow according to both the scene and the light.
  9232. * @param activeCamera The camera we are returning the min for
  9233. * @returns the depth min z
  9234. */
  9235. getDepthMinZ(activeCamera: Camera): number;
  9236. /**
  9237. * Gets the maxZ used for shadow according to both the scene and the light.
  9238. * @param activeCamera The camera we are returning the max for
  9239. * @returns the depth max z
  9240. */
  9241. getDepthMaxZ(activeCamera: Camera): number;
  9242. }
  9243. /**
  9244. * Base implementation IShadowLight
  9245. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9246. */
  9247. export abstract class ShadowLight extends Light implements IShadowLight {
  9248. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9249. protected _position: Vector3;
  9250. protected _setPosition(value: Vector3): void;
  9251. /**
  9252. * Sets the position the shadow will be casted from. Also use as the light position for both
  9253. * point and spot lights.
  9254. */
  9255. get position(): Vector3;
  9256. /**
  9257. * Sets the position the shadow will be casted from. Also use as the light position for both
  9258. * point and spot lights.
  9259. */
  9260. set position(value: Vector3);
  9261. protected _direction: Vector3;
  9262. protected _setDirection(value: Vector3): void;
  9263. /**
  9264. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9265. * Also use as the light direction on spot and directional lights.
  9266. */
  9267. get direction(): Vector3;
  9268. /**
  9269. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9270. * Also use as the light direction on spot and directional lights.
  9271. */
  9272. set direction(value: Vector3);
  9273. protected _shadowMinZ: number;
  9274. /**
  9275. * Gets the shadow projection clipping minimum z value.
  9276. */
  9277. get shadowMinZ(): number;
  9278. /**
  9279. * Sets the shadow projection clipping minimum z value.
  9280. */
  9281. set shadowMinZ(value: number);
  9282. protected _shadowMaxZ: number;
  9283. /**
  9284. * Sets the shadow projection clipping maximum z value.
  9285. */
  9286. get shadowMaxZ(): number;
  9287. /**
  9288. * Gets the shadow projection clipping maximum z value.
  9289. */
  9290. set shadowMaxZ(value: number);
  9291. /**
  9292. * Callback defining a custom Projection Matrix Builder.
  9293. * This can be used to override the default projection matrix computation.
  9294. */
  9295. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9296. /**
  9297. * The transformed position. Position of the light in world space taking parenting in account.
  9298. */
  9299. transformedPosition: Vector3;
  9300. /**
  9301. * The transformed direction. Direction of the light in world space taking parenting in account.
  9302. */
  9303. transformedDirection: Vector3;
  9304. private _needProjectionMatrixCompute;
  9305. /**
  9306. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9307. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9308. */
  9309. computeTransformedInformation(): boolean;
  9310. /**
  9311. * Return the depth scale used for the shadow map.
  9312. * @returns the depth scale.
  9313. */
  9314. getDepthScale(): number;
  9315. /**
  9316. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9317. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9318. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9319. */
  9320. getShadowDirection(faceIndex?: number): Vector3;
  9321. /**
  9322. * Returns the ShadowLight absolute position in the World.
  9323. * @returns the position vector in world space
  9324. */
  9325. getAbsolutePosition(): Vector3;
  9326. /**
  9327. * Sets the ShadowLight direction toward the passed target.
  9328. * @param target The point to target in local space
  9329. * @returns the updated ShadowLight direction
  9330. */
  9331. setDirectionToTarget(target: Vector3): Vector3;
  9332. /**
  9333. * Returns the light rotation in euler definition.
  9334. * @returns the x y z rotation in local space.
  9335. */
  9336. getRotation(): Vector3;
  9337. /**
  9338. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9339. * @returns true if a cube texture needs to be use
  9340. */
  9341. needCube(): boolean;
  9342. /**
  9343. * Detects if the projection matrix requires to be recomputed this frame.
  9344. * @returns true if it requires to be recomputed otherwise, false.
  9345. */
  9346. needProjectionMatrixCompute(): boolean;
  9347. /**
  9348. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9349. */
  9350. forceProjectionMatrixCompute(): void;
  9351. /** @hidden */
  9352. _initCache(): void;
  9353. /** @hidden */
  9354. _isSynchronized(): boolean;
  9355. /**
  9356. * Computes the world matrix of the node
  9357. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9358. * @returns the world matrix
  9359. */
  9360. computeWorldMatrix(force?: boolean): Matrix;
  9361. /**
  9362. * Gets the minZ used for shadow according to both the scene and the light.
  9363. * @param activeCamera The camera we are returning the min for
  9364. * @returns the depth min z
  9365. */
  9366. getDepthMinZ(activeCamera: Camera): number;
  9367. /**
  9368. * Gets the maxZ used for shadow according to both the scene and the light.
  9369. * @param activeCamera The camera we are returning the max for
  9370. * @returns the depth max z
  9371. */
  9372. getDepthMaxZ(activeCamera: Camera): number;
  9373. /**
  9374. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9375. * @param matrix The materix to updated with the projection information
  9376. * @param viewMatrix The transform matrix of the light
  9377. * @param renderList The list of mesh to render in the map
  9378. * @returns The current light
  9379. */
  9380. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9381. }
  9382. }
  9383. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9384. /** @hidden */
  9385. export var packingFunctions: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9391. /** @hidden */
  9392. export var bayerDitherFunctions: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9398. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9399. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9400. /** @hidden */
  9401. export var shadowMapFragmentDeclaration: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9407. /** @hidden */
  9408. export var clipPlaneFragmentDeclaration: {
  9409. name: string;
  9410. shader: string;
  9411. };
  9412. }
  9413. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9414. /** @hidden */
  9415. export var clipPlaneFragment: {
  9416. name: string;
  9417. shader: string;
  9418. };
  9419. }
  9420. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9421. /** @hidden */
  9422. export var shadowMapFragment: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9428. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9429. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9430. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9431. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9432. /** @hidden */
  9433. export var shadowMapPixelShader: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9439. /** @hidden */
  9440. export var bonesDeclaration: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9446. /** @hidden */
  9447. export var morphTargetsVertexGlobalDeclaration: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9453. /** @hidden */
  9454. export var morphTargetsVertexDeclaration: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9460. /** @hidden */
  9461. export var instancesDeclaration: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9467. /** @hidden */
  9468. export var helperFunctions: {
  9469. name: string;
  9470. shader: string;
  9471. };
  9472. }
  9473. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9474. /** @hidden */
  9475. export var shadowMapVertexDeclaration: {
  9476. name: string;
  9477. shader: string;
  9478. };
  9479. }
  9480. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9481. /** @hidden */
  9482. export var clipPlaneVertexDeclaration: {
  9483. name: string;
  9484. shader: string;
  9485. };
  9486. }
  9487. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9488. /** @hidden */
  9489. export var morphTargetsVertex: {
  9490. name: string;
  9491. shader: string;
  9492. };
  9493. }
  9494. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9495. /** @hidden */
  9496. export var instancesVertex: {
  9497. name: string;
  9498. shader: string;
  9499. };
  9500. }
  9501. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9502. /** @hidden */
  9503. export var bonesVertex: {
  9504. name: string;
  9505. shader: string;
  9506. };
  9507. }
  9508. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9509. /** @hidden */
  9510. export var shadowMapVertexNormalBias: {
  9511. name: string;
  9512. shader: string;
  9513. };
  9514. }
  9515. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9516. /** @hidden */
  9517. export var shadowMapVertexMetric: {
  9518. name: string;
  9519. shader: string;
  9520. };
  9521. }
  9522. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9523. /** @hidden */
  9524. export var clipPlaneVertex: {
  9525. name: string;
  9526. shader: string;
  9527. };
  9528. }
  9529. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9530. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9533. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9534. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9535. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9536. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9537. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9538. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9539. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9540. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9541. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9542. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9543. /** @hidden */
  9544. export var shadowMapVertexShader: {
  9545. name: string;
  9546. shader: string;
  9547. };
  9548. }
  9549. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9550. /** @hidden */
  9551. export var depthBoxBlurPixelShader: {
  9552. name: string;
  9553. shader: string;
  9554. };
  9555. }
  9556. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9557. /** @hidden */
  9558. export var shadowMapFragmentSoftTransparentShadow: {
  9559. name: string;
  9560. shader: string;
  9561. };
  9562. }
  9563. declare module "babylonjs/Materials/effectFallbacks" {
  9564. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9565. import { Effect } from "babylonjs/Materials/effect";
  9566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9567. /**
  9568. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9569. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9570. */
  9571. export class EffectFallbacks implements IEffectFallbacks {
  9572. private _defines;
  9573. private _currentRank;
  9574. private _maxRank;
  9575. private _mesh;
  9576. /**
  9577. * Removes the fallback from the bound mesh.
  9578. */
  9579. unBindMesh(): void;
  9580. /**
  9581. * Adds a fallback on the specified property.
  9582. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9583. * @param define The name of the define in the shader
  9584. */
  9585. addFallback(rank: number, define: string): void;
  9586. /**
  9587. * Sets the mesh to use CPU skinning when needing to fallback.
  9588. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9589. * @param mesh The mesh to use the fallbacks.
  9590. */
  9591. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9592. /**
  9593. * Checks to see if more fallbacks are still availible.
  9594. */
  9595. get hasMoreFallbacks(): boolean;
  9596. /**
  9597. * Removes the defines that should be removed when falling back.
  9598. * @param currentDefines defines the current define statements for the shader.
  9599. * @param effect defines the current effect we try to compile
  9600. * @returns The resulting defines with defines of the current rank removed.
  9601. */
  9602. reduce(currentDefines: string, effect: Effect): string;
  9603. }
  9604. }
  9605. declare module "babylonjs/Actions/action" {
  9606. import { Observable } from "babylonjs/Misc/observable";
  9607. import { Condition } from "babylonjs/Actions/condition";
  9608. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9609. import { Nullable } from "babylonjs/types";
  9610. import { Scene } from "babylonjs/scene";
  9611. import { ActionManager } from "babylonjs/Actions/actionManager";
  9612. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9613. import { Node } from "babylonjs/node";
  9614. /**
  9615. * Interface used to define Action
  9616. */
  9617. export interface IAction {
  9618. /**
  9619. * Trigger for the action
  9620. */
  9621. trigger: number;
  9622. /** Options of the trigger */
  9623. triggerOptions: any;
  9624. /**
  9625. * Gets the trigger parameters
  9626. * @returns the trigger parameters
  9627. */
  9628. getTriggerParameter(): any;
  9629. /**
  9630. * Internal only - executes current action event
  9631. * @hidden
  9632. */
  9633. _executeCurrent(evt?: ActionEvent): void;
  9634. /**
  9635. * Serialize placeholder for child classes
  9636. * @param parent of child
  9637. * @returns the serialized object
  9638. */
  9639. serialize(parent: any): any;
  9640. /**
  9641. * Internal only
  9642. * @hidden
  9643. */
  9644. _prepare(): void;
  9645. /**
  9646. * Internal only - manager for action
  9647. * @hidden
  9648. */
  9649. _actionManager: Nullable<AbstractActionManager>;
  9650. /**
  9651. * Adds action to chain of actions, may be a DoNothingAction
  9652. * @param action defines the next action to execute
  9653. * @returns The action passed in
  9654. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9655. */
  9656. then(action: IAction): IAction;
  9657. }
  9658. /**
  9659. * The action to be carried out following a trigger
  9660. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9661. */
  9662. export class Action implements IAction {
  9663. /** the trigger, with or without parameters, for the action */
  9664. triggerOptions: any;
  9665. /**
  9666. * Trigger for the action
  9667. */
  9668. trigger: number;
  9669. /**
  9670. * Internal only - manager for action
  9671. * @hidden
  9672. */
  9673. _actionManager: ActionManager;
  9674. private _nextActiveAction;
  9675. private _child;
  9676. private _condition?;
  9677. private _triggerParameter;
  9678. /**
  9679. * An event triggered prior to action being executed.
  9680. */
  9681. onBeforeExecuteObservable: Observable<Action>;
  9682. /**
  9683. * Creates a new Action
  9684. * @param triggerOptions the trigger, with or without parameters, for the action
  9685. * @param condition an optional determinant of action
  9686. */
  9687. constructor(
  9688. /** the trigger, with or without parameters, for the action */
  9689. triggerOptions: any, condition?: Condition);
  9690. /**
  9691. * Internal only
  9692. * @hidden
  9693. */
  9694. _prepare(): void;
  9695. /**
  9696. * Gets the trigger parameters
  9697. * @returns the trigger parameters
  9698. */
  9699. getTriggerParameter(): any;
  9700. /**
  9701. * Internal only - executes current action event
  9702. * @hidden
  9703. */
  9704. _executeCurrent(evt?: ActionEvent): void;
  9705. /**
  9706. * Execute placeholder for child classes
  9707. * @param evt optional action event
  9708. */
  9709. execute(evt?: ActionEvent): void;
  9710. /**
  9711. * Skips to next active action
  9712. */
  9713. skipToNextActiveAction(): void;
  9714. /**
  9715. * Adds action to chain of actions, may be a DoNothingAction
  9716. * @param action defines the next action to execute
  9717. * @returns The action passed in
  9718. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9719. */
  9720. then(action: Action): Action;
  9721. /**
  9722. * Internal only
  9723. * @hidden
  9724. */
  9725. _getProperty(propertyPath: string): string;
  9726. /**
  9727. * Internal only
  9728. * @hidden
  9729. */
  9730. _getEffectiveTarget(target: any, propertyPath: string): any;
  9731. /**
  9732. * Serialize placeholder for child classes
  9733. * @param parent of child
  9734. * @returns the serialized object
  9735. */
  9736. serialize(parent: any): any;
  9737. /**
  9738. * Internal only called by serialize
  9739. * @hidden
  9740. */
  9741. protected _serialize(serializedAction: any, parent?: any): any;
  9742. /**
  9743. * Internal only
  9744. * @hidden
  9745. */
  9746. static _SerializeValueAsString: (value: any) => string;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. static _GetTargetProperty: (target: Scene | Node) => {
  9752. name: string;
  9753. targetType: string;
  9754. value: string;
  9755. };
  9756. }
  9757. }
  9758. declare module "babylonjs/Actions/condition" {
  9759. import { ActionManager } from "babylonjs/Actions/actionManager";
  9760. /**
  9761. * A Condition applied to an Action
  9762. */
  9763. export class Condition {
  9764. /**
  9765. * Internal only - manager for action
  9766. * @hidden
  9767. */
  9768. _actionManager: ActionManager;
  9769. /**
  9770. * Internal only
  9771. * @hidden
  9772. */
  9773. _evaluationId: number;
  9774. /**
  9775. * Internal only
  9776. * @hidden
  9777. */
  9778. _currentResult: boolean;
  9779. /**
  9780. * Creates a new Condition
  9781. * @param actionManager the manager of the action the condition is applied to
  9782. */
  9783. constructor(actionManager: ActionManager);
  9784. /**
  9785. * Check if the current condition is valid
  9786. * @returns a boolean
  9787. */
  9788. isValid(): boolean;
  9789. /**
  9790. * Internal only
  9791. * @hidden
  9792. */
  9793. _getProperty(propertyPath: string): string;
  9794. /**
  9795. * Internal only
  9796. * @hidden
  9797. */
  9798. _getEffectiveTarget(target: any, propertyPath: string): any;
  9799. /**
  9800. * Serialize placeholder for child classes
  9801. * @returns the serialized object
  9802. */
  9803. serialize(): any;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. protected _serialize(serializedCondition: any): any;
  9809. }
  9810. /**
  9811. * Defines specific conditional operators as extensions of Condition
  9812. */
  9813. export class ValueCondition extends Condition {
  9814. /** path to specify the property of the target the conditional operator uses */
  9815. propertyPath: string;
  9816. /** the value compared by the conditional operator against the current value of the property */
  9817. value: any;
  9818. /** the conditional operator, default ValueCondition.IsEqual */
  9819. operator: number;
  9820. /**
  9821. * Internal only
  9822. * @hidden
  9823. */
  9824. private static _IsEqual;
  9825. /**
  9826. * Internal only
  9827. * @hidden
  9828. */
  9829. private static _IsDifferent;
  9830. /**
  9831. * Internal only
  9832. * @hidden
  9833. */
  9834. private static _IsGreater;
  9835. /**
  9836. * Internal only
  9837. * @hidden
  9838. */
  9839. private static _IsLesser;
  9840. /**
  9841. * returns the number for IsEqual
  9842. */
  9843. static get IsEqual(): number;
  9844. /**
  9845. * Returns the number for IsDifferent
  9846. */
  9847. static get IsDifferent(): number;
  9848. /**
  9849. * Returns the number for IsGreater
  9850. */
  9851. static get IsGreater(): number;
  9852. /**
  9853. * Returns the number for IsLesser
  9854. */
  9855. static get IsLesser(): number;
  9856. /**
  9857. * Internal only The action manager for the condition
  9858. * @hidden
  9859. */
  9860. _actionManager: ActionManager;
  9861. /**
  9862. * Internal only
  9863. * @hidden
  9864. */
  9865. private _target;
  9866. /**
  9867. * Internal only
  9868. * @hidden
  9869. */
  9870. private _effectiveTarget;
  9871. /**
  9872. * Internal only
  9873. * @hidden
  9874. */
  9875. private _property;
  9876. /**
  9877. * Creates a new ValueCondition
  9878. * @param actionManager manager for the action the condition applies to
  9879. * @param target for the action
  9880. * @param propertyPath path to specify the property of the target the conditional operator uses
  9881. * @param value the value compared by the conditional operator against the current value of the property
  9882. * @param operator the conditional operator, default ValueCondition.IsEqual
  9883. */
  9884. constructor(actionManager: ActionManager, target: any,
  9885. /** path to specify the property of the target the conditional operator uses */
  9886. propertyPath: string,
  9887. /** the value compared by the conditional operator against the current value of the property */
  9888. value: any,
  9889. /** the conditional operator, default ValueCondition.IsEqual */
  9890. operator?: number);
  9891. /**
  9892. * Compares the given value with the property value for the specified conditional operator
  9893. * @returns the result of the comparison
  9894. */
  9895. isValid(): boolean;
  9896. /**
  9897. * Serialize the ValueCondition into a JSON compatible object
  9898. * @returns serialization object
  9899. */
  9900. serialize(): any;
  9901. /**
  9902. * Gets the name of the conditional operator for the ValueCondition
  9903. * @param operator the conditional operator
  9904. * @returns the name
  9905. */
  9906. static GetOperatorName(operator: number): string;
  9907. }
  9908. /**
  9909. * Defines a predicate condition as an extension of Condition
  9910. */
  9911. export class PredicateCondition extends Condition {
  9912. /** defines the predicate function used to validate the condition */
  9913. predicate: () => boolean;
  9914. /**
  9915. * Internal only - manager for action
  9916. * @hidden
  9917. */
  9918. _actionManager: ActionManager;
  9919. /**
  9920. * Creates a new PredicateCondition
  9921. * @param actionManager manager for the action the condition applies to
  9922. * @param predicate defines the predicate function used to validate the condition
  9923. */
  9924. constructor(actionManager: ActionManager,
  9925. /** defines the predicate function used to validate the condition */
  9926. predicate: () => boolean);
  9927. /**
  9928. * @returns the validity of the predicate condition
  9929. */
  9930. isValid(): boolean;
  9931. }
  9932. /**
  9933. * Defines a state condition as an extension of Condition
  9934. */
  9935. export class StateCondition extends Condition {
  9936. /** Value to compare with target state */
  9937. value: string;
  9938. /**
  9939. * Internal only - manager for action
  9940. * @hidden
  9941. */
  9942. _actionManager: ActionManager;
  9943. /**
  9944. * Internal only
  9945. * @hidden
  9946. */
  9947. private _target;
  9948. /**
  9949. * Creates a new StateCondition
  9950. * @param actionManager manager for the action the condition applies to
  9951. * @param target of the condition
  9952. * @param value to compare with target state
  9953. */
  9954. constructor(actionManager: ActionManager, target: any,
  9955. /** Value to compare with target state */
  9956. value: string);
  9957. /**
  9958. * Gets a boolean indicating if the current condition is met
  9959. * @returns the validity of the state
  9960. */
  9961. isValid(): boolean;
  9962. /**
  9963. * Serialize the StateCondition into a JSON compatible object
  9964. * @returns serialization object
  9965. */
  9966. serialize(): any;
  9967. }
  9968. }
  9969. declare module "babylonjs/Actions/directActions" {
  9970. import { Action } from "babylonjs/Actions/action";
  9971. import { Condition } from "babylonjs/Actions/condition";
  9972. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9973. /**
  9974. * This defines an action responsible to toggle a boolean once triggered.
  9975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9976. */
  9977. export class SwitchBooleanAction extends Action {
  9978. /**
  9979. * The path to the boolean property in the target object
  9980. */
  9981. propertyPath: string;
  9982. private _target;
  9983. private _effectiveTarget;
  9984. private _property;
  9985. /**
  9986. * Instantiate the action
  9987. * @param triggerOptions defines the trigger options
  9988. * @param target defines the object containing the boolean
  9989. * @param propertyPath defines the path to the boolean property in the target object
  9990. * @param condition defines the trigger related conditions
  9991. */
  9992. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9993. /** @hidden */
  9994. _prepare(): void;
  9995. /**
  9996. * Execute the action toggle the boolean value.
  9997. */
  9998. execute(): void;
  9999. /**
  10000. * Serializes the actions and its related information.
  10001. * @param parent defines the object to serialize in
  10002. * @returns the serialized object
  10003. */
  10004. serialize(parent: any): any;
  10005. }
  10006. /**
  10007. * This defines an action responsible to set a the state field of the target
  10008. * to a desired value once triggered.
  10009. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10010. */
  10011. export class SetStateAction extends Action {
  10012. /**
  10013. * The value to store in the state field.
  10014. */
  10015. value: string;
  10016. private _target;
  10017. /**
  10018. * Instantiate the action
  10019. * @param triggerOptions defines the trigger options
  10020. * @param target defines the object containing the state property
  10021. * @param value defines the value to store in the state field
  10022. * @param condition defines the trigger related conditions
  10023. */
  10024. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10025. /**
  10026. * Execute the action and store the value on the target state property.
  10027. */
  10028. execute(): void;
  10029. /**
  10030. * Serializes the actions and its related information.
  10031. * @param parent defines the object to serialize in
  10032. * @returns the serialized object
  10033. */
  10034. serialize(parent: any): any;
  10035. }
  10036. /**
  10037. * This defines an action responsible to set a property of the target
  10038. * to a desired value once triggered.
  10039. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10040. */
  10041. export class SetValueAction extends Action {
  10042. /**
  10043. * The path of the property to set in the target.
  10044. */
  10045. propertyPath: string;
  10046. /**
  10047. * The value to set in the property
  10048. */
  10049. value: any;
  10050. private _target;
  10051. private _effectiveTarget;
  10052. private _property;
  10053. /**
  10054. * Instantiate the action
  10055. * @param triggerOptions defines the trigger options
  10056. * @param target defines the object containing the property
  10057. * @param propertyPath defines the path of the property to set in the target
  10058. * @param value defines the value to set in the property
  10059. * @param condition defines the trigger related conditions
  10060. */
  10061. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10062. /** @hidden */
  10063. _prepare(): void;
  10064. /**
  10065. * Execute the action and set the targetted property to the desired value.
  10066. */
  10067. execute(): void;
  10068. /**
  10069. * Serializes the actions and its related information.
  10070. * @param parent defines the object to serialize in
  10071. * @returns the serialized object
  10072. */
  10073. serialize(parent: any): any;
  10074. }
  10075. /**
  10076. * This defines an action responsible to increment the target value
  10077. * to a desired value once triggered.
  10078. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10079. */
  10080. export class IncrementValueAction extends Action {
  10081. /**
  10082. * The path of the property to increment in the target.
  10083. */
  10084. propertyPath: string;
  10085. /**
  10086. * The value we should increment the property by.
  10087. */
  10088. value: any;
  10089. private _target;
  10090. private _effectiveTarget;
  10091. private _property;
  10092. /**
  10093. * Instantiate the action
  10094. * @param triggerOptions defines the trigger options
  10095. * @param target defines the object containing the property
  10096. * @param propertyPath defines the path of the property to increment in the target
  10097. * @param value defines the value value we should increment the property by
  10098. * @param condition defines the trigger related conditions
  10099. */
  10100. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10101. /** @hidden */
  10102. _prepare(): void;
  10103. /**
  10104. * Execute the action and increment the target of the value amount.
  10105. */
  10106. execute(): void;
  10107. /**
  10108. * Serializes the actions and its related information.
  10109. * @param parent defines the object to serialize in
  10110. * @returns the serialized object
  10111. */
  10112. serialize(parent: any): any;
  10113. }
  10114. /**
  10115. * This defines an action responsible to start an animation once triggered.
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10117. */
  10118. export class PlayAnimationAction extends Action {
  10119. /**
  10120. * Where the animation should start (animation frame)
  10121. */
  10122. from: number;
  10123. /**
  10124. * Where the animation should stop (animation frame)
  10125. */
  10126. to: number;
  10127. /**
  10128. * Define if the animation should loop or stop after the first play.
  10129. */
  10130. loop?: boolean;
  10131. private _target;
  10132. /**
  10133. * Instantiate the action
  10134. * @param triggerOptions defines the trigger options
  10135. * @param target defines the target animation or animation name
  10136. * @param from defines from where the animation should start (animation frame)
  10137. * @param end defines where the animation should stop (animation frame)
  10138. * @param loop defines if the animation should loop or stop after the first play
  10139. * @param condition defines the trigger related conditions
  10140. */
  10141. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10142. /** @hidden */
  10143. _prepare(): void;
  10144. /**
  10145. * Execute the action and play the animation.
  10146. */
  10147. execute(): void;
  10148. /**
  10149. * Serializes the actions and its related information.
  10150. * @param parent defines the object to serialize in
  10151. * @returns the serialized object
  10152. */
  10153. serialize(parent: any): any;
  10154. }
  10155. /**
  10156. * This defines an action responsible to stop an animation once triggered.
  10157. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10158. */
  10159. export class StopAnimationAction extends Action {
  10160. private _target;
  10161. /**
  10162. * Instantiate the action
  10163. * @param triggerOptions defines the trigger options
  10164. * @param target defines the target animation or animation name
  10165. * @param condition defines the trigger related conditions
  10166. */
  10167. constructor(triggerOptions: any, target: any, condition?: Condition);
  10168. /** @hidden */
  10169. _prepare(): void;
  10170. /**
  10171. * Execute the action and stop the animation.
  10172. */
  10173. execute(): void;
  10174. /**
  10175. * Serializes the actions and its related information.
  10176. * @param parent defines the object to serialize in
  10177. * @returns the serialized object
  10178. */
  10179. serialize(parent: any): any;
  10180. }
  10181. /**
  10182. * This defines an action responsible that does nothing once triggered.
  10183. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10184. */
  10185. export class DoNothingAction extends Action {
  10186. /**
  10187. * Instantiate the action
  10188. * @param triggerOptions defines the trigger options
  10189. * @param condition defines the trigger related conditions
  10190. */
  10191. constructor(triggerOptions?: any, condition?: Condition);
  10192. /**
  10193. * Execute the action and do nothing.
  10194. */
  10195. execute(): void;
  10196. /**
  10197. * Serializes the actions and its related information.
  10198. * @param parent defines the object to serialize in
  10199. * @returns the serialized object
  10200. */
  10201. serialize(parent: any): any;
  10202. }
  10203. /**
  10204. * This defines an action responsible to trigger several actions once triggered.
  10205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10206. */
  10207. export class CombineAction extends Action {
  10208. /**
  10209. * The list of aggregated animations to run.
  10210. */
  10211. children: Action[];
  10212. /**
  10213. * Instantiate the action
  10214. * @param triggerOptions defines the trigger options
  10215. * @param children defines the list of aggregated animations to run
  10216. * @param condition defines the trigger related conditions
  10217. */
  10218. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10219. /** @hidden */
  10220. _prepare(): void;
  10221. /**
  10222. * Execute the action and executes all the aggregated actions.
  10223. */
  10224. execute(evt: ActionEvent): void;
  10225. /**
  10226. * Serializes the actions and its related information.
  10227. * @param parent defines the object to serialize in
  10228. * @returns the serialized object
  10229. */
  10230. serialize(parent: any): any;
  10231. }
  10232. /**
  10233. * This defines an action responsible to run code (external event) once triggered.
  10234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10235. */
  10236. export class ExecuteCodeAction extends Action {
  10237. /**
  10238. * The callback function to run.
  10239. */
  10240. func: (evt: ActionEvent) => void;
  10241. /**
  10242. * Instantiate the action
  10243. * @param triggerOptions defines the trigger options
  10244. * @param func defines the callback function to run
  10245. * @param condition defines the trigger related conditions
  10246. */
  10247. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10248. /**
  10249. * Execute the action and run the attached code.
  10250. */
  10251. execute(evt: ActionEvent): void;
  10252. }
  10253. /**
  10254. * This defines an action responsible to set the parent property of the target once triggered.
  10255. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10256. */
  10257. export class SetParentAction extends Action {
  10258. private _parent;
  10259. private _target;
  10260. /**
  10261. * Instantiate the action
  10262. * @param triggerOptions defines the trigger options
  10263. * @param target defines the target containing the parent property
  10264. * @param parent defines from where the animation should start (animation frame)
  10265. * @param condition defines the trigger related conditions
  10266. */
  10267. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10268. /** @hidden */
  10269. _prepare(): void;
  10270. /**
  10271. * Execute the action and set the parent property.
  10272. */
  10273. execute(): void;
  10274. /**
  10275. * Serializes the actions and its related information.
  10276. * @param parent defines the object to serialize in
  10277. * @returns the serialized object
  10278. */
  10279. serialize(parent: any): any;
  10280. }
  10281. }
  10282. declare module "babylonjs/Actions/actionManager" {
  10283. import { Nullable } from "babylonjs/types";
  10284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10285. import { Scene } from "babylonjs/scene";
  10286. import { IAction } from "babylonjs/Actions/action";
  10287. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10288. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10289. /**
  10290. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10291. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10293. */
  10294. export class ActionManager extends AbstractActionManager {
  10295. /**
  10296. * Nothing
  10297. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10298. */
  10299. static readonly NothingTrigger: number;
  10300. /**
  10301. * On pick
  10302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10303. */
  10304. static readonly OnPickTrigger: number;
  10305. /**
  10306. * On left pick
  10307. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10308. */
  10309. static readonly OnLeftPickTrigger: number;
  10310. /**
  10311. * On right pick
  10312. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10313. */
  10314. static readonly OnRightPickTrigger: number;
  10315. /**
  10316. * On center pick
  10317. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10318. */
  10319. static readonly OnCenterPickTrigger: number;
  10320. /**
  10321. * On pick down
  10322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10323. */
  10324. static readonly OnPickDownTrigger: number;
  10325. /**
  10326. * On double pick
  10327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10328. */
  10329. static readonly OnDoublePickTrigger: number;
  10330. /**
  10331. * On pick up
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPickUpTrigger: number;
  10335. /**
  10336. * On pick out.
  10337. * This trigger will only be raised if you also declared a OnPickDown
  10338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10339. */
  10340. static readonly OnPickOutTrigger: number;
  10341. /**
  10342. * On long press
  10343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10344. */
  10345. static readonly OnLongPressTrigger: number;
  10346. /**
  10347. * On pointer over
  10348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10349. */
  10350. static readonly OnPointerOverTrigger: number;
  10351. /**
  10352. * On pointer out
  10353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10354. */
  10355. static readonly OnPointerOutTrigger: number;
  10356. /**
  10357. * On every frame
  10358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10359. */
  10360. static readonly OnEveryFrameTrigger: number;
  10361. /**
  10362. * On intersection enter
  10363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10364. */
  10365. static readonly OnIntersectionEnterTrigger: number;
  10366. /**
  10367. * On intersection exit
  10368. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10369. */
  10370. static readonly OnIntersectionExitTrigger: number;
  10371. /**
  10372. * On key down
  10373. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10374. */
  10375. static readonly OnKeyDownTrigger: number;
  10376. /**
  10377. * On key up
  10378. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10379. */
  10380. static readonly OnKeyUpTrigger: number;
  10381. private _scene;
  10382. /**
  10383. * Creates a new action manager
  10384. * @param scene defines the hosting scene
  10385. */
  10386. constructor(scene: Scene);
  10387. /**
  10388. * Releases all associated resources
  10389. */
  10390. dispose(): void;
  10391. /**
  10392. * Gets hosting scene
  10393. * @returns the hosting scene
  10394. */
  10395. getScene(): Scene;
  10396. /**
  10397. * Does this action manager handles actions of any of the given triggers
  10398. * @param triggers defines the triggers to be tested
  10399. * @return a boolean indicating whether one (or more) of the triggers is handled
  10400. */
  10401. hasSpecificTriggers(triggers: number[]): boolean;
  10402. /**
  10403. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10404. * speed.
  10405. * @param triggerA defines the trigger to be tested
  10406. * @param triggerB defines the trigger to be tested
  10407. * @return a boolean indicating whether one (or more) of the triggers is handled
  10408. */
  10409. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10410. /**
  10411. * Does this action manager handles actions of a given trigger
  10412. * @param trigger defines the trigger to be tested
  10413. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10414. * @return whether the trigger is handled
  10415. */
  10416. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10417. /**
  10418. * Does this action manager has pointer triggers
  10419. */
  10420. get hasPointerTriggers(): boolean;
  10421. /**
  10422. * Does this action manager has pick triggers
  10423. */
  10424. get hasPickTriggers(): boolean;
  10425. /**
  10426. * Registers an action to this action manager
  10427. * @param action defines the action to be registered
  10428. * @return the action amended (prepared) after registration
  10429. */
  10430. registerAction(action: IAction): Nullable<IAction>;
  10431. /**
  10432. * Unregisters an action to this action manager
  10433. * @param action defines the action to be unregistered
  10434. * @return a boolean indicating whether the action has been unregistered
  10435. */
  10436. unregisterAction(action: IAction): Boolean;
  10437. /**
  10438. * Process a specific trigger
  10439. * @param trigger defines the trigger to process
  10440. * @param evt defines the event details to be processed
  10441. */
  10442. processTrigger(trigger: number, evt?: IActionEvent): void;
  10443. /** @hidden */
  10444. _getEffectiveTarget(target: any, propertyPath: string): any;
  10445. /** @hidden */
  10446. _getProperty(propertyPath: string): string;
  10447. /**
  10448. * Serialize this manager to a JSON object
  10449. * @param name defines the property name to store this manager
  10450. * @returns a JSON representation of this manager
  10451. */
  10452. serialize(name: string): any;
  10453. /**
  10454. * Creates a new ActionManager from a JSON data
  10455. * @param parsedActions defines the JSON data to read from
  10456. * @param object defines the hosting mesh
  10457. * @param scene defines the hosting scene
  10458. */
  10459. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10460. /**
  10461. * Get a trigger name by index
  10462. * @param trigger defines the trigger index
  10463. * @returns a trigger name
  10464. */
  10465. static GetTriggerName(trigger: number): string;
  10466. }
  10467. }
  10468. declare module "babylonjs/Sprites/sprite" {
  10469. import { Vector3 } from "babylonjs/Maths/math.vector";
  10470. import { Nullable } from "babylonjs/types";
  10471. import { ActionManager } from "babylonjs/Actions/actionManager";
  10472. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10473. import { Color4 } from "babylonjs/Maths/math.color";
  10474. import { Observable } from "babylonjs/Misc/observable";
  10475. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10476. import { Animation } from "babylonjs/Animations/animation";
  10477. /**
  10478. * Class used to represent a sprite
  10479. * @see https://doc.babylonjs.com/babylon101/sprites
  10480. */
  10481. export class Sprite implements IAnimatable {
  10482. /** defines the name */
  10483. name: string;
  10484. /** Gets or sets the current world position */
  10485. position: Vector3;
  10486. /** Gets or sets the main color */
  10487. color: Color4;
  10488. /** Gets or sets the width */
  10489. width: number;
  10490. /** Gets or sets the height */
  10491. height: number;
  10492. /** Gets or sets rotation angle */
  10493. angle: number;
  10494. /** Gets or sets the cell index in the sprite sheet */
  10495. cellIndex: number;
  10496. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10497. cellRef: string;
  10498. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10499. invertU: boolean;
  10500. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10501. invertV: boolean;
  10502. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10503. disposeWhenFinishedAnimating: boolean;
  10504. /** Gets the list of attached animations */
  10505. animations: Nullable<Array<Animation>>;
  10506. /** Gets or sets a boolean indicating if the sprite can be picked */
  10507. isPickable: boolean;
  10508. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10509. useAlphaForPicking: boolean;
  10510. /** @hidden */
  10511. _xOffset: number;
  10512. /** @hidden */
  10513. _yOffset: number;
  10514. /** @hidden */
  10515. _xSize: number;
  10516. /** @hidden */
  10517. _ySize: number;
  10518. /**
  10519. * Gets or sets the associated action manager
  10520. */
  10521. actionManager: Nullable<ActionManager>;
  10522. /**
  10523. * An event triggered when the control has been disposed
  10524. */
  10525. onDisposeObservable: Observable<Sprite>;
  10526. private _animationStarted;
  10527. private _loopAnimation;
  10528. private _fromIndex;
  10529. private _toIndex;
  10530. private _delay;
  10531. private _direction;
  10532. private _manager;
  10533. private _time;
  10534. private _onAnimationEnd;
  10535. /**
  10536. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10537. */
  10538. isVisible: boolean;
  10539. /**
  10540. * Gets or sets the sprite size
  10541. */
  10542. get size(): number;
  10543. set size(value: number);
  10544. /**
  10545. * Returns a boolean indicating if the animation is started
  10546. */
  10547. get animationStarted(): boolean;
  10548. /**
  10549. * Gets or sets the unique id of the sprite
  10550. */
  10551. uniqueId: number;
  10552. /**
  10553. * Gets the manager of this sprite
  10554. */
  10555. get manager(): ISpriteManager;
  10556. /**
  10557. * Creates a new Sprite
  10558. * @param name defines the name
  10559. * @param manager defines the manager
  10560. */
  10561. constructor(
  10562. /** defines the name */
  10563. name: string, manager: ISpriteManager);
  10564. /**
  10565. * Returns the string "Sprite"
  10566. * @returns "Sprite"
  10567. */
  10568. getClassName(): string;
  10569. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10570. get fromIndex(): number;
  10571. set fromIndex(value: number);
  10572. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10573. get toIndex(): number;
  10574. set toIndex(value: number);
  10575. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10576. get loopAnimation(): boolean;
  10577. set loopAnimation(value: boolean);
  10578. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10579. get delay(): number;
  10580. set delay(value: number);
  10581. /**
  10582. * Starts an animation
  10583. * @param from defines the initial key
  10584. * @param to defines the end key
  10585. * @param loop defines if the animation must loop
  10586. * @param delay defines the start delay (in ms)
  10587. * @param onAnimationEnd defines a callback to call when animation ends
  10588. */
  10589. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10590. /** Stops current animation (if any) */
  10591. stopAnimation(): void;
  10592. /** @hidden */
  10593. _animate(deltaTime: number): void;
  10594. /** Release associated resources */
  10595. dispose(): void;
  10596. /**
  10597. * Serializes the sprite to a JSON object
  10598. * @returns the JSON object
  10599. */
  10600. serialize(): any;
  10601. /**
  10602. * Parses a JSON object to create a new sprite
  10603. * @param parsedSprite The JSON object to parse
  10604. * @param manager defines the hosting manager
  10605. * @returns the new sprite
  10606. */
  10607. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10608. }
  10609. }
  10610. declare module "babylonjs/Collisions/pickingInfo" {
  10611. import { Nullable } from "babylonjs/types";
  10612. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10614. import { Sprite } from "babylonjs/Sprites/sprite";
  10615. import { Ray } from "babylonjs/Culling/ray";
  10616. /**
  10617. * Information about the result of picking within a scene
  10618. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10619. */
  10620. export class PickingInfo {
  10621. /** @hidden */
  10622. _pickingUnavailable: boolean;
  10623. /**
  10624. * If the pick collided with an object
  10625. */
  10626. hit: boolean;
  10627. /**
  10628. * Distance away where the pick collided
  10629. */
  10630. distance: number;
  10631. /**
  10632. * The location of pick collision
  10633. */
  10634. pickedPoint: Nullable<Vector3>;
  10635. /**
  10636. * The mesh corresponding the the pick collision
  10637. */
  10638. pickedMesh: Nullable<AbstractMesh>;
  10639. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10640. bu: number;
  10641. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10642. bv: number;
  10643. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10644. faceId: number;
  10645. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10646. subMeshFaceId: number;
  10647. /** Id of the the submesh that was picked */
  10648. subMeshId: number;
  10649. /** If a sprite was picked, this will be the sprite the pick collided with */
  10650. pickedSprite: Nullable<Sprite>;
  10651. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10652. thinInstanceIndex: number;
  10653. /**
  10654. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10655. */
  10656. originMesh: Nullable<AbstractMesh>;
  10657. /**
  10658. * The ray that was used to perform the picking.
  10659. */
  10660. ray: Nullable<Ray>;
  10661. /**
  10662. * Gets the normal correspodning to the face the pick collided with
  10663. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10664. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10665. * @returns The normal correspodning to the face the pick collided with
  10666. */
  10667. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10668. /**
  10669. * Gets the texture coordinates of where the pick occured
  10670. * @returns the vector containing the coordnates of the texture
  10671. */
  10672. getTextureCoordinates(): Nullable<Vector2>;
  10673. }
  10674. }
  10675. declare module "babylonjs/Culling/ray" {
  10676. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10677. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10679. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10680. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10681. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10682. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10683. import { Plane } from "babylonjs/Maths/math.plane";
  10684. /**
  10685. * Class representing a ray with position and direction
  10686. */
  10687. export class Ray {
  10688. /** origin point */
  10689. origin: Vector3;
  10690. /** direction */
  10691. direction: Vector3;
  10692. /** length of the ray */
  10693. length: number;
  10694. private static readonly _TmpVector3;
  10695. private _tmpRay;
  10696. /**
  10697. * Creates a new ray
  10698. * @param origin origin point
  10699. * @param direction direction
  10700. * @param length length of the ray
  10701. */
  10702. constructor(
  10703. /** origin point */
  10704. origin: Vector3,
  10705. /** direction */
  10706. direction: Vector3,
  10707. /** length of the ray */
  10708. length?: number);
  10709. /**
  10710. * Checks if the ray intersects a box
  10711. * This does not account for the ray lenght by design to improve perfs.
  10712. * @param minimum bound of the box
  10713. * @param maximum bound of the box
  10714. * @param intersectionTreshold extra extend to be added to the box in all direction
  10715. * @returns if the box was hit
  10716. */
  10717. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10718. /**
  10719. * Checks if the ray intersects a box
  10720. * This does not account for the ray lenght by design to improve perfs.
  10721. * @param box the bounding box to check
  10722. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10723. * @returns if the box was hit
  10724. */
  10725. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10726. /**
  10727. * If the ray hits a sphere
  10728. * @param sphere the bounding sphere to check
  10729. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10730. * @returns true if it hits the sphere
  10731. */
  10732. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10733. /**
  10734. * If the ray hits a triange
  10735. * @param vertex0 triangle vertex
  10736. * @param vertex1 triangle vertex
  10737. * @param vertex2 triangle vertex
  10738. * @returns intersection information if hit
  10739. */
  10740. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10741. /**
  10742. * Checks if ray intersects a plane
  10743. * @param plane the plane to check
  10744. * @returns the distance away it was hit
  10745. */
  10746. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10747. /**
  10748. * Calculate the intercept of a ray on a given axis
  10749. * @param axis to check 'x' | 'y' | 'z'
  10750. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10751. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10752. */
  10753. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10754. /**
  10755. * Checks if ray intersects a mesh
  10756. * @param mesh the mesh to check
  10757. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10758. * @returns picking info of the intersecton
  10759. */
  10760. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10761. /**
  10762. * Checks if ray intersects a mesh
  10763. * @param meshes the meshes to check
  10764. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10765. * @param results array to store result in
  10766. * @returns Array of picking infos
  10767. */
  10768. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10769. private _comparePickingInfo;
  10770. private static smallnum;
  10771. private static rayl;
  10772. /**
  10773. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10774. * @param sega the first point of the segment to test the intersection against
  10775. * @param segb the second point of the segment to test the intersection against
  10776. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10777. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10778. */
  10779. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10780. /**
  10781. * Update the ray from viewport position
  10782. * @param x position
  10783. * @param y y position
  10784. * @param viewportWidth viewport width
  10785. * @param viewportHeight viewport height
  10786. * @param world world matrix
  10787. * @param view view matrix
  10788. * @param projection projection matrix
  10789. * @returns this ray updated
  10790. */
  10791. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10792. /**
  10793. * Creates a ray with origin and direction of 0,0,0
  10794. * @returns the new ray
  10795. */
  10796. static Zero(): Ray;
  10797. /**
  10798. * Creates a new ray from screen space and viewport
  10799. * @param x position
  10800. * @param y y position
  10801. * @param viewportWidth viewport width
  10802. * @param viewportHeight viewport height
  10803. * @param world world matrix
  10804. * @param view view matrix
  10805. * @param projection projection matrix
  10806. * @returns new ray
  10807. */
  10808. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10809. /**
  10810. * 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
  10811. * transformed to the given world matrix.
  10812. * @param origin The origin point
  10813. * @param end The end point
  10814. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10815. * @returns the new ray
  10816. */
  10817. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10818. /**
  10819. * Transforms a ray by a matrix
  10820. * @param ray ray to transform
  10821. * @param matrix matrix to apply
  10822. * @returns the resulting new ray
  10823. */
  10824. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10825. /**
  10826. * Transforms a ray by a matrix
  10827. * @param ray ray to transform
  10828. * @param matrix matrix to apply
  10829. * @param result ray to store result in
  10830. */
  10831. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10832. /**
  10833. * Unproject a ray from screen space to object space
  10834. * @param sourceX defines the screen space x coordinate to use
  10835. * @param sourceY defines the screen space y coordinate to use
  10836. * @param viewportWidth defines the current width of the viewport
  10837. * @param viewportHeight defines the current height of the viewport
  10838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10839. * @param view defines the view matrix to use
  10840. * @param projection defines the projection matrix to use
  10841. */
  10842. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10843. }
  10844. /**
  10845. * Type used to define predicate used to select faces when a mesh intersection is detected
  10846. */
  10847. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10848. module "babylonjs/scene" {
  10849. interface Scene {
  10850. /** @hidden */
  10851. _tempPickingRay: Nullable<Ray>;
  10852. /** @hidden */
  10853. _cachedRayForTransform: Ray;
  10854. /** @hidden */
  10855. _pickWithRayInverseMatrix: Matrix;
  10856. /** @hidden */
  10857. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10858. /** @hidden */
  10859. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10860. /** @hidden */
  10861. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10862. }
  10863. }
  10864. }
  10865. declare module "babylonjs/sceneComponent" {
  10866. import { Scene } from "babylonjs/scene";
  10867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10868. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10869. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10870. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10871. import { Nullable } from "babylonjs/types";
  10872. import { Camera } from "babylonjs/Cameras/camera";
  10873. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10874. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10875. import { AbstractScene } from "babylonjs/abstractScene";
  10876. import { Mesh } from "babylonjs/Meshes/mesh";
  10877. /**
  10878. * Groups all the scene component constants in one place to ease maintenance.
  10879. * @hidden
  10880. */
  10881. export class SceneComponentConstants {
  10882. static readonly NAME_EFFECTLAYER: string;
  10883. static readonly NAME_LAYER: string;
  10884. static readonly NAME_LENSFLARESYSTEM: string;
  10885. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10886. static readonly NAME_PARTICLESYSTEM: string;
  10887. static readonly NAME_GAMEPAD: string;
  10888. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10889. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10890. static readonly NAME_PREPASSRENDERER: string;
  10891. static readonly NAME_DEPTHRENDERER: string;
  10892. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10893. static readonly NAME_SPRITE: string;
  10894. static readonly NAME_SUBSURFACE: string;
  10895. static readonly NAME_OUTLINERENDERER: string;
  10896. static readonly NAME_PROCEDURALTEXTURE: string;
  10897. static readonly NAME_SHADOWGENERATOR: string;
  10898. static readonly NAME_OCTREE: string;
  10899. static readonly NAME_PHYSICSENGINE: string;
  10900. static readonly NAME_AUDIO: string;
  10901. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10902. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10903. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10904. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10905. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10906. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10907. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10908. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10909. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10910. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10911. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10912. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10913. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10914. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10915. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10916. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10917. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10918. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10919. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10920. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10921. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10922. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10923. static readonly STEP_AFTERRENDER_AUDIO: number;
  10924. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10925. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10926. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10927. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10928. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10929. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10930. static readonly STEP_POINTERMOVE_SPRITE: number;
  10931. static readonly STEP_POINTERDOWN_SPRITE: number;
  10932. static readonly STEP_POINTERUP_SPRITE: number;
  10933. }
  10934. /**
  10935. * This represents a scene component.
  10936. *
  10937. * This is used to decouple the dependency the scene is having on the different workloads like
  10938. * layers, post processes...
  10939. */
  10940. export interface ISceneComponent {
  10941. /**
  10942. * The name of the component. Each component must have a unique name.
  10943. */
  10944. name: string;
  10945. /**
  10946. * The scene the component belongs to.
  10947. */
  10948. scene: Scene;
  10949. /**
  10950. * Register the component to one instance of a scene.
  10951. */
  10952. register(): void;
  10953. /**
  10954. * Rebuilds the elements related to this component in case of
  10955. * context lost for instance.
  10956. */
  10957. rebuild(): void;
  10958. /**
  10959. * Disposes the component and the associated ressources.
  10960. */
  10961. dispose(): void;
  10962. }
  10963. /**
  10964. * This represents a SERIALIZABLE scene component.
  10965. *
  10966. * This extends Scene Component to add Serialization methods on top.
  10967. */
  10968. export interface ISceneSerializableComponent extends ISceneComponent {
  10969. /**
  10970. * Adds all the elements from the container to the scene
  10971. * @param container the container holding the elements
  10972. */
  10973. addFromContainer(container: AbstractScene): void;
  10974. /**
  10975. * Removes all the elements in the container from the scene
  10976. * @param container contains the elements to remove
  10977. * @param dispose if the removed element should be disposed (default: false)
  10978. */
  10979. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10980. /**
  10981. * Serializes the component data to the specified json object
  10982. * @param serializationObject The object to serialize to
  10983. */
  10984. serialize(serializationObject: any): void;
  10985. }
  10986. /**
  10987. * Strong typing of a Mesh related stage step action
  10988. */
  10989. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10990. /**
  10991. * Strong typing of a Evaluate Sub Mesh related stage step action
  10992. */
  10993. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10994. /**
  10995. * Strong typing of a Active Mesh related stage step action
  10996. */
  10997. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10998. /**
  10999. * Strong typing of a Camera related stage step action
  11000. */
  11001. export type CameraStageAction = (camera: Camera) => void;
  11002. /**
  11003. * Strong typing of a Camera Frame buffer related stage step action
  11004. */
  11005. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11006. /**
  11007. * Strong typing of a Render Target related stage step action
  11008. */
  11009. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11010. /**
  11011. * Strong typing of a RenderingGroup related stage step action
  11012. */
  11013. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11014. /**
  11015. * Strong typing of a Mesh Render related stage step action
  11016. */
  11017. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11018. /**
  11019. * Strong typing of a simple stage step action
  11020. */
  11021. export type SimpleStageAction = () => void;
  11022. /**
  11023. * Strong typing of a render target action.
  11024. */
  11025. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11026. /**
  11027. * Strong typing of a pointer move action.
  11028. */
  11029. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11030. /**
  11031. * Strong typing of a pointer up/down action.
  11032. */
  11033. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11034. /**
  11035. * Representation of a stage in the scene (Basically a list of ordered steps)
  11036. * @hidden
  11037. */
  11038. export class Stage<T extends Function> extends Array<{
  11039. index: number;
  11040. component: ISceneComponent;
  11041. action: T;
  11042. }> {
  11043. /**
  11044. * Hide ctor from the rest of the world.
  11045. * @param items The items to add.
  11046. */
  11047. private constructor();
  11048. /**
  11049. * Creates a new Stage.
  11050. * @returns A new instance of a Stage
  11051. */
  11052. static Create<T extends Function>(): Stage<T>;
  11053. /**
  11054. * Registers a step in an ordered way in the targeted stage.
  11055. * @param index Defines the position to register the step in
  11056. * @param component Defines the component attached to the step
  11057. * @param action Defines the action to launch during the step
  11058. */
  11059. registerStep(index: number, component: ISceneComponent, action: T): void;
  11060. /**
  11061. * Clears all the steps from the stage.
  11062. */
  11063. clear(): void;
  11064. }
  11065. }
  11066. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11067. import { Nullable } from "babylonjs/types";
  11068. import { Observable } from "babylonjs/Misc/observable";
  11069. import { Scene } from "babylonjs/scene";
  11070. import { Sprite } from "babylonjs/Sprites/sprite";
  11071. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11072. import { Ray } from "babylonjs/Culling/ray";
  11073. import { Camera } from "babylonjs/Cameras/camera";
  11074. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11075. import { ISceneComponent } from "babylonjs/sceneComponent";
  11076. module "babylonjs/scene" {
  11077. interface Scene {
  11078. /** @hidden */
  11079. _pointerOverSprite: Nullable<Sprite>;
  11080. /** @hidden */
  11081. _pickedDownSprite: Nullable<Sprite>;
  11082. /** @hidden */
  11083. _tempSpritePickingRay: Nullable<Ray>;
  11084. /**
  11085. * All of the sprite managers added to this scene
  11086. * @see https://doc.babylonjs.com/babylon101/sprites
  11087. */
  11088. spriteManagers: Array<ISpriteManager>;
  11089. /**
  11090. * An event triggered when sprites rendering is about to start
  11091. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11092. */
  11093. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11094. /**
  11095. * An event triggered when sprites rendering is done
  11096. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11097. */
  11098. onAfterSpritesRenderingObservable: Observable<Scene>;
  11099. /** @hidden */
  11100. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11101. /** Launch a ray to try to pick a sprite in the scene
  11102. * @param x position on screen
  11103. * @param y position on screen
  11104. * @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
  11105. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11106. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11107. * @returns a PickingInfo
  11108. */
  11109. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11110. /** Use the given ray to pick a sprite in the scene
  11111. * @param ray The ray (in world space) to use to pick meshes
  11112. * @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
  11113. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11114. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11115. * @returns a PickingInfo
  11116. */
  11117. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11118. /** @hidden */
  11119. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11120. /** Launch a ray to try to pick sprites in the scene
  11121. * @param x position on screen
  11122. * @param y position on screen
  11123. * @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
  11124. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11125. * @returns a PickingInfo array
  11126. */
  11127. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11128. /** Use the given ray to pick sprites in the scene
  11129. * @param ray The ray (in world space) to use to pick meshes
  11130. * @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
  11131. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11132. * @returns a PickingInfo array
  11133. */
  11134. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11135. /**
  11136. * Force the sprite under the pointer
  11137. * @param sprite defines the sprite to use
  11138. */
  11139. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11140. /**
  11141. * Gets the sprite under the pointer
  11142. * @returns a Sprite or null if no sprite is under the pointer
  11143. */
  11144. getPointerOverSprite(): Nullable<Sprite>;
  11145. }
  11146. }
  11147. /**
  11148. * Defines the sprite scene component responsible to manage sprites
  11149. * in a given scene.
  11150. */
  11151. export class SpriteSceneComponent implements ISceneComponent {
  11152. /**
  11153. * The component name helpfull to identify the component in the list of scene components.
  11154. */
  11155. readonly name: string;
  11156. /**
  11157. * The scene the component belongs to.
  11158. */
  11159. scene: Scene;
  11160. /** @hidden */
  11161. private _spritePredicate;
  11162. /**
  11163. * Creates a new instance of the component for the given scene
  11164. * @param scene Defines the scene to register the component in
  11165. */
  11166. constructor(scene: Scene);
  11167. /**
  11168. * Registers the component in a given scene
  11169. */
  11170. register(): void;
  11171. /**
  11172. * Rebuilds the elements related to this component in case of
  11173. * context lost for instance.
  11174. */
  11175. rebuild(): void;
  11176. /**
  11177. * Disposes the component and the associated ressources.
  11178. */
  11179. dispose(): void;
  11180. private _pickSpriteButKeepRay;
  11181. private _pointerMove;
  11182. private _pointerDown;
  11183. private _pointerUp;
  11184. }
  11185. }
  11186. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11187. /** @hidden */
  11188. export var fogFragmentDeclaration: {
  11189. name: string;
  11190. shader: string;
  11191. };
  11192. }
  11193. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11194. /** @hidden */
  11195. export var fogFragment: {
  11196. name: string;
  11197. shader: string;
  11198. };
  11199. }
  11200. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  11201. /** @hidden */
  11202. export var imageProcessingCompatibility: {
  11203. name: string;
  11204. shader: string;
  11205. };
  11206. }
  11207. declare module "babylonjs/Shaders/sprites.fragment" {
  11208. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11209. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11210. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  11211. /** @hidden */
  11212. export var spritesPixelShader: {
  11213. name: string;
  11214. shader: string;
  11215. };
  11216. }
  11217. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11218. /** @hidden */
  11219. export var fogVertexDeclaration: {
  11220. name: string;
  11221. shader: string;
  11222. };
  11223. }
  11224. declare module "babylonjs/Shaders/sprites.vertex" {
  11225. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11226. /** @hidden */
  11227. export var spritesVertexShader: {
  11228. name: string;
  11229. shader: string;
  11230. };
  11231. }
  11232. declare module "babylonjs/Sprites/spriteManager" {
  11233. import { IDisposable, Scene } from "babylonjs/scene";
  11234. import { Nullable } from "babylonjs/types";
  11235. import { Observable } from "babylonjs/Misc/observable";
  11236. import { Sprite } from "babylonjs/Sprites/sprite";
  11237. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11238. import { Camera } from "babylonjs/Cameras/camera";
  11239. import { Texture } from "babylonjs/Materials/Textures/texture";
  11240. import "babylonjs/Shaders/sprites.fragment";
  11241. import "babylonjs/Shaders/sprites.vertex";
  11242. import { Ray } from "babylonjs/Culling/ray";
  11243. /**
  11244. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11245. */
  11246. export interface ISpriteManager extends IDisposable {
  11247. /**
  11248. * Gets manager's name
  11249. */
  11250. name: string;
  11251. /**
  11252. * Restricts the camera to viewing objects with the same layerMask.
  11253. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11254. */
  11255. layerMask: number;
  11256. /**
  11257. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11258. */
  11259. isPickable: boolean;
  11260. /**
  11261. * Gets the hosting scene
  11262. */
  11263. scene: Scene;
  11264. /**
  11265. * Specifies the rendering group id for this mesh (0 by default)
  11266. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11267. */
  11268. renderingGroupId: number;
  11269. /**
  11270. * Defines the list of sprites managed by the manager.
  11271. */
  11272. sprites: Array<Sprite>;
  11273. /**
  11274. * Gets or sets the spritesheet texture
  11275. */
  11276. texture: Texture;
  11277. /** Defines the default width of a cell in the spritesheet */
  11278. cellWidth: number;
  11279. /** Defines the default height of a cell in the spritesheet */
  11280. cellHeight: number;
  11281. /**
  11282. * Tests the intersection of a sprite with a specific ray.
  11283. * @param ray The ray we are sending to test the collision
  11284. * @param camera The camera space we are sending rays in
  11285. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11286. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11287. * @returns picking info or null.
  11288. */
  11289. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11290. /**
  11291. * Intersects the sprites with a ray
  11292. * @param ray defines the ray to intersect with
  11293. * @param camera defines the current active camera
  11294. * @param predicate defines a predicate used to select candidate sprites
  11295. * @returns null if no hit or a PickingInfo array
  11296. */
  11297. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11298. /**
  11299. * Renders the list of sprites on screen.
  11300. */
  11301. render(): void;
  11302. }
  11303. /**
  11304. * Class used to manage multiple sprites on the same spritesheet
  11305. * @see https://doc.babylonjs.com/babylon101/sprites
  11306. */
  11307. export class SpriteManager implements ISpriteManager {
  11308. /** defines the manager's name */
  11309. name: string;
  11310. /** Define the Url to load snippets */
  11311. static SnippetUrl: string;
  11312. /** Snippet ID if the manager was created from the snippet server */
  11313. snippetId: string;
  11314. /** Gets the list of sprites */
  11315. sprites: Sprite[];
  11316. /** Gets or sets the rendering group id (0 by default) */
  11317. renderingGroupId: number;
  11318. /** Gets or sets camera layer mask */
  11319. layerMask: number;
  11320. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11321. fogEnabled: boolean;
  11322. /** Gets or sets a boolean indicating if the sprites are pickable */
  11323. isPickable: boolean;
  11324. /** Defines the default width of a cell in the spritesheet */
  11325. cellWidth: number;
  11326. /** Defines the default height of a cell in the spritesheet */
  11327. cellHeight: number;
  11328. /** Associative array from JSON sprite data file */
  11329. private _cellData;
  11330. /** Array of sprite names from JSON sprite data file */
  11331. private _spriteMap;
  11332. /** True when packed cell data from JSON file is ready*/
  11333. private _packedAndReady;
  11334. private _textureContent;
  11335. private _useInstancing;
  11336. /**
  11337. * An event triggered when the manager is disposed.
  11338. */
  11339. onDisposeObservable: Observable<SpriteManager>;
  11340. private _onDisposeObserver;
  11341. /**
  11342. * Callback called when the manager is disposed
  11343. */
  11344. set onDispose(callback: () => void);
  11345. private _capacity;
  11346. private _fromPacked;
  11347. private _spriteTexture;
  11348. private _epsilon;
  11349. private _scene;
  11350. private _vertexData;
  11351. private _buffer;
  11352. private _vertexBuffers;
  11353. private _spriteBuffer;
  11354. private _indexBuffer;
  11355. private _effectBase;
  11356. private _effectFog;
  11357. private _vertexBufferSize;
  11358. /**
  11359. * Gets or sets the unique id of the sprite
  11360. */
  11361. uniqueId: number;
  11362. /**
  11363. * Gets the array of sprites
  11364. */
  11365. get children(): Sprite[];
  11366. /**
  11367. * Gets the hosting scene
  11368. */
  11369. get scene(): Scene;
  11370. /**
  11371. * Gets the capacity of the manager
  11372. */
  11373. get capacity(): number;
  11374. /**
  11375. * Gets or sets the spritesheet texture
  11376. */
  11377. get texture(): Texture;
  11378. set texture(value: Texture);
  11379. private _blendMode;
  11380. /**
  11381. * Blend mode use to render the particle, it can be any of
  11382. * the static Constants.ALPHA_x properties provided in this class.
  11383. * Default value is Constants.ALPHA_COMBINE
  11384. */
  11385. get blendMode(): number;
  11386. set blendMode(blendMode: number);
  11387. /** Disables writing to the depth buffer when rendering the sprites.
  11388. * It can be handy to disable depth writing when using textures without alpha channel
  11389. * and setting some specific blend modes.
  11390. */
  11391. disableDepthWrite: boolean;
  11392. /**
  11393. * Creates a new sprite manager
  11394. * @param name defines the manager's name
  11395. * @param imgUrl defines the sprite sheet url
  11396. * @param capacity defines the maximum allowed number of sprites
  11397. * @param cellSize defines the size of a sprite cell
  11398. * @param scene defines the hosting scene
  11399. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11400. * @param samplingMode defines the smapling mode to use with spritesheet
  11401. * @param fromPacked set to false; do not alter
  11402. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11403. */
  11404. constructor(
  11405. /** defines the manager's name */
  11406. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11407. /**
  11408. * Returns the string "SpriteManager"
  11409. * @returns "SpriteManager"
  11410. */
  11411. getClassName(): string;
  11412. private _makePacked;
  11413. private _appendSpriteVertex;
  11414. private _checkTextureAlpha;
  11415. /**
  11416. * Intersects the sprites with a ray
  11417. * @param ray defines the ray to intersect with
  11418. * @param camera defines the current active camera
  11419. * @param predicate defines a predicate used to select candidate sprites
  11420. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11421. * @returns null if no hit or a PickingInfo
  11422. */
  11423. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11424. /**
  11425. * Intersects the sprites with a ray
  11426. * @param ray defines the ray to intersect with
  11427. * @param camera defines the current active camera
  11428. * @param predicate defines a predicate used to select candidate sprites
  11429. * @returns null if no hit or a PickingInfo array
  11430. */
  11431. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11432. /**
  11433. * Render all child sprites
  11434. */
  11435. render(): void;
  11436. /**
  11437. * Release associated resources
  11438. */
  11439. dispose(): void;
  11440. /**
  11441. * Serializes the sprite manager to a JSON object
  11442. * @param serializeTexture defines if the texture must be serialized as well
  11443. * @returns the JSON object
  11444. */
  11445. serialize(serializeTexture?: boolean): any;
  11446. /**
  11447. * Parses a JSON object to create a new sprite manager.
  11448. * @param parsedManager The JSON object to parse
  11449. * @param scene The scene to create the sprite managerin
  11450. * @param rootUrl The root url to use to load external dependencies like texture
  11451. * @returns the new sprite manager
  11452. */
  11453. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11454. /**
  11455. * Creates a sprite manager from a snippet saved in a remote file
  11456. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11457. * @param url defines the url to load from
  11458. * @param scene defines the hosting scene
  11459. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11460. * @returns a promise that will resolve to the new sprite manager
  11461. */
  11462. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11463. /**
  11464. * Creates a sprite manager from a snippet saved by the sprite editor
  11465. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11466. * @param scene defines the hosting scene
  11467. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11468. * @returns a promise that will resolve to the new sprite manager
  11469. */
  11470. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11471. }
  11472. }
  11473. declare module "babylonjs/Misc/gradients" {
  11474. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11475. /** Interface used by value gradients (color, factor, ...) */
  11476. export interface IValueGradient {
  11477. /**
  11478. * Gets or sets the gradient value (between 0 and 1)
  11479. */
  11480. gradient: number;
  11481. }
  11482. /** Class used to store color4 gradient */
  11483. export class ColorGradient implements IValueGradient {
  11484. /**
  11485. * Gets or sets the gradient value (between 0 and 1)
  11486. */
  11487. gradient: number;
  11488. /**
  11489. * Gets or sets first associated color
  11490. */
  11491. color1: Color4;
  11492. /**
  11493. * Gets or sets second associated color
  11494. */
  11495. color2?: Color4 | undefined;
  11496. /**
  11497. * Creates a new color4 gradient
  11498. * @param gradient gets or sets the gradient value (between 0 and 1)
  11499. * @param color1 gets or sets first associated color
  11500. * @param color2 gets or sets first second color
  11501. */
  11502. constructor(
  11503. /**
  11504. * Gets or sets the gradient value (between 0 and 1)
  11505. */
  11506. gradient: number,
  11507. /**
  11508. * Gets or sets first associated color
  11509. */
  11510. color1: Color4,
  11511. /**
  11512. * Gets or sets second associated color
  11513. */
  11514. color2?: Color4 | undefined);
  11515. /**
  11516. * Will get a color picked randomly between color1 and color2.
  11517. * If color2 is undefined then color1 will be used
  11518. * @param result defines the target Color4 to store the result in
  11519. */
  11520. getColorToRef(result: Color4): void;
  11521. }
  11522. /** Class used to store color 3 gradient */
  11523. export class Color3Gradient implements IValueGradient {
  11524. /**
  11525. * Gets or sets the gradient value (between 0 and 1)
  11526. */
  11527. gradient: number;
  11528. /**
  11529. * Gets or sets the associated color
  11530. */
  11531. color: Color3;
  11532. /**
  11533. * Creates a new color3 gradient
  11534. * @param gradient gets or sets the gradient value (between 0 and 1)
  11535. * @param color gets or sets associated color
  11536. */
  11537. constructor(
  11538. /**
  11539. * Gets or sets the gradient value (between 0 and 1)
  11540. */
  11541. gradient: number,
  11542. /**
  11543. * Gets or sets the associated color
  11544. */
  11545. color: Color3);
  11546. }
  11547. /** Class used to store factor gradient */
  11548. export class FactorGradient implements IValueGradient {
  11549. /**
  11550. * Gets or sets the gradient value (between 0 and 1)
  11551. */
  11552. gradient: number;
  11553. /**
  11554. * Gets or sets first associated factor
  11555. */
  11556. factor1: number;
  11557. /**
  11558. * Gets or sets second associated factor
  11559. */
  11560. factor2?: number | undefined;
  11561. /**
  11562. * Creates a new factor gradient
  11563. * @param gradient gets or sets the gradient value (between 0 and 1)
  11564. * @param factor1 gets or sets first associated factor
  11565. * @param factor2 gets or sets second associated factor
  11566. */
  11567. constructor(
  11568. /**
  11569. * Gets or sets the gradient value (between 0 and 1)
  11570. */
  11571. gradient: number,
  11572. /**
  11573. * Gets or sets first associated factor
  11574. */
  11575. factor1: number,
  11576. /**
  11577. * Gets or sets second associated factor
  11578. */
  11579. factor2?: number | undefined);
  11580. /**
  11581. * Will get a number picked randomly between factor1 and factor2.
  11582. * If factor2 is undefined then factor1 will be used
  11583. * @returns the picked number
  11584. */
  11585. getFactor(): number;
  11586. }
  11587. /**
  11588. * Helper used to simplify some generic gradient tasks
  11589. */
  11590. export class GradientHelper {
  11591. /**
  11592. * Gets the current gradient from an array of IValueGradient
  11593. * @param ratio defines the current ratio to get
  11594. * @param gradients defines the array of IValueGradient
  11595. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11596. */
  11597. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11598. }
  11599. }
  11600. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11601. import { Nullable } from "babylonjs/types";
  11602. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11603. import { Scene } from "babylonjs/scene";
  11604. module "babylonjs/Engines/thinEngine" {
  11605. interface ThinEngine {
  11606. /**
  11607. * Creates a raw texture
  11608. * @param data defines the data to store in the texture
  11609. * @param width defines the width of the texture
  11610. * @param height defines the height of the texture
  11611. * @param format defines the format of the data
  11612. * @param generateMipMaps defines if the engine should generate the mip levels
  11613. * @param invertY defines if data must be stored with Y axis inverted
  11614. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11615. * @param compression defines the compression used (null by default)
  11616. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11617. * @returns the raw texture inside an InternalTexture
  11618. */
  11619. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11620. /**
  11621. * Update a raw texture
  11622. * @param texture defines the texture to update
  11623. * @param data defines the data to store in the texture
  11624. * @param format defines the format of the data
  11625. * @param invertY defines if data must be stored with Y axis inverted
  11626. */
  11627. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11628. /**
  11629. * Update a raw texture
  11630. * @param texture defines the texture to update
  11631. * @param data defines the data to store in the texture
  11632. * @param format defines the format of the data
  11633. * @param invertY defines if data must be stored with Y axis inverted
  11634. * @param compression defines the compression used (null by default)
  11635. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11636. */
  11637. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11638. /**
  11639. * Creates a new raw cube texture
  11640. * @param data defines the array of data to use to create each face
  11641. * @param size defines the size of the textures
  11642. * @param format defines the format of the data
  11643. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11644. * @param generateMipMaps defines if the engine should generate the mip levels
  11645. * @param invertY defines if data must be stored with Y axis inverted
  11646. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11647. * @param compression defines the compression used (null by default)
  11648. * @returns the cube texture as an InternalTexture
  11649. */
  11650. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11651. /**
  11652. * Update a raw cube texture
  11653. * @param texture defines the texture to udpdate
  11654. * @param data defines the data to store
  11655. * @param format defines the data format
  11656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11657. * @param invertY defines if data must be stored with Y axis inverted
  11658. */
  11659. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11660. /**
  11661. * Update a raw cube texture
  11662. * @param texture defines the texture to udpdate
  11663. * @param data defines the data to store
  11664. * @param format defines the data format
  11665. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11666. * @param invertY defines if data must be stored with Y axis inverted
  11667. * @param compression defines the compression used (null by default)
  11668. */
  11669. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11670. /**
  11671. * Update a raw cube texture
  11672. * @param texture defines the texture to udpdate
  11673. * @param data defines the data to store
  11674. * @param format defines the data format
  11675. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11676. * @param invertY defines if data must be stored with Y axis inverted
  11677. * @param compression defines the compression used (null by default)
  11678. * @param level defines which level of the texture to update
  11679. */
  11680. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11681. /**
  11682. * Creates a new raw cube texture from a specified url
  11683. * @param url defines the url where the data is located
  11684. * @param scene defines the current scene
  11685. * @param size defines the size of the textures
  11686. * @param format defines the format of the data
  11687. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11688. * @param noMipmap defines if the engine should avoid generating the mip levels
  11689. * @param callback defines a callback used to extract texture data from loaded data
  11690. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11691. * @param onLoad defines a callback called when texture is loaded
  11692. * @param onError defines a callback called if there is an error
  11693. * @returns the cube texture as an InternalTexture
  11694. */
  11695. 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;
  11696. /**
  11697. * Creates a new raw cube texture from a specified url
  11698. * @param url defines the url where the data is located
  11699. * @param scene defines the current scene
  11700. * @param size defines the size of the textures
  11701. * @param format defines the format of the data
  11702. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11703. * @param noMipmap defines if the engine should avoid generating the mip levels
  11704. * @param callback defines a callback used to extract texture data from loaded data
  11705. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11706. * @param onLoad defines a callback called when texture is loaded
  11707. * @param onError defines a callback called if there is an error
  11708. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11709. * @param invertY defines if data must be stored with Y axis inverted
  11710. * @returns the cube texture as an InternalTexture
  11711. */
  11712. 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;
  11713. /**
  11714. * Creates a new raw 3D texture
  11715. * @param data defines the data used to create the texture
  11716. * @param width defines the width of the texture
  11717. * @param height defines the height of the texture
  11718. * @param depth defines the depth of the texture
  11719. * @param format defines the format of the texture
  11720. * @param generateMipMaps defines if the engine must generate mip levels
  11721. * @param invertY defines if data must be stored with Y axis inverted
  11722. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11723. * @param compression defines the compressed used (can be null)
  11724. * @param textureType defines the compressed used (can be null)
  11725. * @returns a new raw 3D texture (stored in an InternalTexture)
  11726. */
  11727. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11728. /**
  11729. * Update a raw 3D texture
  11730. * @param texture defines the texture to update
  11731. * @param data defines the data to store
  11732. * @param format defines the data format
  11733. * @param invertY defines if data must be stored with Y axis inverted
  11734. */
  11735. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11736. /**
  11737. * Update a raw 3D texture
  11738. * @param texture defines the texture to update
  11739. * @param data defines the data to store
  11740. * @param format defines the data format
  11741. * @param invertY defines if data must be stored with Y axis inverted
  11742. * @param compression defines the used compression (can be null)
  11743. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11744. */
  11745. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11746. /**
  11747. * Creates a new raw 2D array texture
  11748. * @param data defines the data used to create the texture
  11749. * @param width defines the width of the texture
  11750. * @param height defines the height of the texture
  11751. * @param depth defines the number of layers of the texture
  11752. * @param format defines the format of the texture
  11753. * @param generateMipMaps defines if the engine must generate mip levels
  11754. * @param invertY defines if data must be stored with Y axis inverted
  11755. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11756. * @param compression defines the compressed used (can be null)
  11757. * @param textureType defines the compressed used (can be null)
  11758. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11759. */
  11760. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11761. /**
  11762. * Update a raw 2D array texture
  11763. * @param texture defines the texture to update
  11764. * @param data defines the data to store
  11765. * @param format defines the data format
  11766. * @param invertY defines if data must be stored with Y axis inverted
  11767. */
  11768. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11769. /**
  11770. * Update a raw 2D array texture
  11771. * @param texture defines the texture to update
  11772. * @param data defines the data to store
  11773. * @param format defines the data format
  11774. * @param invertY defines if data must be stored with Y axis inverted
  11775. * @param compression defines the used compression (can be null)
  11776. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11777. */
  11778. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11779. }
  11780. }
  11781. }
  11782. declare module "babylonjs/Materials/Textures/rawTexture" {
  11783. import { Texture } from "babylonjs/Materials/Textures/texture";
  11784. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11785. import { Nullable } from "babylonjs/types";
  11786. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11787. import { Scene } from "babylonjs/scene";
  11788. /**
  11789. * Raw texture can help creating a texture directly from an array of data.
  11790. * This can be super useful if you either get the data from an uncompressed source or
  11791. * if you wish to create your texture pixel by pixel.
  11792. */
  11793. export class RawTexture extends Texture {
  11794. /**
  11795. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11796. */
  11797. format: number;
  11798. /**
  11799. * Instantiates a new RawTexture.
  11800. * Raw texture can help creating a texture directly from an array of data.
  11801. * This can be super useful if you either get the data from an uncompressed source or
  11802. * if you wish to create your texture pixel by pixel.
  11803. * @param data define the array of data to use to create the texture
  11804. * @param width define the width of the texture
  11805. * @param height define the height of the texture
  11806. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11807. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11808. * @param generateMipMaps define whether mip maps should be generated or not
  11809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11811. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11812. */
  11813. constructor(data: ArrayBufferView, width: number, height: number,
  11814. /**
  11815. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11816. */
  11817. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11818. /**
  11819. * Updates the texture underlying data.
  11820. * @param data Define the new data of the texture
  11821. */
  11822. update(data: ArrayBufferView): void;
  11823. /**
  11824. * Creates a luminance 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 luminance texture
  11833. */
  11834. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11835. /**
  11836. * Creates a luminance alpha 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. * @returns the luminance alpha texture
  11845. */
  11846. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11847. /**
  11848. * Creates an alpha texture from some data.
  11849. * @param data Define the texture data
  11850. * @param width Define the width of the texture
  11851. * @param height Define the height of the texture
  11852. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11853. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11854. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11855. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11856. * @returns the alpha texture
  11857. */
  11858. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11859. /**
  11860. * Creates a RGB texture from some data.
  11861. * @param data Define the texture data
  11862. * @param width Define the width of the texture
  11863. * @param height Define the height of the texture
  11864. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11865. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11866. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11867. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11868. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11869. * @returns the RGB alpha texture
  11870. */
  11871. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11872. /**
  11873. * Creates a RGBA texture from some data.
  11874. * @param data Define the texture data
  11875. * @param width Define the width of the texture
  11876. * @param height Define the height of the texture
  11877. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11878. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11879. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11880. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11881. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11882. * @returns the RGBA texture
  11883. */
  11884. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11885. /**
  11886. * Creates a R texture from some data.
  11887. * @param data Define the texture data
  11888. * @param width Define the width of the texture
  11889. * @param height Define the height of the texture
  11890. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11891. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11892. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11893. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11894. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11895. * @returns the R texture
  11896. */
  11897. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11898. }
  11899. }
  11900. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11901. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11902. import { IndicesArray, DataArray } from "babylonjs/types";
  11903. module "babylonjs/Engines/thinEngine" {
  11904. interface ThinEngine {
  11905. /**
  11906. * Update a dynamic index buffer
  11907. * @param indexBuffer defines the target index buffer
  11908. * @param indices defines the data to update
  11909. * @param offset defines the offset in the target index buffer where update should start
  11910. */
  11911. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11912. /**
  11913. * Updates a dynamic vertex buffer.
  11914. * @param vertexBuffer the vertex buffer to update
  11915. * @param data the data used to update the vertex buffer
  11916. * @param byteOffset the byte offset of the data
  11917. * @param byteLength the byte length of the data
  11918. */
  11919. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11920. }
  11921. }
  11922. }
  11923. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11924. import { Scene } from "babylonjs/scene";
  11925. import { ISceneComponent } from "babylonjs/sceneComponent";
  11926. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11927. module "babylonjs/abstractScene" {
  11928. interface AbstractScene {
  11929. /**
  11930. * The list of procedural textures added to the scene
  11931. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11932. */
  11933. proceduralTextures: Array<ProceduralTexture>;
  11934. }
  11935. }
  11936. /**
  11937. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11938. * in a given scene.
  11939. */
  11940. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11941. /**
  11942. * The component name helpfull to identify the component in the list of scene components.
  11943. */
  11944. readonly name: string;
  11945. /**
  11946. * The scene the component belongs to.
  11947. */
  11948. scene: Scene;
  11949. /**
  11950. * Creates a new instance of the component for the given scene
  11951. * @param scene Defines the scene to register the component in
  11952. */
  11953. constructor(scene: Scene);
  11954. /**
  11955. * Registers the component in a given scene
  11956. */
  11957. register(): void;
  11958. /**
  11959. * Rebuilds the elements related to this component in case of
  11960. * context lost for instance.
  11961. */
  11962. rebuild(): void;
  11963. /**
  11964. * Disposes the component and the associated ressources.
  11965. */
  11966. dispose(): void;
  11967. private _beforeClear;
  11968. }
  11969. }
  11970. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11971. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11972. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11973. module "babylonjs/Engines/thinEngine" {
  11974. interface ThinEngine {
  11975. /**
  11976. * Creates a new render target cube texture
  11977. * @param size defines the size of the texture
  11978. * @param options defines the options used to create the texture
  11979. * @returns a new render target cube texture stored in an InternalTexture
  11980. */
  11981. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11982. }
  11983. }
  11984. }
  11985. declare module "babylonjs/Shaders/procedural.vertex" {
  11986. /** @hidden */
  11987. export var proceduralVertexShader: {
  11988. name: string;
  11989. shader: string;
  11990. };
  11991. }
  11992. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11993. import { Observable } from "babylonjs/Misc/observable";
  11994. import { Nullable } from "babylonjs/types";
  11995. import { Scene } from "babylonjs/scene";
  11996. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11997. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11998. import { Effect } from "babylonjs/Materials/effect";
  11999. import { Texture } from "babylonjs/Materials/Textures/texture";
  12000. import "babylonjs/Engines/Extensions/engine.renderTarget";
  12001. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  12002. import "babylonjs/Shaders/procedural.vertex";
  12003. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12004. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  12005. /**
  12006. * 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.
  12007. * This is the base class of any Procedural texture and contains most of the shareable code.
  12008. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12009. */
  12010. export class ProceduralTexture extends Texture {
  12011. /**
  12012. * Define if the texture is enabled or not (disabled texture will not render)
  12013. */
  12014. isEnabled: boolean;
  12015. /**
  12016. * Define if the texture must be cleared before rendering (default is true)
  12017. */
  12018. autoClear: boolean;
  12019. /**
  12020. * Callback called when the texture is generated
  12021. */
  12022. onGenerated: () => void;
  12023. /**
  12024. * Event raised when the texture is generated
  12025. */
  12026. onGeneratedObservable: Observable<ProceduralTexture>;
  12027. /**
  12028. * Event raised before the texture is generated
  12029. */
  12030. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12031. /**
  12032. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12033. */
  12034. nodeMaterialSource: Nullable<NodeMaterial>;
  12035. /** @hidden */
  12036. _generateMipMaps: boolean;
  12037. /** @hidden **/
  12038. _effect: Effect;
  12039. /** @hidden */
  12040. _textures: {
  12041. [key: string]: Texture;
  12042. };
  12043. /** @hidden */
  12044. protected _fallbackTexture: Nullable<Texture>;
  12045. private _size;
  12046. private _currentRefreshId;
  12047. private _frameId;
  12048. private _refreshRate;
  12049. private _vertexBuffers;
  12050. private _indexBuffer;
  12051. private _uniforms;
  12052. private _samplers;
  12053. private _fragment;
  12054. private _floats;
  12055. private _ints;
  12056. private _floatsArrays;
  12057. private _colors3;
  12058. private _colors4;
  12059. private _vectors2;
  12060. private _vectors3;
  12061. private _matrices;
  12062. private _fallbackTextureUsed;
  12063. private _fullEngine;
  12064. private _cachedDefines;
  12065. private _contentUpdateId;
  12066. private _contentData;
  12067. /**
  12068. * Instantiates a new procedural texture.
  12069. * 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.
  12070. * This is the base class of any Procedural texture and contains most of the shareable code.
  12071. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12072. * @param name Define the name of the texture
  12073. * @param size Define the size of the texture to create
  12074. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12075. * @param scene Define the scene the texture belongs to
  12076. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12077. * @param generateMipMaps Define if the texture should creates mip maps or not
  12078. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12079. * @param textureType The FBO internal texture type
  12080. */
  12081. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12082. /**
  12083. * The effect that is created when initializing the post process.
  12084. * @returns The created effect corresponding the the postprocess.
  12085. */
  12086. getEffect(): Effect;
  12087. /**
  12088. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12089. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12090. */
  12091. getContent(): Nullable<ArrayBufferView>;
  12092. private _createIndexBuffer;
  12093. /** @hidden */
  12094. _rebuild(): void;
  12095. /**
  12096. * Resets the texture in order to recreate its associated resources.
  12097. * This can be called in case of context loss
  12098. */
  12099. reset(): void;
  12100. protected _getDefines(): string;
  12101. /**
  12102. * Is the texture ready to be used ? (rendered at least once)
  12103. * @returns true if ready, otherwise, false.
  12104. */
  12105. isReady(): boolean;
  12106. /**
  12107. * Resets the refresh counter of the texture and start bak from scratch.
  12108. * Could be useful to regenerate the texture if it is setup to render only once.
  12109. */
  12110. resetRefreshCounter(): void;
  12111. /**
  12112. * Set the fragment shader to use in order to render the texture.
  12113. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12114. */
  12115. setFragment(fragment: any): void;
  12116. /**
  12117. * Define the refresh rate of the texture or the rendering frequency.
  12118. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12119. */
  12120. get refreshRate(): number;
  12121. set refreshRate(value: number);
  12122. /** @hidden */
  12123. _shouldRender(): boolean;
  12124. /**
  12125. * Get the size the texture is rendering at.
  12126. * @returns the size (on cube texture it is always squared)
  12127. */
  12128. getRenderSize(): RenderTargetTextureSize;
  12129. /**
  12130. * Resize the texture to new value.
  12131. * @param size Define the new size the texture should have
  12132. * @param generateMipMaps Define whether the new texture should create mip maps
  12133. */
  12134. resize(size: number, generateMipMaps: boolean): void;
  12135. private _checkUniform;
  12136. /**
  12137. * Set a texture in the shader program used to render.
  12138. * @param name Define the name of the uniform samplers as defined in the shader
  12139. * @param texture Define the texture to bind to this sampler
  12140. * @return the texture itself allowing "fluent" like uniform updates
  12141. */
  12142. setTexture(name: string, texture: Texture): ProceduralTexture;
  12143. /**
  12144. * Set a float in the shader.
  12145. * @param name Define the name of the uniform as defined in the shader
  12146. * @param value Define the value to give to the uniform
  12147. * @return the texture itself allowing "fluent" like uniform updates
  12148. */
  12149. setFloat(name: string, value: number): ProceduralTexture;
  12150. /**
  12151. * Set a int in the shader.
  12152. * @param name Define the name of the uniform as defined in the shader
  12153. * @param value Define the value to give to the uniform
  12154. * @return the texture itself allowing "fluent" like uniform updates
  12155. */
  12156. setInt(name: string, value: number): ProceduralTexture;
  12157. /**
  12158. * Set an array of floats in the shader.
  12159. * @param name Define the name of the uniform as defined in the shader
  12160. * @param value Define the value to give to the uniform
  12161. * @return the texture itself allowing "fluent" like uniform updates
  12162. */
  12163. setFloats(name: string, value: number[]): ProceduralTexture;
  12164. /**
  12165. * Set a vec3 in the shader from a Color3.
  12166. * @param name Define the name of the uniform as defined in the shader
  12167. * @param value Define the value to give to the uniform
  12168. * @return the texture itself allowing "fluent" like uniform updates
  12169. */
  12170. setColor3(name: string, value: Color3): ProceduralTexture;
  12171. /**
  12172. * Set a vec4 in the shader from a Color4.
  12173. * @param name Define the name of the uniform as defined in the shader
  12174. * @param value Define the value to give to the uniform
  12175. * @return the texture itself allowing "fluent" like uniform updates
  12176. */
  12177. setColor4(name: string, value: Color4): ProceduralTexture;
  12178. /**
  12179. * Set a vec2 in the shader from a Vector2.
  12180. * @param name Define the name of the uniform as defined in the shader
  12181. * @param value Define the value to give to the uniform
  12182. * @return the texture itself allowing "fluent" like uniform updates
  12183. */
  12184. setVector2(name: string, value: Vector2): ProceduralTexture;
  12185. /**
  12186. * Set a vec3 in the shader from a Vector3.
  12187. * @param name Define the name of the uniform as defined in the shader
  12188. * @param value Define the value to give to the uniform
  12189. * @return the texture itself allowing "fluent" like uniform updates
  12190. */
  12191. setVector3(name: string, value: Vector3): ProceduralTexture;
  12192. /**
  12193. * Set a mat4 in the shader from a MAtrix.
  12194. * @param name Define the name of the uniform as defined in the shader
  12195. * @param value Define the value to give to the uniform
  12196. * @return the texture itself allowing "fluent" like uniform updates
  12197. */
  12198. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12199. /**
  12200. * Render the texture to its associated render target.
  12201. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12202. */
  12203. render(useCameraPostProcess?: boolean): void;
  12204. /**
  12205. * Clone the texture.
  12206. * @returns the cloned texture
  12207. */
  12208. clone(): ProceduralTexture;
  12209. /**
  12210. * Dispose the texture and release its asoociated resources.
  12211. */
  12212. dispose(): void;
  12213. }
  12214. }
  12215. declare module "babylonjs/Particles/baseParticleSystem" {
  12216. import { Nullable } from "babylonjs/types";
  12217. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12219. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12220. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12221. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12222. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12223. import { Color4 } from "babylonjs/Maths/math.color";
  12224. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12225. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12226. import { Animation } from "babylonjs/Animations/animation";
  12227. import { Scene } from "babylonjs/scene";
  12228. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12229. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12230. /**
  12231. * This represents the base class for particle system in Babylon.
  12232. * 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.
  12233. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12234. * @example https://doc.babylonjs.com/babylon101/particles
  12235. */
  12236. export class BaseParticleSystem {
  12237. /**
  12238. * Source color is added to the destination color without alpha affecting the result
  12239. */
  12240. static BLENDMODE_ONEONE: number;
  12241. /**
  12242. * Blend current color and particle color using particle’s alpha
  12243. */
  12244. static BLENDMODE_STANDARD: number;
  12245. /**
  12246. * Add current color and particle color multiplied by particle’s alpha
  12247. */
  12248. static BLENDMODE_ADD: number;
  12249. /**
  12250. * Multiply current color with particle color
  12251. */
  12252. static BLENDMODE_MULTIPLY: number;
  12253. /**
  12254. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12255. */
  12256. static BLENDMODE_MULTIPLYADD: number;
  12257. /**
  12258. * List of animations used by the particle system.
  12259. */
  12260. animations: Animation[];
  12261. /**
  12262. * Gets or sets the unique id of the particle system
  12263. */
  12264. uniqueId: number;
  12265. /**
  12266. * The id of the Particle system.
  12267. */
  12268. id: string;
  12269. /**
  12270. * The friendly name of the Particle system.
  12271. */
  12272. name: string;
  12273. /**
  12274. * Snippet ID if the particle system was created from the snippet server
  12275. */
  12276. snippetId: string;
  12277. /**
  12278. * The rendering group used by the Particle system to chose when to render.
  12279. */
  12280. renderingGroupId: number;
  12281. /**
  12282. * The emitter represents the Mesh or position we are attaching the particle system to.
  12283. */
  12284. emitter: Nullable<AbstractMesh | Vector3>;
  12285. /**
  12286. * The maximum number of particles to emit per frame
  12287. */
  12288. emitRate: number;
  12289. /**
  12290. * If you want to launch only a few particles at once, that can be done, as well.
  12291. */
  12292. manualEmitCount: number;
  12293. /**
  12294. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12295. */
  12296. updateSpeed: number;
  12297. /**
  12298. * The amount of time the particle system is running (depends of the overall update speed).
  12299. */
  12300. targetStopDuration: number;
  12301. /**
  12302. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12303. */
  12304. disposeOnStop: boolean;
  12305. /**
  12306. * Minimum power of emitting particles.
  12307. */
  12308. minEmitPower: number;
  12309. /**
  12310. * Maximum power of emitting particles.
  12311. */
  12312. maxEmitPower: number;
  12313. /**
  12314. * Minimum life time of emitting particles.
  12315. */
  12316. minLifeTime: number;
  12317. /**
  12318. * Maximum life time of emitting particles.
  12319. */
  12320. maxLifeTime: number;
  12321. /**
  12322. * Minimum Size of emitting particles.
  12323. */
  12324. minSize: number;
  12325. /**
  12326. * Maximum Size of emitting particles.
  12327. */
  12328. maxSize: number;
  12329. /**
  12330. * Minimum scale of emitting particles on X axis.
  12331. */
  12332. minScaleX: number;
  12333. /**
  12334. * Maximum scale of emitting particles on X axis.
  12335. */
  12336. maxScaleX: number;
  12337. /**
  12338. * Minimum scale of emitting particles on Y axis.
  12339. */
  12340. minScaleY: number;
  12341. /**
  12342. * Maximum scale of emitting particles on Y axis.
  12343. */
  12344. maxScaleY: number;
  12345. /**
  12346. * Gets or sets the minimal initial rotation in radians.
  12347. */
  12348. minInitialRotation: number;
  12349. /**
  12350. * Gets or sets the maximal initial rotation in radians.
  12351. */
  12352. maxInitialRotation: number;
  12353. /**
  12354. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12355. */
  12356. minAngularSpeed: number;
  12357. /**
  12358. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12359. */
  12360. maxAngularSpeed: number;
  12361. /**
  12362. * The texture used to render each particle. (this can be a spritesheet)
  12363. */
  12364. particleTexture: Nullable<BaseTexture>;
  12365. /**
  12366. * The layer mask we are rendering the particles through.
  12367. */
  12368. layerMask: number;
  12369. /**
  12370. * This can help using your own shader to render the particle system.
  12371. * The according effect will be created
  12372. */
  12373. customShader: any;
  12374. /**
  12375. * By default particle system starts as soon as they are created. This prevents the
  12376. * automatic start to happen and let you decide when to start emitting particles.
  12377. */
  12378. preventAutoStart: boolean;
  12379. private _noiseTexture;
  12380. /**
  12381. * Gets or sets a texture used to add random noise to particle positions
  12382. */
  12383. get noiseTexture(): Nullable<ProceduralTexture>;
  12384. set noiseTexture(value: Nullable<ProceduralTexture>);
  12385. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12386. noiseStrength: Vector3;
  12387. /**
  12388. * Callback triggered when the particle animation is ending.
  12389. */
  12390. onAnimationEnd: Nullable<() => void>;
  12391. /**
  12392. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12393. */
  12394. blendMode: number;
  12395. /**
  12396. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12397. * to override the particles.
  12398. */
  12399. forceDepthWrite: boolean;
  12400. /** 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 */
  12401. preWarmCycles: number;
  12402. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12403. preWarmStepOffset: number;
  12404. /**
  12405. * 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)
  12406. */
  12407. spriteCellChangeSpeed: number;
  12408. /**
  12409. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12410. */
  12411. startSpriteCellID: number;
  12412. /**
  12413. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12414. */
  12415. endSpriteCellID: number;
  12416. /**
  12417. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12418. */
  12419. spriteCellWidth: number;
  12420. /**
  12421. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12422. */
  12423. spriteCellHeight: number;
  12424. /**
  12425. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12426. */
  12427. spriteRandomStartCell: boolean;
  12428. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12429. translationPivot: Vector2;
  12430. /** @hidden */
  12431. protected _isAnimationSheetEnabled: boolean;
  12432. /**
  12433. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12434. */
  12435. beginAnimationOnStart: boolean;
  12436. /**
  12437. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12438. */
  12439. beginAnimationFrom: number;
  12440. /**
  12441. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12442. */
  12443. beginAnimationTo: number;
  12444. /**
  12445. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12446. */
  12447. beginAnimationLoop: boolean;
  12448. /**
  12449. * Gets or sets a world offset applied to all particles
  12450. */
  12451. worldOffset: Vector3;
  12452. /**
  12453. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12454. */
  12455. get isAnimationSheetEnabled(): boolean;
  12456. set isAnimationSheetEnabled(value: boolean);
  12457. /**
  12458. * Get hosting scene
  12459. * @returns the scene
  12460. */
  12461. getScene(): Nullable<Scene>;
  12462. /**
  12463. * You can use gravity if you want to give an orientation to your particles.
  12464. */
  12465. gravity: Vector3;
  12466. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12467. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12468. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12469. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12470. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12471. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12472. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12473. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12474. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12475. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12476. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12477. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12478. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12479. /**
  12480. * Defines the delay in milliseconds before starting the system (0 by default)
  12481. */
  12482. startDelay: number;
  12483. /**
  12484. * Gets the current list of drag gradients.
  12485. * You must use addDragGradient and removeDragGradient to udpate this list
  12486. * @returns the list of drag gradients
  12487. */
  12488. getDragGradients(): Nullable<Array<FactorGradient>>;
  12489. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12490. limitVelocityDamping: number;
  12491. /**
  12492. * Gets the current list of limit velocity gradients.
  12493. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12494. * @returns the list of limit velocity gradients
  12495. */
  12496. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12497. /**
  12498. * Gets the current list of color gradients.
  12499. * You must use addColorGradient and removeColorGradient to udpate this list
  12500. * @returns the list of color gradients
  12501. */
  12502. getColorGradients(): Nullable<Array<ColorGradient>>;
  12503. /**
  12504. * Gets the current list of size gradients.
  12505. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12506. * @returns the list of size gradients
  12507. */
  12508. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12509. /**
  12510. * Gets the current list of color remap gradients.
  12511. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12512. * @returns the list of color remap gradients
  12513. */
  12514. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12515. /**
  12516. * Gets the current list of alpha remap gradients.
  12517. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12518. * @returns the list of alpha remap gradients
  12519. */
  12520. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12521. /**
  12522. * Gets the current list of life time gradients.
  12523. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12524. * @returns the list of life time gradients
  12525. */
  12526. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12527. /**
  12528. * Gets the current list of angular speed gradients.
  12529. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12530. * @returns the list of angular speed gradients
  12531. */
  12532. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12533. /**
  12534. * Gets the current list of velocity gradients.
  12535. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12536. * @returns the list of velocity gradients
  12537. */
  12538. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12539. /**
  12540. * Gets the current list of start size gradients.
  12541. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12542. * @returns the list of start size gradients
  12543. */
  12544. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12545. /**
  12546. * Gets the current list of emit rate gradients.
  12547. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12548. * @returns the list of emit rate gradients
  12549. */
  12550. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12551. /**
  12552. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12553. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12554. */
  12555. get direction1(): Vector3;
  12556. set direction1(value: Vector3);
  12557. /**
  12558. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12559. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12560. */
  12561. get direction2(): Vector3;
  12562. set direction2(value: Vector3);
  12563. /**
  12564. * 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.
  12565. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12566. */
  12567. get minEmitBox(): Vector3;
  12568. set minEmitBox(value: Vector3);
  12569. /**
  12570. * 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.
  12571. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12572. */
  12573. get maxEmitBox(): Vector3;
  12574. set maxEmitBox(value: Vector3);
  12575. /**
  12576. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12577. */
  12578. color1: Color4;
  12579. /**
  12580. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12581. */
  12582. color2: Color4;
  12583. /**
  12584. * Color the particle will have at the end of its lifetime
  12585. */
  12586. colorDead: Color4;
  12587. /**
  12588. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12589. */
  12590. textureMask: Color4;
  12591. /**
  12592. * The particle emitter type defines the emitter used by the particle system.
  12593. * It can be for example box, sphere, or cone...
  12594. */
  12595. particleEmitterType: IParticleEmitterType;
  12596. /** @hidden */
  12597. _isSubEmitter: boolean;
  12598. /**
  12599. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12600. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12601. */
  12602. billboardMode: number;
  12603. protected _isBillboardBased: boolean;
  12604. /**
  12605. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12606. */
  12607. get isBillboardBased(): boolean;
  12608. set isBillboardBased(value: boolean);
  12609. /**
  12610. * The scene the particle system belongs to.
  12611. */
  12612. protected _scene: Nullable<Scene>;
  12613. /**
  12614. * The engine the particle system belongs to.
  12615. */
  12616. protected _engine: ThinEngine;
  12617. /**
  12618. * Local cache of defines for image processing.
  12619. */
  12620. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12621. /**
  12622. * Default configuration related to image processing available in the standard Material.
  12623. */
  12624. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12625. /**
  12626. * Gets the image processing configuration used either in this material.
  12627. */
  12628. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12629. /**
  12630. * Sets the Default image processing configuration used either in the this material.
  12631. *
  12632. * If sets to null, the scene one is in use.
  12633. */
  12634. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12635. /**
  12636. * Attaches a new image processing configuration to the Standard Material.
  12637. * @param configuration
  12638. */
  12639. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12640. /** @hidden */
  12641. protected _reset(): void;
  12642. /** @hidden */
  12643. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12644. /**
  12645. * Instantiates a particle system.
  12646. * 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.
  12647. * @param name The name of the particle system
  12648. */
  12649. constructor(name: string);
  12650. /**
  12651. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12654. * @returns the emitter
  12655. */
  12656. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12657. /**
  12658. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12659. * @param radius The radius of the hemisphere to emit from
  12660. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12661. * @returns the emitter
  12662. */
  12663. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12664. /**
  12665. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12666. * @param radius The radius of the sphere to emit from
  12667. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12668. * @returns the emitter
  12669. */
  12670. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12671. /**
  12672. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12673. * @param radius The radius of the sphere to emit from
  12674. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12675. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12676. * @returns the emitter
  12677. */
  12678. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12679. /**
  12680. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12681. * @param radius The radius of the emission cylinder
  12682. * @param height The height of the emission cylinder
  12683. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12684. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12685. * @returns the emitter
  12686. */
  12687. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12688. /**
  12689. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12690. * @param radius The radius of the cylinder to emit from
  12691. * @param height The height of the emission cylinder
  12692. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12695. * @returns the emitter
  12696. */
  12697. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12698. /**
  12699. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12700. * @param radius The radius of the cone to emit from
  12701. * @param angle The base angle of the cone
  12702. * @returns the emitter
  12703. */
  12704. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12705. /**
  12706. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12707. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12708. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12709. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12710. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12711. * @returns the emitter
  12712. */
  12713. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12714. }
  12715. }
  12716. declare module "babylonjs/Particles/subEmitter" {
  12717. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12718. import { Scene } from "babylonjs/scene";
  12719. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12720. /**
  12721. * Type of sub emitter
  12722. */
  12723. export enum SubEmitterType {
  12724. /**
  12725. * Attached to the particle over it's lifetime
  12726. */
  12727. ATTACHED = 0,
  12728. /**
  12729. * Created when the particle dies
  12730. */
  12731. END = 1
  12732. }
  12733. /**
  12734. * Sub emitter class used to emit particles from an existing particle
  12735. */
  12736. export class SubEmitter {
  12737. /**
  12738. * the particle system to be used by the sub emitter
  12739. */
  12740. particleSystem: ParticleSystem;
  12741. /**
  12742. * Type of the submitter (Default: END)
  12743. */
  12744. type: SubEmitterType;
  12745. /**
  12746. * 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)
  12747. * Note: This only is supported when using an emitter of type Mesh
  12748. */
  12749. inheritDirection: boolean;
  12750. /**
  12751. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12752. */
  12753. inheritedVelocityAmount: number;
  12754. /**
  12755. * Creates a sub emitter
  12756. * @param particleSystem the particle system to be used by the sub emitter
  12757. */
  12758. constructor(
  12759. /**
  12760. * the particle system to be used by the sub emitter
  12761. */
  12762. particleSystem: ParticleSystem);
  12763. /**
  12764. * Clones the sub emitter
  12765. * @returns the cloned sub emitter
  12766. */
  12767. clone(): SubEmitter;
  12768. /**
  12769. * Serialize current object to a JSON object
  12770. * @returns the serialized object
  12771. */
  12772. serialize(): any;
  12773. /** @hidden */
  12774. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12775. /**
  12776. * Creates a new SubEmitter from a serialized JSON version
  12777. * @param serializationObject defines the JSON object to read from
  12778. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12779. * @param rootUrl defines the rootUrl for data loading
  12780. * @returns a new SubEmitter
  12781. */
  12782. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12783. /** Release associated resources */
  12784. dispose(): void;
  12785. }
  12786. }
  12787. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12788. /** @hidden */
  12789. export var imageProcessingDeclaration: {
  12790. name: string;
  12791. shader: string;
  12792. };
  12793. }
  12794. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12795. /** @hidden */
  12796. export var imageProcessingFunctions: {
  12797. name: string;
  12798. shader: string;
  12799. };
  12800. }
  12801. declare module "babylonjs/Shaders/particles.fragment" {
  12802. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12803. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12804. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12805. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12806. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12807. /** @hidden */
  12808. export var particlesPixelShader: {
  12809. name: string;
  12810. shader: string;
  12811. };
  12812. }
  12813. declare module "babylonjs/Shaders/particles.vertex" {
  12814. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12815. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12816. /** @hidden */
  12817. export var particlesVertexShader: {
  12818. name: string;
  12819. shader: string;
  12820. };
  12821. }
  12822. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12823. import { Nullable } from "babylonjs/types";
  12824. import { Plane } from "babylonjs/Maths/math";
  12825. /**
  12826. * Interface used to define entities containing multiple clip planes
  12827. */
  12828. export interface IClipPlanesHolder {
  12829. /**
  12830. * Gets or sets the active clipplane 1
  12831. */
  12832. clipPlane: Nullable<Plane>;
  12833. /**
  12834. * Gets or sets the active clipplane 2
  12835. */
  12836. clipPlane2: Nullable<Plane>;
  12837. /**
  12838. * Gets or sets the active clipplane 3
  12839. */
  12840. clipPlane3: Nullable<Plane>;
  12841. /**
  12842. * Gets or sets the active clipplane 4
  12843. */
  12844. clipPlane4: Nullable<Plane>;
  12845. /**
  12846. * Gets or sets the active clipplane 5
  12847. */
  12848. clipPlane5: Nullable<Plane>;
  12849. /**
  12850. * Gets or sets the active clipplane 6
  12851. */
  12852. clipPlane6: Nullable<Plane>;
  12853. }
  12854. }
  12855. declare module "babylonjs/Materials/thinMaterialHelper" {
  12856. import { Effect } from "babylonjs/Materials/effect";
  12857. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12858. /**
  12859. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12860. *
  12861. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12862. *
  12863. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12864. */
  12865. export class ThinMaterialHelper {
  12866. /**
  12867. * Binds the clip plane information from the holder to the effect.
  12868. * @param effect The effect we are binding the data to
  12869. * @param holder The entity containing the clip plane information
  12870. */
  12871. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12872. }
  12873. }
  12874. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12875. module "babylonjs/Engines/thinEngine" {
  12876. interface ThinEngine {
  12877. /**
  12878. * Sets alpha constants used by some alpha blending modes
  12879. * @param r defines the red component
  12880. * @param g defines the green component
  12881. * @param b defines the blue component
  12882. * @param a defines the alpha component
  12883. */
  12884. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12885. /**
  12886. * Sets the current alpha mode
  12887. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12888. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12889. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12890. */
  12891. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12892. /**
  12893. * Gets the current alpha mode
  12894. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12895. * @returns the current alpha mode
  12896. */
  12897. getAlphaMode(): number;
  12898. /**
  12899. * Sets the current alpha equation
  12900. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12901. */
  12902. setAlphaEquation(equation: number): void;
  12903. /**
  12904. * Gets the current alpha equation.
  12905. * @returns the current alpha equation
  12906. */
  12907. getAlphaEquation(): number;
  12908. }
  12909. }
  12910. }
  12911. declare module "babylonjs/Particles/particleSystem" {
  12912. import { Nullable } from "babylonjs/types";
  12913. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12914. import { Observable } from "babylonjs/Misc/observable";
  12915. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12916. import { Effect } from "babylonjs/Materials/effect";
  12917. import { IDisposable } from "babylonjs/scene";
  12918. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12919. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12920. import { Particle } from "babylonjs/Particles/particle";
  12921. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12922. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12923. import "babylonjs/Shaders/particles.fragment";
  12924. import "babylonjs/Shaders/particles.vertex";
  12925. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12926. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12927. import "babylonjs/Engines/Extensions/engine.alpha";
  12928. import { Scene } from "babylonjs/scene";
  12929. /**
  12930. * This represents a particle system in Babylon.
  12931. * 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.
  12932. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12933. * @example https://doc.babylonjs.com/babylon101/particles
  12934. */
  12935. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12936. /**
  12937. * Billboard mode will only apply to Y axis
  12938. */
  12939. static readonly BILLBOARDMODE_Y: number;
  12940. /**
  12941. * Billboard mode will apply to all axes
  12942. */
  12943. static readonly BILLBOARDMODE_ALL: number;
  12944. /**
  12945. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12946. */
  12947. static readonly BILLBOARDMODE_STRETCHED: number;
  12948. /**
  12949. * This function can be defined to provide custom update for active particles.
  12950. * This function will be called instead of regular update (age, position, color, etc.).
  12951. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12952. */
  12953. updateFunction: (particles: Particle[]) => void;
  12954. private _emitterWorldMatrix;
  12955. /**
  12956. * This function can be defined to specify initial direction for every new particle.
  12957. * It by default use the emitterType defined function
  12958. */
  12959. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12960. /**
  12961. * This function can be defined to specify initial position for every new particle.
  12962. * It by default use the emitterType defined function
  12963. */
  12964. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12965. /**
  12966. * @hidden
  12967. */
  12968. _inheritedVelocityOffset: Vector3;
  12969. /**
  12970. * An event triggered when the system is disposed
  12971. */
  12972. onDisposeObservable: Observable<IParticleSystem>;
  12973. /**
  12974. * An event triggered when the system is stopped
  12975. */
  12976. onStoppedObservable: Observable<IParticleSystem>;
  12977. private _onDisposeObserver;
  12978. /**
  12979. * Sets a callback that will be triggered when the system is disposed
  12980. */
  12981. set onDispose(callback: () => void);
  12982. private _particles;
  12983. private _epsilon;
  12984. private _capacity;
  12985. private _stockParticles;
  12986. private _newPartsExcess;
  12987. private _vertexData;
  12988. private _vertexBuffer;
  12989. private _vertexBuffers;
  12990. private _spriteBuffer;
  12991. private _indexBuffer;
  12992. private _effect;
  12993. private _customEffect;
  12994. private _cachedDefines;
  12995. private _scaledColorStep;
  12996. private _colorDiff;
  12997. private _scaledDirection;
  12998. private _scaledGravity;
  12999. private _currentRenderId;
  13000. private _alive;
  13001. private _useInstancing;
  13002. private _started;
  13003. private _stopped;
  13004. private _actualFrame;
  13005. private _scaledUpdateSpeed;
  13006. private _vertexBufferSize;
  13007. /** @hidden */
  13008. _currentEmitRateGradient: Nullable<FactorGradient>;
  13009. /** @hidden */
  13010. _currentEmitRate1: number;
  13011. /** @hidden */
  13012. _currentEmitRate2: number;
  13013. /** @hidden */
  13014. _currentStartSizeGradient: Nullable<FactorGradient>;
  13015. /** @hidden */
  13016. _currentStartSize1: number;
  13017. /** @hidden */
  13018. _currentStartSize2: number;
  13019. private readonly _rawTextureWidth;
  13020. private _rampGradientsTexture;
  13021. private _useRampGradients;
  13022. /** Gets or sets a matrix to use to compute projection */
  13023. defaultProjectionMatrix: Matrix;
  13024. /** Gets or sets a matrix to use to compute view */
  13025. defaultViewMatrix: Matrix;
  13026. /** Gets or sets a boolean indicating that ramp gradients must be used
  13027. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13028. */
  13029. get useRampGradients(): boolean;
  13030. set useRampGradients(value: boolean);
  13031. /**
  13032. * 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.
  13033. * 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: [])
  13034. */
  13035. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13036. private _subEmitters;
  13037. /**
  13038. * @hidden
  13039. * If the particle systems emitter should be disposed when the particle system is disposed
  13040. */
  13041. _disposeEmitterOnDispose: boolean;
  13042. /**
  13043. * The current active Sub-systems, this property is used by the root particle system only.
  13044. */
  13045. activeSubSystems: Array<ParticleSystem>;
  13046. /**
  13047. * Specifies if the particles are updated in emitter local space or world space
  13048. */
  13049. isLocal: boolean;
  13050. private _rootParticleSystem;
  13051. /**
  13052. * Gets the current list of active particles
  13053. */
  13054. get particles(): Particle[];
  13055. /**
  13056. * Gets the number of particles active at the same time.
  13057. * @returns The number of active particles.
  13058. */
  13059. getActiveCount(): number;
  13060. /**
  13061. * Returns the string "ParticleSystem"
  13062. * @returns a string containing the class name
  13063. */
  13064. getClassName(): string;
  13065. /**
  13066. * Gets a boolean indicating that the system is stopping
  13067. * @returns true if the system is currently stopping
  13068. */
  13069. isStopping(): boolean;
  13070. /**
  13071. * Gets the custom effect used to render the particles
  13072. * @param blendMode Blend mode for which the effect should be retrieved
  13073. * @returns The effect
  13074. */
  13075. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13076. /**
  13077. * Sets the custom effect used to render the particles
  13078. * @param effect The effect to set
  13079. * @param blendMode Blend mode for which the effect should be set
  13080. */
  13081. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13082. /** @hidden */
  13083. private _onBeforeDrawParticlesObservable;
  13084. /**
  13085. * Observable that will be called just before the particles are drawn
  13086. */
  13087. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13088. /**
  13089. * Gets the name of the particle vertex shader
  13090. */
  13091. get vertexShaderName(): string;
  13092. /**
  13093. * Instantiates a particle system.
  13094. * 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.
  13095. * @param name The name of the particle system
  13096. * @param capacity The max number of particles alive at the same time
  13097. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13098. * @param customEffect a custom effect used to change the way particles are rendered by default
  13099. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13100. * @param epsilon Offset used to render the particles
  13101. */
  13102. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13103. private _addFactorGradient;
  13104. private _removeFactorGradient;
  13105. /**
  13106. * Adds a new life time gradient
  13107. * @param gradient defines the gradient to use (between 0 and 1)
  13108. * @param factor defines the life time factor to affect to the specified gradient
  13109. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13110. * @returns the current particle system
  13111. */
  13112. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13113. /**
  13114. * Remove a specific life time gradient
  13115. * @param gradient defines the gradient to remove
  13116. * @returns the current particle system
  13117. */
  13118. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13119. /**
  13120. * Adds a new size gradient
  13121. * @param gradient defines the gradient to use (between 0 and 1)
  13122. * @param factor defines the size factor to affect to the specified gradient
  13123. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13124. * @returns the current particle system
  13125. */
  13126. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13127. /**
  13128. * Remove a specific size gradient
  13129. * @param gradient defines the gradient to remove
  13130. * @returns the current particle system
  13131. */
  13132. removeSizeGradient(gradient: number): IParticleSystem;
  13133. /**
  13134. * Adds a new color remap gradient
  13135. * @param gradient defines the gradient to use (between 0 and 1)
  13136. * @param min defines the color remap minimal range
  13137. * @param max defines the color remap maximal range
  13138. * @returns the current particle system
  13139. */
  13140. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13141. /**
  13142. * Remove a specific color remap gradient
  13143. * @param gradient defines the gradient to remove
  13144. * @returns the current particle system
  13145. */
  13146. removeColorRemapGradient(gradient: number): IParticleSystem;
  13147. /**
  13148. * Adds a new alpha remap gradient
  13149. * @param gradient defines the gradient to use (between 0 and 1)
  13150. * @param min defines the alpha remap minimal range
  13151. * @param max defines the alpha remap maximal range
  13152. * @returns the current particle system
  13153. */
  13154. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13155. /**
  13156. * Remove a specific alpha remap gradient
  13157. * @param gradient defines the gradient to remove
  13158. * @returns the current particle system
  13159. */
  13160. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13161. /**
  13162. * Adds a new angular speed gradient
  13163. * @param gradient defines the gradient to use (between 0 and 1)
  13164. * @param factor defines the angular speed to affect to the specified gradient
  13165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13166. * @returns the current particle system
  13167. */
  13168. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13169. /**
  13170. * Remove a specific angular speed gradient
  13171. * @param gradient defines the gradient to remove
  13172. * @returns the current particle system
  13173. */
  13174. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13175. /**
  13176. * Adds a new velocity gradient
  13177. * @param gradient defines the gradient to use (between 0 and 1)
  13178. * @param factor defines the velocity to affect to the specified gradient
  13179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13180. * @returns the current particle system
  13181. */
  13182. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13183. /**
  13184. * Remove a specific velocity gradient
  13185. * @param gradient defines the gradient to remove
  13186. * @returns the current particle system
  13187. */
  13188. removeVelocityGradient(gradient: number): IParticleSystem;
  13189. /**
  13190. * Adds a new limit velocity gradient
  13191. * @param gradient defines the gradient to use (between 0 and 1)
  13192. * @param factor defines the limit velocity value to affect to the specified gradient
  13193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13194. * @returns the current particle system
  13195. */
  13196. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13197. /**
  13198. * Remove a specific limit velocity gradient
  13199. * @param gradient defines the gradient to remove
  13200. * @returns the current particle system
  13201. */
  13202. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13203. /**
  13204. * Adds a new drag gradient
  13205. * @param gradient defines the gradient to use (between 0 and 1)
  13206. * @param factor defines the drag value to affect to the specified gradient
  13207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13208. * @returns the current particle system
  13209. */
  13210. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13211. /**
  13212. * Remove a specific drag gradient
  13213. * @param gradient defines the gradient to remove
  13214. * @returns the current particle system
  13215. */
  13216. removeDragGradient(gradient: number): IParticleSystem;
  13217. /**
  13218. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13219. * @param gradient defines the gradient to use (between 0 and 1)
  13220. * @param factor defines the emit rate value to affect to the specified gradient
  13221. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13222. * @returns the current particle system
  13223. */
  13224. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13225. /**
  13226. * Remove a specific emit rate gradient
  13227. * @param gradient defines the gradient to remove
  13228. * @returns the current particle system
  13229. */
  13230. removeEmitRateGradient(gradient: number): IParticleSystem;
  13231. /**
  13232. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13233. * @param gradient defines the gradient to use (between 0 and 1)
  13234. * @param factor defines the start size value to affect to the specified gradient
  13235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13236. * @returns the current particle system
  13237. */
  13238. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13239. /**
  13240. * Remove a specific start size gradient
  13241. * @param gradient defines the gradient to remove
  13242. * @returns the current particle system
  13243. */
  13244. removeStartSizeGradient(gradient: number): IParticleSystem;
  13245. private _createRampGradientTexture;
  13246. /**
  13247. * Gets the current list of ramp gradients.
  13248. * You must use addRampGradient and removeRampGradient to udpate this list
  13249. * @returns the list of ramp gradients
  13250. */
  13251. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13252. /** Force the system to rebuild all gradients that need to be resync */
  13253. forceRefreshGradients(): void;
  13254. private _syncRampGradientTexture;
  13255. /**
  13256. * Adds a new ramp gradient used to remap particle colors
  13257. * @param gradient defines the gradient to use (between 0 and 1)
  13258. * @param color defines the color to affect to the specified gradient
  13259. * @returns the current particle system
  13260. */
  13261. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13262. /**
  13263. * Remove a specific ramp gradient
  13264. * @param gradient defines the gradient to remove
  13265. * @returns the current particle system
  13266. */
  13267. removeRampGradient(gradient: number): ParticleSystem;
  13268. /**
  13269. * Adds a new color gradient
  13270. * @param gradient defines the gradient to use (between 0 and 1)
  13271. * @param color1 defines the color to affect to the specified gradient
  13272. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13273. * @returns this particle system
  13274. */
  13275. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13276. /**
  13277. * Remove a specific color gradient
  13278. * @param gradient defines the gradient to remove
  13279. * @returns this particle system
  13280. */
  13281. removeColorGradient(gradient: number): IParticleSystem;
  13282. private _fetchR;
  13283. protected _reset(): void;
  13284. private _resetEffect;
  13285. private _createVertexBuffers;
  13286. private _createIndexBuffer;
  13287. /**
  13288. * Gets the maximum number of particles active at the same time.
  13289. * @returns The max number of active particles.
  13290. */
  13291. getCapacity(): number;
  13292. /**
  13293. * Gets whether there are still active particles in the system.
  13294. * @returns True if it is alive, otherwise false.
  13295. */
  13296. isAlive(): boolean;
  13297. /**
  13298. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13299. * @returns True if it has been started, otherwise false.
  13300. */
  13301. isStarted(): boolean;
  13302. private _prepareSubEmitterInternalArray;
  13303. /**
  13304. * Starts the particle system and begins to emit
  13305. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13306. */
  13307. start(delay?: number): void;
  13308. /**
  13309. * Stops the particle system.
  13310. * @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.
  13311. */
  13312. stop(stopSubEmitters?: boolean): void;
  13313. /**
  13314. * Remove all active particles
  13315. */
  13316. reset(): void;
  13317. /**
  13318. * @hidden (for internal use only)
  13319. */
  13320. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13321. /**
  13322. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13323. * Its lifetime will start back at 0.
  13324. */
  13325. recycleParticle: (particle: Particle) => void;
  13326. private _stopSubEmitters;
  13327. private _createParticle;
  13328. private _removeFromRoot;
  13329. private _emitFromParticle;
  13330. private _update;
  13331. /** @hidden */
  13332. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13333. /** @hidden */
  13334. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13335. /**
  13336. * Fill the defines array according to the current settings of the particle system
  13337. * @param defines Array to be updated
  13338. * @param blendMode blend mode to take into account when updating the array
  13339. */
  13340. fillDefines(defines: Array<string>, blendMode: number): void;
  13341. /**
  13342. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13343. * @param uniforms Uniforms array to fill
  13344. * @param attributes Attributes array to fill
  13345. * @param samplers Samplers array to fill
  13346. */
  13347. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13348. /** @hidden */
  13349. private _getEffect;
  13350. /**
  13351. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13352. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13353. */
  13354. animate(preWarmOnly?: boolean): void;
  13355. private _appendParticleVertices;
  13356. /**
  13357. * Rebuilds the particle system.
  13358. */
  13359. rebuild(): void;
  13360. /**
  13361. * Is this system ready to be used/rendered
  13362. * @return true if the system is ready
  13363. */
  13364. isReady(): boolean;
  13365. private _render;
  13366. /**
  13367. * Renders the particle system in its current state.
  13368. * @returns the current number of particles
  13369. */
  13370. render(): number;
  13371. /**
  13372. * Disposes the particle system and free the associated resources
  13373. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13374. */
  13375. dispose(disposeTexture?: boolean): void;
  13376. /**
  13377. * Clones the particle system.
  13378. * @param name The name of the cloned object
  13379. * @param newEmitter The new emitter to use
  13380. * @returns the cloned particle system
  13381. */
  13382. clone(name: string, newEmitter: any): ParticleSystem;
  13383. /**
  13384. * Serializes the particle system to a JSON object
  13385. * @param serializeTexture defines if the texture must be serialized as well
  13386. * @returns the JSON object
  13387. */
  13388. serialize(serializeTexture?: boolean): any;
  13389. /** @hidden */
  13390. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13391. /** @hidden */
  13392. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13393. /**
  13394. * Parses a JSON object to create a particle system.
  13395. * @param parsedParticleSystem The JSON object to parse
  13396. * @param sceneOrEngine The scene or the engine to create the particle system in
  13397. * @param rootUrl The root url to use to load external dependencies like texture
  13398. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13399. * @returns the Parsed particle system
  13400. */
  13401. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13402. }
  13403. }
  13404. declare module "babylonjs/Particles/particle" {
  13405. import { Nullable } from "babylonjs/types";
  13406. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13407. import { Color4 } from "babylonjs/Maths/math.color";
  13408. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13409. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13410. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13411. /**
  13412. * A particle represents one of the element emitted by a particle system.
  13413. * This is mainly define by its coordinates, direction, velocity and age.
  13414. */
  13415. export class Particle {
  13416. /**
  13417. * The particle system the particle belongs to.
  13418. */
  13419. particleSystem: ParticleSystem;
  13420. private static _Count;
  13421. /**
  13422. * Unique ID of the particle
  13423. */
  13424. id: number;
  13425. /**
  13426. * The world position of the particle in the scene.
  13427. */
  13428. position: Vector3;
  13429. /**
  13430. * The world direction of the particle in the scene.
  13431. */
  13432. direction: Vector3;
  13433. /**
  13434. * The color of the particle.
  13435. */
  13436. color: Color4;
  13437. /**
  13438. * The color change of the particle per step.
  13439. */
  13440. colorStep: Color4;
  13441. /**
  13442. * Defines how long will the life of the particle be.
  13443. */
  13444. lifeTime: number;
  13445. /**
  13446. * The current age of the particle.
  13447. */
  13448. age: number;
  13449. /**
  13450. * The current size of the particle.
  13451. */
  13452. size: number;
  13453. /**
  13454. * The current scale of the particle.
  13455. */
  13456. scale: Vector2;
  13457. /**
  13458. * The current angle of the particle.
  13459. */
  13460. angle: number;
  13461. /**
  13462. * Defines how fast is the angle changing.
  13463. */
  13464. angularSpeed: number;
  13465. /**
  13466. * Defines the cell index used by the particle to be rendered from a sprite.
  13467. */
  13468. cellIndex: number;
  13469. /**
  13470. * The information required to support color remapping
  13471. */
  13472. remapData: Vector4;
  13473. /** @hidden */
  13474. _randomCellOffset?: number;
  13475. /** @hidden */
  13476. _initialDirection: Nullable<Vector3>;
  13477. /** @hidden */
  13478. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13479. /** @hidden */
  13480. _initialStartSpriteCellID: number;
  13481. /** @hidden */
  13482. _initialEndSpriteCellID: number;
  13483. /** @hidden */
  13484. _currentColorGradient: Nullable<ColorGradient>;
  13485. /** @hidden */
  13486. _currentColor1: Color4;
  13487. /** @hidden */
  13488. _currentColor2: Color4;
  13489. /** @hidden */
  13490. _currentSizeGradient: Nullable<FactorGradient>;
  13491. /** @hidden */
  13492. _currentSize1: number;
  13493. /** @hidden */
  13494. _currentSize2: number;
  13495. /** @hidden */
  13496. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13497. /** @hidden */
  13498. _currentAngularSpeed1: number;
  13499. /** @hidden */
  13500. _currentAngularSpeed2: number;
  13501. /** @hidden */
  13502. _currentVelocityGradient: Nullable<FactorGradient>;
  13503. /** @hidden */
  13504. _currentVelocity1: number;
  13505. /** @hidden */
  13506. _currentVelocity2: number;
  13507. /** @hidden */
  13508. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13509. /** @hidden */
  13510. _currentLimitVelocity1: number;
  13511. /** @hidden */
  13512. _currentLimitVelocity2: number;
  13513. /** @hidden */
  13514. _currentDragGradient: Nullable<FactorGradient>;
  13515. /** @hidden */
  13516. _currentDrag1: number;
  13517. /** @hidden */
  13518. _currentDrag2: number;
  13519. /** @hidden */
  13520. _randomNoiseCoordinates1: Vector3;
  13521. /** @hidden */
  13522. _randomNoiseCoordinates2: Vector3;
  13523. /** @hidden */
  13524. _localPosition?: Vector3;
  13525. /**
  13526. * Creates a new instance Particle
  13527. * @param particleSystem the particle system the particle belongs to
  13528. */
  13529. constructor(
  13530. /**
  13531. * The particle system the particle belongs to.
  13532. */
  13533. particleSystem: ParticleSystem);
  13534. private updateCellInfoFromSystem;
  13535. /**
  13536. * Defines how the sprite cell index is updated for the particle
  13537. */
  13538. updateCellIndex(): void;
  13539. /** @hidden */
  13540. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13541. /** @hidden */
  13542. _inheritParticleInfoToSubEmitters(): void;
  13543. /** @hidden */
  13544. _reset(): void;
  13545. /**
  13546. * Copy the properties of particle to another one.
  13547. * @param other the particle to copy the information to.
  13548. */
  13549. copyTo(other: Particle): void;
  13550. }
  13551. }
  13552. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13553. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13554. import { Effect } from "babylonjs/Materials/effect";
  13555. import { Particle } from "babylonjs/Particles/particle";
  13556. import { Nullable } from "babylonjs/types";
  13557. import { Scene } from "babylonjs/scene";
  13558. /**
  13559. * Particle emitter represents a volume emitting particles.
  13560. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13561. */
  13562. export interface IParticleEmitterType {
  13563. /**
  13564. * Called by the particle System when the direction is computed for the created particle.
  13565. * @param worldMatrix is the world matrix of the particle system
  13566. * @param directionToUpdate is the direction vector to update with the result
  13567. * @param particle is the particle we are computed the direction for
  13568. * @param isLocal defines if the direction should be set in local space
  13569. */
  13570. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13571. /**
  13572. * Called by the particle System when the position is computed for the created particle.
  13573. * @param worldMatrix is the world matrix of the particle system
  13574. * @param positionToUpdate is the position vector to update with the result
  13575. * @param particle is the particle we are computed the position for
  13576. * @param isLocal defines if the position should be set in local space
  13577. */
  13578. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13579. /**
  13580. * Clones the current emitter and returns a copy of it
  13581. * @returns the new emitter
  13582. */
  13583. clone(): IParticleEmitterType;
  13584. /**
  13585. * Called by the GPUParticleSystem to setup the update shader
  13586. * @param effect defines the update shader
  13587. */
  13588. applyToShader(effect: Effect): void;
  13589. /**
  13590. * Returns a string to use to update the GPU particles update shader
  13591. * @returns the effect defines string
  13592. */
  13593. getEffectDefines(): string;
  13594. /**
  13595. * Returns a string representing the class name
  13596. * @returns a string containing the class name
  13597. */
  13598. getClassName(): string;
  13599. /**
  13600. * Serializes the particle system to a JSON object.
  13601. * @returns the JSON object
  13602. */
  13603. serialize(): any;
  13604. /**
  13605. * Parse properties from a JSON object
  13606. * @param serializationObject defines the JSON object
  13607. * @param scene defines the hosting scene
  13608. */
  13609. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13610. }
  13611. }
  13612. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13613. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13614. import { Effect } from "babylonjs/Materials/effect";
  13615. import { Particle } from "babylonjs/Particles/particle";
  13616. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13617. /**
  13618. * Particle emitter emitting particles from the inside of a box.
  13619. * It emits the particles randomly between 2 given directions.
  13620. */
  13621. export class BoxParticleEmitter implements IParticleEmitterType {
  13622. /**
  13623. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13624. */
  13625. direction1: Vector3;
  13626. /**
  13627. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13628. */
  13629. direction2: Vector3;
  13630. /**
  13631. * 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.
  13632. */
  13633. minEmitBox: Vector3;
  13634. /**
  13635. * 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.
  13636. */
  13637. maxEmitBox: Vector3;
  13638. /**
  13639. * Creates a new instance BoxParticleEmitter
  13640. */
  13641. constructor();
  13642. /**
  13643. * Called by the particle System when the direction is computed for the created particle.
  13644. * @param worldMatrix is the world matrix of the particle system
  13645. * @param directionToUpdate is the direction vector to update with the result
  13646. * @param particle is the particle we are computed the direction for
  13647. * @param isLocal defines if the direction should be set in local space
  13648. */
  13649. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13650. /**
  13651. * Called by the particle System when the position is computed for the created particle.
  13652. * @param worldMatrix is the world matrix of the particle system
  13653. * @param positionToUpdate is the position vector to update with the result
  13654. * @param particle is the particle we are computed the position for
  13655. * @param isLocal defines if the position should be set in local space
  13656. */
  13657. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13658. /**
  13659. * Clones the current emitter and returns a copy of it
  13660. * @returns the new emitter
  13661. */
  13662. clone(): BoxParticleEmitter;
  13663. /**
  13664. * Called by the GPUParticleSystem to setup the update shader
  13665. * @param effect defines the update shader
  13666. */
  13667. applyToShader(effect: Effect): void;
  13668. /**
  13669. * Returns a string to use to update the GPU particles update shader
  13670. * @returns a string containng the defines string
  13671. */
  13672. getEffectDefines(): string;
  13673. /**
  13674. * Returns the string "BoxParticleEmitter"
  13675. * @returns a string containing the class name
  13676. */
  13677. getClassName(): string;
  13678. /**
  13679. * Serializes the particle system to a JSON object.
  13680. * @returns the JSON object
  13681. */
  13682. serialize(): any;
  13683. /**
  13684. * Parse properties from a JSON object
  13685. * @param serializationObject defines the JSON object
  13686. */
  13687. parse(serializationObject: any): void;
  13688. }
  13689. }
  13690. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13691. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13692. import { Effect } from "babylonjs/Materials/effect";
  13693. import { Particle } from "babylonjs/Particles/particle";
  13694. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13695. /**
  13696. * Particle emitter emitting particles from the inside of a cone.
  13697. * It emits the particles alongside the cone volume from the base to the particle.
  13698. * The emission direction might be randomized.
  13699. */
  13700. export class ConeParticleEmitter implements IParticleEmitterType {
  13701. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13702. directionRandomizer: number;
  13703. private _radius;
  13704. private _angle;
  13705. private _height;
  13706. /**
  13707. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13708. */
  13709. radiusRange: number;
  13710. /**
  13711. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13712. */
  13713. heightRange: number;
  13714. /**
  13715. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13716. */
  13717. emitFromSpawnPointOnly: boolean;
  13718. /**
  13719. * Gets or sets the radius of the emission cone
  13720. */
  13721. get radius(): number;
  13722. set radius(value: number);
  13723. /**
  13724. * Gets or sets the angle of the emission cone
  13725. */
  13726. get angle(): number;
  13727. set angle(value: number);
  13728. private _buildHeight;
  13729. /**
  13730. * Creates a new instance ConeParticleEmitter
  13731. * @param radius the radius of the emission cone (1 by default)
  13732. * @param angle the cone base angle (PI by default)
  13733. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13734. */
  13735. constructor(radius?: number, angle?: number,
  13736. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13737. directionRandomizer?: number);
  13738. /**
  13739. * Called by the particle System when the direction is computed for the created particle.
  13740. * @param worldMatrix is the world matrix of the particle system
  13741. * @param directionToUpdate is the direction vector to update with the result
  13742. * @param particle is the particle we are computed the direction for
  13743. * @param isLocal defines if the direction should be set in local space
  13744. */
  13745. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13746. /**
  13747. * Called by the particle System when the position is computed for the created particle.
  13748. * @param worldMatrix is the world matrix of the particle system
  13749. * @param positionToUpdate is the position vector to update with the result
  13750. * @param particle is the particle we are computed the position for
  13751. * @param isLocal defines if the position should be set in local space
  13752. */
  13753. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13754. /**
  13755. * Clones the current emitter and returns a copy of it
  13756. * @returns the new emitter
  13757. */
  13758. clone(): ConeParticleEmitter;
  13759. /**
  13760. * Called by the GPUParticleSystem to setup the update shader
  13761. * @param effect defines the update shader
  13762. */
  13763. applyToShader(effect: Effect): void;
  13764. /**
  13765. * Returns a string to use to update the GPU particles update shader
  13766. * @returns a string containng the defines string
  13767. */
  13768. getEffectDefines(): string;
  13769. /**
  13770. * Returns the string "ConeParticleEmitter"
  13771. * @returns a string containing the class name
  13772. */
  13773. getClassName(): string;
  13774. /**
  13775. * Serializes the particle system to a JSON object.
  13776. * @returns the JSON object
  13777. */
  13778. serialize(): any;
  13779. /**
  13780. * Parse properties from a JSON object
  13781. * @param serializationObject defines the JSON object
  13782. */
  13783. parse(serializationObject: any): void;
  13784. }
  13785. }
  13786. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13787. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13788. import { Effect } from "babylonjs/Materials/effect";
  13789. import { Particle } from "babylonjs/Particles/particle";
  13790. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13791. /**
  13792. * Particle emitter emitting particles from the inside of a cylinder.
  13793. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13794. */
  13795. export class CylinderParticleEmitter implements IParticleEmitterType {
  13796. /**
  13797. * The radius of the emission cylinder.
  13798. */
  13799. radius: number;
  13800. /**
  13801. * The height of the emission cylinder.
  13802. */
  13803. height: number;
  13804. /**
  13805. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13806. */
  13807. radiusRange: number;
  13808. /**
  13809. * How much to randomize the particle direction [0-1].
  13810. */
  13811. directionRandomizer: number;
  13812. /**
  13813. * Creates a new instance CylinderParticleEmitter
  13814. * @param radius the radius of the emission cylinder (1 by default)
  13815. * @param height the height of the emission cylinder (1 by default)
  13816. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13817. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13818. */
  13819. constructor(
  13820. /**
  13821. * The radius of the emission cylinder.
  13822. */
  13823. radius?: number,
  13824. /**
  13825. * The height of the emission cylinder.
  13826. */
  13827. height?: number,
  13828. /**
  13829. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13830. */
  13831. radiusRange?: number,
  13832. /**
  13833. * How much to randomize the particle direction [0-1].
  13834. */
  13835. directionRandomizer?: number);
  13836. /**
  13837. * Called by the particle System when the direction is computed for the created particle.
  13838. * @param worldMatrix is the world matrix of the particle system
  13839. * @param directionToUpdate is the direction vector to update with the result
  13840. * @param particle is the particle we are computed the direction for
  13841. * @param isLocal defines if the direction should be set in local space
  13842. */
  13843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13844. /**
  13845. * Called by the particle System when the position is computed for the created particle.
  13846. * @param worldMatrix is the world matrix of the particle system
  13847. * @param positionToUpdate is the position vector to update with the result
  13848. * @param particle is the particle we are computed the position for
  13849. * @param isLocal defines if the position should be set in local space
  13850. */
  13851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13852. /**
  13853. * Clones the current emitter and returns a copy of it
  13854. * @returns the new emitter
  13855. */
  13856. clone(): CylinderParticleEmitter;
  13857. /**
  13858. * Called by the GPUParticleSystem to setup the update shader
  13859. * @param effect defines the update shader
  13860. */
  13861. applyToShader(effect: Effect): void;
  13862. /**
  13863. * Returns a string to use to update the GPU particles update shader
  13864. * @returns a string containng the defines string
  13865. */
  13866. getEffectDefines(): string;
  13867. /**
  13868. * Returns the string "CylinderParticleEmitter"
  13869. * @returns a string containing the class name
  13870. */
  13871. getClassName(): string;
  13872. /**
  13873. * Serializes the particle system to a JSON object.
  13874. * @returns the JSON object
  13875. */
  13876. serialize(): any;
  13877. /**
  13878. * Parse properties from a JSON object
  13879. * @param serializationObject defines the JSON object
  13880. */
  13881. parse(serializationObject: any): void;
  13882. }
  13883. /**
  13884. * Particle emitter emitting particles from the inside of a cylinder.
  13885. * It emits the particles randomly between two vectors.
  13886. */
  13887. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13888. /**
  13889. * The min limit of the emission direction.
  13890. */
  13891. direction1: Vector3;
  13892. /**
  13893. * The max limit of the emission direction.
  13894. */
  13895. direction2: Vector3;
  13896. /**
  13897. * Creates a new instance CylinderDirectedParticleEmitter
  13898. * @param radius the radius of the emission cylinder (1 by default)
  13899. * @param height the height of the emission cylinder (1 by default)
  13900. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13901. * @param direction1 the min limit of the emission direction (up vector by default)
  13902. * @param direction2 the max limit of the emission direction (up vector by default)
  13903. */
  13904. constructor(radius?: number, height?: number, radiusRange?: number,
  13905. /**
  13906. * The min limit of the emission direction.
  13907. */
  13908. direction1?: Vector3,
  13909. /**
  13910. * The max limit of the emission direction.
  13911. */
  13912. direction2?: Vector3);
  13913. /**
  13914. * Called by the particle System when the direction is computed for the created particle.
  13915. * @param worldMatrix is the world matrix of the particle system
  13916. * @param directionToUpdate is the direction vector to update with the result
  13917. * @param particle is the particle we are computed the direction for
  13918. */
  13919. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13920. /**
  13921. * Clones the current emitter and returns a copy of it
  13922. * @returns the new emitter
  13923. */
  13924. clone(): CylinderDirectedParticleEmitter;
  13925. /**
  13926. * Called by the GPUParticleSystem to setup the update shader
  13927. * @param effect defines the update shader
  13928. */
  13929. applyToShader(effect: Effect): void;
  13930. /**
  13931. * Returns a string to use to update the GPU particles update shader
  13932. * @returns a string containng the defines string
  13933. */
  13934. getEffectDefines(): string;
  13935. /**
  13936. * Returns the string "CylinderDirectedParticleEmitter"
  13937. * @returns a string containing the class name
  13938. */
  13939. getClassName(): string;
  13940. /**
  13941. * Serializes the particle system to a JSON object.
  13942. * @returns the JSON object
  13943. */
  13944. serialize(): any;
  13945. /**
  13946. * Parse properties from a JSON object
  13947. * @param serializationObject defines the JSON object
  13948. */
  13949. parse(serializationObject: any): void;
  13950. }
  13951. }
  13952. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13953. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13954. import { Effect } from "babylonjs/Materials/effect";
  13955. import { Particle } from "babylonjs/Particles/particle";
  13956. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13957. /**
  13958. * Particle emitter emitting particles from the inside of a hemisphere.
  13959. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13960. */
  13961. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13962. /**
  13963. * The radius of the emission hemisphere.
  13964. */
  13965. radius: number;
  13966. /**
  13967. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13968. */
  13969. radiusRange: number;
  13970. /**
  13971. * How much to randomize the particle direction [0-1].
  13972. */
  13973. directionRandomizer: number;
  13974. /**
  13975. * Creates a new instance HemisphericParticleEmitter
  13976. * @param radius the radius of the emission hemisphere (1 by default)
  13977. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13978. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13979. */
  13980. constructor(
  13981. /**
  13982. * The radius of the emission hemisphere.
  13983. */
  13984. radius?: number,
  13985. /**
  13986. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13987. */
  13988. radiusRange?: number,
  13989. /**
  13990. * How much to randomize the particle direction [0-1].
  13991. */
  13992. directionRandomizer?: number);
  13993. /**
  13994. * Called by the particle System when the direction is computed for the created particle.
  13995. * @param worldMatrix is the world matrix of the particle system
  13996. * @param directionToUpdate is the direction vector to update with the result
  13997. * @param particle is the particle we are computed the direction for
  13998. * @param isLocal defines if the direction should be set in local space
  13999. */
  14000. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14001. /**
  14002. * Called by the particle System when the position is computed for the created particle.
  14003. * @param worldMatrix is the world matrix of the particle system
  14004. * @param positionToUpdate is the position vector to update with the result
  14005. * @param particle is the particle we are computed the position for
  14006. * @param isLocal defines if the position should be set in local space
  14007. */
  14008. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14009. /**
  14010. * Clones the current emitter and returns a copy of it
  14011. * @returns the new emitter
  14012. */
  14013. clone(): HemisphericParticleEmitter;
  14014. /**
  14015. * Called by the GPUParticleSystem to setup the update shader
  14016. * @param effect defines the update shader
  14017. */
  14018. applyToShader(effect: Effect): void;
  14019. /**
  14020. * Returns a string to use to update the GPU particles update shader
  14021. * @returns a string containng the defines string
  14022. */
  14023. getEffectDefines(): string;
  14024. /**
  14025. * Returns the string "HemisphericParticleEmitter"
  14026. * @returns a string containing the class name
  14027. */
  14028. getClassName(): string;
  14029. /**
  14030. * Serializes the particle system to a JSON object.
  14031. * @returns the JSON object
  14032. */
  14033. serialize(): any;
  14034. /**
  14035. * Parse properties from a JSON object
  14036. * @param serializationObject defines the JSON object
  14037. */
  14038. parse(serializationObject: any): void;
  14039. }
  14040. }
  14041. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14042. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14043. import { Effect } from "babylonjs/Materials/effect";
  14044. import { Particle } from "babylonjs/Particles/particle";
  14045. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14046. /**
  14047. * Particle emitter emitting particles from a point.
  14048. * It emits the particles randomly between 2 given directions.
  14049. */
  14050. export class PointParticleEmitter implements IParticleEmitterType {
  14051. /**
  14052. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14053. */
  14054. direction1: Vector3;
  14055. /**
  14056. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14057. */
  14058. direction2: Vector3;
  14059. /**
  14060. * Creates a new instance PointParticleEmitter
  14061. */
  14062. constructor();
  14063. /**
  14064. * Called by the particle System when the direction is computed for the created particle.
  14065. * @param worldMatrix is the world matrix of the particle system
  14066. * @param directionToUpdate is the direction vector to update with the result
  14067. * @param particle is the particle we are computed the direction for
  14068. * @param isLocal defines if the direction should be set in local space
  14069. */
  14070. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14071. /**
  14072. * Called by the particle System when the position is computed for the created particle.
  14073. * @param worldMatrix is the world matrix of the particle system
  14074. * @param positionToUpdate is the position vector to update with the result
  14075. * @param particle is the particle we are computed the position for
  14076. * @param isLocal defines if the position should be set in local space
  14077. */
  14078. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14079. /**
  14080. * Clones the current emitter and returns a copy of it
  14081. * @returns the new emitter
  14082. */
  14083. clone(): PointParticleEmitter;
  14084. /**
  14085. * Called by the GPUParticleSystem to setup the update shader
  14086. * @param effect defines the update shader
  14087. */
  14088. applyToShader(effect: Effect): void;
  14089. /**
  14090. * Returns a string to use to update the GPU particles update shader
  14091. * @returns a string containng the defines string
  14092. */
  14093. getEffectDefines(): string;
  14094. /**
  14095. * Returns the string "PointParticleEmitter"
  14096. * @returns a string containing the class name
  14097. */
  14098. getClassName(): string;
  14099. /**
  14100. * Serializes the particle system to a JSON object.
  14101. * @returns the JSON object
  14102. */
  14103. serialize(): any;
  14104. /**
  14105. * Parse properties from a JSON object
  14106. * @param serializationObject defines the JSON object
  14107. */
  14108. parse(serializationObject: any): void;
  14109. }
  14110. }
  14111. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14112. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14113. import { Effect } from "babylonjs/Materials/effect";
  14114. import { Particle } from "babylonjs/Particles/particle";
  14115. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14116. /**
  14117. * Particle emitter emitting particles from the inside of a sphere.
  14118. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14119. */
  14120. export class SphereParticleEmitter implements IParticleEmitterType {
  14121. /**
  14122. * The radius of the emission sphere.
  14123. */
  14124. radius: number;
  14125. /**
  14126. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14127. */
  14128. radiusRange: number;
  14129. /**
  14130. * How much to randomize the particle direction [0-1].
  14131. */
  14132. directionRandomizer: number;
  14133. /**
  14134. * Creates a new instance SphereParticleEmitter
  14135. * @param radius the radius of the emission sphere (1 by default)
  14136. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14137. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14138. */
  14139. constructor(
  14140. /**
  14141. * The radius of the emission sphere.
  14142. */
  14143. radius?: number,
  14144. /**
  14145. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14146. */
  14147. radiusRange?: number,
  14148. /**
  14149. * How much to randomize the particle direction [0-1].
  14150. */
  14151. directionRandomizer?: number);
  14152. /**
  14153. * Called by the particle System when the direction is computed for the created particle.
  14154. * @param worldMatrix is the world matrix of the particle system
  14155. * @param directionToUpdate is the direction vector to update with the result
  14156. * @param particle is the particle we are computed the direction for
  14157. * @param isLocal defines if the direction should be set in local space
  14158. */
  14159. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14160. /**
  14161. * Called by the particle System when the position is computed for the created particle.
  14162. * @param worldMatrix is the world matrix of the particle system
  14163. * @param positionToUpdate is the position vector to update with the result
  14164. * @param particle is the particle we are computed the position for
  14165. * @param isLocal defines if the position should be set in local space
  14166. */
  14167. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14168. /**
  14169. * Clones the current emitter and returns a copy of it
  14170. * @returns the new emitter
  14171. */
  14172. clone(): SphereParticleEmitter;
  14173. /**
  14174. * Called by the GPUParticleSystem to setup the update shader
  14175. * @param effect defines the update shader
  14176. */
  14177. applyToShader(effect: Effect): void;
  14178. /**
  14179. * Returns a string to use to update the GPU particles update shader
  14180. * @returns a string containng the defines string
  14181. */
  14182. getEffectDefines(): string;
  14183. /**
  14184. * Returns the string "SphereParticleEmitter"
  14185. * @returns a string containing the class name
  14186. */
  14187. getClassName(): string;
  14188. /**
  14189. * Serializes the particle system to a JSON object.
  14190. * @returns the JSON object
  14191. */
  14192. serialize(): any;
  14193. /**
  14194. * Parse properties from a JSON object
  14195. * @param serializationObject defines the JSON object
  14196. */
  14197. parse(serializationObject: any): void;
  14198. }
  14199. /**
  14200. * Particle emitter emitting particles from the inside of a sphere.
  14201. * It emits the particles randomly between two vectors.
  14202. */
  14203. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14204. /**
  14205. * The min limit of the emission direction.
  14206. */
  14207. direction1: Vector3;
  14208. /**
  14209. * The max limit of the emission direction.
  14210. */
  14211. direction2: Vector3;
  14212. /**
  14213. * Creates a new instance SphereDirectedParticleEmitter
  14214. * @param radius the radius of the emission sphere (1 by default)
  14215. * @param direction1 the min limit of the emission direction (up vector by default)
  14216. * @param direction2 the max limit of the emission direction (up vector by default)
  14217. */
  14218. constructor(radius?: number,
  14219. /**
  14220. * The min limit of the emission direction.
  14221. */
  14222. direction1?: Vector3,
  14223. /**
  14224. * The max limit of the emission direction.
  14225. */
  14226. direction2?: Vector3);
  14227. /**
  14228. * Called by the particle System when the direction is computed for the created particle.
  14229. * @param worldMatrix is the world matrix of the particle system
  14230. * @param directionToUpdate is the direction vector to update with the result
  14231. * @param particle is the particle we are computed the direction for
  14232. */
  14233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14234. /**
  14235. * Clones the current emitter and returns a copy of it
  14236. * @returns the new emitter
  14237. */
  14238. clone(): SphereDirectedParticleEmitter;
  14239. /**
  14240. * Called by the GPUParticleSystem to setup the update shader
  14241. * @param effect defines the update shader
  14242. */
  14243. applyToShader(effect: Effect): void;
  14244. /**
  14245. * Returns a string to use to update the GPU particles update shader
  14246. * @returns a string containng the defines string
  14247. */
  14248. getEffectDefines(): string;
  14249. /**
  14250. * Returns the string "SphereDirectedParticleEmitter"
  14251. * @returns a string containing the class name
  14252. */
  14253. getClassName(): string;
  14254. /**
  14255. * Serializes the particle system to a JSON object.
  14256. * @returns the JSON object
  14257. */
  14258. serialize(): any;
  14259. /**
  14260. * Parse properties from a JSON object
  14261. * @param serializationObject defines the JSON object
  14262. */
  14263. parse(serializationObject: any): void;
  14264. }
  14265. }
  14266. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14267. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14268. import { Effect } from "babylonjs/Materials/effect";
  14269. import { Particle } from "babylonjs/Particles/particle";
  14270. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14271. import { Nullable } from "babylonjs/types";
  14272. /**
  14273. * Particle emitter emitting particles from a custom list of positions.
  14274. */
  14275. export class CustomParticleEmitter implements IParticleEmitterType {
  14276. /**
  14277. * Gets or sets the position generator that will create the inital position of each particle.
  14278. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14279. */
  14280. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14281. /**
  14282. * Gets or sets the destination generator that will create the final destination of each particle.
  14283. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14284. */
  14285. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14286. /**
  14287. * Creates a new instance CustomParticleEmitter
  14288. */
  14289. constructor();
  14290. /**
  14291. * Called by the particle System when the direction is computed for the created particle.
  14292. * @param worldMatrix is the world matrix of the particle system
  14293. * @param directionToUpdate is the direction vector to update with the result
  14294. * @param particle is the particle we are computed the direction for
  14295. * @param isLocal defines if the direction should be set in local space
  14296. */
  14297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14298. /**
  14299. * Called by the particle System when the position is computed for the created particle.
  14300. * @param worldMatrix is the world matrix of the particle system
  14301. * @param positionToUpdate is the position vector to update with the result
  14302. * @param particle is the particle we are computed the position for
  14303. * @param isLocal defines if the position should be set in local space
  14304. */
  14305. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14306. /**
  14307. * Clones the current emitter and returns a copy of it
  14308. * @returns the new emitter
  14309. */
  14310. clone(): CustomParticleEmitter;
  14311. /**
  14312. * Called by the GPUParticleSystem to setup the update shader
  14313. * @param effect defines the update shader
  14314. */
  14315. applyToShader(effect: Effect): void;
  14316. /**
  14317. * Returns a string to use to update the GPU particles update shader
  14318. * @returns a string containng the defines string
  14319. */
  14320. getEffectDefines(): string;
  14321. /**
  14322. * Returns the string "PointParticleEmitter"
  14323. * @returns a string containing the class name
  14324. */
  14325. getClassName(): string;
  14326. /**
  14327. * Serializes the particle system to a JSON object.
  14328. * @returns the JSON object
  14329. */
  14330. serialize(): any;
  14331. /**
  14332. * Parse properties from a JSON object
  14333. * @param serializationObject defines the JSON object
  14334. */
  14335. parse(serializationObject: any): void;
  14336. }
  14337. }
  14338. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14339. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14340. import { Effect } from "babylonjs/Materials/effect";
  14341. import { Particle } from "babylonjs/Particles/particle";
  14342. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14343. import { Nullable } from "babylonjs/types";
  14344. import { Scene } from "babylonjs/scene";
  14345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14346. /**
  14347. * Particle emitter emitting particles from the inside of a box.
  14348. * It emits the particles randomly between 2 given directions.
  14349. */
  14350. export class MeshParticleEmitter implements IParticleEmitterType {
  14351. private _indices;
  14352. private _positions;
  14353. private _normals;
  14354. private _storedNormal;
  14355. private _mesh;
  14356. /**
  14357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14358. */
  14359. direction1: Vector3;
  14360. /**
  14361. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14362. */
  14363. direction2: Vector3;
  14364. /**
  14365. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14366. */
  14367. useMeshNormalsForDirection: boolean;
  14368. /** Defines the mesh to use as source */
  14369. get mesh(): Nullable<AbstractMesh>;
  14370. set mesh(value: Nullable<AbstractMesh>);
  14371. /**
  14372. * Creates a new instance MeshParticleEmitter
  14373. * @param mesh defines the mesh to use as source
  14374. */
  14375. constructor(mesh?: Nullable<AbstractMesh>);
  14376. /**
  14377. * Called by the particle System when the direction is computed for the created particle.
  14378. * @param worldMatrix is the world matrix of the particle system
  14379. * @param directionToUpdate is the direction vector to update with the result
  14380. * @param particle is the particle we are computed the direction for
  14381. * @param isLocal defines if the direction should be set in local space
  14382. */
  14383. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14384. /**
  14385. * Called by the particle System when the position is computed for the created particle.
  14386. * @param worldMatrix is the world matrix of the particle system
  14387. * @param positionToUpdate is the position vector to update with the result
  14388. * @param particle is the particle we are computed the position for
  14389. * @param isLocal defines if the position should be set in local space
  14390. */
  14391. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14392. /**
  14393. * Clones the current emitter and returns a copy of it
  14394. * @returns the new emitter
  14395. */
  14396. clone(): MeshParticleEmitter;
  14397. /**
  14398. * Called by the GPUParticleSystem to setup the update shader
  14399. * @param effect defines the update shader
  14400. */
  14401. applyToShader(effect: Effect): void;
  14402. /**
  14403. * Returns a string to use to update the GPU particles update shader
  14404. * @returns a string containng the defines string
  14405. */
  14406. getEffectDefines(): string;
  14407. /**
  14408. * Returns the string "BoxParticleEmitter"
  14409. * @returns a string containing the class name
  14410. */
  14411. getClassName(): string;
  14412. /**
  14413. * Serializes the particle system to a JSON object.
  14414. * @returns the JSON object
  14415. */
  14416. serialize(): any;
  14417. /**
  14418. * Parse properties from a JSON object
  14419. * @param serializationObject defines the JSON object
  14420. * @param scene defines the hosting scene
  14421. */
  14422. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14423. }
  14424. }
  14425. declare module "babylonjs/Particles/EmitterTypes/index" {
  14426. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14427. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14428. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14429. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14430. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14431. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14432. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14433. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14434. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14435. }
  14436. declare module "babylonjs/Particles/IParticleSystem" {
  14437. import { Nullable } from "babylonjs/types";
  14438. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14439. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14440. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14441. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14442. import { Scene } from "babylonjs/scene";
  14443. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14444. import { Effect } from "babylonjs/Materials/effect";
  14445. import { Observable } from "babylonjs/Misc/observable";
  14446. import { Animation } from "babylonjs/Animations/animation";
  14447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14448. /**
  14449. * Interface representing a particle system in Babylon.js.
  14450. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14451. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14452. */
  14453. export interface IParticleSystem {
  14454. /**
  14455. * List of animations used by the particle system.
  14456. */
  14457. animations: Animation[];
  14458. /**
  14459. * The id of the Particle system.
  14460. */
  14461. id: string;
  14462. /**
  14463. * The name of the Particle system.
  14464. */
  14465. name: string;
  14466. /**
  14467. * The emitter represents the Mesh or position we are attaching the particle system to.
  14468. */
  14469. emitter: Nullable<AbstractMesh | Vector3>;
  14470. /**
  14471. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14472. */
  14473. isBillboardBased: boolean;
  14474. /**
  14475. * The rendering group used by the Particle system to chose when to render.
  14476. */
  14477. renderingGroupId: number;
  14478. /**
  14479. * The layer mask we are rendering the particles through.
  14480. */
  14481. layerMask: number;
  14482. /**
  14483. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14484. */
  14485. updateSpeed: number;
  14486. /**
  14487. * The amount of time the particle system is running (depends of the overall update speed).
  14488. */
  14489. targetStopDuration: number;
  14490. /**
  14491. * The texture used to render each particle. (this can be a spritesheet)
  14492. */
  14493. particleTexture: Nullable<BaseTexture>;
  14494. /**
  14495. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14496. */
  14497. blendMode: number;
  14498. /**
  14499. * Minimum life time of emitting particles.
  14500. */
  14501. minLifeTime: number;
  14502. /**
  14503. * Maximum life time of emitting particles.
  14504. */
  14505. maxLifeTime: number;
  14506. /**
  14507. * Minimum Size of emitting particles.
  14508. */
  14509. minSize: number;
  14510. /**
  14511. * Maximum Size of emitting particles.
  14512. */
  14513. maxSize: number;
  14514. /**
  14515. * Minimum scale of emitting particles on X axis.
  14516. */
  14517. minScaleX: number;
  14518. /**
  14519. * Maximum scale of emitting particles on X axis.
  14520. */
  14521. maxScaleX: number;
  14522. /**
  14523. * Minimum scale of emitting particles on Y axis.
  14524. */
  14525. minScaleY: number;
  14526. /**
  14527. * Maximum scale of emitting particles on Y axis.
  14528. */
  14529. maxScaleY: number;
  14530. /**
  14531. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14532. */
  14533. color1: Color4;
  14534. /**
  14535. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14536. */
  14537. color2: Color4;
  14538. /**
  14539. * Color the particle will have at the end of its lifetime.
  14540. */
  14541. colorDead: Color4;
  14542. /**
  14543. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14544. */
  14545. emitRate: number;
  14546. /**
  14547. * You can use gravity if you want to give an orientation to your particles.
  14548. */
  14549. gravity: Vector3;
  14550. /**
  14551. * Minimum power of emitting particles.
  14552. */
  14553. minEmitPower: number;
  14554. /**
  14555. * Maximum power of emitting particles.
  14556. */
  14557. maxEmitPower: number;
  14558. /**
  14559. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14560. */
  14561. minAngularSpeed: number;
  14562. /**
  14563. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14564. */
  14565. maxAngularSpeed: number;
  14566. /**
  14567. * Gets or sets the minimal initial rotation in radians.
  14568. */
  14569. minInitialRotation: number;
  14570. /**
  14571. * Gets or sets the maximal initial rotation in radians.
  14572. */
  14573. maxInitialRotation: number;
  14574. /**
  14575. * The particle emitter type defines the emitter used by the particle system.
  14576. * It can be for example box, sphere, or cone...
  14577. */
  14578. particleEmitterType: Nullable<IParticleEmitterType>;
  14579. /**
  14580. * Defines the delay in milliseconds before starting the system (0 by default)
  14581. */
  14582. startDelay: number;
  14583. /**
  14584. * 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
  14585. */
  14586. preWarmCycles: number;
  14587. /**
  14588. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14589. */
  14590. preWarmStepOffset: number;
  14591. /**
  14592. * 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)
  14593. */
  14594. spriteCellChangeSpeed: number;
  14595. /**
  14596. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14597. */
  14598. startSpriteCellID: number;
  14599. /**
  14600. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14601. */
  14602. endSpriteCellID: number;
  14603. /**
  14604. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14605. */
  14606. spriteCellWidth: number;
  14607. /**
  14608. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14609. */
  14610. spriteCellHeight: number;
  14611. /**
  14612. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14613. */
  14614. spriteRandomStartCell: boolean;
  14615. /**
  14616. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14617. */
  14618. isAnimationSheetEnabled: boolean;
  14619. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14620. translationPivot: Vector2;
  14621. /**
  14622. * Gets or sets a texture used to add random noise to particle positions
  14623. */
  14624. noiseTexture: Nullable<BaseTexture>;
  14625. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14626. noiseStrength: Vector3;
  14627. /**
  14628. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14629. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14630. */
  14631. billboardMode: number;
  14632. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14633. limitVelocityDamping: number;
  14634. /**
  14635. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14636. */
  14637. beginAnimationOnStart: boolean;
  14638. /**
  14639. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14640. */
  14641. beginAnimationFrom: number;
  14642. /**
  14643. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14644. */
  14645. beginAnimationTo: number;
  14646. /**
  14647. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14648. */
  14649. beginAnimationLoop: boolean;
  14650. /**
  14651. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14652. */
  14653. disposeOnStop: boolean;
  14654. /**
  14655. * Specifies if the particles are updated in emitter local space or world space
  14656. */
  14657. isLocal: boolean;
  14658. /** Snippet ID if the particle system was created from the snippet server */
  14659. snippetId: string;
  14660. /** Gets or sets a matrix to use to compute projection */
  14661. defaultProjectionMatrix: Matrix;
  14662. /**
  14663. * Gets the maximum number of particles active at the same time.
  14664. * @returns The max number of active particles.
  14665. */
  14666. getCapacity(): number;
  14667. /**
  14668. * Gets the number of particles active at the same time.
  14669. * @returns The number of active particles.
  14670. */
  14671. getActiveCount(): number;
  14672. /**
  14673. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14674. * @returns True if it has been started, otherwise false.
  14675. */
  14676. isStarted(): boolean;
  14677. /**
  14678. * Animates the particle system for this frame.
  14679. */
  14680. animate(): void;
  14681. /**
  14682. * Renders the particle system in its current state.
  14683. * @returns the current number of particles
  14684. */
  14685. render(): number;
  14686. /**
  14687. * Dispose the particle system and frees its associated resources.
  14688. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14689. */
  14690. dispose(disposeTexture?: boolean): void;
  14691. /**
  14692. * An event triggered when the system is disposed
  14693. */
  14694. onDisposeObservable: Observable<IParticleSystem>;
  14695. /**
  14696. * An event triggered when the system is stopped
  14697. */
  14698. onStoppedObservable: Observable<IParticleSystem>;
  14699. /**
  14700. * Clones the particle system.
  14701. * @param name The name of the cloned object
  14702. * @param newEmitter The new emitter to use
  14703. * @returns the cloned particle system
  14704. */
  14705. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14706. /**
  14707. * Serializes the particle system to a JSON object
  14708. * @param serializeTexture defines if the texture must be serialized as well
  14709. * @returns the JSON object
  14710. */
  14711. serialize(serializeTexture: boolean): any;
  14712. /**
  14713. * Rebuild the particle system
  14714. */
  14715. rebuild(): void;
  14716. /** Force the system to rebuild all gradients that need to be resync */
  14717. forceRefreshGradients(): void;
  14718. /**
  14719. * Starts the particle system and begins to emit
  14720. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14721. */
  14722. start(delay?: number): void;
  14723. /**
  14724. * Stops the particle system.
  14725. */
  14726. stop(): void;
  14727. /**
  14728. * Remove all active particles
  14729. */
  14730. reset(): void;
  14731. /**
  14732. * Gets a boolean indicating that the system is stopping
  14733. * @returns true if the system is currently stopping
  14734. */
  14735. isStopping(): boolean;
  14736. /**
  14737. * Is this system ready to be used/rendered
  14738. * @return true if the system is ready
  14739. */
  14740. isReady(): boolean;
  14741. /**
  14742. * Returns the string "ParticleSystem"
  14743. * @returns a string containing the class name
  14744. */
  14745. getClassName(): string;
  14746. /**
  14747. * Gets the custom effect used to render the particles
  14748. * @param blendMode Blend mode for which the effect should be retrieved
  14749. * @returns The effect
  14750. */
  14751. getCustomEffect(blendMode: number): Nullable<Effect>;
  14752. /**
  14753. * Sets the custom effect used to render the particles
  14754. * @param effect The effect to set
  14755. * @param blendMode Blend mode for which the effect should be set
  14756. */
  14757. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14758. /**
  14759. * Fill the defines array according to the current settings of the particle system
  14760. * @param defines Array to be updated
  14761. * @param blendMode blend mode to take into account when updating the array
  14762. */
  14763. fillDefines(defines: Array<string>, blendMode: number): void;
  14764. /**
  14765. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14766. * @param uniforms Uniforms array to fill
  14767. * @param attributes Attributes array to fill
  14768. * @param samplers Samplers array to fill
  14769. */
  14770. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14771. /**
  14772. * Observable that will be called just before the particles are drawn
  14773. */
  14774. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14775. /**
  14776. * Gets the name of the particle vertex shader
  14777. */
  14778. vertexShaderName: string;
  14779. /**
  14780. * Adds a new color gradient
  14781. * @param gradient defines the gradient to use (between 0 and 1)
  14782. * @param color1 defines the color to affect to the specified gradient
  14783. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14784. * @returns the current particle system
  14785. */
  14786. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14787. /**
  14788. * Remove a specific color gradient
  14789. * @param gradient defines the gradient to remove
  14790. * @returns the current particle system
  14791. */
  14792. removeColorGradient(gradient: number): IParticleSystem;
  14793. /**
  14794. * Adds a new size gradient
  14795. * @param gradient defines the gradient to use (between 0 and 1)
  14796. * @param factor defines the size factor to affect to the specified gradient
  14797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14798. * @returns the current particle system
  14799. */
  14800. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14801. /**
  14802. * Remove a specific size gradient
  14803. * @param gradient defines the gradient to remove
  14804. * @returns the current particle system
  14805. */
  14806. removeSizeGradient(gradient: number): IParticleSystem;
  14807. /**
  14808. * Gets the current list of color gradients.
  14809. * You must use addColorGradient and removeColorGradient to udpate this list
  14810. * @returns the list of color gradients
  14811. */
  14812. getColorGradients(): Nullable<Array<ColorGradient>>;
  14813. /**
  14814. * Gets the current list of size gradients.
  14815. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14816. * @returns the list of size gradients
  14817. */
  14818. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14819. /**
  14820. * Gets the current list of angular speed gradients.
  14821. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14822. * @returns the list of angular speed gradients
  14823. */
  14824. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14825. /**
  14826. * Adds a new angular speed gradient
  14827. * @param gradient defines the gradient to use (between 0 and 1)
  14828. * @param factor defines the angular speed to affect to the specified gradient
  14829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14830. * @returns the current particle system
  14831. */
  14832. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14833. /**
  14834. * Remove a specific angular speed gradient
  14835. * @param gradient defines the gradient to remove
  14836. * @returns the current particle system
  14837. */
  14838. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14839. /**
  14840. * Gets the current list of velocity gradients.
  14841. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14842. * @returns the list of velocity gradients
  14843. */
  14844. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14845. /**
  14846. * Adds a new velocity gradient
  14847. * @param gradient defines the gradient to use (between 0 and 1)
  14848. * @param factor defines the velocity to affect to the specified gradient
  14849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14850. * @returns the current particle system
  14851. */
  14852. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14853. /**
  14854. * Remove a specific velocity gradient
  14855. * @param gradient defines the gradient to remove
  14856. * @returns the current particle system
  14857. */
  14858. removeVelocityGradient(gradient: number): IParticleSystem;
  14859. /**
  14860. * Gets the current list of limit velocity gradients.
  14861. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14862. * @returns the list of limit velocity gradients
  14863. */
  14864. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14865. /**
  14866. * Adds a new limit velocity gradient
  14867. * @param gradient defines the gradient to use (between 0 and 1)
  14868. * @param factor defines the limit velocity to affect to the specified gradient
  14869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14870. * @returns the current particle system
  14871. */
  14872. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14873. /**
  14874. * Remove a specific limit velocity gradient
  14875. * @param gradient defines the gradient to remove
  14876. * @returns the current particle system
  14877. */
  14878. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14879. /**
  14880. * Adds a new drag gradient
  14881. * @param gradient defines the gradient to use (between 0 and 1)
  14882. * @param factor defines the drag to affect to the specified gradient
  14883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14884. * @returns the current particle system
  14885. */
  14886. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14887. /**
  14888. * Remove a specific drag gradient
  14889. * @param gradient defines the gradient to remove
  14890. * @returns the current particle system
  14891. */
  14892. removeDragGradient(gradient: number): IParticleSystem;
  14893. /**
  14894. * Gets the current list of drag gradients.
  14895. * You must use addDragGradient and removeDragGradient to udpate this list
  14896. * @returns the list of drag gradients
  14897. */
  14898. getDragGradients(): Nullable<Array<FactorGradient>>;
  14899. /**
  14900. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14901. * @param gradient defines the gradient to use (between 0 and 1)
  14902. * @param factor defines the emit rate to affect to the specified gradient
  14903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14904. * @returns the current particle system
  14905. */
  14906. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14907. /**
  14908. * Remove a specific emit rate gradient
  14909. * @param gradient defines the gradient to remove
  14910. * @returns the current particle system
  14911. */
  14912. removeEmitRateGradient(gradient: number): IParticleSystem;
  14913. /**
  14914. * Gets the current list of emit rate gradients.
  14915. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14916. * @returns the list of emit rate gradients
  14917. */
  14918. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14919. /**
  14920. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14921. * @param gradient defines the gradient to use (between 0 and 1)
  14922. * @param factor defines the start size to affect to the specified gradient
  14923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14924. * @returns the current particle system
  14925. */
  14926. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14927. /**
  14928. * Remove a specific start size gradient
  14929. * @param gradient defines the gradient to remove
  14930. * @returns the current particle system
  14931. */
  14932. removeStartSizeGradient(gradient: number): IParticleSystem;
  14933. /**
  14934. * Gets the current list of start size gradients.
  14935. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14936. * @returns the list of start size gradients
  14937. */
  14938. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14939. /**
  14940. * Adds a new life time gradient
  14941. * @param gradient defines the gradient to use (between 0 and 1)
  14942. * @param factor defines the life time factor to affect to the specified gradient
  14943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14944. * @returns the current particle system
  14945. */
  14946. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14947. /**
  14948. * Remove a specific life time gradient
  14949. * @param gradient defines the gradient to remove
  14950. * @returns the current particle system
  14951. */
  14952. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14953. /**
  14954. * Gets the current list of life time gradients.
  14955. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14956. * @returns the list of life time gradients
  14957. */
  14958. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14959. /**
  14960. * Gets the current list of color gradients.
  14961. * You must use addColorGradient and removeColorGradient to udpate this list
  14962. * @returns the list of color gradients
  14963. */
  14964. getColorGradients(): Nullable<Array<ColorGradient>>;
  14965. /**
  14966. * Adds a new ramp gradient used to remap particle colors
  14967. * @param gradient defines the gradient to use (between 0 and 1)
  14968. * @param color defines the color to affect to the specified gradient
  14969. * @returns the current particle system
  14970. */
  14971. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14972. /**
  14973. * Gets the current list of ramp gradients.
  14974. * You must use addRampGradient and removeRampGradient to udpate this list
  14975. * @returns the list of ramp gradients
  14976. */
  14977. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14978. /** Gets or sets a boolean indicating that ramp gradients must be used
  14979. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14980. */
  14981. useRampGradients: boolean;
  14982. /**
  14983. * Adds a new color remap gradient
  14984. * @param gradient defines the gradient to use (between 0 and 1)
  14985. * @param min defines the color remap minimal range
  14986. * @param max defines the color remap maximal range
  14987. * @returns the current particle system
  14988. */
  14989. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14990. /**
  14991. * Gets the current list of color remap gradients.
  14992. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14993. * @returns the list of color remap gradients
  14994. */
  14995. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14996. /**
  14997. * Adds a new alpha remap gradient
  14998. * @param gradient defines the gradient to use (between 0 and 1)
  14999. * @param min defines the alpha remap minimal range
  15000. * @param max defines the alpha remap maximal range
  15001. * @returns the current particle system
  15002. */
  15003. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15004. /**
  15005. * Gets the current list of alpha remap gradients.
  15006. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15007. * @returns the list of alpha remap gradients
  15008. */
  15009. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15010. /**
  15011. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15012. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15013. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15014. * @returns the emitter
  15015. */
  15016. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15017. /**
  15018. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15019. * @param radius The radius of the hemisphere to emit from
  15020. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15021. * @returns the emitter
  15022. */
  15023. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15024. /**
  15025. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15026. * @param radius The radius of the sphere to emit from
  15027. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15028. * @returns the emitter
  15029. */
  15030. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15031. /**
  15032. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15033. * @param radius The radius of the sphere to emit from
  15034. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15035. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15036. * @returns the emitter
  15037. */
  15038. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15039. /**
  15040. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15041. * @param radius The radius of the emission cylinder
  15042. * @param height The height of the emission cylinder
  15043. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15044. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15045. * @returns the emitter
  15046. */
  15047. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15048. /**
  15049. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15050. * @param radius The radius of the cylinder to emit from
  15051. * @param height The height of the emission cylinder
  15052. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15053. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15054. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15055. * @returns the emitter
  15056. */
  15057. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15058. /**
  15059. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15060. * @param radius The radius of the cone to emit from
  15061. * @param angle The base angle of the cone
  15062. * @returns the emitter
  15063. */
  15064. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15065. /**
  15066. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15067. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15068. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15069. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15070. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15071. * @returns the emitter
  15072. */
  15073. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15074. /**
  15075. * Get hosting scene
  15076. * @returns the scene
  15077. */
  15078. getScene(): Nullable<Scene>;
  15079. }
  15080. }
  15081. declare module "babylonjs/Meshes/transformNode" {
  15082. import { DeepImmutable } from "babylonjs/types";
  15083. import { Observable } from "babylonjs/Misc/observable";
  15084. import { Nullable } from "babylonjs/types";
  15085. import { Camera } from "babylonjs/Cameras/camera";
  15086. import { Scene } from "babylonjs/scene";
  15087. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15088. import { Node } from "babylonjs/node";
  15089. import { Bone } from "babylonjs/Bones/bone";
  15090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15091. import { Space } from "babylonjs/Maths/math.axis";
  15092. /**
  15093. * 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.
  15094. * @see https://doc.babylonjs.com/how_to/transformnode
  15095. */
  15096. export class TransformNode extends Node {
  15097. /**
  15098. * Object will not rotate to face the camera
  15099. */
  15100. static BILLBOARDMODE_NONE: number;
  15101. /**
  15102. * Object will rotate to face the camera but only on the x axis
  15103. */
  15104. static BILLBOARDMODE_X: number;
  15105. /**
  15106. * Object will rotate to face the camera but only on the y axis
  15107. */
  15108. static BILLBOARDMODE_Y: number;
  15109. /**
  15110. * Object will rotate to face the camera but only on the z axis
  15111. */
  15112. static BILLBOARDMODE_Z: number;
  15113. /**
  15114. * Object will rotate to face the camera
  15115. */
  15116. static BILLBOARDMODE_ALL: number;
  15117. /**
  15118. * Object will rotate to face the camera's position instead of orientation
  15119. */
  15120. static BILLBOARDMODE_USE_POSITION: number;
  15121. private static _TmpRotation;
  15122. private static _TmpScaling;
  15123. private static _TmpTranslation;
  15124. private _forward;
  15125. private _forwardInverted;
  15126. private _up;
  15127. private _right;
  15128. private _rightInverted;
  15129. private _position;
  15130. private _rotation;
  15131. private _rotationQuaternion;
  15132. protected _scaling: Vector3;
  15133. protected _isDirty: boolean;
  15134. private _transformToBoneReferal;
  15135. private _isAbsoluteSynced;
  15136. private _billboardMode;
  15137. /**
  15138. * Gets or sets the billboard mode. Default is 0.
  15139. *
  15140. * | Value | Type | Description |
  15141. * | --- | --- | --- |
  15142. * | 0 | BILLBOARDMODE_NONE | |
  15143. * | 1 | BILLBOARDMODE_X | |
  15144. * | 2 | BILLBOARDMODE_Y | |
  15145. * | 4 | BILLBOARDMODE_Z | |
  15146. * | 7 | BILLBOARDMODE_ALL | |
  15147. *
  15148. */
  15149. get billboardMode(): number;
  15150. set billboardMode(value: number);
  15151. private _preserveParentRotationForBillboard;
  15152. /**
  15153. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15154. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15155. */
  15156. get preserveParentRotationForBillboard(): boolean;
  15157. set preserveParentRotationForBillboard(value: boolean);
  15158. /**
  15159. * 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
  15160. */
  15161. scalingDeterminant: number;
  15162. private _infiniteDistance;
  15163. /**
  15164. * Gets or sets the distance of the object to max, often used by skybox
  15165. */
  15166. get infiniteDistance(): boolean;
  15167. set infiniteDistance(value: boolean);
  15168. /**
  15169. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15170. * By default the system will update normals to compensate
  15171. */
  15172. ignoreNonUniformScaling: boolean;
  15173. /**
  15174. * 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
  15175. */
  15176. reIntegrateRotationIntoRotationQuaternion: boolean;
  15177. /** @hidden */
  15178. _poseMatrix: Nullable<Matrix>;
  15179. /** @hidden */
  15180. _localMatrix: Matrix;
  15181. private _usePivotMatrix;
  15182. private _absolutePosition;
  15183. private _absoluteScaling;
  15184. private _absoluteRotationQuaternion;
  15185. private _pivotMatrix;
  15186. private _pivotMatrixInverse;
  15187. /** @hidden */
  15188. _postMultiplyPivotMatrix: boolean;
  15189. protected _isWorldMatrixFrozen: boolean;
  15190. /** @hidden */
  15191. _indexInSceneTransformNodesArray: number;
  15192. /**
  15193. * An event triggered after the world matrix is updated
  15194. */
  15195. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15196. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15197. /**
  15198. * Gets a string identifying the name of the class
  15199. * @returns "TransformNode" string
  15200. */
  15201. getClassName(): string;
  15202. /**
  15203. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15204. */
  15205. get position(): Vector3;
  15206. set position(newPosition: Vector3);
  15207. /**
  15208. * 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)).
  15209. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15210. */
  15211. get rotation(): Vector3;
  15212. set rotation(newRotation: Vector3);
  15213. /**
  15214. * 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)).
  15215. */
  15216. get scaling(): Vector3;
  15217. set scaling(newScaling: Vector3);
  15218. /**
  15219. * 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).
  15220. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15221. */
  15222. get rotationQuaternion(): Nullable<Quaternion>;
  15223. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15224. /**
  15225. * The forward direction of that transform in world space.
  15226. */
  15227. get forward(): Vector3;
  15228. /**
  15229. * The up direction of that transform in world space.
  15230. */
  15231. get up(): Vector3;
  15232. /**
  15233. * The right direction of that transform in world space.
  15234. */
  15235. get right(): Vector3;
  15236. /**
  15237. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15238. * @param matrix the matrix to copy the pose from
  15239. * @returns this TransformNode.
  15240. */
  15241. updatePoseMatrix(matrix: Matrix): TransformNode;
  15242. /**
  15243. * Returns the mesh Pose matrix.
  15244. * @returns the pose matrix
  15245. */
  15246. getPoseMatrix(): Matrix;
  15247. /** @hidden */
  15248. _isSynchronized(): boolean;
  15249. /** @hidden */
  15250. _initCache(): void;
  15251. /**
  15252. * Flag the transform node as dirty (Forcing it to update everything)
  15253. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15254. * @returns this transform node
  15255. */
  15256. markAsDirty(property: string): TransformNode;
  15257. /**
  15258. * Returns the current mesh absolute position.
  15259. * Returns a Vector3.
  15260. */
  15261. get absolutePosition(): Vector3;
  15262. /**
  15263. * Returns the current mesh absolute scaling.
  15264. * Returns a Vector3.
  15265. */
  15266. get absoluteScaling(): Vector3;
  15267. /**
  15268. * Returns the current mesh absolute rotation.
  15269. * Returns a Quaternion.
  15270. */
  15271. get absoluteRotationQuaternion(): Quaternion;
  15272. /**
  15273. * Sets a new matrix to apply before all other transformation
  15274. * @param matrix defines the transform matrix
  15275. * @returns the current TransformNode
  15276. */
  15277. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15278. /**
  15279. * Sets a new pivot matrix to the current node
  15280. * @param matrix defines the new pivot matrix to use
  15281. * @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
  15282. * @returns the current TransformNode
  15283. */
  15284. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15285. /**
  15286. * Returns the mesh pivot matrix.
  15287. * Default : Identity.
  15288. * @returns the matrix
  15289. */
  15290. getPivotMatrix(): Matrix;
  15291. /**
  15292. * Instantiate (when possible) or clone that node with its hierarchy
  15293. * @param newParent defines the new parent to use for the instance (or clone)
  15294. * @param options defines options to configure how copy is done
  15295. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15296. * @returns an instance (or a clone) of the current node with its hiearchy
  15297. */
  15298. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15299. doNotInstantiate: boolean;
  15300. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15301. /**
  15302. * Prevents the World matrix to be computed any longer
  15303. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15304. * @returns the TransformNode.
  15305. */
  15306. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15307. /**
  15308. * Allows back the World matrix computation.
  15309. * @returns the TransformNode.
  15310. */
  15311. unfreezeWorldMatrix(): this;
  15312. /**
  15313. * True if the World matrix has been frozen.
  15314. */
  15315. get isWorldMatrixFrozen(): boolean;
  15316. /**
  15317. * Retuns the mesh absolute position in the World.
  15318. * @returns a Vector3.
  15319. */
  15320. getAbsolutePosition(): Vector3;
  15321. /**
  15322. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15323. * @param absolutePosition the absolute position to set
  15324. * @returns the TransformNode.
  15325. */
  15326. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15327. /**
  15328. * Sets the mesh position in its local space.
  15329. * @param vector3 the position to set in localspace
  15330. * @returns the TransformNode.
  15331. */
  15332. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15333. /**
  15334. * Returns the mesh position in the local space from the current World matrix values.
  15335. * @returns a new Vector3.
  15336. */
  15337. getPositionExpressedInLocalSpace(): Vector3;
  15338. /**
  15339. * Translates the mesh along the passed Vector3 in its local space.
  15340. * @param vector3 the distance to translate in localspace
  15341. * @returns the TransformNode.
  15342. */
  15343. locallyTranslate(vector3: Vector3): TransformNode;
  15344. private static _lookAtVectorCache;
  15345. /**
  15346. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15347. * @param targetPoint the position (must be in same space as current mesh) to look at
  15348. * @param yawCor optional yaw (y-axis) correction in radians
  15349. * @param pitchCor optional pitch (x-axis) correction in radians
  15350. * @param rollCor optional roll (z-axis) correction in radians
  15351. * @param space the choosen space of the target
  15352. * @returns the TransformNode.
  15353. */
  15354. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15355. /**
  15356. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15357. * This Vector3 is expressed in the World space.
  15358. * @param localAxis axis to rotate
  15359. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15360. */
  15361. getDirection(localAxis: Vector3): Vector3;
  15362. /**
  15363. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15364. * localAxis is expressed in the mesh local space.
  15365. * result is computed in the Wordl space from the mesh World matrix.
  15366. * @param localAxis axis to rotate
  15367. * @param result the resulting transformnode
  15368. * @returns this TransformNode.
  15369. */
  15370. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15371. /**
  15372. * Sets this transform node rotation to the given local axis.
  15373. * @param localAxis the axis in local space
  15374. * @param yawCor optional yaw (y-axis) correction in radians
  15375. * @param pitchCor optional pitch (x-axis) correction in radians
  15376. * @param rollCor optional roll (z-axis) correction in radians
  15377. * @returns this TransformNode
  15378. */
  15379. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15380. /**
  15381. * Sets a new pivot point to the current node
  15382. * @param point defines the new pivot point to use
  15383. * @param space defines if the point is in world or local space (local by default)
  15384. * @returns the current TransformNode
  15385. */
  15386. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15387. /**
  15388. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15389. * @returns the pivot point
  15390. */
  15391. getPivotPoint(): Vector3;
  15392. /**
  15393. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15394. * @param result the vector3 to store the result
  15395. * @returns this TransformNode.
  15396. */
  15397. getPivotPointToRef(result: Vector3): TransformNode;
  15398. /**
  15399. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15400. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15401. */
  15402. getAbsolutePivotPoint(): Vector3;
  15403. /**
  15404. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15405. * @param result vector3 to store the result
  15406. * @returns this TransformNode.
  15407. */
  15408. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15409. /**
  15410. * Defines the passed node as the parent of the current node.
  15411. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15412. * @see https://doc.babylonjs.com/how_to/parenting
  15413. * @param node the node ot set as the parent
  15414. * @returns this TransformNode.
  15415. */
  15416. setParent(node: Nullable<Node>): TransformNode;
  15417. private _nonUniformScaling;
  15418. /**
  15419. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15420. */
  15421. get nonUniformScaling(): boolean;
  15422. /** @hidden */
  15423. _updateNonUniformScalingState(value: boolean): boolean;
  15424. /**
  15425. * Attach the current TransformNode to another TransformNode associated with a bone
  15426. * @param bone Bone affecting the TransformNode
  15427. * @param affectedTransformNode TransformNode associated with the bone
  15428. * @returns this object
  15429. */
  15430. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15431. /**
  15432. * Detach the transform node if its associated with a bone
  15433. * @returns this object
  15434. */
  15435. detachFromBone(): TransformNode;
  15436. private static _rotationAxisCache;
  15437. /**
  15438. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15439. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15440. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15441. * The passed axis is also normalized.
  15442. * @param axis the axis to rotate around
  15443. * @param amount the amount to rotate in radians
  15444. * @param space Space to rotate in (Default: local)
  15445. * @returns the TransformNode.
  15446. */
  15447. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15448. /**
  15449. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15450. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15451. * The passed axis is also normalized. .
  15452. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15453. * @param point the point to rotate around
  15454. * @param axis the axis to rotate around
  15455. * @param amount the amount to rotate in radians
  15456. * @returns the TransformNode
  15457. */
  15458. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15459. /**
  15460. * Translates the mesh along the axis vector for the passed distance in the given space.
  15461. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15462. * @param axis the axis to translate in
  15463. * @param distance the distance to translate
  15464. * @param space Space to rotate in (Default: local)
  15465. * @returns the TransformNode.
  15466. */
  15467. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15468. /**
  15469. * Adds a rotation step to the mesh current rotation.
  15470. * x, y, z are Euler angles expressed in radians.
  15471. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15472. * This means this rotation is made in the mesh local space only.
  15473. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15474. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15475. * ```javascript
  15476. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15477. * ```
  15478. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15479. * 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.
  15480. * @param x Rotation to add
  15481. * @param y Rotation to add
  15482. * @param z Rotation to add
  15483. * @returns the TransformNode.
  15484. */
  15485. addRotation(x: number, y: number, z: number): TransformNode;
  15486. /**
  15487. * @hidden
  15488. */
  15489. protected _getEffectiveParent(): Nullable<Node>;
  15490. /**
  15491. * Computes the world matrix of the node
  15492. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15493. * @returns the world matrix
  15494. */
  15495. computeWorldMatrix(force?: boolean): Matrix;
  15496. /**
  15497. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15498. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15499. */
  15500. resetLocalMatrix(independentOfChildren?: boolean): void;
  15501. protected _afterComputeWorldMatrix(): void;
  15502. /**
  15503. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15504. * @param func callback function to add
  15505. *
  15506. * @returns the TransformNode.
  15507. */
  15508. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15509. /**
  15510. * Removes a registered callback function.
  15511. * @param func callback function to remove
  15512. * @returns the TransformNode.
  15513. */
  15514. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15515. /**
  15516. * Gets the position of the current mesh in camera space
  15517. * @param camera defines the camera to use
  15518. * @returns a position
  15519. */
  15520. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15521. /**
  15522. * Returns the distance from the mesh to the active camera
  15523. * @param camera defines the camera to use
  15524. * @returns the distance
  15525. */
  15526. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15527. /**
  15528. * Clone the current transform node
  15529. * @param name Name of the new clone
  15530. * @param newParent New parent for the clone
  15531. * @param doNotCloneChildren Do not clone children hierarchy
  15532. * @returns the new transform node
  15533. */
  15534. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15535. /**
  15536. * Serializes the objects information.
  15537. * @param currentSerializationObject defines the object to serialize in
  15538. * @returns the serialized object
  15539. */
  15540. serialize(currentSerializationObject?: any): any;
  15541. /**
  15542. * Returns a new TransformNode object parsed from the source provided.
  15543. * @param parsedTransformNode is the source.
  15544. * @param scene the scne the object belongs to
  15545. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15546. * @returns a new TransformNode object parsed from the source provided.
  15547. */
  15548. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15549. /**
  15550. * Get all child-transformNodes of this node
  15551. * @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
  15552. * @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
  15553. * @returns an array of TransformNode
  15554. */
  15555. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15556. /**
  15557. * Releases resources associated with this transform node.
  15558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15560. */
  15561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15562. /**
  15563. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15564. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15565. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15566. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15567. * @returns the current mesh
  15568. */
  15569. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15570. private _syncAbsoluteScalingAndRotation;
  15571. }
  15572. }
  15573. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15574. /**
  15575. * Class used to override all child animations of a given target
  15576. */
  15577. export class AnimationPropertiesOverride {
  15578. /**
  15579. * Gets or sets a value indicating if animation blending must be used
  15580. */
  15581. enableBlending: boolean;
  15582. /**
  15583. * Gets or sets the blending speed to use when enableBlending is true
  15584. */
  15585. blendingSpeed: number;
  15586. /**
  15587. * Gets or sets the default loop mode to use
  15588. */
  15589. loopMode: number;
  15590. }
  15591. }
  15592. declare module "babylonjs/Bones/bone" {
  15593. import { Skeleton } from "babylonjs/Bones/skeleton";
  15594. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15595. import { Nullable } from "babylonjs/types";
  15596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15597. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15598. import { Node } from "babylonjs/node";
  15599. import { Space } from "babylonjs/Maths/math.axis";
  15600. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15601. /**
  15602. * Class used to store bone information
  15603. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15604. */
  15605. export class Bone extends Node {
  15606. /**
  15607. * defines the bone name
  15608. */
  15609. name: string;
  15610. private static _tmpVecs;
  15611. private static _tmpQuat;
  15612. private static _tmpMats;
  15613. /**
  15614. * Gets the list of child bones
  15615. */
  15616. children: Bone[];
  15617. /** Gets the animations associated with this bone */
  15618. animations: import("babylonjs/Animations/animation").Animation[];
  15619. /**
  15620. * Gets or sets bone length
  15621. */
  15622. length: number;
  15623. /**
  15624. * @hidden Internal only
  15625. * Set this value to map this bone to a different index in the transform matrices
  15626. * Set this value to -1 to exclude the bone from the transform matrices
  15627. */
  15628. _index: Nullable<number>;
  15629. private _skeleton;
  15630. private _localMatrix;
  15631. private _restPose;
  15632. private _bindPose;
  15633. private _baseMatrix;
  15634. private _absoluteTransform;
  15635. private _invertedAbsoluteTransform;
  15636. private _parent;
  15637. private _scalingDeterminant;
  15638. private _worldTransform;
  15639. private _localScaling;
  15640. private _localRotation;
  15641. private _localPosition;
  15642. private _needToDecompose;
  15643. private _needToCompose;
  15644. /** @hidden */
  15645. _linkedTransformNode: Nullable<TransformNode>;
  15646. /** @hidden */
  15647. _waitingTransformNodeId: Nullable<string>;
  15648. /** @hidden */
  15649. get _matrix(): Matrix;
  15650. /** @hidden */
  15651. set _matrix(value: Matrix);
  15652. /**
  15653. * Create a new bone
  15654. * @param name defines the bone name
  15655. * @param skeleton defines the parent skeleton
  15656. * @param parentBone defines the parent (can be null if the bone is the root)
  15657. * @param localMatrix defines the local matrix
  15658. * @param restPose defines the rest pose matrix
  15659. * @param baseMatrix defines the base matrix
  15660. * @param index defines index of the bone in the hiearchy
  15661. */
  15662. constructor(
  15663. /**
  15664. * defines the bone name
  15665. */
  15666. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15667. /**
  15668. * Gets the current object class name.
  15669. * @return the class name
  15670. */
  15671. getClassName(): string;
  15672. /**
  15673. * Gets the parent skeleton
  15674. * @returns a skeleton
  15675. */
  15676. getSkeleton(): Skeleton;
  15677. /**
  15678. * Gets parent bone
  15679. * @returns a bone or null if the bone is the root of the bone hierarchy
  15680. */
  15681. getParent(): Nullable<Bone>;
  15682. /**
  15683. * Returns an array containing the root bones
  15684. * @returns an array containing the root bones
  15685. */
  15686. getChildren(): Array<Bone>;
  15687. /**
  15688. * Gets the node index in matrix array generated for rendering
  15689. * @returns the node index
  15690. */
  15691. getIndex(): number;
  15692. /**
  15693. * Sets the parent bone
  15694. * @param parent defines the parent (can be null if the bone is the root)
  15695. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15696. */
  15697. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15698. /**
  15699. * Gets the local matrix
  15700. * @returns a matrix
  15701. */
  15702. getLocalMatrix(): Matrix;
  15703. /**
  15704. * Gets the base matrix (initial matrix which remains unchanged)
  15705. * @returns a matrix
  15706. */
  15707. getBaseMatrix(): Matrix;
  15708. /**
  15709. * Gets the rest pose matrix
  15710. * @returns a matrix
  15711. */
  15712. getRestPose(): Matrix;
  15713. /**
  15714. * Sets the rest pose matrix
  15715. * @param matrix the local-space rest pose to set for this bone
  15716. */
  15717. setRestPose(matrix: Matrix): void;
  15718. /**
  15719. * Gets the bind pose matrix
  15720. * @returns the bind pose matrix
  15721. */
  15722. getBindPose(): Matrix;
  15723. /**
  15724. * Sets the bind pose matrix
  15725. * @param matrix the local-space bind pose to set for this bone
  15726. */
  15727. setBindPose(matrix: Matrix): void;
  15728. /**
  15729. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15730. */
  15731. getWorldMatrix(): Matrix;
  15732. /**
  15733. * Sets the local matrix to rest pose matrix
  15734. */
  15735. returnToRest(): void;
  15736. /**
  15737. * Gets the inverse of the absolute transform matrix.
  15738. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15739. * @returns a matrix
  15740. */
  15741. getInvertedAbsoluteTransform(): Matrix;
  15742. /**
  15743. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15744. * @returns a matrix
  15745. */
  15746. getAbsoluteTransform(): Matrix;
  15747. /**
  15748. * Links with the given transform node.
  15749. * The local matrix of this bone is copied from the transform node every frame.
  15750. * @param transformNode defines the transform node to link to
  15751. */
  15752. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15753. /**
  15754. * Gets the node used to drive the bone's transformation
  15755. * @returns a transform node or null
  15756. */
  15757. getTransformNode(): Nullable<TransformNode>;
  15758. /** Gets or sets current position (in local space) */
  15759. get position(): Vector3;
  15760. set position(newPosition: Vector3);
  15761. /** Gets or sets current rotation (in local space) */
  15762. get rotation(): Vector3;
  15763. set rotation(newRotation: Vector3);
  15764. /** Gets or sets current rotation quaternion (in local space) */
  15765. get rotationQuaternion(): Quaternion;
  15766. set rotationQuaternion(newRotation: Quaternion);
  15767. /** Gets or sets current scaling (in local space) */
  15768. get scaling(): Vector3;
  15769. set scaling(newScaling: Vector3);
  15770. /**
  15771. * Gets the animation properties override
  15772. */
  15773. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15774. private _decompose;
  15775. private _compose;
  15776. /**
  15777. * Update the base and local matrices
  15778. * @param matrix defines the new base or local matrix
  15779. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15780. * @param updateLocalMatrix defines if the local matrix should be updated
  15781. */
  15782. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15783. /** @hidden */
  15784. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15785. /**
  15786. * Flag the bone as dirty (Forcing it to update everything)
  15787. */
  15788. markAsDirty(): void;
  15789. /** @hidden */
  15790. _markAsDirtyAndCompose(): void;
  15791. private _markAsDirtyAndDecompose;
  15792. /**
  15793. * Translate the bone in local or world space
  15794. * @param vec The amount to translate the bone
  15795. * @param space The space that the translation is in
  15796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15797. */
  15798. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15799. /**
  15800. * Set the postion of the bone in local or world space
  15801. * @param position The position to set the bone
  15802. * @param space The space that the position is in
  15803. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15804. */
  15805. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15806. /**
  15807. * Set the absolute position of the bone (world space)
  15808. * @param position The position to set the bone
  15809. * @param mesh The mesh that this bone is attached to
  15810. */
  15811. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15812. /**
  15813. * Scale the bone on the x, y and z axes (in local space)
  15814. * @param x The amount to scale the bone on the x axis
  15815. * @param y The amount to scale the bone on the y axis
  15816. * @param z The amount to scale the bone on the z axis
  15817. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15818. */
  15819. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15820. /**
  15821. * Set the bone scaling in local space
  15822. * @param scale defines the scaling vector
  15823. */
  15824. setScale(scale: Vector3): void;
  15825. /**
  15826. * Gets the current scaling in local space
  15827. * @returns the current scaling vector
  15828. */
  15829. getScale(): Vector3;
  15830. /**
  15831. * Gets the current scaling in local space and stores it in a target vector
  15832. * @param result defines the target vector
  15833. */
  15834. getScaleToRef(result: Vector3): void;
  15835. /**
  15836. * Set the yaw, pitch, and roll of the bone in local or world space
  15837. * @param yaw The rotation of the bone on the y axis
  15838. * @param pitch The rotation of the bone on the x axis
  15839. * @param roll The rotation of the bone on the z axis
  15840. * @param space The space that the axes of rotation are in
  15841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15842. */
  15843. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15844. /**
  15845. * Add a rotation to the bone on an axis in local or world space
  15846. * @param axis The axis to rotate the bone on
  15847. * @param amount The amount to rotate the bone
  15848. * @param space The space that the axis is in
  15849. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15850. */
  15851. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15852. /**
  15853. * Set the rotation of the bone to a particular axis angle in local or world space
  15854. * @param axis The axis to rotate the bone on
  15855. * @param angle The angle that the bone should be rotated to
  15856. * @param space The space that the axis is in
  15857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15858. */
  15859. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15860. /**
  15861. * Set the euler rotation of the bone in local or world space
  15862. * @param rotation The euler rotation that the bone should be set to
  15863. * @param space The space that the rotation is in
  15864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15865. */
  15866. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15867. /**
  15868. * Set the quaternion rotation of the bone in local or world space
  15869. * @param quat The quaternion rotation that the bone should be set to
  15870. * @param space The space that the rotation is in
  15871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15872. */
  15873. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15874. /**
  15875. * Set the rotation matrix of the bone in local or world space
  15876. * @param rotMat The rotation matrix that the bone should be set to
  15877. * @param space The space that the rotation is in
  15878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15879. */
  15880. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15881. private _rotateWithMatrix;
  15882. private _getNegativeRotationToRef;
  15883. /**
  15884. * Get the position of the bone in local or world space
  15885. * @param space The space that the returned position is in
  15886. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15887. * @returns The position of the bone
  15888. */
  15889. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15890. /**
  15891. * Copy the position of the bone to a vector3 in local or world space
  15892. * @param space The space that the returned position is in
  15893. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15894. * @param result The vector3 to copy the position to
  15895. */
  15896. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15897. /**
  15898. * Get the absolute position of the bone (world space)
  15899. * @param mesh The mesh that this bone is attached to
  15900. * @returns The absolute position of the bone
  15901. */
  15902. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15903. /**
  15904. * Copy the absolute position of the bone (world space) to the result param
  15905. * @param mesh The mesh that this bone is attached to
  15906. * @param result The vector3 to copy the absolute position to
  15907. */
  15908. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15909. /**
  15910. * Compute the absolute transforms of this bone and its children
  15911. */
  15912. computeAbsoluteTransforms(): void;
  15913. /**
  15914. * Get the world direction from an axis that is in the local space of the bone
  15915. * @param localAxis The local direction that is used to compute the world direction
  15916. * @param mesh The mesh that this bone is attached to
  15917. * @returns The world direction
  15918. */
  15919. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15920. /**
  15921. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15922. * @param localAxis The local direction that is used to compute the world direction
  15923. * @param mesh The mesh that this bone is attached to
  15924. * @param result The vector3 that the world direction will be copied to
  15925. */
  15926. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15927. /**
  15928. * Get the euler rotation of the bone in local or world space
  15929. * @param space The space that the rotation should be in
  15930. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15931. * @returns The euler rotation
  15932. */
  15933. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15934. /**
  15935. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15936. * @param space The space that the rotation should be in
  15937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15938. * @param result The vector3 that the rotation should be copied to
  15939. */
  15940. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15941. /**
  15942. * Get the quaternion rotation of the bone in either local or world space
  15943. * @param space The space that the rotation should be in
  15944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15945. * @returns The quaternion rotation
  15946. */
  15947. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15948. /**
  15949. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15950. * @param space The space that the rotation should be in
  15951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15952. * @param result The quaternion that the rotation should be copied to
  15953. */
  15954. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15955. /**
  15956. * Get the rotation matrix of the bone in local or world space
  15957. * @param space The space that the rotation should be in
  15958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15959. * @returns The rotation matrix
  15960. */
  15961. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15962. /**
  15963. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15964. * @param space The space that the rotation should be in
  15965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15966. * @param result The quaternion that the rotation should be copied to
  15967. */
  15968. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15969. /**
  15970. * Get the world position of a point that is in the local space of the bone
  15971. * @param position The local position
  15972. * @param mesh The mesh that this bone is attached to
  15973. * @returns The world position
  15974. */
  15975. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15976. /**
  15977. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15978. * @param position The local position
  15979. * @param mesh The mesh that this bone is attached to
  15980. * @param result The vector3 that the world position should be copied to
  15981. */
  15982. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15983. /**
  15984. * Get the local position of a point that is in world space
  15985. * @param position The world position
  15986. * @param mesh The mesh that this bone is attached to
  15987. * @returns The local position
  15988. */
  15989. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15990. /**
  15991. * Get the local position of a point that is in world space and copy it to the result param
  15992. * @param position The world position
  15993. * @param mesh The mesh that this bone is attached to
  15994. * @param result The vector3 that the local position should be copied to
  15995. */
  15996. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15997. /**
  15998. * Set the current local matrix as the restPose for this bone.
  15999. */
  16000. setCurrentPoseAsRest(): void;
  16001. }
  16002. }
  16003. declare module "babylonjs/Animations/runtimeAnimation" {
  16004. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  16005. import { Animatable } from "babylonjs/Animations/animatable";
  16006. import { Scene } from "babylonjs/scene";
  16007. /**
  16008. * Defines a runtime animation
  16009. */
  16010. export class RuntimeAnimation {
  16011. private _events;
  16012. /**
  16013. * The current frame of the runtime animation
  16014. */
  16015. private _currentFrame;
  16016. /**
  16017. * The animation used by the runtime animation
  16018. */
  16019. private _animation;
  16020. /**
  16021. * The target of the runtime animation
  16022. */
  16023. private _target;
  16024. /**
  16025. * The initiating animatable
  16026. */
  16027. private _host;
  16028. /**
  16029. * The original value of the runtime animation
  16030. */
  16031. private _originalValue;
  16032. /**
  16033. * The original blend value of the runtime animation
  16034. */
  16035. private _originalBlendValue;
  16036. /**
  16037. * The offsets cache of the runtime animation
  16038. */
  16039. private _offsetsCache;
  16040. /**
  16041. * The high limits cache of the runtime animation
  16042. */
  16043. private _highLimitsCache;
  16044. /**
  16045. * Specifies if the runtime animation has been stopped
  16046. */
  16047. private _stopped;
  16048. /**
  16049. * The blending factor of the runtime animation
  16050. */
  16051. private _blendingFactor;
  16052. /**
  16053. * The BabylonJS scene
  16054. */
  16055. private _scene;
  16056. /**
  16057. * The current value of the runtime animation
  16058. */
  16059. private _currentValue;
  16060. /** @hidden */
  16061. _animationState: _IAnimationState;
  16062. /**
  16063. * The active target of the runtime animation
  16064. */
  16065. private _activeTargets;
  16066. private _currentActiveTarget;
  16067. private _directTarget;
  16068. /**
  16069. * The target path of the runtime animation
  16070. */
  16071. private _targetPath;
  16072. /**
  16073. * The weight of the runtime animation
  16074. */
  16075. private _weight;
  16076. /**
  16077. * The ratio offset of the runtime animation
  16078. */
  16079. private _ratioOffset;
  16080. /**
  16081. * The previous delay of the runtime animation
  16082. */
  16083. private _previousDelay;
  16084. /**
  16085. * The previous ratio of the runtime animation
  16086. */
  16087. private _previousRatio;
  16088. private _enableBlending;
  16089. private _keys;
  16090. private _minFrame;
  16091. private _maxFrame;
  16092. private _minValue;
  16093. private _maxValue;
  16094. private _targetIsArray;
  16095. /**
  16096. * Gets the current frame of the runtime animation
  16097. */
  16098. get currentFrame(): number;
  16099. /**
  16100. * Gets the weight of the runtime animation
  16101. */
  16102. get weight(): number;
  16103. /**
  16104. * Gets the current value of the runtime animation
  16105. */
  16106. get currentValue(): any;
  16107. /**
  16108. * Gets the target path of the runtime animation
  16109. */
  16110. get targetPath(): string;
  16111. /**
  16112. * Gets the actual target of the runtime animation
  16113. */
  16114. get target(): any;
  16115. /**
  16116. * Gets the additive state of the runtime animation
  16117. */
  16118. get isAdditive(): boolean;
  16119. /** @hidden */
  16120. _onLoop: () => void;
  16121. /**
  16122. * Create a new RuntimeAnimation object
  16123. * @param target defines the target of the animation
  16124. * @param animation defines the source animation object
  16125. * @param scene defines the hosting scene
  16126. * @param host defines the initiating Animatable
  16127. */
  16128. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16129. private _preparePath;
  16130. /**
  16131. * Gets the animation from the runtime animation
  16132. */
  16133. get animation(): Animation;
  16134. /**
  16135. * Resets the runtime animation to the beginning
  16136. * @param restoreOriginal defines whether to restore the target property to the original value
  16137. */
  16138. reset(restoreOriginal?: boolean): void;
  16139. /**
  16140. * Specifies if the runtime animation is stopped
  16141. * @returns Boolean specifying if the runtime animation is stopped
  16142. */
  16143. isStopped(): boolean;
  16144. /**
  16145. * Disposes of the runtime animation
  16146. */
  16147. dispose(): void;
  16148. /**
  16149. * Apply the interpolated value to the target
  16150. * @param currentValue defines the value computed by the animation
  16151. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16152. */
  16153. setValue(currentValue: any, weight: number): void;
  16154. private _getOriginalValues;
  16155. private _setValue;
  16156. /**
  16157. * Gets the loop pmode of the runtime animation
  16158. * @returns Loop Mode
  16159. */
  16160. private _getCorrectLoopMode;
  16161. /**
  16162. * Move the current animation to a given frame
  16163. * @param frame defines the frame to move to
  16164. */
  16165. goToFrame(frame: number): void;
  16166. /**
  16167. * @hidden Internal use only
  16168. */
  16169. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16170. /**
  16171. * Execute the current animation
  16172. * @param delay defines the delay to add to the current frame
  16173. * @param from defines the lower bound of the animation range
  16174. * @param to defines the upper bound of the animation range
  16175. * @param loop defines if the current animation must loop
  16176. * @param speedRatio defines the current speed ratio
  16177. * @param weight defines the weight of the animation (default is -1 so no weight)
  16178. * @param onLoop optional callback called when animation loops
  16179. * @returns a boolean indicating if the animation is running
  16180. */
  16181. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16182. }
  16183. }
  16184. declare module "babylonjs/Animations/animatable" {
  16185. import { Animation } from "babylonjs/Animations/animation";
  16186. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16187. import { Nullable } from "babylonjs/types";
  16188. import { Observable } from "babylonjs/Misc/observable";
  16189. import { Scene } from "babylonjs/scene";
  16190. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16191. import { Node } from "babylonjs/node";
  16192. /**
  16193. * Class used to store an actual running animation
  16194. */
  16195. export class Animatable {
  16196. /** defines the target object */
  16197. target: any;
  16198. /** defines the starting frame number (default is 0) */
  16199. fromFrame: number;
  16200. /** defines the ending frame number (default is 100) */
  16201. toFrame: number;
  16202. /** defines if the animation must loop (default is false) */
  16203. loopAnimation: boolean;
  16204. /** defines a callback to call when animation ends if it is not looping */
  16205. onAnimationEnd?: (() => void) | null | undefined;
  16206. /** defines a callback to call when animation loops */
  16207. onAnimationLoop?: (() => void) | null | undefined;
  16208. /** defines whether the animation should be evaluated additively */
  16209. isAdditive: boolean;
  16210. private _localDelayOffset;
  16211. private _pausedDelay;
  16212. private _runtimeAnimations;
  16213. private _paused;
  16214. private _scene;
  16215. private _speedRatio;
  16216. private _weight;
  16217. private _syncRoot;
  16218. /**
  16219. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16220. * This will only apply for non looping animation (default is true)
  16221. */
  16222. disposeOnEnd: boolean;
  16223. /**
  16224. * Gets a boolean indicating if the animation has started
  16225. */
  16226. animationStarted: boolean;
  16227. /**
  16228. * Observer raised when the animation ends
  16229. */
  16230. onAnimationEndObservable: Observable<Animatable>;
  16231. /**
  16232. * Observer raised when the animation loops
  16233. */
  16234. onAnimationLoopObservable: Observable<Animatable>;
  16235. /**
  16236. * Gets the root Animatable used to synchronize and normalize animations
  16237. */
  16238. get syncRoot(): Nullable<Animatable>;
  16239. /**
  16240. * Gets the current frame of the first RuntimeAnimation
  16241. * Used to synchronize Animatables
  16242. */
  16243. get masterFrame(): number;
  16244. /**
  16245. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16246. */
  16247. get weight(): number;
  16248. set weight(value: number);
  16249. /**
  16250. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16251. */
  16252. get speedRatio(): number;
  16253. set speedRatio(value: number);
  16254. /**
  16255. * Creates a new Animatable
  16256. * @param scene defines the hosting scene
  16257. * @param target defines the target object
  16258. * @param fromFrame defines the starting frame number (default is 0)
  16259. * @param toFrame defines the ending frame number (default is 100)
  16260. * @param loopAnimation defines if the animation must loop (default is false)
  16261. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16262. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16263. * @param animations defines a group of animation to add to the new Animatable
  16264. * @param onAnimationLoop defines a callback to call when animation loops
  16265. * @param isAdditive defines whether the animation should be evaluated additively
  16266. */
  16267. constructor(scene: Scene,
  16268. /** defines the target object */
  16269. target: any,
  16270. /** defines the starting frame number (default is 0) */
  16271. fromFrame?: number,
  16272. /** defines the ending frame number (default is 100) */
  16273. toFrame?: number,
  16274. /** defines if the animation must loop (default is false) */
  16275. loopAnimation?: boolean, speedRatio?: number,
  16276. /** defines a callback to call when animation ends if it is not looping */
  16277. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16278. /** defines a callback to call when animation loops */
  16279. onAnimationLoop?: (() => void) | null | undefined,
  16280. /** defines whether the animation should be evaluated additively */
  16281. isAdditive?: boolean);
  16282. /**
  16283. * Synchronize and normalize current Animatable with a source Animatable
  16284. * This is useful when using animation weights and when animations are not of the same length
  16285. * @param root defines the root Animatable to synchronize with
  16286. * @returns the current Animatable
  16287. */
  16288. syncWith(root: Animatable): Animatable;
  16289. /**
  16290. * Gets the list of runtime animations
  16291. * @returns an array of RuntimeAnimation
  16292. */
  16293. getAnimations(): RuntimeAnimation[];
  16294. /**
  16295. * Adds more animations to the current animatable
  16296. * @param target defines the target of the animations
  16297. * @param animations defines the new animations to add
  16298. */
  16299. appendAnimations(target: any, animations: Animation[]): void;
  16300. /**
  16301. * Gets the source animation for a specific property
  16302. * @param property defines the propertyu to look for
  16303. * @returns null or the source animation for the given property
  16304. */
  16305. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16306. /**
  16307. * Gets the runtime animation for a specific property
  16308. * @param property defines the propertyu to look for
  16309. * @returns null or the runtime animation for the given property
  16310. */
  16311. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16312. /**
  16313. * Resets the animatable to its original state
  16314. */
  16315. reset(): void;
  16316. /**
  16317. * Allows the animatable to blend with current running animations
  16318. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16319. * @param blendingSpeed defines the blending speed to use
  16320. */
  16321. enableBlending(blendingSpeed: number): void;
  16322. /**
  16323. * Disable animation blending
  16324. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16325. */
  16326. disableBlending(): void;
  16327. /**
  16328. * Jump directly to a given frame
  16329. * @param frame defines the frame to jump to
  16330. */
  16331. goToFrame(frame: number): void;
  16332. /**
  16333. * Pause the animation
  16334. */
  16335. pause(): void;
  16336. /**
  16337. * Restart the animation
  16338. */
  16339. restart(): void;
  16340. private _raiseOnAnimationEnd;
  16341. /**
  16342. * Stop and delete the current animation
  16343. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16344. * @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)
  16345. */
  16346. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16347. /**
  16348. * Wait asynchronously for the animation to end
  16349. * @returns a promise which will be fullfilled when the animation ends
  16350. */
  16351. waitAsync(): Promise<Animatable>;
  16352. /** @hidden */
  16353. _animate(delay: number): boolean;
  16354. }
  16355. module "babylonjs/scene" {
  16356. interface Scene {
  16357. /** @hidden */
  16358. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16359. /** @hidden */
  16360. _processLateAnimationBindingsForMatrices(holder: {
  16361. totalWeight: number;
  16362. totalAdditiveWeight: number;
  16363. animations: RuntimeAnimation[];
  16364. additiveAnimations: RuntimeAnimation[];
  16365. originalValue: Matrix;
  16366. }): any;
  16367. /** @hidden */
  16368. _processLateAnimationBindingsForQuaternions(holder: {
  16369. totalWeight: number;
  16370. totalAdditiveWeight: number;
  16371. animations: RuntimeAnimation[];
  16372. additiveAnimations: RuntimeAnimation[];
  16373. originalValue: Quaternion;
  16374. }, refQuaternion: Quaternion): Quaternion;
  16375. /** @hidden */
  16376. _processLateAnimationBindings(): void;
  16377. /**
  16378. * Will start the animation sequence of a given target
  16379. * @param target defines the target
  16380. * @param from defines from which frame should animation start
  16381. * @param to defines until which frame should animation run.
  16382. * @param weight defines the weight to apply to the animation (1.0 by default)
  16383. * @param loop defines if the animation loops
  16384. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16385. * @param onAnimationEnd defines the function to be executed when the animation ends
  16386. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  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 animatable object created for this animation
  16391. */
  16392. 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;
  16393. /**
  16394. * Will start the animation sequence of a given target
  16395. * @param target defines the target
  16396. * @param from defines from which frame should animation start
  16397. * @param to defines until which frame should animation run.
  16398. * @param loop defines if the animation loops
  16399. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16400. * @param onAnimationEnd defines the function to be executed when the animation ends
  16401. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16402. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16403. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16404. * @param onAnimationLoop defines the callback to call when an animation loops
  16405. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16406. * @returns the animatable object created for this animation
  16407. */
  16408. 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;
  16409. /**
  16410. * Will start the animation sequence of a given target and its hierarchy
  16411. * @param target defines the target
  16412. * @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.
  16413. * @param from defines from which frame should animation start
  16414. * @param to defines until which frame should animation run.
  16415. * @param loop defines if the animation loops
  16416. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16417. * @param onAnimationEnd defines the function to be executed when the animation ends
  16418. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16419. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16420. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16421. * @param onAnimationLoop defines the callback to call when an animation loops
  16422. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16423. * @returns the list of created animatables
  16424. */
  16425. 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[];
  16426. /**
  16427. * Begin a new animation on a given node
  16428. * @param target defines the target where the animation will take place
  16429. * @param animations defines the list of animations to start
  16430. * @param from defines the initial value
  16431. * @param to defines the final value
  16432. * @param loop defines if you want animation to loop (off by default)
  16433. * @param speedRatio defines the speed ratio to apply to all animations
  16434. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16435. * @param onAnimationLoop defines the callback to call when an animation loops
  16436. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16437. * @returns the list of created animatables
  16438. */
  16439. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16440. /**
  16441. * Begin a new animation on a given node and its hierarchy
  16442. * @param target defines the root node where the animation will take place
  16443. * @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.
  16444. * @param animations defines the list of animations to start
  16445. * @param from defines the initial value
  16446. * @param to defines the final value
  16447. * @param loop defines if you want animation to loop (off by default)
  16448. * @param speedRatio defines the speed ratio to apply to all animations
  16449. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16450. * @param onAnimationLoop defines the callback to call when an animation loops
  16451. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16452. * @returns the list of animatables created for all nodes
  16453. */
  16454. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16455. /**
  16456. * Gets the animatable associated with a specific target
  16457. * @param target defines the target of the animatable
  16458. * @returns the required animatable if found
  16459. */
  16460. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16461. /**
  16462. * Gets all animatables associated with a given target
  16463. * @param target defines the target to look animatables for
  16464. * @returns an array of Animatables
  16465. */
  16466. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16467. /**
  16468. * Stops and removes all animations that have been applied to the scene
  16469. */
  16470. stopAllAnimations(): void;
  16471. /**
  16472. * Gets the current delta time used by animation engine
  16473. */
  16474. deltaTime: number;
  16475. }
  16476. }
  16477. module "babylonjs/Bones/bone" {
  16478. interface Bone {
  16479. /**
  16480. * Copy an animation range from another bone
  16481. * @param source defines the source bone
  16482. * @param rangeName defines the range name to copy
  16483. * @param frameOffset defines the frame offset
  16484. * @param rescaleAsRequired defines if rescaling must be applied if required
  16485. * @param skelDimensionsRatio defines the scaling ratio
  16486. * @returns true if operation was successful
  16487. */
  16488. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16489. }
  16490. }
  16491. }
  16492. declare module "babylonjs/Bones/skeleton" {
  16493. import { Bone } from "babylonjs/Bones/bone";
  16494. import { Observable } from "babylonjs/Misc/observable";
  16495. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16496. import { Scene } from "babylonjs/scene";
  16497. import { Nullable } from "babylonjs/types";
  16498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16499. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16500. import { Animatable } from "babylonjs/Animations/animatable";
  16501. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16502. import { Animation } from "babylonjs/Animations/animation";
  16503. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16504. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16505. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16506. /**
  16507. * Class used to handle skinning animations
  16508. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16509. */
  16510. export class Skeleton implements IAnimatable {
  16511. /** defines the skeleton name */
  16512. name: string;
  16513. /** defines the skeleton Id */
  16514. id: string;
  16515. /**
  16516. * Defines the list of child bones
  16517. */
  16518. bones: Bone[];
  16519. /**
  16520. * Defines an estimate of the dimension of the skeleton at rest
  16521. */
  16522. dimensionsAtRest: Vector3;
  16523. /**
  16524. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16525. */
  16526. needInitialSkinMatrix: boolean;
  16527. /**
  16528. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16529. */
  16530. overrideMesh: Nullable<AbstractMesh>;
  16531. /**
  16532. * Gets the list of animations attached to this skeleton
  16533. */
  16534. animations: Array<Animation>;
  16535. private _scene;
  16536. private _isDirty;
  16537. private _transformMatrices;
  16538. private _transformMatrixTexture;
  16539. private _meshesWithPoseMatrix;
  16540. private _animatables;
  16541. private _identity;
  16542. private _synchronizedWithMesh;
  16543. private _ranges;
  16544. private _lastAbsoluteTransformsUpdateId;
  16545. private _canUseTextureForBones;
  16546. private _uniqueId;
  16547. /** @hidden */
  16548. _numBonesWithLinkedTransformNode: number;
  16549. /** @hidden */
  16550. _hasWaitingData: Nullable<boolean>;
  16551. /** @hidden */
  16552. _waitingOverrideMeshId: Nullable<string>;
  16553. /**
  16554. * Specifies if the skeleton should be serialized
  16555. */
  16556. doNotSerialize: boolean;
  16557. private _useTextureToStoreBoneMatrices;
  16558. /**
  16559. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16560. * Please note that this option is not available if the hardware does not support it
  16561. */
  16562. get useTextureToStoreBoneMatrices(): boolean;
  16563. set useTextureToStoreBoneMatrices(value: boolean);
  16564. private _animationPropertiesOverride;
  16565. /**
  16566. * Gets or sets the animation properties override
  16567. */
  16568. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16569. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16570. /**
  16571. * List of inspectable custom properties (used by the Inspector)
  16572. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16573. */
  16574. inspectableCustomProperties: IInspectable[];
  16575. /**
  16576. * An observable triggered before computing the skeleton's matrices
  16577. */
  16578. onBeforeComputeObservable: Observable<Skeleton>;
  16579. /**
  16580. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16581. */
  16582. get isUsingTextureForMatrices(): boolean;
  16583. /**
  16584. * Gets the unique ID of this skeleton
  16585. */
  16586. get uniqueId(): number;
  16587. /**
  16588. * Creates a new skeleton
  16589. * @param name defines the skeleton name
  16590. * @param id defines the skeleton Id
  16591. * @param scene defines the hosting scene
  16592. */
  16593. constructor(
  16594. /** defines the skeleton name */
  16595. name: string,
  16596. /** defines the skeleton Id */
  16597. id: string, scene: Scene);
  16598. /**
  16599. * Gets the current object class name.
  16600. * @return the class name
  16601. */
  16602. getClassName(): string;
  16603. /**
  16604. * Returns an array containing the root bones
  16605. * @returns an array containing the root bones
  16606. */
  16607. getChildren(): Array<Bone>;
  16608. /**
  16609. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16610. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16611. * @returns a Float32Array containing matrices data
  16612. */
  16613. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16614. /**
  16615. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16616. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16617. * @returns a raw texture containing the data
  16618. */
  16619. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16620. /**
  16621. * Gets the current hosting scene
  16622. * @returns a scene object
  16623. */
  16624. getScene(): Scene;
  16625. /**
  16626. * Gets a string representing the current skeleton data
  16627. * @param fullDetails defines a boolean indicating if we want a verbose version
  16628. * @returns a string representing the current skeleton data
  16629. */
  16630. toString(fullDetails?: boolean): string;
  16631. /**
  16632. * Get bone's index searching by name
  16633. * @param name defines bone's name to search for
  16634. * @return the indice of the bone. Returns -1 if not found
  16635. */
  16636. getBoneIndexByName(name: string): number;
  16637. /**
  16638. * Creater a new animation range
  16639. * @param name defines the name of the range
  16640. * @param from defines the start key
  16641. * @param to defines the end key
  16642. */
  16643. createAnimationRange(name: string, from: number, to: number): void;
  16644. /**
  16645. * Delete a specific animation range
  16646. * @param name defines the name of the range
  16647. * @param deleteFrames defines if frames must be removed as well
  16648. */
  16649. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16650. /**
  16651. * Gets a specific animation range
  16652. * @param name defines the name of the range to look for
  16653. * @returns the requested animation range or null if not found
  16654. */
  16655. getAnimationRange(name: string): Nullable<AnimationRange>;
  16656. /**
  16657. * Gets the list of all animation ranges defined on this skeleton
  16658. * @returns an array
  16659. */
  16660. getAnimationRanges(): Nullable<AnimationRange>[];
  16661. /**
  16662. * Copy animation range from a source skeleton.
  16663. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16664. * @param source defines the source skeleton
  16665. * @param name defines the name of the range to copy
  16666. * @param rescaleAsRequired defines if rescaling must be applied if required
  16667. * @returns true if operation was successful
  16668. */
  16669. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16670. /**
  16671. * Forces the skeleton to go to rest pose
  16672. */
  16673. returnToRest(): void;
  16674. private _getHighestAnimationFrame;
  16675. /**
  16676. * Begin a specific animation range
  16677. * @param name defines the name of the range to start
  16678. * @param loop defines if looping must be turned on (false by default)
  16679. * @param speedRatio defines the speed ratio to apply (1 by default)
  16680. * @param onAnimationEnd defines a callback which will be called when animation will end
  16681. * @returns a new animatable
  16682. */
  16683. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16684. /**
  16685. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16686. * @param skeleton defines the Skeleton containing the animation range to convert
  16687. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16688. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16689. * @returns the original skeleton
  16690. */
  16691. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16692. /** @hidden */
  16693. _markAsDirty(): void;
  16694. /** @hidden */
  16695. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16696. /** @hidden */
  16697. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16698. private _computeTransformMatrices;
  16699. /**
  16700. * Build all resources required to render a skeleton
  16701. */
  16702. prepare(): void;
  16703. /**
  16704. * Gets the list of animatables currently running for this skeleton
  16705. * @returns an array of animatables
  16706. */
  16707. getAnimatables(): IAnimatable[];
  16708. /**
  16709. * Clone the current skeleton
  16710. * @param name defines the name of the new skeleton
  16711. * @param id defines the id of the new skeleton
  16712. * @returns the new skeleton
  16713. */
  16714. clone(name: string, id?: string): Skeleton;
  16715. /**
  16716. * Enable animation blending for this skeleton
  16717. * @param blendingSpeed defines the blending speed to apply
  16718. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16719. */
  16720. enableBlending(blendingSpeed?: number): void;
  16721. /**
  16722. * Releases all resources associated with the current skeleton
  16723. */
  16724. dispose(): void;
  16725. /**
  16726. * Serialize the skeleton in a JSON object
  16727. * @returns a JSON object
  16728. */
  16729. serialize(): any;
  16730. /**
  16731. * Creates a new skeleton from serialized data
  16732. * @param parsedSkeleton defines the serialized data
  16733. * @param scene defines the hosting scene
  16734. * @returns a new skeleton
  16735. */
  16736. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16737. /**
  16738. * Compute all node absolute transforms
  16739. * @param forceUpdate defines if computation must be done even if cache is up to date
  16740. */
  16741. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16742. /**
  16743. * Gets the root pose matrix
  16744. * @returns a matrix
  16745. */
  16746. getPoseMatrix(): Nullable<Matrix>;
  16747. /**
  16748. * Sorts bones per internal index
  16749. */
  16750. sortBones(): void;
  16751. private _sortBones;
  16752. /**
  16753. * Set the current local matrix as the restPose for all bones in the skeleton.
  16754. */
  16755. setCurrentPoseAsRest(): void;
  16756. }
  16757. }
  16758. declare module "babylonjs/Meshes/instancedMesh" {
  16759. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16760. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16761. import { Camera } from "babylonjs/Cameras/camera";
  16762. import { Node } from "babylonjs/node";
  16763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16764. import { Mesh } from "babylonjs/Meshes/mesh";
  16765. import { Material } from "babylonjs/Materials/material";
  16766. import { Skeleton } from "babylonjs/Bones/skeleton";
  16767. import { Light } from "babylonjs/Lights/light";
  16768. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16769. /**
  16770. * Creates an instance based on a source mesh.
  16771. */
  16772. export class InstancedMesh extends AbstractMesh {
  16773. private _sourceMesh;
  16774. private _currentLOD;
  16775. /** @hidden */
  16776. _indexInSourceMeshInstanceArray: number;
  16777. constructor(name: string, source: Mesh);
  16778. /**
  16779. * Returns the string "InstancedMesh".
  16780. */
  16781. getClassName(): string;
  16782. /** Gets the list of lights affecting that mesh */
  16783. get lightSources(): Light[];
  16784. _resyncLightSources(): void;
  16785. _resyncLightSource(light: Light): void;
  16786. _removeLightSource(light: Light, dispose: boolean): void;
  16787. /**
  16788. * If the source mesh receives shadows
  16789. */
  16790. get receiveShadows(): boolean;
  16791. /**
  16792. * The material of the source mesh
  16793. */
  16794. get material(): Nullable<Material>;
  16795. /**
  16796. * Visibility of the source mesh
  16797. */
  16798. get visibility(): number;
  16799. /**
  16800. * Skeleton of the source mesh
  16801. */
  16802. get skeleton(): Nullable<Skeleton>;
  16803. /**
  16804. * Rendering ground id of the source mesh
  16805. */
  16806. get renderingGroupId(): number;
  16807. set renderingGroupId(value: number);
  16808. /**
  16809. * Returns the total number of vertices (integer).
  16810. */
  16811. getTotalVertices(): number;
  16812. /**
  16813. * Returns a positive integer : the total number of indices in this mesh geometry.
  16814. * @returns the numner of indices or zero if the mesh has no geometry.
  16815. */
  16816. getTotalIndices(): number;
  16817. /**
  16818. * The source mesh of the instance
  16819. */
  16820. get sourceMesh(): Mesh;
  16821. /**
  16822. * Creates a new InstancedMesh object from the mesh model.
  16823. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16824. * @param name defines the name of the new instance
  16825. * @returns a new InstancedMesh
  16826. */
  16827. createInstance(name: string): InstancedMesh;
  16828. /**
  16829. * Is this node ready to be used/rendered
  16830. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16831. * @return {boolean} is it ready
  16832. */
  16833. isReady(completeCheck?: boolean): boolean;
  16834. /**
  16835. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16836. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16837. * @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.
  16838. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16839. */
  16840. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16841. /**
  16842. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16843. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16844. * The `data` are either a numeric array either a Float32Array.
  16845. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16846. * 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).
  16847. * Note that a new underlying VertexBuffer object is created each call.
  16848. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16849. *
  16850. * Possible `kind` values :
  16851. * - VertexBuffer.PositionKind
  16852. * - VertexBuffer.UVKind
  16853. * - VertexBuffer.UV2Kind
  16854. * - VertexBuffer.UV3Kind
  16855. * - VertexBuffer.UV4Kind
  16856. * - VertexBuffer.UV5Kind
  16857. * - VertexBuffer.UV6Kind
  16858. * - VertexBuffer.ColorKind
  16859. * - VertexBuffer.MatricesIndicesKind
  16860. * - VertexBuffer.MatricesIndicesExtraKind
  16861. * - VertexBuffer.MatricesWeightsKind
  16862. * - VertexBuffer.MatricesWeightsExtraKind
  16863. *
  16864. * Returns the Mesh.
  16865. */
  16866. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16867. /**
  16868. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16869. * If the mesh has no geometry, it is simply returned as it is.
  16870. * The `data` are either a numeric array either a Float32Array.
  16871. * No new underlying VertexBuffer object is created.
  16872. * 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.
  16873. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16874. *
  16875. * Possible `kind` values :
  16876. * - VertexBuffer.PositionKind
  16877. * - VertexBuffer.UVKind
  16878. * - VertexBuffer.UV2Kind
  16879. * - VertexBuffer.UV3Kind
  16880. * - VertexBuffer.UV4Kind
  16881. * - VertexBuffer.UV5Kind
  16882. * - VertexBuffer.UV6Kind
  16883. * - VertexBuffer.ColorKind
  16884. * - VertexBuffer.MatricesIndicesKind
  16885. * - VertexBuffer.MatricesIndicesExtraKind
  16886. * - VertexBuffer.MatricesWeightsKind
  16887. * - VertexBuffer.MatricesWeightsExtraKind
  16888. *
  16889. * Returns the Mesh.
  16890. */
  16891. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16892. /**
  16893. * Sets the mesh indices.
  16894. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16895. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16896. * This method creates a new index buffer each call.
  16897. * Returns the Mesh.
  16898. */
  16899. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16900. /**
  16901. * Boolean : True if the mesh owns the requested kind of data.
  16902. */
  16903. isVerticesDataPresent(kind: string): boolean;
  16904. /**
  16905. * Returns an array of indices (IndicesArray).
  16906. */
  16907. getIndices(): Nullable<IndicesArray>;
  16908. get _positions(): Nullable<Vector3[]>;
  16909. /**
  16910. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16911. * This means the mesh underlying bounding box and sphere are recomputed.
  16912. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16913. * @returns the current mesh
  16914. */
  16915. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16916. /** @hidden */
  16917. _preActivate(): InstancedMesh;
  16918. /** @hidden */
  16919. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16920. /** @hidden */
  16921. _postActivate(): void;
  16922. getWorldMatrix(): Matrix;
  16923. get isAnInstance(): boolean;
  16924. /**
  16925. * Returns the current associated LOD AbstractMesh.
  16926. */
  16927. getLOD(camera: Camera): AbstractMesh;
  16928. /** @hidden */
  16929. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16930. /** @hidden */
  16931. _syncSubMeshes(): InstancedMesh;
  16932. /** @hidden */
  16933. _generatePointsArray(): boolean;
  16934. /** @hidden */
  16935. _updateBoundingInfo(): AbstractMesh;
  16936. /**
  16937. * Creates a new InstancedMesh from the current mesh.
  16938. * - name (string) : the cloned mesh name
  16939. * - newParent (optional Node) : the optional Node to parent the clone to.
  16940. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16941. *
  16942. * Returns the clone.
  16943. */
  16944. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16945. /**
  16946. * Disposes the InstancedMesh.
  16947. * Returns nothing.
  16948. */
  16949. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16950. }
  16951. module "babylonjs/Meshes/mesh" {
  16952. interface Mesh {
  16953. /**
  16954. * Register a custom buffer that will be instanced
  16955. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16956. * @param kind defines the buffer kind
  16957. * @param stride defines the stride in floats
  16958. */
  16959. registerInstancedBuffer(kind: string, stride: number): void;
  16960. /**
  16961. * true to use the edge renderer for all instances of this mesh
  16962. */
  16963. edgesShareWithInstances: boolean;
  16964. /** @hidden */
  16965. _userInstancedBuffersStorage: {
  16966. data: {
  16967. [key: string]: Float32Array;
  16968. };
  16969. sizes: {
  16970. [key: string]: number;
  16971. };
  16972. vertexBuffers: {
  16973. [key: string]: Nullable<VertexBuffer>;
  16974. };
  16975. strides: {
  16976. [key: string]: number;
  16977. };
  16978. };
  16979. }
  16980. }
  16981. module "babylonjs/Meshes/abstractMesh" {
  16982. interface AbstractMesh {
  16983. /**
  16984. * Object used to store instanced buffers defined by user
  16985. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16986. */
  16987. instancedBuffers: {
  16988. [key: string]: any;
  16989. };
  16990. }
  16991. }
  16992. }
  16993. declare module "babylonjs/Materials/shaderMaterial" {
  16994. import { Nullable } from "babylonjs/types";
  16995. import { Scene } from "babylonjs/scene";
  16996. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16998. import { Mesh } from "babylonjs/Meshes/mesh";
  16999. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17000. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17001. import { Effect } from "babylonjs/Materials/effect";
  17002. import { Material } from "babylonjs/Materials/material";
  17003. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17004. /**
  17005. * Defines the options associated with the creation of a shader material.
  17006. */
  17007. export interface IShaderMaterialOptions {
  17008. /**
  17009. * Does the material work in alpha blend mode
  17010. */
  17011. needAlphaBlending: boolean;
  17012. /**
  17013. * Does the material work in alpha test mode
  17014. */
  17015. needAlphaTesting: boolean;
  17016. /**
  17017. * The list of attribute names used in the shader
  17018. */
  17019. attributes: string[];
  17020. /**
  17021. * The list of unifrom names used in the shader
  17022. */
  17023. uniforms: string[];
  17024. /**
  17025. * The list of UBO names used in the shader
  17026. */
  17027. uniformBuffers: string[];
  17028. /**
  17029. * The list of sampler names used in the shader
  17030. */
  17031. samplers: string[];
  17032. /**
  17033. * The list of defines used in the shader
  17034. */
  17035. defines: string[];
  17036. }
  17037. /**
  17038. * 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.
  17039. *
  17040. * This returned material effects how the mesh will look based on the code in the shaders.
  17041. *
  17042. * @see https://doc.babylonjs.com/how_to/shader_material
  17043. */
  17044. export class ShaderMaterial extends Material {
  17045. private _shaderPath;
  17046. private _options;
  17047. private _textures;
  17048. private _textureArrays;
  17049. private _floats;
  17050. private _ints;
  17051. private _floatsArrays;
  17052. private _colors3;
  17053. private _colors3Arrays;
  17054. private _colors4;
  17055. private _colors4Arrays;
  17056. private _vectors2;
  17057. private _vectors3;
  17058. private _vectors4;
  17059. private _matrices;
  17060. private _matrixArrays;
  17061. private _matrices3x3;
  17062. private _matrices2x2;
  17063. private _vectors2Arrays;
  17064. private _vectors3Arrays;
  17065. private _vectors4Arrays;
  17066. private _cachedWorldViewMatrix;
  17067. private _cachedWorldViewProjectionMatrix;
  17068. private _renderId;
  17069. private _multiview;
  17070. private _cachedDefines;
  17071. /** Define the Url to load snippets */
  17072. static SnippetUrl: string;
  17073. /** Snippet ID if the material was created from the snippet server */
  17074. snippetId: string;
  17075. /**
  17076. * Instantiate a new shader material.
  17077. * 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.
  17078. * This returned material effects how the mesh will look based on the code in the shaders.
  17079. * @see https://doc.babylonjs.com/how_to/shader_material
  17080. * @param name Define the name of the material in the scene
  17081. * @param scene Define the scene the material belongs to
  17082. * @param shaderPath Defines the route to the shader code in one of three ways:
  17083. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17084. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17085. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17086. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17087. * @param options Define the options used to create the shader
  17088. */
  17089. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17090. /**
  17091. * Gets the shader path used to define the shader code
  17092. * It can be modified to trigger a new compilation
  17093. */
  17094. get shaderPath(): any;
  17095. /**
  17096. * Sets the shader path used to define the shader code
  17097. * It can be modified to trigger a new compilation
  17098. */
  17099. set shaderPath(shaderPath: any);
  17100. /**
  17101. * Gets the options used to compile the shader.
  17102. * They can be modified to trigger a new compilation
  17103. */
  17104. get options(): IShaderMaterialOptions;
  17105. /**
  17106. * Gets the current class name of the material e.g. "ShaderMaterial"
  17107. * Mainly use in serialization.
  17108. * @returns the class name
  17109. */
  17110. getClassName(): string;
  17111. /**
  17112. * Specifies if the material will require alpha blending
  17113. * @returns a boolean specifying if alpha blending is needed
  17114. */
  17115. needAlphaBlending(): boolean;
  17116. /**
  17117. * Specifies if this material should be rendered in alpha test mode
  17118. * @returns a boolean specifying if an alpha test is needed.
  17119. */
  17120. needAlphaTesting(): boolean;
  17121. private _checkUniform;
  17122. /**
  17123. * Set a texture in the shader.
  17124. * @param name Define the name of the uniform samplers as defined in the shader
  17125. * @param texture Define the texture to bind to this sampler
  17126. * @return the material itself allowing "fluent" like uniform updates
  17127. */
  17128. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17129. /**
  17130. * Set a texture array in the shader.
  17131. * @param name Define the name of the uniform sampler array as defined in the shader
  17132. * @param textures Define the list of textures to bind to this sampler
  17133. * @return the material itself allowing "fluent" like uniform updates
  17134. */
  17135. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17136. /**
  17137. * Set a float in the shader.
  17138. * @param name Define the name of the uniform as defined in the shader
  17139. * @param value Define the value to give to the uniform
  17140. * @return the material itself allowing "fluent" like uniform updates
  17141. */
  17142. setFloat(name: string, value: number): ShaderMaterial;
  17143. /**
  17144. * Set a int in the shader.
  17145. * @param name Define the name of the uniform as defined in the shader
  17146. * @param value Define the value to give to the uniform
  17147. * @return the material itself allowing "fluent" like uniform updates
  17148. */
  17149. setInt(name: string, value: number): ShaderMaterial;
  17150. /**
  17151. * Set an array of floats in the shader.
  17152. * @param name Define the name of the uniform as defined in the shader
  17153. * @param value Define the value to give to the uniform
  17154. * @return the material itself allowing "fluent" like uniform updates
  17155. */
  17156. setFloats(name: string, value: number[]): ShaderMaterial;
  17157. /**
  17158. * Set a vec3 in the shader from a Color3.
  17159. * @param name Define the name of the uniform as defined in the shader
  17160. * @param value Define the value to give to the uniform
  17161. * @return the material itself allowing "fluent" like uniform updates
  17162. */
  17163. setColor3(name: string, value: Color3): ShaderMaterial;
  17164. /**
  17165. * Set a vec3 array in the shader from a Color3 array.
  17166. * @param name Define the name of the uniform as defined in the shader
  17167. * @param value Define the value to give to the uniform
  17168. * @return the material itself allowing "fluent" like uniform updates
  17169. */
  17170. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17171. /**
  17172. * Set a vec4 in the shader from a Color4.
  17173. * @param name Define the name of the uniform as defined in the shader
  17174. * @param value Define the value to give to the uniform
  17175. * @return the material itself allowing "fluent" like uniform updates
  17176. */
  17177. setColor4(name: string, value: Color4): ShaderMaterial;
  17178. /**
  17179. * Set a vec4 array in the shader from a Color4 array.
  17180. * @param name Define the name of the uniform as defined in the shader
  17181. * @param value Define the value to give to the uniform
  17182. * @return the material itself allowing "fluent" like uniform updates
  17183. */
  17184. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17185. /**
  17186. * Set a vec2 in the shader from a Vector2.
  17187. * @param name Define the name of the uniform as defined in the shader
  17188. * @param value Define the value to give to the uniform
  17189. * @return the material itself allowing "fluent" like uniform updates
  17190. */
  17191. setVector2(name: string, value: Vector2): ShaderMaterial;
  17192. /**
  17193. * Set a vec3 in the shader from a Vector3.
  17194. * @param name Define the name of the uniform as defined in the shader
  17195. * @param value Define the value to give to the uniform
  17196. * @return the material itself allowing "fluent" like uniform updates
  17197. */
  17198. setVector3(name: string, value: Vector3): ShaderMaterial;
  17199. /**
  17200. * Set a vec4 in the shader from a Vector4.
  17201. * @param name Define the name of the uniform as defined in the shader
  17202. * @param value Define the value to give to the uniform
  17203. * @return the material itself allowing "fluent" like uniform updates
  17204. */
  17205. setVector4(name: string, value: Vector4): ShaderMaterial;
  17206. /**
  17207. * Set a mat4 in the shader from a Matrix.
  17208. * @param name Define the name of the uniform as defined in the shader
  17209. * @param value Define the value to give to the uniform
  17210. * @return the material itself allowing "fluent" like uniform updates
  17211. */
  17212. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17213. /**
  17214. * Set a float32Array in the shader from a matrix array.
  17215. * @param name Define the name of the uniform as defined in the shader
  17216. * @param value Define the value to give to the uniform
  17217. * @return the material itself allowing "fluent" like uniform updates
  17218. */
  17219. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17220. /**
  17221. * Set a mat3 in the shader from a Float32Array.
  17222. * @param name Define the name of the uniform as defined in the shader
  17223. * @param value Define the value to give to the uniform
  17224. * @return the material itself allowing "fluent" like uniform updates
  17225. */
  17226. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17227. /**
  17228. * Set a mat2 in the shader from a Float32Array.
  17229. * @param name Define the name of the uniform as defined in the shader
  17230. * @param value Define the value to give to the uniform
  17231. * @return the material itself allowing "fluent" like uniform updates
  17232. */
  17233. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17234. /**
  17235. * Set a vec2 array in the shader from a number array.
  17236. * @param name Define the name of the uniform as defined in the shader
  17237. * @param value Define the value to give to the uniform
  17238. * @return the material itself allowing "fluent" like uniform updates
  17239. */
  17240. setArray2(name: string, value: number[]): ShaderMaterial;
  17241. /**
  17242. * Set a vec3 array in the shader from a number array.
  17243. * @param name Define the name of the uniform as defined in the shader
  17244. * @param value Define the value to give to the uniform
  17245. * @return the material itself allowing "fluent" like uniform updates
  17246. */
  17247. setArray3(name: string, value: number[]): ShaderMaterial;
  17248. /**
  17249. * Set a vec4 array in the shader from a number array.
  17250. * @param name Define the name of the uniform as defined in the shader
  17251. * @param value Define the value to give to the uniform
  17252. * @return the material itself allowing "fluent" like uniform updates
  17253. */
  17254. setArray4(name: string, value: number[]): ShaderMaterial;
  17255. private _checkCache;
  17256. /**
  17257. * Specifies that the submesh is ready to be used
  17258. * @param mesh defines the mesh to check
  17259. * @param subMesh defines which submesh to check
  17260. * @param useInstances specifies that instances should be used
  17261. * @returns a boolean indicating that the submesh is ready or not
  17262. */
  17263. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17264. /**
  17265. * Checks if the material is ready to render the requested mesh
  17266. * @param mesh Define the mesh to render
  17267. * @param useInstances Define whether or not the material is used with instances
  17268. * @returns true if ready, otherwise false
  17269. */
  17270. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17271. /**
  17272. * Binds the world matrix to the material
  17273. * @param world defines the world transformation matrix
  17274. * @param effectOverride - If provided, use this effect instead of internal effect
  17275. */
  17276. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17277. /**
  17278. * Binds the submesh to this material by preparing the effect and shader to draw
  17279. * @param world defines the world transformation matrix
  17280. * @param mesh defines the mesh containing the submesh
  17281. * @param subMesh defines the submesh to bind the material to
  17282. */
  17283. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17284. /**
  17285. * Binds the material to the mesh
  17286. * @param world defines the world transformation matrix
  17287. * @param mesh defines the mesh to bind the material to
  17288. * @param effectOverride - If provided, use this effect instead of internal effect
  17289. */
  17290. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17291. protected _afterBind(mesh?: Mesh): void;
  17292. /**
  17293. * Gets the active textures from the material
  17294. * @returns an array of textures
  17295. */
  17296. getActiveTextures(): BaseTexture[];
  17297. /**
  17298. * Specifies if the material uses a texture
  17299. * @param texture defines the texture to check against the material
  17300. * @returns a boolean specifying if the material uses the texture
  17301. */
  17302. hasTexture(texture: BaseTexture): boolean;
  17303. /**
  17304. * Makes a duplicate of the material, and gives it a new name
  17305. * @param name defines the new name for the duplicated material
  17306. * @returns the cloned material
  17307. */
  17308. clone(name: string): ShaderMaterial;
  17309. /**
  17310. * Disposes the material
  17311. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17312. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17313. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17314. */
  17315. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17316. /**
  17317. * Serializes this material in a JSON representation
  17318. * @returns the serialized material object
  17319. */
  17320. serialize(): any;
  17321. /**
  17322. * Creates a shader material from parsed shader material data
  17323. * @param source defines the JSON represnetation of the material
  17324. * @param scene defines the hosting scene
  17325. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17326. * @returns a new material
  17327. */
  17328. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17329. /**
  17330. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17331. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17332. * @param url defines the url to load from
  17333. * @param scene defines the hosting scene
  17334. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17335. * @returns a promise that will resolve to the new ShaderMaterial
  17336. */
  17337. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17338. /**
  17339. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17340. * @param snippetId defines the snippet to load
  17341. * @param scene defines the hosting scene
  17342. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17343. * @returns a promise that will resolve to the new ShaderMaterial
  17344. */
  17345. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17346. }
  17347. }
  17348. declare module "babylonjs/Shaders/color.fragment" {
  17349. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17350. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17351. /** @hidden */
  17352. export var colorPixelShader: {
  17353. name: string;
  17354. shader: string;
  17355. };
  17356. }
  17357. declare module "babylonjs/Shaders/color.vertex" {
  17358. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17359. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17360. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17361. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17362. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17363. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17364. /** @hidden */
  17365. export var colorVertexShader: {
  17366. name: string;
  17367. shader: string;
  17368. };
  17369. }
  17370. declare module "babylonjs/Meshes/linesMesh" {
  17371. import { Nullable } from "babylonjs/types";
  17372. import { Scene } from "babylonjs/scene";
  17373. import { Color3 } from "babylonjs/Maths/math.color";
  17374. import { Node } from "babylonjs/node";
  17375. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17376. import { Mesh } from "babylonjs/Meshes/mesh";
  17377. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17378. import { Effect } from "babylonjs/Materials/effect";
  17379. import { Material } from "babylonjs/Materials/material";
  17380. import "babylonjs/Shaders/color.fragment";
  17381. import "babylonjs/Shaders/color.vertex";
  17382. /**
  17383. * Line mesh
  17384. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17385. */
  17386. export class LinesMesh extends Mesh {
  17387. /**
  17388. * If vertex color should be applied to the mesh
  17389. */
  17390. readonly useVertexColor?: boolean | undefined;
  17391. /**
  17392. * If vertex alpha should be applied to the mesh
  17393. */
  17394. readonly useVertexAlpha?: boolean | undefined;
  17395. /**
  17396. * Color of the line (Default: White)
  17397. */
  17398. color: Color3;
  17399. /**
  17400. * Alpha of the line (Default: 1)
  17401. */
  17402. alpha: number;
  17403. /**
  17404. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17405. * This margin is expressed in world space coordinates, so its value may vary.
  17406. * Default value is 0.1
  17407. */
  17408. intersectionThreshold: number;
  17409. private _colorShader;
  17410. private color4;
  17411. /**
  17412. * Creates a new LinesMesh
  17413. * @param name defines the name
  17414. * @param scene defines the hosting scene
  17415. * @param parent defines the parent mesh if any
  17416. * @param source defines the optional source LinesMesh used to clone data from
  17417. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17418. * When false, achieved by calling a clone(), also passing False.
  17419. * This will make creation of children, recursive.
  17420. * @param useVertexColor defines if this LinesMesh supports vertex color
  17421. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17422. */
  17423. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17424. /**
  17425. * If vertex color should be applied to the mesh
  17426. */
  17427. useVertexColor?: boolean | undefined,
  17428. /**
  17429. * If vertex alpha should be applied to the mesh
  17430. */
  17431. useVertexAlpha?: boolean | undefined);
  17432. private _addClipPlaneDefine;
  17433. private _removeClipPlaneDefine;
  17434. isReady(): boolean;
  17435. /**
  17436. * Returns the string "LineMesh"
  17437. */
  17438. getClassName(): string;
  17439. /**
  17440. * @hidden
  17441. */
  17442. get material(): Material;
  17443. /**
  17444. * @hidden
  17445. */
  17446. set material(value: Material);
  17447. /**
  17448. * @hidden
  17449. */
  17450. get checkCollisions(): boolean;
  17451. /** @hidden */
  17452. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17453. /** @hidden */
  17454. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17455. /**
  17456. * Disposes of the line mesh
  17457. * @param doNotRecurse If children should be disposed
  17458. */
  17459. dispose(doNotRecurse?: boolean): void;
  17460. /**
  17461. * Returns a new LineMesh object cloned from the current one.
  17462. */
  17463. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17464. /**
  17465. * Creates a new InstancedLinesMesh object from the mesh model.
  17466. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17467. * @param name defines the name of the new instance
  17468. * @returns a new InstancedLinesMesh
  17469. */
  17470. createInstance(name: string): InstancedLinesMesh;
  17471. }
  17472. /**
  17473. * Creates an instance based on a source LinesMesh
  17474. */
  17475. export class InstancedLinesMesh extends InstancedMesh {
  17476. /**
  17477. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17478. * This margin is expressed in world space coordinates, so its value may vary.
  17479. * Initilized with the intersectionThreshold value of the source LinesMesh
  17480. */
  17481. intersectionThreshold: number;
  17482. constructor(name: string, source: LinesMesh);
  17483. /**
  17484. * Returns the string "InstancedLinesMesh".
  17485. */
  17486. getClassName(): string;
  17487. }
  17488. }
  17489. declare module "babylonjs/Shaders/line.fragment" {
  17490. /** @hidden */
  17491. export var linePixelShader: {
  17492. name: string;
  17493. shader: string;
  17494. };
  17495. }
  17496. declare module "babylonjs/Shaders/line.vertex" {
  17497. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17498. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17499. /** @hidden */
  17500. export var lineVertexShader: {
  17501. name: string;
  17502. shader: string;
  17503. };
  17504. }
  17505. declare module "babylonjs/Rendering/edgesRenderer" {
  17506. import { Nullable } from "babylonjs/types";
  17507. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17509. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17510. import { IDisposable } from "babylonjs/scene";
  17511. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17512. import "babylonjs/Shaders/line.fragment";
  17513. import "babylonjs/Shaders/line.vertex";
  17514. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17515. import { SmartArray } from "babylonjs/Misc/smartArray";
  17516. module "babylonjs/scene" {
  17517. interface Scene {
  17518. /** @hidden */
  17519. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17520. }
  17521. }
  17522. module "babylonjs/Meshes/abstractMesh" {
  17523. interface AbstractMesh {
  17524. /**
  17525. * Gets the edgesRenderer associated with the mesh
  17526. */
  17527. edgesRenderer: Nullable<EdgesRenderer>;
  17528. }
  17529. }
  17530. module "babylonjs/Meshes/linesMesh" {
  17531. interface LinesMesh {
  17532. /**
  17533. * Enables the edge rendering mode on the mesh.
  17534. * This mode makes the mesh edges visible
  17535. * @param epsilon defines the maximal distance between two angles to detect a face
  17536. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17537. * @returns the currentAbstractMesh
  17538. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17539. */
  17540. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17541. }
  17542. }
  17543. module "babylonjs/Meshes/linesMesh" {
  17544. interface InstancedLinesMesh {
  17545. /**
  17546. * Enables the edge rendering mode on the mesh.
  17547. * This mode makes the mesh edges visible
  17548. * @param epsilon defines the maximal distance between two angles to detect a face
  17549. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17550. * @returns the current InstancedLinesMesh
  17551. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17552. */
  17553. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17554. }
  17555. }
  17556. /**
  17557. * Defines the minimum contract an Edges renderer should follow.
  17558. */
  17559. export interface IEdgesRenderer extends IDisposable {
  17560. /**
  17561. * Gets or sets a boolean indicating if the edgesRenderer is active
  17562. */
  17563. isEnabled: boolean;
  17564. /**
  17565. * Renders the edges of the attached mesh,
  17566. */
  17567. render(): void;
  17568. /**
  17569. * Checks wether or not the edges renderer is ready to render.
  17570. * @return true if ready, otherwise false.
  17571. */
  17572. isReady(): boolean;
  17573. /**
  17574. * List of instances to render in case the source mesh has instances
  17575. */
  17576. customInstances: SmartArray<Matrix>;
  17577. }
  17578. /**
  17579. * Defines the additional options of the edges renderer
  17580. */
  17581. export interface IEdgesRendererOptions {
  17582. /**
  17583. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17584. * If not defined, the default value is true
  17585. */
  17586. useAlternateEdgeFinder?: boolean;
  17587. /**
  17588. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17589. * If not defined, the default value is true.
  17590. * 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)
  17591. * This option is used only if useAlternateEdgeFinder = true
  17592. */
  17593. useFastVertexMerger?: boolean;
  17594. /**
  17595. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17596. * The default value is 1e-6
  17597. * This option is used only if useAlternateEdgeFinder = true
  17598. */
  17599. epsilonVertexMerge?: number;
  17600. /**
  17601. * 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
  17602. * 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.
  17603. * This option is used only if useAlternateEdgeFinder = true
  17604. */
  17605. applyTessellation?: boolean;
  17606. /**
  17607. * 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
  17608. * The default value is 1e-6
  17609. * This option is used only if useAlternateEdgeFinder = true
  17610. */
  17611. epsilonVertexAligned?: number;
  17612. }
  17613. /**
  17614. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17615. */
  17616. export class EdgesRenderer implements IEdgesRenderer {
  17617. /**
  17618. * Define the size of the edges with an orthographic camera
  17619. */
  17620. edgesWidthScalerForOrthographic: number;
  17621. /**
  17622. * Define the size of the edges with a perspective camera
  17623. */
  17624. edgesWidthScalerForPerspective: number;
  17625. protected _source: AbstractMesh;
  17626. protected _linesPositions: number[];
  17627. protected _linesNormals: number[];
  17628. protected _linesIndices: number[];
  17629. protected _epsilon: number;
  17630. protected _indicesCount: number;
  17631. protected _lineShader: ShaderMaterial;
  17632. protected _ib: DataBuffer;
  17633. protected _buffers: {
  17634. [key: string]: Nullable<VertexBuffer>;
  17635. };
  17636. protected _buffersForInstances: {
  17637. [key: string]: Nullable<VertexBuffer>;
  17638. };
  17639. protected _checkVerticesInsteadOfIndices: boolean;
  17640. protected _options: Nullable<IEdgesRendererOptions>;
  17641. private _meshRebuildObserver;
  17642. private _meshDisposeObserver;
  17643. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17644. isEnabled: boolean;
  17645. /**
  17646. * List of instances to render in case the source mesh has instances
  17647. */
  17648. customInstances: SmartArray<Matrix>;
  17649. private static GetShader;
  17650. /**
  17651. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17652. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17653. * @param source Mesh used to create edges
  17654. * @param epsilon sum of angles in adjacency to check for edge
  17655. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17656. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17657. * @param options The options to apply when generating the edges
  17658. */
  17659. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17660. protected _prepareRessources(): void;
  17661. /** @hidden */
  17662. _rebuild(): void;
  17663. /**
  17664. * Releases the required resources for the edges renderer
  17665. */
  17666. dispose(): void;
  17667. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17668. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17669. /**
  17670. * Checks if the pair of p0 and p1 is en edge
  17671. * @param faceIndex
  17672. * @param edge
  17673. * @param faceNormals
  17674. * @param p0
  17675. * @param p1
  17676. * @private
  17677. */
  17678. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17679. /**
  17680. * push line into the position, normal and index buffer
  17681. * @protected
  17682. */
  17683. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17684. /**
  17685. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17686. */
  17687. private _tessellateTriangle;
  17688. private _generateEdgesLinesAlternate;
  17689. /**
  17690. * Generates lines edges from adjacencjes
  17691. * @private
  17692. */
  17693. _generateEdgesLines(): void;
  17694. /**
  17695. * Checks wether or not the edges renderer is ready to render.
  17696. * @return true if ready, otherwise false.
  17697. */
  17698. isReady(): boolean;
  17699. /**
  17700. * Renders the edges of the attached mesh,
  17701. */
  17702. render(): void;
  17703. }
  17704. /**
  17705. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17706. */
  17707. export class LineEdgesRenderer extends EdgesRenderer {
  17708. /**
  17709. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17710. * @param source LineMesh used to generate edges
  17711. * @param epsilon not important (specified angle for edge detection)
  17712. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17713. */
  17714. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17715. /**
  17716. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17717. */
  17718. _generateEdgesLines(): void;
  17719. }
  17720. }
  17721. declare module "babylonjs/Rendering/renderingGroup" {
  17722. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17723. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17725. import { Nullable } from "babylonjs/types";
  17726. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17727. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17728. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17729. import { Material } from "babylonjs/Materials/material";
  17730. import { Scene } from "babylonjs/scene";
  17731. /**
  17732. * This represents the object necessary to create a rendering group.
  17733. * This is exclusively used and created by the rendering manager.
  17734. * To modify the behavior, you use the available helpers in your scene or meshes.
  17735. * @hidden
  17736. */
  17737. export class RenderingGroup {
  17738. index: number;
  17739. private static _zeroVector;
  17740. private _scene;
  17741. private _opaqueSubMeshes;
  17742. private _transparentSubMeshes;
  17743. private _alphaTestSubMeshes;
  17744. private _depthOnlySubMeshes;
  17745. private _particleSystems;
  17746. private _spriteManagers;
  17747. private _opaqueSortCompareFn;
  17748. private _alphaTestSortCompareFn;
  17749. private _transparentSortCompareFn;
  17750. private _renderOpaque;
  17751. private _renderAlphaTest;
  17752. private _renderTransparent;
  17753. /** @hidden */
  17754. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17755. onBeforeTransparentRendering: () => void;
  17756. /**
  17757. * Set the opaque sort comparison function.
  17758. * If null the sub meshes will be render in the order they were created
  17759. */
  17760. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17761. /**
  17762. * Set the alpha test sort comparison function.
  17763. * If null the sub meshes will be render in the order they were created
  17764. */
  17765. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17766. /**
  17767. * Set the transparent sort comparison function.
  17768. * If null the sub meshes will be render in the order they were created
  17769. */
  17770. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17771. /**
  17772. * Creates a new rendering group.
  17773. * @param index The rendering group index
  17774. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17775. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17776. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17777. */
  17778. 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>);
  17779. /**
  17780. * Render all the sub meshes contained in the group.
  17781. * @param customRenderFunction Used to override the default render behaviour of the group.
  17782. * @returns true if rendered some submeshes.
  17783. */
  17784. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17785. /**
  17786. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17787. * @param subMeshes The submeshes to render
  17788. */
  17789. private renderOpaqueSorted;
  17790. /**
  17791. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17792. * @param subMeshes The submeshes to render
  17793. */
  17794. private renderAlphaTestSorted;
  17795. /**
  17796. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17797. * @param subMeshes The submeshes to render
  17798. */
  17799. private renderTransparentSorted;
  17800. /**
  17801. * Renders the submeshes in a specified order.
  17802. * @param subMeshes The submeshes to sort before render
  17803. * @param sortCompareFn The comparison function use to sort
  17804. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17805. * @param transparent Specifies to activate blending if true
  17806. */
  17807. private static renderSorted;
  17808. /**
  17809. * Renders the submeshes in the order they were dispatched (no sort applied).
  17810. * @param subMeshes The submeshes to render
  17811. */
  17812. private static renderUnsorted;
  17813. /**
  17814. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17815. * are rendered back to front if in the same alpha index.
  17816. *
  17817. * @param a The first submesh
  17818. * @param b The second submesh
  17819. * @returns The result of the comparison
  17820. */
  17821. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17822. /**
  17823. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17824. * are rendered back to front.
  17825. *
  17826. * @param a The first submesh
  17827. * @param b The second submesh
  17828. * @returns The result of the comparison
  17829. */
  17830. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17831. /**
  17832. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17833. * are rendered front to back (prevent overdraw).
  17834. *
  17835. * @param a The first submesh
  17836. * @param b The second submesh
  17837. * @returns The result of the comparison
  17838. */
  17839. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17840. /**
  17841. * Resets the different lists of submeshes to prepare a new frame.
  17842. */
  17843. prepare(): void;
  17844. dispose(): void;
  17845. /**
  17846. * Inserts the submesh in its correct queue depending on its material.
  17847. * @param subMesh The submesh to dispatch
  17848. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17849. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17850. */
  17851. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17852. dispatchSprites(spriteManager: ISpriteManager): void;
  17853. dispatchParticles(particleSystem: IParticleSystem): void;
  17854. private _renderParticles;
  17855. private _renderSprites;
  17856. }
  17857. }
  17858. declare module "babylonjs/Rendering/renderingManager" {
  17859. import { Nullable } from "babylonjs/types";
  17860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17861. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17862. import { SmartArray } from "babylonjs/Misc/smartArray";
  17863. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17864. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17865. import { Material } from "babylonjs/Materials/material";
  17866. import { Scene } from "babylonjs/scene";
  17867. import { Camera } from "babylonjs/Cameras/camera";
  17868. /**
  17869. * Interface describing the different options available in the rendering manager
  17870. * regarding Auto Clear between groups.
  17871. */
  17872. export interface IRenderingManagerAutoClearSetup {
  17873. /**
  17874. * Defines whether or not autoclear is enable.
  17875. */
  17876. autoClear: boolean;
  17877. /**
  17878. * Defines whether or not to autoclear the depth buffer.
  17879. */
  17880. depth: boolean;
  17881. /**
  17882. * Defines whether or not to autoclear the stencil buffer.
  17883. */
  17884. stencil: boolean;
  17885. }
  17886. /**
  17887. * This class is used by the onRenderingGroupObservable
  17888. */
  17889. export class RenderingGroupInfo {
  17890. /**
  17891. * The Scene that being rendered
  17892. */
  17893. scene: Scene;
  17894. /**
  17895. * The camera currently used for the rendering pass
  17896. */
  17897. camera: Nullable<Camera>;
  17898. /**
  17899. * The ID of the renderingGroup being processed
  17900. */
  17901. renderingGroupId: number;
  17902. }
  17903. /**
  17904. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17905. * It is enable to manage the different groups as well as the different necessary sort functions.
  17906. * This should not be used directly aside of the few static configurations
  17907. */
  17908. export class RenderingManager {
  17909. /**
  17910. * The max id used for rendering groups (not included)
  17911. */
  17912. static MAX_RENDERINGGROUPS: number;
  17913. /**
  17914. * The min id used for rendering groups (included)
  17915. */
  17916. static MIN_RENDERINGGROUPS: number;
  17917. /**
  17918. * Used to globally prevent autoclearing scenes.
  17919. */
  17920. static AUTOCLEAR: boolean;
  17921. /**
  17922. * @hidden
  17923. */
  17924. _useSceneAutoClearSetup: boolean;
  17925. private _scene;
  17926. private _renderingGroups;
  17927. private _depthStencilBufferAlreadyCleaned;
  17928. private _autoClearDepthStencil;
  17929. private _customOpaqueSortCompareFn;
  17930. private _customAlphaTestSortCompareFn;
  17931. private _customTransparentSortCompareFn;
  17932. private _renderingGroupInfo;
  17933. /**
  17934. * Instantiates a new rendering group for a particular scene
  17935. * @param scene Defines the scene the groups belongs to
  17936. */
  17937. constructor(scene: Scene);
  17938. private _clearDepthStencilBuffer;
  17939. /**
  17940. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17941. * @hidden
  17942. */
  17943. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17944. /**
  17945. * Resets the different information of the group to prepare a new frame
  17946. * @hidden
  17947. */
  17948. reset(): void;
  17949. /**
  17950. * Dispose and release the group and its associated resources.
  17951. * @hidden
  17952. */
  17953. dispose(): void;
  17954. /**
  17955. * Clear the info related to rendering groups preventing retention points during dispose.
  17956. */
  17957. freeRenderingGroups(): void;
  17958. private _prepareRenderingGroup;
  17959. /**
  17960. * Add a sprite manager to the rendering manager in order to render it this frame.
  17961. * @param spriteManager Define the sprite manager to render
  17962. */
  17963. dispatchSprites(spriteManager: ISpriteManager): void;
  17964. /**
  17965. * Add a particle system to the rendering manager in order to render it this frame.
  17966. * @param particleSystem Define the particle system to render
  17967. */
  17968. dispatchParticles(particleSystem: IParticleSystem): void;
  17969. /**
  17970. * Add a submesh to the manager in order to render it this frame
  17971. * @param subMesh The submesh to dispatch
  17972. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17973. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17974. */
  17975. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17976. /**
  17977. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17978. * This allowed control for front to back rendering or reversly depending of the special needs.
  17979. *
  17980. * @param renderingGroupId The rendering group id corresponding to its index
  17981. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17982. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17983. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17984. */
  17985. 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;
  17986. /**
  17987. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17988. *
  17989. * @param renderingGroupId The rendering group id corresponding to its index
  17990. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17991. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17992. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17993. */
  17994. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17995. /**
  17996. * Gets the current auto clear configuration for one rendering group of the rendering
  17997. * manager.
  17998. * @param index the rendering group index to get the information for
  17999. * @returns The auto clear setup for the requested rendering group
  18000. */
  18001. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18002. }
  18003. }
  18004. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  18005. import { SmartArray } from "babylonjs/Misc/smartArray";
  18006. import { Nullable } from "babylonjs/types";
  18007. import { Scene } from "babylonjs/scene";
  18008. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  18009. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18011. import { Mesh } from "babylonjs/Meshes/mesh";
  18012. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  18013. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18014. import { Effect } from "babylonjs/Materials/effect";
  18015. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18016. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18017. import "babylonjs/Shaders/shadowMap.fragment";
  18018. import "babylonjs/Shaders/shadowMap.vertex";
  18019. import "babylonjs/Shaders/depthBoxBlur.fragment";
  18020. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  18021. import { Observable } from "babylonjs/Misc/observable";
  18022. /**
  18023. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18024. */
  18025. export interface ICustomShaderOptions {
  18026. /**
  18027. * Gets or sets the custom shader name to use
  18028. */
  18029. shaderName: string;
  18030. /**
  18031. * The list of attribute names used in the shader
  18032. */
  18033. attributes?: string[];
  18034. /**
  18035. * The list of unifrom names used in the shader
  18036. */
  18037. uniforms?: string[];
  18038. /**
  18039. * The list of sampler names used in the shader
  18040. */
  18041. samplers?: string[];
  18042. /**
  18043. * The list of defines used in the shader
  18044. */
  18045. defines?: string[];
  18046. }
  18047. /**
  18048. * Interface to implement to create a shadow generator compatible with BJS.
  18049. */
  18050. export interface IShadowGenerator {
  18051. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18052. id: string;
  18053. /**
  18054. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18055. * @returns The render target texture if present otherwise, null
  18056. */
  18057. getShadowMap(): Nullable<RenderTargetTexture>;
  18058. /**
  18059. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18060. * @param subMesh The submesh we want to render in the shadow map
  18061. * @param useInstances Defines wether will draw in the map using instances
  18062. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18063. * @returns true if ready otherwise, false
  18064. */
  18065. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18066. /**
  18067. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18068. * @param defines Defines of the material we want to update
  18069. * @param lightIndex Index of the light in the enabled light list of the material
  18070. */
  18071. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18072. /**
  18073. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18074. * defined in the generator but impacting the effect).
  18075. * It implies the unifroms available on the materials are the standard BJS ones.
  18076. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18077. * @param effect The effect we are binfing the information for
  18078. */
  18079. bindShadowLight(lightIndex: string, effect: Effect): void;
  18080. /**
  18081. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18082. * (eq to shadow prjection matrix * light transform matrix)
  18083. * @returns The transform matrix used to create the shadow map
  18084. */
  18085. getTransformMatrix(): Matrix;
  18086. /**
  18087. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18088. * Cube and 2D textures for instance.
  18089. */
  18090. recreateShadowMap(): void;
  18091. /**
  18092. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18093. * @param onCompiled Callback triggered at the and of the effects compilation
  18094. * @param options Sets of optional options forcing the compilation with different modes
  18095. */
  18096. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18097. useInstances: boolean;
  18098. }>): void;
  18099. /**
  18100. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18101. * @param options Sets of optional options forcing the compilation with different modes
  18102. * @returns A promise that resolves when the compilation completes
  18103. */
  18104. forceCompilationAsync(options?: Partial<{
  18105. useInstances: boolean;
  18106. }>): Promise<void>;
  18107. /**
  18108. * Serializes the shadow generator setup to a json object.
  18109. * @returns The serialized JSON object
  18110. */
  18111. serialize(): any;
  18112. /**
  18113. * Disposes the Shadow map and related Textures and effects.
  18114. */
  18115. dispose(): void;
  18116. }
  18117. /**
  18118. * Default implementation IShadowGenerator.
  18119. * This is the main object responsible of generating shadows in the framework.
  18120. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18121. */
  18122. export class ShadowGenerator implements IShadowGenerator {
  18123. /**
  18124. * Name of the shadow generator class
  18125. */
  18126. static CLASSNAME: string;
  18127. /**
  18128. * Shadow generator mode None: no filtering applied.
  18129. */
  18130. static readonly FILTER_NONE: number;
  18131. /**
  18132. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18133. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18134. */
  18135. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18136. /**
  18137. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18138. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18139. */
  18140. static readonly FILTER_POISSONSAMPLING: number;
  18141. /**
  18142. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18143. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18144. */
  18145. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18146. /**
  18147. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18148. * edge artifacts on steep falloff.
  18149. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18150. */
  18151. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18152. /**
  18153. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18154. * edge artifacts on steep falloff.
  18155. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18156. */
  18157. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18158. /**
  18159. * Shadow generator mode PCF: Percentage Closer Filtering
  18160. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18161. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18162. */
  18163. static readonly FILTER_PCF: number;
  18164. /**
  18165. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18166. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18167. * Contact Hardening
  18168. */
  18169. static readonly FILTER_PCSS: number;
  18170. /**
  18171. * Reserved for PCF and PCSS
  18172. * Highest Quality.
  18173. *
  18174. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18175. *
  18176. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18177. */
  18178. static readonly QUALITY_HIGH: number;
  18179. /**
  18180. * Reserved for PCF and PCSS
  18181. * Good tradeoff for quality/perf cross devices
  18182. *
  18183. * Execute PCF on a 3*3 kernel.
  18184. *
  18185. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18186. */
  18187. static readonly QUALITY_MEDIUM: number;
  18188. /**
  18189. * Reserved for PCF and PCSS
  18190. * The lowest quality but the fastest.
  18191. *
  18192. * Execute PCF on a 1*1 kernel.
  18193. *
  18194. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18195. */
  18196. static readonly QUALITY_LOW: number;
  18197. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18198. id: string;
  18199. /** Gets or sets the custom shader name to use */
  18200. customShaderOptions: ICustomShaderOptions;
  18201. /**
  18202. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18203. */
  18204. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18205. /**
  18206. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18207. */
  18208. onAfterShadowMapRenderObservable: Observable<Effect>;
  18209. /**
  18210. * Observable triggered before a mesh is rendered in the shadow map.
  18211. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18212. */
  18213. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18214. /**
  18215. * Observable triggered after a mesh is rendered in the shadow map.
  18216. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18217. */
  18218. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18219. protected _bias: number;
  18220. /**
  18221. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18222. */
  18223. get bias(): number;
  18224. /**
  18225. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18226. */
  18227. set bias(bias: number);
  18228. protected _normalBias: number;
  18229. /**
  18230. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18231. */
  18232. get normalBias(): number;
  18233. /**
  18234. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18235. */
  18236. set normalBias(normalBias: number);
  18237. protected _blurBoxOffset: number;
  18238. /**
  18239. * Gets the blur box offset: offset applied during the blur pass.
  18240. * Only useful if useKernelBlur = false
  18241. */
  18242. get blurBoxOffset(): number;
  18243. /**
  18244. * Sets the blur box offset: offset applied during the blur pass.
  18245. * Only useful if useKernelBlur = false
  18246. */
  18247. set blurBoxOffset(value: number);
  18248. protected _blurScale: number;
  18249. /**
  18250. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18251. * 2 means half of the size.
  18252. */
  18253. get blurScale(): number;
  18254. /**
  18255. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18256. * 2 means half of the size.
  18257. */
  18258. set blurScale(value: number);
  18259. protected _blurKernel: number;
  18260. /**
  18261. * Gets the blur kernel: kernel size of the blur pass.
  18262. * Only useful if useKernelBlur = true
  18263. */
  18264. get blurKernel(): number;
  18265. /**
  18266. * Sets the blur kernel: kernel size of the blur pass.
  18267. * Only useful if useKernelBlur = true
  18268. */
  18269. set blurKernel(value: number);
  18270. protected _useKernelBlur: boolean;
  18271. /**
  18272. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18273. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18274. */
  18275. get useKernelBlur(): boolean;
  18276. /**
  18277. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18278. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18279. */
  18280. set useKernelBlur(value: boolean);
  18281. protected _depthScale: number;
  18282. /**
  18283. * Gets the depth scale used in ESM mode.
  18284. */
  18285. get depthScale(): number;
  18286. /**
  18287. * Sets the depth scale used in ESM mode.
  18288. * This can override the scale stored on the light.
  18289. */
  18290. set depthScale(value: number);
  18291. protected _validateFilter(filter: number): number;
  18292. protected _filter: number;
  18293. /**
  18294. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18295. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18296. */
  18297. get filter(): number;
  18298. /**
  18299. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18300. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18301. */
  18302. set filter(value: number);
  18303. /**
  18304. * Gets if the current filter is set to Poisson Sampling.
  18305. */
  18306. get usePoissonSampling(): boolean;
  18307. /**
  18308. * Sets the current filter to Poisson Sampling.
  18309. */
  18310. set usePoissonSampling(value: boolean);
  18311. /**
  18312. * Gets if the current filter is set to ESM.
  18313. */
  18314. get useExponentialShadowMap(): boolean;
  18315. /**
  18316. * Sets the current filter is to ESM.
  18317. */
  18318. set useExponentialShadowMap(value: boolean);
  18319. /**
  18320. * Gets if the current filter is set to filtered ESM.
  18321. */
  18322. get useBlurExponentialShadowMap(): boolean;
  18323. /**
  18324. * Gets if the current filter is set to filtered ESM.
  18325. */
  18326. set useBlurExponentialShadowMap(value: boolean);
  18327. /**
  18328. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18329. * exponential to prevent steep falloff artifacts).
  18330. */
  18331. get useCloseExponentialShadowMap(): boolean;
  18332. /**
  18333. * Sets the current filter to "close ESM" (using the inverse of the
  18334. * exponential to prevent steep falloff artifacts).
  18335. */
  18336. set useCloseExponentialShadowMap(value: boolean);
  18337. /**
  18338. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18339. * exponential to prevent steep falloff artifacts).
  18340. */
  18341. get useBlurCloseExponentialShadowMap(): boolean;
  18342. /**
  18343. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18344. * exponential to prevent steep falloff artifacts).
  18345. */
  18346. set useBlurCloseExponentialShadowMap(value: boolean);
  18347. /**
  18348. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18349. */
  18350. get usePercentageCloserFiltering(): boolean;
  18351. /**
  18352. * Sets the current filter to "PCF" (percentage closer filtering).
  18353. */
  18354. set usePercentageCloserFiltering(value: boolean);
  18355. protected _filteringQuality: number;
  18356. /**
  18357. * Gets the PCF or PCSS Quality.
  18358. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18359. */
  18360. get filteringQuality(): number;
  18361. /**
  18362. * Sets the PCF or PCSS Quality.
  18363. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18364. */
  18365. set filteringQuality(filteringQuality: number);
  18366. /**
  18367. * Gets if the current filter is set to "PCSS" (contact hardening).
  18368. */
  18369. get useContactHardeningShadow(): boolean;
  18370. /**
  18371. * Sets the current filter to "PCSS" (contact hardening).
  18372. */
  18373. set useContactHardeningShadow(value: boolean);
  18374. protected _contactHardeningLightSizeUVRatio: number;
  18375. /**
  18376. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18377. * Using a ratio helps keeping shape stability independently of the map size.
  18378. *
  18379. * It does not account for the light projection as it was having too much
  18380. * instability during the light setup or during light position changes.
  18381. *
  18382. * Only valid if useContactHardeningShadow is true.
  18383. */
  18384. get contactHardeningLightSizeUVRatio(): number;
  18385. /**
  18386. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18387. * Using a ratio helps keeping shape stability independently of the map size.
  18388. *
  18389. * It does not account for the light projection as it was having too much
  18390. * instability during the light setup or during light position changes.
  18391. *
  18392. * Only valid if useContactHardeningShadow is true.
  18393. */
  18394. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18395. protected _darkness: number;
  18396. /** Gets or sets the actual darkness of a shadow */
  18397. get darkness(): number;
  18398. set darkness(value: number);
  18399. /**
  18400. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18401. * 0 means strongest and 1 would means no shadow.
  18402. * @returns the darkness.
  18403. */
  18404. getDarkness(): number;
  18405. /**
  18406. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18407. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18408. * @returns the shadow generator allowing fluent coding.
  18409. */
  18410. setDarkness(darkness: number): ShadowGenerator;
  18411. protected _transparencyShadow: boolean;
  18412. /** Gets or sets the ability to have transparent shadow */
  18413. get transparencyShadow(): boolean;
  18414. set transparencyShadow(value: boolean);
  18415. /**
  18416. * Sets the ability to have transparent shadow (boolean).
  18417. * @param transparent True if transparent else False
  18418. * @returns the shadow generator allowing fluent coding
  18419. */
  18420. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18421. /**
  18422. * Enables or disables shadows with varying strength based on the transparency
  18423. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18424. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18425. * mesh.visibility * alphaTexture.a
  18426. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18427. */
  18428. enableSoftTransparentShadow: boolean;
  18429. protected _shadowMap: Nullable<RenderTargetTexture>;
  18430. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18431. /**
  18432. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18433. * @returns The render target texture if present otherwise, null
  18434. */
  18435. getShadowMap(): Nullable<RenderTargetTexture>;
  18436. /**
  18437. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18438. * @returns The render target texture if the shadow map is present otherwise, null
  18439. */
  18440. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18441. /**
  18442. * Gets the class name of that object
  18443. * @returns "ShadowGenerator"
  18444. */
  18445. getClassName(): string;
  18446. /**
  18447. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18448. * @param mesh Mesh to add
  18449. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18450. * @returns the Shadow Generator itself
  18451. */
  18452. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18453. /**
  18454. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18455. * @param mesh Mesh to remove
  18456. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18457. * @returns the Shadow Generator itself
  18458. */
  18459. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18460. /**
  18461. * Controls the extent to which the shadows fade out at the edge of the frustum
  18462. */
  18463. frustumEdgeFalloff: number;
  18464. protected _light: IShadowLight;
  18465. /**
  18466. * Returns the associated light object.
  18467. * @returns the light generating the shadow
  18468. */
  18469. getLight(): IShadowLight;
  18470. /**
  18471. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18472. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18473. * It might on the other hand introduce peter panning.
  18474. */
  18475. forceBackFacesOnly: boolean;
  18476. protected _scene: Scene;
  18477. protected _lightDirection: Vector3;
  18478. protected _effect: Effect;
  18479. protected _viewMatrix: Matrix;
  18480. protected _projectionMatrix: Matrix;
  18481. protected _transformMatrix: Matrix;
  18482. protected _cachedPosition: Vector3;
  18483. protected _cachedDirection: Vector3;
  18484. protected _cachedDefines: string;
  18485. protected _currentRenderID: number;
  18486. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18487. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18488. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18489. protected _blurPostProcesses: PostProcess[];
  18490. protected _mapSize: number;
  18491. protected _currentFaceIndex: number;
  18492. protected _currentFaceIndexCache: number;
  18493. protected _textureType: number;
  18494. protected _defaultTextureMatrix: Matrix;
  18495. protected _storedUniqueId: Nullable<number>;
  18496. /** @hidden */
  18497. static _SceneComponentInitialization: (scene: Scene) => void;
  18498. /**
  18499. * Gets or sets the size of the texture what stores the shadows
  18500. */
  18501. get mapSize(): number;
  18502. set mapSize(size: number);
  18503. /**
  18504. * Creates a ShadowGenerator object.
  18505. * A ShadowGenerator is the required tool to use the shadows.
  18506. * Each light casting shadows needs to use its own ShadowGenerator.
  18507. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18508. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18509. * @param light The light object generating the shadows.
  18510. * @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.
  18511. */
  18512. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18513. protected _initializeGenerator(): void;
  18514. protected _createTargetRenderTexture(): void;
  18515. protected _initializeShadowMap(): void;
  18516. protected _initializeBlurRTTAndPostProcesses(): void;
  18517. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18518. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18519. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18520. protected _applyFilterValues(): void;
  18521. /**
  18522. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18523. * @param onCompiled Callback triggered at the and of the effects compilation
  18524. * @param options Sets of optional options forcing the compilation with different modes
  18525. */
  18526. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18527. useInstances: boolean;
  18528. }>): void;
  18529. /**
  18530. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18531. * @param options Sets of optional options forcing the compilation with different modes
  18532. * @returns A promise that resolves when the compilation completes
  18533. */
  18534. forceCompilationAsync(options?: Partial<{
  18535. useInstances: boolean;
  18536. }>): Promise<void>;
  18537. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18538. private _prepareShadowDefines;
  18539. /**
  18540. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18541. * @param subMesh The submesh we want to render in the shadow map
  18542. * @param useInstances Defines wether will draw in the map using instances
  18543. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18544. * @returns true if ready otherwise, false
  18545. */
  18546. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18547. /**
  18548. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18549. * @param defines Defines of the material we want to update
  18550. * @param lightIndex Index of the light in the enabled light list of the material
  18551. */
  18552. prepareDefines(defines: any, lightIndex: number): void;
  18553. /**
  18554. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18555. * defined in the generator but impacting the effect).
  18556. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18557. * @param effect The effect we are binfing the information for
  18558. */
  18559. bindShadowLight(lightIndex: string, effect: Effect): void;
  18560. /**
  18561. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18562. * (eq to shadow prjection matrix * light transform matrix)
  18563. * @returns The transform matrix used to create the shadow map
  18564. */
  18565. getTransformMatrix(): Matrix;
  18566. /**
  18567. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18568. * Cube and 2D textures for instance.
  18569. */
  18570. recreateShadowMap(): void;
  18571. protected _disposeBlurPostProcesses(): void;
  18572. protected _disposeRTTandPostProcesses(): void;
  18573. /**
  18574. * Disposes the ShadowGenerator.
  18575. * Returns nothing.
  18576. */
  18577. dispose(): void;
  18578. /**
  18579. * Serializes the shadow generator setup to a json object.
  18580. * @returns The serialized JSON object
  18581. */
  18582. serialize(): any;
  18583. /**
  18584. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18585. * @param parsedShadowGenerator The JSON object to parse
  18586. * @param scene The scene to create the shadow map for
  18587. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18588. * @returns The parsed shadow generator
  18589. */
  18590. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18591. }
  18592. }
  18593. declare module "babylonjs/Lights/light" {
  18594. import { Nullable } from "babylonjs/types";
  18595. import { Scene } from "babylonjs/scene";
  18596. import { Vector3 } from "babylonjs/Maths/math.vector";
  18597. import { Color3 } from "babylonjs/Maths/math.color";
  18598. import { Node } from "babylonjs/node";
  18599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18600. import { Effect } from "babylonjs/Materials/effect";
  18601. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18602. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18603. /**
  18604. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18605. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18606. * 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.
  18607. */
  18608. export abstract class Light extends Node {
  18609. /**
  18610. * Falloff Default: light is falling off following the material specification:
  18611. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18612. */
  18613. static readonly FALLOFF_DEFAULT: number;
  18614. /**
  18615. * Falloff Physical: light is falling off following the inverse squared distance law.
  18616. */
  18617. static readonly FALLOFF_PHYSICAL: number;
  18618. /**
  18619. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18620. * to enhance interoperability with other engines.
  18621. */
  18622. static readonly FALLOFF_GLTF: number;
  18623. /**
  18624. * Falloff Standard: light is falling off like in the standard material
  18625. * to enhance interoperability with other materials.
  18626. */
  18627. static readonly FALLOFF_STANDARD: number;
  18628. /**
  18629. * If every light affecting the material is in this lightmapMode,
  18630. * material.lightmapTexture adds or multiplies
  18631. * (depends on material.useLightmapAsShadowmap)
  18632. * after every other light calculations.
  18633. */
  18634. static readonly LIGHTMAP_DEFAULT: number;
  18635. /**
  18636. * material.lightmapTexture as only diffuse lighting from this light
  18637. * adds only specular lighting from this light
  18638. * adds dynamic shadows
  18639. */
  18640. static readonly LIGHTMAP_SPECULAR: number;
  18641. /**
  18642. * material.lightmapTexture as only lighting
  18643. * no light calculation from this light
  18644. * only adds dynamic shadows from this light
  18645. */
  18646. static readonly LIGHTMAP_SHADOWSONLY: number;
  18647. /**
  18648. * Each light type uses the default quantity according to its type:
  18649. * point/spot lights use luminous intensity
  18650. * directional lights use illuminance
  18651. */
  18652. static readonly INTENSITYMODE_AUTOMATIC: number;
  18653. /**
  18654. * lumen (lm)
  18655. */
  18656. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18657. /**
  18658. * candela (lm/sr)
  18659. */
  18660. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18661. /**
  18662. * lux (lm/m^2)
  18663. */
  18664. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18665. /**
  18666. * nit (cd/m^2)
  18667. */
  18668. static readonly INTENSITYMODE_LUMINANCE: number;
  18669. /**
  18670. * Light type const id of the point light.
  18671. */
  18672. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18673. /**
  18674. * Light type const id of the directional light.
  18675. */
  18676. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18677. /**
  18678. * Light type const id of the spot light.
  18679. */
  18680. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18681. /**
  18682. * Light type const id of the hemispheric light.
  18683. */
  18684. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18685. /**
  18686. * Diffuse gives the basic color to an object.
  18687. */
  18688. diffuse: Color3;
  18689. /**
  18690. * Specular produces a highlight color on an object.
  18691. * Note: This is note affecting PBR materials.
  18692. */
  18693. specular: Color3;
  18694. /**
  18695. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18696. * falling off base on range or angle.
  18697. * This can be set to any values in Light.FALLOFF_x.
  18698. *
  18699. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18700. * other types of materials.
  18701. */
  18702. falloffType: number;
  18703. /**
  18704. * Strength of the light.
  18705. * Note: By default it is define in the framework own unit.
  18706. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18707. */
  18708. intensity: number;
  18709. private _range;
  18710. protected _inverseSquaredRange: number;
  18711. /**
  18712. * Defines how far from the source the light is impacting in scene units.
  18713. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18714. */
  18715. get range(): number;
  18716. /**
  18717. * Defines how far from the source the light is impacting in scene units.
  18718. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18719. */
  18720. set range(value: number);
  18721. /**
  18722. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18723. * of light.
  18724. */
  18725. private _photometricScale;
  18726. private _intensityMode;
  18727. /**
  18728. * Gets the photometric scale used to interpret the intensity.
  18729. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18730. */
  18731. get intensityMode(): number;
  18732. /**
  18733. * Sets the photometric scale used to interpret the intensity.
  18734. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18735. */
  18736. set intensityMode(value: number);
  18737. private _radius;
  18738. /**
  18739. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18740. */
  18741. get radius(): number;
  18742. /**
  18743. * sets the light radius used by PBR Materials to simulate soft area lights.
  18744. */
  18745. set radius(value: number);
  18746. private _renderPriority;
  18747. /**
  18748. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18749. * exceeding the number allowed of the materials.
  18750. */
  18751. renderPriority: number;
  18752. private _shadowEnabled;
  18753. /**
  18754. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18755. * the current shadow generator.
  18756. */
  18757. get shadowEnabled(): boolean;
  18758. /**
  18759. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18760. * the current shadow generator.
  18761. */
  18762. set shadowEnabled(value: boolean);
  18763. private _includedOnlyMeshes;
  18764. /**
  18765. * Gets the only meshes impacted by this light.
  18766. */
  18767. get includedOnlyMeshes(): AbstractMesh[];
  18768. /**
  18769. * Sets the only meshes impacted by this light.
  18770. */
  18771. set includedOnlyMeshes(value: AbstractMesh[]);
  18772. private _excludedMeshes;
  18773. /**
  18774. * Gets the meshes not impacted by this light.
  18775. */
  18776. get excludedMeshes(): AbstractMesh[];
  18777. /**
  18778. * Sets the meshes not impacted by this light.
  18779. */
  18780. set excludedMeshes(value: AbstractMesh[]);
  18781. private _excludeWithLayerMask;
  18782. /**
  18783. * Gets the layer id use to find what meshes are not impacted by the light.
  18784. * Inactive if 0
  18785. */
  18786. get excludeWithLayerMask(): number;
  18787. /**
  18788. * Sets the layer id use to find what meshes are not impacted by the light.
  18789. * Inactive if 0
  18790. */
  18791. set excludeWithLayerMask(value: number);
  18792. private _includeOnlyWithLayerMask;
  18793. /**
  18794. * Gets the layer id use to find what meshes are impacted by the light.
  18795. * Inactive if 0
  18796. */
  18797. get includeOnlyWithLayerMask(): number;
  18798. /**
  18799. * Sets the layer id use to find what meshes are impacted by the light.
  18800. * Inactive if 0
  18801. */
  18802. set includeOnlyWithLayerMask(value: number);
  18803. private _lightmapMode;
  18804. /**
  18805. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18806. */
  18807. get lightmapMode(): number;
  18808. /**
  18809. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18810. */
  18811. set lightmapMode(value: number);
  18812. /**
  18813. * Shadow generator associted to the light.
  18814. * @hidden Internal use only.
  18815. */
  18816. _shadowGenerator: Nullable<IShadowGenerator>;
  18817. /**
  18818. * @hidden Internal use only.
  18819. */
  18820. _excludedMeshesIds: string[];
  18821. /**
  18822. * @hidden Internal use only.
  18823. */
  18824. _includedOnlyMeshesIds: string[];
  18825. /**
  18826. * The current light unifom buffer.
  18827. * @hidden Internal use only.
  18828. */
  18829. _uniformBuffer: UniformBuffer;
  18830. /** @hidden */
  18831. _renderId: number;
  18832. /**
  18833. * Creates a Light object in the scene.
  18834. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18835. * @param name The firendly name of the light
  18836. * @param scene The scene the light belongs too
  18837. */
  18838. constructor(name: string, scene: Scene);
  18839. protected abstract _buildUniformLayout(): void;
  18840. /**
  18841. * Sets the passed Effect "effect" with the Light information.
  18842. * @param effect The effect to update
  18843. * @param lightIndex The index of the light in the effect to update
  18844. * @returns The light
  18845. */
  18846. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18847. /**
  18848. * Sets the passed Effect "effect" with the Light textures.
  18849. * @param effect The effect to update
  18850. * @param lightIndex The index of the light in the effect to update
  18851. * @returns The light
  18852. */
  18853. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18854. /**
  18855. * Binds the lights information from the scene to the effect for the given mesh.
  18856. * @param lightIndex Light index
  18857. * @param scene The scene where the light belongs to
  18858. * @param effect The effect we are binding the data to
  18859. * @param useSpecular Defines if specular is supported
  18860. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18861. */
  18862. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18863. /**
  18864. * Sets the passed Effect "effect" with the Light information.
  18865. * @param effect The effect to update
  18866. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18867. * @returns The light
  18868. */
  18869. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18870. /**
  18871. * Returns the string "Light".
  18872. * @returns the class name
  18873. */
  18874. getClassName(): string;
  18875. /** @hidden */
  18876. readonly _isLight: boolean;
  18877. /**
  18878. * Converts the light information to a readable string for debug purpose.
  18879. * @param fullDetails Supports for multiple levels of logging within scene loading
  18880. * @returns the human readable light info
  18881. */
  18882. toString(fullDetails?: boolean): string;
  18883. /** @hidden */
  18884. protected _syncParentEnabledState(): void;
  18885. /**
  18886. * Set the enabled state of this node.
  18887. * @param value - the new enabled state
  18888. */
  18889. setEnabled(value: boolean): void;
  18890. /**
  18891. * Returns the Light associated shadow generator if any.
  18892. * @return the associated shadow generator.
  18893. */
  18894. getShadowGenerator(): Nullable<IShadowGenerator>;
  18895. /**
  18896. * Returns a Vector3, the absolute light position in the World.
  18897. * @returns the world space position of the light
  18898. */
  18899. getAbsolutePosition(): Vector3;
  18900. /**
  18901. * Specifies if the light will affect the passed mesh.
  18902. * @param mesh The mesh to test against the light
  18903. * @return true the mesh is affected otherwise, false.
  18904. */
  18905. canAffectMesh(mesh: AbstractMesh): boolean;
  18906. /**
  18907. * Sort function to order lights for rendering.
  18908. * @param a First Light object to compare to second.
  18909. * @param b Second Light object to compare first.
  18910. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18911. */
  18912. static CompareLightsPriority(a: Light, b: Light): number;
  18913. /**
  18914. * Releases resources associated with this node.
  18915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18917. */
  18918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18919. /**
  18920. * Returns the light type ID (integer).
  18921. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18922. */
  18923. getTypeID(): number;
  18924. /**
  18925. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18926. * @returns the scaled intensity in intensity mode unit
  18927. */
  18928. getScaledIntensity(): number;
  18929. /**
  18930. * Returns a new Light object, named "name", from the current one.
  18931. * @param name The name of the cloned light
  18932. * @param newParent The parent of this light, if it has one
  18933. * @returns the new created light
  18934. */
  18935. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18936. /**
  18937. * Serializes the current light into a Serialization object.
  18938. * @returns the serialized object.
  18939. */
  18940. serialize(): any;
  18941. /**
  18942. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18943. * This new light is named "name" and added to the passed scene.
  18944. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18945. * @param name The friendly name of the light
  18946. * @param scene The scene the new light will belong to
  18947. * @returns the constructor function
  18948. */
  18949. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18950. /**
  18951. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18952. * @param parsedLight The JSON representation of the light
  18953. * @param scene The scene to create the parsed light in
  18954. * @returns the created light after parsing
  18955. */
  18956. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18957. private _hookArrayForExcluded;
  18958. private _hookArrayForIncludedOnly;
  18959. private _resyncMeshes;
  18960. /**
  18961. * Forces the meshes to update their light related information in their rendering used effects
  18962. * @hidden Internal Use Only
  18963. */
  18964. _markMeshesAsLightDirty(): void;
  18965. /**
  18966. * Recomputes the cached photometric scale if needed.
  18967. */
  18968. private _computePhotometricScale;
  18969. /**
  18970. * Returns the Photometric Scale according to the light type and intensity mode.
  18971. */
  18972. private _getPhotometricScale;
  18973. /**
  18974. * Reorder the light in the scene according to their defined priority.
  18975. * @hidden Internal Use Only
  18976. */
  18977. _reorderLightsInScene(): void;
  18978. /**
  18979. * Prepares the list of defines specific to the light type.
  18980. * @param defines the list of defines
  18981. * @param lightIndex defines the index of the light for the effect
  18982. */
  18983. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18984. }
  18985. }
  18986. declare module "babylonjs/Materials/prePassConfiguration" {
  18987. import { Matrix } from "babylonjs/Maths/math.vector";
  18988. import { Mesh } from "babylonjs/Meshes/mesh";
  18989. import { Scene } from "babylonjs/scene";
  18990. import { Effect } from "babylonjs/Materials/effect";
  18991. /**
  18992. * Configuration needed for prepass-capable materials
  18993. */
  18994. export class PrePassConfiguration {
  18995. /**
  18996. * Previous world matrices of meshes carrying this material
  18997. * Used for computing velocity
  18998. */
  18999. previousWorldMatrices: {
  19000. [index: number]: Matrix;
  19001. };
  19002. /**
  19003. * Previous view project matrix
  19004. * Used for computing velocity
  19005. */
  19006. previousViewProjection: Matrix;
  19007. /**
  19008. * Previous bones of meshes carrying this material
  19009. * Used for computing velocity
  19010. */
  19011. previousBones: {
  19012. [index: number]: Float32Array;
  19013. };
  19014. /**
  19015. * Add the required uniforms to the current list.
  19016. * @param uniforms defines the current uniform list.
  19017. */
  19018. static AddUniforms(uniforms: string[]): void;
  19019. /**
  19020. * Add the required samplers to the current list.
  19021. * @param samplers defines the current sampler list.
  19022. */
  19023. static AddSamplers(samplers: string[]): void;
  19024. /**
  19025. * Binds the material data.
  19026. * @param effect defines the effect to update
  19027. * @param scene defines the scene the material belongs to.
  19028. * @param mesh The mesh
  19029. * @param world World matrix of this mesh
  19030. * @param isFrozen Is the material frozen
  19031. */
  19032. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19033. }
  19034. }
  19035. declare module "babylonjs/Cameras/targetCamera" {
  19036. import { Nullable } from "babylonjs/types";
  19037. import { Camera } from "babylonjs/Cameras/camera";
  19038. import { Scene } from "babylonjs/scene";
  19039. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19040. /**
  19041. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19042. * This is the base of the follow, arc rotate cameras and Free camera
  19043. * @see https://doc.babylonjs.com/features/cameras
  19044. */
  19045. export class TargetCamera extends Camera {
  19046. private static _RigCamTransformMatrix;
  19047. private static _TargetTransformMatrix;
  19048. private static _TargetFocalPoint;
  19049. private _tmpUpVector;
  19050. private _tmpTargetVector;
  19051. /**
  19052. * Define the current direction the camera is moving to
  19053. */
  19054. cameraDirection: Vector3;
  19055. /**
  19056. * Define the current rotation the camera is rotating to
  19057. */
  19058. cameraRotation: Vector2;
  19059. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19060. ignoreParentScaling: boolean;
  19061. /**
  19062. * When set, the up vector of the camera will be updated by the rotation of the camera
  19063. */
  19064. updateUpVectorFromRotation: boolean;
  19065. private _tmpQuaternion;
  19066. /**
  19067. * Define the current rotation of the camera
  19068. */
  19069. rotation: Vector3;
  19070. /**
  19071. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19072. */
  19073. rotationQuaternion: Quaternion;
  19074. /**
  19075. * Define the current speed of the camera
  19076. */
  19077. speed: number;
  19078. /**
  19079. * Add constraint to the camera to prevent it to move freely in all directions and
  19080. * around all axis.
  19081. */
  19082. noRotationConstraint: boolean;
  19083. /**
  19084. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19085. * panning
  19086. */
  19087. invertRotation: boolean;
  19088. /**
  19089. * Speed multiplier for inverse camera panning
  19090. */
  19091. inverseRotationSpeed: number;
  19092. /**
  19093. * Define the current target of the camera as an object or a position.
  19094. */
  19095. lockedTarget: any;
  19096. /** @hidden */
  19097. _currentTarget: Vector3;
  19098. /** @hidden */
  19099. _initialFocalDistance: number;
  19100. /** @hidden */
  19101. _viewMatrix: Matrix;
  19102. /** @hidden */
  19103. _camMatrix: Matrix;
  19104. /** @hidden */
  19105. _cameraTransformMatrix: Matrix;
  19106. /** @hidden */
  19107. _cameraRotationMatrix: Matrix;
  19108. /** @hidden */
  19109. _referencePoint: Vector3;
  19110. /** @hidden */
  19111. _transformedReferencePoint: Vector3;
  19112. /** @hidden */
  19113. _reset: () => void;
  19114. private _defaultUp;
  19115. /**
  19116. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19117. * This is the base of the follow, arc rotate cameras and Free camera
  19118. * @see https://doc.babylonjs.com/features/cameras
  19119. * @param name Defines the name of the camera in the scene
  19120. * @param position Defines the start position of the camera in the scene
  19121. * @param scene Defines the scene the camera belongs to
  19122. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19123. */
  19124. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19125. /**
  19126. * Gets the position in front of the camera at a given distance.
  19127. * @param distance The distance from the camera we want the position to be
  19128. * @returns the position
  19129. */
  19130. getFrontPosition(distance: number): Vector3;
  19131. /** @hidden */
  19132. _getLockedTargetPosition(): Nullable<Vector3>;
  19133. private _storedPosition;
  19134. private _storedRotation;
  19135. private _storedRotationQuaternion;
  19136. /**
  19137. * Store current camera state of the camera (fov, position, rotation, etc..)
  19138. * @returns the camera
  19139. */
  19140. storeState(): Camera;
  19141. /**
  19142. * Restored camera state. You must call storeState() first
  19143. * @returns whether it was successful or not
  19144. * @hidden
  19145. */
  19146. _restoreStateValues(): boolean;
  19147. /** @hidden */
  19148. _initCache(): void;
  19149. /** @hidden */
  19150. _updateCache(ignoreParentClass?: boolean): void;
  19151. /** @hidden */
  19152. _isSynchronizedViewMatrix(): boolean;
  19153. /** @hidden */
  19154. _computeLocalCameraSpeed(): number;
  19155. /**
  19156. * Defines the target the camera should look at.
  19157. * @param target Defines the new target as a Vector or a mesh
  19158. */
  19159. setTarget(target: Vector3): void;
  19160. /**
  19161. * Defines the target point of the camera.
  19162. * The camera looks towards it form the radius distance.
  19163. */
  19164. get target(): Vector3;
  19165. set target(value: Vector3);
  19166. /**
  19167. * Return the current target position of the camera. This value is expressed in local space.
  19168. * @returns the target position
  19169. */
  19170. getTarget(): Vector3;
  19171. /** @hidden */
  19172. _decideIfNeedsToMove(): boolean;
  19173. /** @hidden */
  19174. _updatePosition(): void;
  19175. /** @hidden */
  19176. _checkInputs(): void;
  19177. protected _updateCameraRotationMatrix(): void;
  19178. /**
  19179. * 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)
  19180. * @returns the current camera
  19181. */
  19182. private _rotateUpVectorWithCameraRotationMatrix;
  19183. private _cachedRotationZ;
  19184. private _cachedQuaternionRotationZ;
  19185. /** @hidden */
  19186. _getViewMatrix(): Matrix;
  19187. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19188. /**
  19189. * @hidden
  19190. */
  19191. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19192. /**
  19193. * @hidden
  19194. */
  19195. _updateRigCameras(): void;
  19196. private _getRigCamPositionAndTarget;
  19197. /**
  19198. * Gets the current object class name.
  19199. * @return the class name
  19200. */
  19201. getClassName(): string;
  19202. }
  19203. }
  19204. declare module "babylonjs/Events/keyboardEvents" {
  19205. /**
  19206. * Gather the list of keyboard event types as constants.
  19207. */
  19208. export class KeyboardEventTypes {
  19209. /**
  19210. * The keydown event is fired when a key becomes active (pressed).
  19211. */
  19212. static readonly KEYDOWN: number;
  19213. /**
  19214. * The keyup event is fired when a key has been released.
  19215. */
  19216. static readonly KEYUP: number;
  19217. }
  19218. /**
  19219. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19220. */
  19221. export class KeyboardInfo {
  19222. /**
  19223. * Defines the type of event (KeyboardEventTypes)
  19224. */
  19225. type: number;
  19226. /**
  19227. * Defines the related dom event
  19228. */
  19229. event: KeyboardEvent;
  19230. /**
  19231. * Instantiates a new keyboard info.
  19232. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19233. * @param type Defines the type of event (KeyboardEventTypes)
  19234. * @param event Defines the related dom event
  19235. */
  19236. constructor(
  19237. /**
  19238. * Defines the type of event (KeyboardEventTypes)
  19239. */
  19240. type: number,
  19241. /**
  19242. * Defines the related dom event
  19243. */
  19244. event: KeyboardEvent);
  19245. }
  19246. /**
  19247. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19248. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19249. */
  19250. export class KeyboardInfoPre extends KeyboardInfo {
  19251. /**
  19252. * Defines the type of event (KeyboardEventTypes)
  19253. */
  19254. type: number;
  19255. /**
  19256. * Defines the related dom event
  19257. */
  19258. event: KeyboardEvent;
  19259. /**
  19260. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19261. */
  19262. skipOnPointerObservable: boolean;
  19263. /**
  19264. * Instantiates a new keyboard pre info.
  19265. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19266. * @param type Defines the type of event (KeyboardEventTypes)
  19267. * @param event Defines the related dom event
  19268. */
  19269. constructor(
  19270. /**
  19271. * Defines the type of event (KeyboardEventTypes)
  19272. */
  19273. type: number,
  19274. /**
  19275. * Defines the related dom event
  19276. */
  19277. event: KeyboardEvent);
  19278. }
  19279. }
  19280. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19281. import { Nullable } from "babylonjs/types";
  19282. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19283. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19284. /**
  19285. * Manage the keyboard inputs to control the movement of a free camera.
  19286. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19287. */
  19288. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19289. /**
  19290. * Defines the camera the input is attached to.
  19291. */
  19292. camera: FreeCamera;
  19293. /**
  19294. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19295. */
  19296. keysUp: number[];
  19297. /**
  19298. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19299. */
  19300. keysUpward: number[];
  19301. /**
  19302. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19303. */
  19304. keysDown: number[];
  19305. /**
  19306. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19307. */
  19308. keysDownward: number[];
  19309. /**
  19310. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19311. */
  19312. keysLeft: number[];
  19313. /**
  19314. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19315. */
  19316. keysRight: number[];
  19317. private _keys;
  19318. private _onCanvasBlurObserver;
  19319. private _onKeyboardObserver;
  19320. private _engine;
  19321. private _scene;
  19322. /**
  19323. * Attach the input controls to a specific dom element to get the input from.
  19324. * @param element Defines the element the controls should be listened from
  19325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19326. */
  19327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19328. /**
  19329. * Detach the current controls from the specified dom element.
  19330. * @param element Defines the element to stop listening the inputs from
  19331. */
  19332. detachControl(element: Nullable<HTMLElement>): void;
  19333. /**
  19334. * Update the current camera state depending on the inputs that have been used this frame.
  19335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19336. */
  19337. checkInputs(): void;
  19338. /**
  19339. * Gets the class name of the current intput.
  19340. * @returns the class name
  19341. */
  19342. getClassName(): string;
  19343. /** @hidden */
  19344. _onLostFocus(): void;
  19345. /**
  19346. * Get the friendly name associated with the input class.
  19347. * @returns the input friendly name
  19348. */
  19349. getSimpleName(): string;
  19350. }
  19351. }
  19352. declare module "babylonjs/Events/pointerEvents" {
  19353. import { Nullable } from "babylonjs/types";
  19354. import { Vector2 } from "babylonjs/Maths/math.vector";
  19355. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19356. import { Ray } from "babylonjs/Culling/ray";
  19357. /**
  19358. * Gather the list of pointer event types as constants.
  19359. */
  19360. export class PointerEventTypes {
  19361. /**
  19362. * 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.
  19363. */
  19364. static readonly POINTERDOWN: number;
  19365. /**
  19366. * The pointerup event is fired when a pointer is no longer active.
  19367. */
  19368. static readonly POINTERUP: number;
  19369. /**
  19370. * The pointermove event is fired when a pointer changes coordinates.
  19371. */
  19372. static readonly POINTERMOVE: number;
  19373. /**
  19374. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19375. */
  19376. static readonly POINTERWHEEL: number;
  19377. /**
  19378. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19379. */
  19380. static readonly POINTERPICK: number;
  19381. /**
  19382. * The pointertap event is fired when a the object has been touched and released without drag.
  19383. */
  19384. static readonly POINTERTAP: number;
  19385. /**
  19386. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19387. */
  19388. static readonly POINTERDOUBLETAP: number;
  19389. }
  19390. /**
  19391. * Base class of pointer info types.
  19392. */
  19393. export class PointerInfoBase {
  19394. /**
  19395. * Defines the type of event (PointerEventTypes)
  19396. */
  19397. type: number;
  19398. /**
  19399. * Defines the related dom event
  19400. */
  19401. event: PointerEvent | MouseWheelEvent;
  19402. /**
  19403. * Instantiates the base class of pointers info.
  19404. * @param type Defines the type of event (PointerEventTypes)
  19405. * @param event Defines the related dom event
  19406. */
  19407. constructor(
  19408. /**
  19409. * Defines the type of event (PointerEventTypes)
  19410. */
  19411. type: number,
  19412. /**
  19413. * Defines the related dom event
  19414. */
  19415. event: PointerEvent | MouseWheelEvent);
  19416. }
  19417. /**
  19418. * This class is used to store pointer related info for the onPrePointerObservable event.
  19419. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19420. */
  19421. export class PointerInfoPre extends PointerInfoBase {
  19422. /**
  19423. * Ray from a pointer if availible (eg. 6dof controller)
  19424. */
  19425. ray: Nullable<Ray>;
  19426. /**
  19427. * Defines the local position of the pointer on the canvas.
  19428. */
  19429. localPosition: Vector2;
  19430. /**
  19431. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19432. */
  19433. skipOnPointerObservable: boolean;
  19434. /**
  19435. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19436. * @param type Defines the type of event (PointerEventTypes)
  19437. * @param event Defines the related dom event
  19438. * @param localX Defines the local x coordinates of the pointer when the event occured
  19439. * @param localY Defines the local y coordinates of the pointer when the event occured
  19440. */
  19441. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19442. }
  19443. /**
  19444. * This type contains all the data related to a pointer event in Babylon.js.
  19445. * 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.
  19446. */
  19447. export class PointerInfo extends PointerInfoBase {
  19448. /**
  19449. * Defines the picking info associated to the info (if any)\
  19450. */
  19451. pickInfo: Nullable<PickingInfo>;
  19452. /**
  19453. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19454. * @param type Defines the type of event (PointerEventTypes)
  19455. * @param event Defines the related dom event
  19456. * @param pickInfo Defines the picking info associated to the info (if any)\
  19457. */
  19458. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19459. /**
  19460. * Defines the picking info associated to the info (if any)\
  19461. */
  19462. pickInfo: Nullable<PickingInfo>);
  19463. }
  19464. /**
  19465. * Data relating to a touch event on the screen.
  19466. */
  19467. export interface PointerTouch {
  19468. /**
  19469. * X coordinate of touch.
  19470. */
  19471. x: number;
  19472. /**
  19473. * Y coordinate of touch.
  19474. */
  19475. y: number;
  19476. /**
  19477. * Id of touch. Unique for each finger.
  19478. */
  19479. pointerId: number;
  19480. /**
  19481. * Event type passed from DOM.
  19482. */
  19483. type: any;
  19484. }
  19485. }
  19486. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19487. import { Observable } from "babylonjs/Misc/observable";
  19488. import { Nullable } from "babylonjs/types";
  19489. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19490. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19491. /**
  19492. * Manage the mouse inputs to control the movement of a free camera.
  19493. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19494. */
  19495. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19496. /**
  19497. * Define if touch is enabled in the mouse input
  19498. */
  19499. touchEnabled: boolean;
  19500. /**
  19501. * Defines the camera the input is attached to.
  19502. */
  19503. camera: FreeCamera;
  19504. /**
  19505. * Defines the buttons associated with the input to handle camera move.
  19506. */
  19507. buttons: number[];
  19508. /**
  19509. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19510. */
  19511. angularSensibility: number;
  19512. private _pointerInput;
  19513. private _onMouseMove;
  19514. private _observer;
  19515. private previousPosition;
  19516. /**
  19517. * Observable for when a pointer move event occurs containing the move offset
  19518. */
  19519. onPointerMovedObservable: Observable<{
  19520. offsetX: number;
  19521. offsetY: number;
  19522. }>;
  19523. /**
  19524. * @hidden
  19525. * If the camera should be rotated automatically based on pointer movement
  19526. */
  19527. _allowCameraRotation: boolean;
  19528. /**
  19529. * Manage the mouse inputs to control the movement of a free camera.
  19530. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19531. * @param touchEnabled Defines if touch is enabled or not
  19532. */
  19533. constructor(
  19534. /**
  19535. * Define if touch is enabled in the mouse input
  19536. */
  19537. touchEnabled?: boolean);
  19538. /**
  19539. * Attach the input controls to a specific dom element to get the input from.
  19540. * @param element Defines the element the controls should be listened from
  19541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19542. */
  19543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19544. /**
  19545. * Called on JS contextmenu event.
  19546. * Override this method to provide functionality.
  19547. */
  19548. protected onContextMenu(evt: PointerEvent): void;
  19549. /**
  19550. * Detach the current controls from the specified dom element.
  19551. * @param element Defines the element to stop listening the inputs from
  19552. */
  19553. detachControl(element: Nullable<HTMLElement>): void;
  19554. /**
  19555. * Gets the class name of the current intput.
  19556. * @returns the class name
  19557. */
  19558. getClassName(): string;
  19559. /**
  19560. * Get the friendly name associated with the input class.
  19561. * @returns the input friendly name
  19562. */
  19563. getSimpleName(): string;
  19564. }
  19565. }
  19566. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19567. import { Nullable } from "babylonjs/types";
  19568. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19569. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19570. /**
  19571. * Manage the touch inputs to control the movement of a free camera.
  19572. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19573. */
  19574. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19575. /**
  19576. * Define if mouse events can be treated as touch events
  19577. */
  19578. allowMouse: boolean;
  19579. /**
  19580. * Defines the camera the input is attached to.
  19581. */
  19582. camera: FreeCamera;
  19583. /**
  19584. * Defines the touch sensibility for rotation.
  19585. * The higher the faster.
  19586. */
  19587. touchAngularSensibility: number;
  19588. /**
  19589. * Defines the touch sensibility for move.
  19590. * The higher the faster.
  19591. */
  19592. touchMoveSensibility: number;
  19593. private _offsetX;
  19594. private _offsetY;
  19595. private _pointerPressed;
  19596. private _pointerInput;
  19597. private _observer;
  19598. private _onLostFocus;
  19599. /**
  19600. * Manage the touch inputs to control the movement of a free camera.
  19601. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19602. * @param allowMouse Defines if mouse events can be treated as touch events
  19603. */
  19604. constructor(
  19605. /**
  19606. * Define if mouse events can be treated as touch events
  19607. */
  19608. allowMouse?: boolean);
  19609. /**
  19610. * Attach the input controls to a specific dom element to get the input from.
  19611. * @param element Defines the element the controls should be listened from
  19612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19613. */
  19614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19615. /**
  19616. * Detach the current controls from the specified dom element.
  19617. * @param element Defines the element to stop listening the inputs from
  19618. */
  19619. detachControl(element: Nullable<HTMLElement>): void;
  19620. /**
  19621. * Update the current camera state depending on the inputs that have been used this frame.
  19622. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19623. */
  19624. checkInputs(): void;
  19625. /**
  19626. * Gets the class name of the current intput.
  19627. * @returns the class name
  19628. */
  19629. getClassName(): string;
  19630. /**
  19631. * Get the friendly name associated with the input class.
  19632. * @returns the input friendly name
  19633. */
  19634. getSimpleName(): string;
  19635. }
  19636. }
  19637. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19638. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19639. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19640. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19641. import { Nullable } from "babylonjs/types";
  19642. /**
  19643. * Default Inputs manager for the FreeCamera.
  19644. * It groups all the default supported inputs for ease of use.
  19645. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19646. */
  19647. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19648. /**
  19649. * @hidden
  19650. */
  19651. _mouseInput: Nullable<FreeCameraMouseInput>;
  19652. /**
  19653. * Instantiates a new FreeCameraInputsManager.
  19654. * @param camera Defines the camera the inputs belong to
  19655. */
  19656. constructor(camera: FreeCamera);
  19657. /**
  19658. * Add keyboard input support to the input manager.
  19659. * @returns the current input manager
  19660. */
  19661. addKeyboard(): FreeCameraInputsManager;
  19662. /**
  19663. * Add mouse input support to the input manager.
  19664. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19665. * @returns the current input manager
  19666. */
  19667. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19668. /**
  19669. * Removes the mouse input support from the manager
  19670. * @returns the current input manager
  19671. */
  19672. removeMouse(): FreeCameraInputsManager;
  19673. /**
  19674. * Add touch input support to the input manager.
  19675. * @returns the current input manager
  19676. */
  19677. addTouch(): FreeCameraInputsManager;
  19678. /**
  19679. * Remove all attached input methods from a camera
  19680. */
  19681. clear(): void;
  19682. }
  19683. }
  19684. declare module "babylonjs/Cameras/freeCamera" {
  19685. import { Vector3 } from "babylonjs/Maths/math.vector";
  19686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19687. import { Scene } from "babylonjs/scene";
  19688. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19689. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19690. /**
  19691. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19692. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19693. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19694. */
  19695. export class FreeCamera extends TargetCamera {
  19696. /**
  19697. * Define the collision ellipsoid of the camera.
  19698. * This is helpful to simulate a camera body like the player body around the camera
  19699. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19700. */
  19701. ellipsoid: Vector3;
  19702. /**
  19703. * Define an offset for the position of the ellipsoid around the camera.
  19704. * This can be helpful to determine the center of the body near the gravity center of the body
  19705. * instead of its head.
  19706. */
  19707. ellipsoidOffset: Vector3;
  19708. /**
  19709. * Enable or disable collisions of the camera with the rest of the scene objects.
  19710. */
  19711. checkCollisions: boolean;
  19712. /**
  19713. * Enable or disable gravity on the camera.
  19714. */
  19715. applyGravity: boolean;
  19716. /**
  19717. * Define the input manager associated to the camera.
  19718. */
  19719. inputs: FreeCameraInputsManager;
  19720. /**
  19721. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19722. * Higher values reduce sensitivity.
  19723. */
  19724. get angularSensibility(): number;
  19725. /**
  19726. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19727. * Higher values reduce sensitivity.
  19728. */
  19729. set angularSensibility(value: number);
  19730. /**
  19731. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19732. */
  19733. get keysUp(): number[];
  19734. set keysUp(value: number[]);
  19735. /**
  19736. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19737. */
  19738. get keysUpward(): number[];
  19739. set keysUpward(value: number[]);
  19740. /**
  19741. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19742. */
  19743. get keysDown(): number[];
  19744. set keysDown(value: number[]);
  19745. /**
  19746. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19747. */
  19748. get keysDownward(): number[];
  19749. set keysDownward(value: number[]);
  19750. /**
  19751. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19752. */
  19753. get keysLeft(): number[];
  19754. set keysLeft(value: number[]);
  19755. /**
  19756. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19757. */
  19758. get keysRight(): number[];
  19759. set keysRight(value: number[]);
  19760. /**
  19761. * Event raised when the camera collide with a mesh in the scene.
  19762. */
  19763. onCollide: (collidedMesh: AbstractMesh) => void;
  19764. private _collider;
  19765. private _needMoveForGravity;
  19766. private _oldPosition;
  19767. private _diffPosition;
  19768. private _newPosition;
  19769. /** @hidden */
  19770. _localDirection: Vector3;
  19771. /** @hidden */
  19772. _transformedDirection: Vector3;
  19773. /**
  19774. * Instantiates a Free Camera.
  19775. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19776. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19777. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19778. * @param name Define the name of the camera in the scene
  19779. * @param position Define the start position of the camera in the scene
  19780. * @param scene Define the scene the camera belongs to
  19781. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19782. */
  19783. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19784. /**
  19785. * Attached controls to the current camera.
  19786. * @param element Defines the element the controls should be listened from
  19787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19788. */
  19789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19790. /**
  19791. * Detach the current controls from the camera.
  19792. * The camera will stop reacting to inputs.
  19793. * @param element Defines the element to stop listening the inputs from
  19794. */
  19795. detachControl(element: HTMLElement): void;
  19796. private _collisionMask;
  19797. /**
  19798. * Define a collision mask to limit the list of object the camera can collide with
  19799. */
  19800. get collisionMask(): number;
  19801. set collisionMask(mask: number);
  19802. /** @hidden */
  19803. _collideWithWorld(displacement: Vector3): void;
  19804. private _onCollisionPositionChange;
  19805. /** @hidden */
  19806. _checkInputs(): void;
  19807. /** @hidden */
  19808. _decideIfNeedsToMove(): boolean;
  19809. /** @hidden */
  19810. _updatePosition(): void;
  19811. /**
  19812. * Destroy the camera and release the current resources hold by it.
  19813. */
  19814. dispose(): void;
  19815. /**
  19816. * Gets the current object class name.
  19817. * @return the class name
  19818. */
  19819. getClassName(): string;
  19820. }
  19821. }
  19822. declare module "babylonjs/Gamepads/gamepad" {
  19823. import { Observable } from "babylonjs/Misc/observable";
  19824. /**
  19825. * Represents a gamepad control stick position
  19826. */
  19827. export class StickValues {
  19828. /**
  19829. * The x component of the control stick
  19830. */
  19831. x: number;
  19832. /**
  19833. * The y component of the control stick
  19834. */
  19835. y: number;
  19836. /**
  19837. * Initializes the gamepad x and y control stick values
  19838. * @param x The x component of the gamepad control stick value
  19839. * @param y The y component of the gamepad control stick value
  19840. */
  19841. constructor(
  19842. /**
  19843. * The x component of the control stick
  19844. */
  19845. x: number,
  19846. /**
  19847. * The y component of the control stick
  19848. */
  19849. y: number);
  19850. }
  19851. /**
  19852. * An interface which manages callbacks for gamepad button changes
  19853. */
  19854. export interface GamepadButtonChanges {
  19855. /**
  19856. * Called when a gamepad has been changed
  19857. */
  19858. changed: boolean;
  19859. /**
  19860. * Called when a gamepad press event has been triggered
  19861. */
  19862. pressChanged: boolean;
  19863. /**
  19864. * Called when a touch event has been triggered
  19865. */
  19866. touchChanged: boolean;
  19867. /**
  19868. * Called when a value has changed
  19869. */
  19870. valueChanged: boolean;
  19871. }
  19872. /**
  19873. * Represents a gamepad
  19874. */
  19875. export class Gamepad {
  19876. /**
  19877. * The id of the gamepad
  19878. */
  19879. id: string;
  19880. /**
  19881. * The index of the gamepad
  19882. */
  19883. index: number;
  19884. /**
  19885. * The browser gamepad
  19886. */
  19887. browserGamepad: any;
  19888. /**
  19889. * Specifies what type of gamepad this represents
  19890. */
  19891. type: number;
  19892. private _leftStick;
  19893. private _rightStick;
  19894. /** @hidden */
  19895. _isConnected: boolean;
  19896. private _leftStickAxisX;
  19897. private _leftStickAxisY;
  19898. private _rightStickAxisX;
  19899. private _rightStickAxisY;
  19900. /**
  19901. * Triggered when the left control stick has been changed
  19902. */
  19903. private _onleftstickchanged;
  19904. /**
  19905. * Triggered when the right control stick has been changed
  19906. */
  19907. private _onrightstickchanged;
  19908. /**
  19909. * Represents a gamepad controller
  19910. */
  19911. static GAMEPAD: number;
  19912. /**
  19913. * Represents a generic controller
  19914. */
  19915. static GENERIC: number;
  19916. /**
  19917. * Represents an XBox controller
  19918. */
  19919. static XBOX: number;
  19920. /**
  19921. * Represents a pose-enabled controller
  19922. */
  19923. static POSE_ENABLED: number;
  19924. /**
  19925. * Represents an Dual Shock controller
  19926. */
  19927. static DUALSHOCK: number;
  19928. /**
  19929. * Specifies whether the left control stick should be Y-inverted
  19930. */
  19931. protected _invertLeftStickY: boolean;
  19932. /**
  19933. * Specifies if the gamepad has been connected
  19934. */
  19935. get isConnected(): boolean;
  19936. /**
  19937. * Initializes the gamepad
  19938. * @param id The id of the gamepad
  19939. * @param index The index of the gamepad
  19940. * @param browserGamepad The browser gamepad
  19941. * @param leftStickX The x component of the left joystick
  19942. * @param leftStickY The y component of the left joystick
  19943. * @param rightStickX The x component of the right joystick
  19944. * @param rightStickY The y component of the right joystick
  19945. */
  19946. constructor(
  19947. /**
  19948. * The id of the gamepad
  19949. */
  19950. id: string,
  19951. /**
  19952. * The index of the gamepad
  19953. */
  19954. index: number,
  19955. /**
  19956. * The browser gamepad
  19957. */
  19958. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19959. /**
  19960. * Callback triggered when the left joystick has changed
  19961. * @param callback
  19962. */
  19963. onleftstickchanged(callback: (values: StickValues) => void): void;
  19964. /**
  19965. * Callback triggered when the right joystick has changed
  19966. * @param callback
  19967. */
  19968. onrightstickchanged(callback: (values: StickValues) => void): void;
  19969. /**
  19970. * Gets the left joystick
  19971. */
  19972. get leftStick(): StickValues;
  19973. /**
  19974. * Sets the left joystick values
  19975. */
  19976. set leftStick(newValues: StickValues);
  19977. /**
  19978. * Gets the right joystick
  19979. */
  19980. get rightStick(): StickValues;
  19981. /**
  19982. * Sets the right joystick value
  19983. */
  19984. set rightStick(newValues: StickValues);
  19985. /**
  19986. * Updates the gamepad joystick positions
  19987. */
  19988. update(): void;
  19989. /**
  19990. * Disposes the gamepad
  19991. */
  19992. dispose(): void;
  19993. }
  19994. /**
  19995. * Represents a generic gamepad
  19996. */
  19997. export class GenericPad extends Gamepad {
  19998. private _buttons;
  19999. private _onbuttondown;
  20000. private _onbuttonup;
  20001. /**
  20002. * Observable triggered when a button has been pressed
  20003. */
  20004. onButtonDownObservable: Observable<number>;
  20005. /**
  20006. * Observable triggered when a button has been released
  20007. */
  20008. onButtonUpObservable: Observable<number>;
  20009. /**
  20010. * Callback triggered when a button has been pressed
  20011. * @param callback Called when a button has been pressed
  20012. */
  20013. onbuttondown(callback: (buttonPressed: number) => void): void;
  20014. /**
  20015. * Callback triggered when a button has been released
  20016. * @param callback Called when a button has been released
  20017. */
  20018. onbuttonup(callback: (buttonReleased: number) => void): void;
  20019. /**
  20020. * Initializes the generic gamepad
  20021. * @param id The id of the generic gamepad
  20022. * @param index The index of the generic gamepad
  20023. * @param browserGamepad The browser gamepad
  20024. */
  20025. constructor(id: string, index: number, browserGamepad: any);
  20026. private _setButtonValue;
  20027. /**
  20028. * Updates the generic gamepad
  20029. */
  20030. update(): void;
  20031. /**
  20032. * Disposes the generic gamepad
  20033. */
  20034. dispose(): void;
  20035. }
  20036. }
  20037. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20038. import { Observable } from "babylonjs/Misc/observable";
  20039. import { Nullable } from "babylonjs/types";
  20040. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20041. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20043. import { Ray } from "babylonjs/Culling/ray";
  20044. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20045. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20046. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20047. /**
  20048. * Defines the types of pose enabled controllers that are supported
  20049. */
  20050. export enum PoseEnabledControllerType {
  20051. /**
  20052. * HTC Vive
  20053. */
  20054. VIVE = 0,
  20055. /**
  20056. * Oculus Rift
  20057. */
  20058. OCULUS = 1,
  20059. /**
  20060. * Windows mixed reality
  20061. */
  20062. WINDOWS = 2,
  20063. /**
  20064. * Samsung gear VR
  20065. */
  20066. GEAR_VR = 3,
  20067. /**
  20068. * Google Daydream
  20069. */
  20070. DAYDREAM = 4,
  20071. /**
  20072. * Generic
  20073. */
  20074. GENERIC = 5
  20075. }
  20076. /**
  20077. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20078. */
  20079. export interface MutableGamepadButton {
  20080. /**
  20081. * Value of the button/trigger
  20082. */
  20083. value: number;
  20084. /**
  20085. * If the button/trigger is currently touched
  20086. */
  20087. touched: boolean;
  20088. /**
  20089. * If the button/trigger is currently pressed
  20090. */
  20091. pressed: boolean;
  20092. }
  20093. /**
  20094. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20095. * @hidden
  20096. */
  20097. export interface ExtendedGamepadButton extends GamepadButton {
  20098. /**
  20099. * If the button/trigger is currently pressed
  20100. */
  20101. readonly pressed: boolean;
  20102. /**
  20103. * If the button/trigger is currently touched
  20104. */
  20105. readonly touched: boolean;
  20106. /**
  20107. * Value of the button/trigger
  20108. */
  20109. readonly value: number;
  20110. }
  20111. /** @hidden */
  20112. export interface _GamePadFactory {
  20113. /**
  20114. * Returns whether or not the current gamepad can be created for this type of controller.
  20115. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20116. * @returns true if it can be created, otherwise false
  20117. */
  20118. canCreate(gamepadInfo: any): boolean;
  20119. /**
  20120. * Creates a new instance of the Gamepad.
  20121. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20122. * @returns the new gamepad instance
  20123. */
  20124. create(gamepadInfo: any): Gamepad;
  20125. }
  20126. /**
  20127. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20128. */
  20129. export class PoseEnabledControllerHelper {
  20130. /** @hidden */
  20131. static _ControllerFactories: _GamePadFactory[];
  20132. /** @hidden */
  20133. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20134. /**
  20135. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20136. * @param vrGamepad the gamepad to initialized
  20137. * @returns a vr controller of the type the gamepad identified as
  20138. */
  20139. static InitiateController(vrGamepad: any): Gamepad;
  20140. }
  20141. /**
  20142. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20143. */
  20144. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20145. /**
  20146. * If the controller is used in a webXR session
  20147. */
  20148. isXR: boolean;
  20149. private _deviceRoomPosition;
  20150. private _deviceRoomRotationQuaternion;
  20151. /**
  20152. * The device position in babylon space
  20153. */
  20154. devicePosition: Vector3;
  20155. /**
  20156. * The device rotation in babylon space
  20157. */
  20158. deviceRotationQuaternion: Quaternion;
  20159. /**
  20160. * The scale factor of the device in babylon space
  20161. */
  20162. deviceScaleFactor: number;
  20163. /**
  20164. * (Likely devicePosition should be used instead) The device position in its room space
  20165. */
  20166. position: Vector3;
  20167. /**
  20168. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20169. */
  20170. rotationQuaternion: Quaternion;
  20171. /**
  20172. * The type of controller (Eg. Windows mixed reality)
  20173. */
  20174. controllerType: PoseEnabledControllerType;
  20175. protected _calculatedPosition: Vector3;
  20176. private _calculatedRotation;
  20177. /**
  20178. * The raw pose from the device
  20179. */
  20180. rawPose: DevicePose;
  20181. private _trackPosition;
  20182. private _maxRotationDistFromHeadset;
  20183. private _draggedRoomRotation;
  20184. /**
  20185. * @hidden
  20186. */
  20187. _disableTrackPosition(fixedPosition: Vector3): void;
  20188. /**
  20189. * Internal, the mesh attached to the controller
  20190. * @hidden
  20191. */
  20192. _mesh: Nullable<AbstractMesh>;
  20193. private _poseControlledCamera;
  20194. private _leftHandSystemQuaternion;
  20195. /**
  20196. * Internal, matrix used to convert room space to babylon space
  20197. * @hidden
  20198. */
  20199. _deviceToWorld: Matrix;
  20200. /**
  20201. * Node to be used when casting a ray from the controller
  20202. * @hidden
  20203. */
  20204. _pointingPoseNode: Nullable<TransformNode>;
  20205. /**
  20206. * Name of the child mesh that can be used to cast a ray from the controller
  20207. */
  20208. static readonly POINTING_POSE: string;
  20209. /**
  20210. * Creates a new PoseEnabledController from a gamepad
  20211. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20212. */
  20213. constructor(browserGamepad: any);
  20214. private _workingMatrix;
  20215. /**
  20216. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20217. */
  20218. update(): void;
  20219. /**
  20220. * Updates only the pose device and mesh without doing any button event checking
  20221. */
  20222. protected _updatePoseAndMesh(): void;
  20223. /**
  20224. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20225. * @param poseData raw pose fromthe device
  20226. */
  20227. updateFromDevice(poseData: DevicePose): void;
  20228. /**
  20229. * @hidden
  20230. */
  20231. _meshAttachedObservable: Observable<AbstractMesh>;
  20232. /**
  20233. * Attaches a mesh to the controller
  20234. * @param mesh the mesh to be attached
  20235. */
  20236. attachToMesh(mesh: AbstractMesh): void;
  20237. /**
  20238. * Attaches the controllers mesh to a camera
  20239. * @param camera the camera the mesh should be attached to
  20240. */
  20241. attachToPoseControlledCamera(camera: TargetCamera): void;
  20242. /**
  20243. * Disposes of the controller
  20244. */
  20245. dispose(): void;
  20246. /**
  20247. * The mesh that is attached to the controller
  20248. */
  20249. get mesh(): Nullable<AbstractMesh>;
  20250. /**
  20251. * Gets the ray of the controller in the direction the controller is pointing
  20252. * @param length the length the resulting ray should be
  20253. * @returns a ray in the direction the controller is pointing
  20254. */
  20255. getForwardRay(length?: number): Ray;
  20256. }
  20257. }
  20258. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20259. import { Observable } from "babylonjs/Misc/observable";
  20260. import { Scene } from "babylonjs/scene";
  20261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20262. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20263. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20264. import { Nullable } from "babylonjs/types";
  20265. /**
  20266. * Defines the WebVRController object that represents controllers tracked in 3D space
  20267. */
  20268. export abstract class WebVRController extends PoseEnabledController {
  20269. /**
  20270. * Internal, the default controller model for the controller
  20271. */
  20272. protected _defaultModel: Nullable<AbstractMesh>;
  20273. /**
  20274. * Fired when the trigger state has changed
  20275. */
  20276. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20277. /**
  20278. * Fired when the main button state has changed
  20279. */
  20280. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20281. /**
  20282. * Fired when the secondary button state has changed
  20283. */
  20284. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20285. /**
  20286. * Fired when the pad state has changed
  20287. */
  20288. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20289. /**
  20290. * Fired when controllers stick values have changed
  20291. */
  20292. onPadValuesChangedObservable: Observable<StickValues>;
  20293. /**
  20294. * Array of button availible on the controller
  20295. */
  20296. protected _buttons: Array<MutableGamepadButton>;
  20297. private _onButtonStateChange;
  20298. /**
  20299. * Fired when a controller button's state has changed
  20300. * @param callback the callback containing the button that was modified
  20301. */
  20302. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20303. /**
  20304. * X and Y axis corresponding to the controllers joystick
  20305. */
  20306. pad: StickValues;
  20307. /**
  20308. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20309. */
  20310. hand: string;
  20311. /**
  20312. * The default controller model for the controller
  20313. */
  20314. get defaultModel(): Nullable<AbstractMesh>;
  20315. /**
  20316. * Creates a new WebVRController from a gamepad
  20317. * @param vrGamepad the gamepad that the WebVRController should be created from
  20318. */
  20319. constructor(vrGamepad: any);
  20320. /**
  20321. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20322. */
  20323. update(): void;
  20324. /**
  20325. * Function to be called when a button is modified
  20326. */
  20327. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20328. /**
  20329. * Loads a mesh and attaches it to the controller
  20330. * @param scene the scene the mesh should be added to
  20331. * @param meshLoaded callback for when the mesh has been loaded
  20332. */
  20333. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20334. private _setButtonValue;
  20335. private _changes;
  20336. private _checkChanges;
  20337. /**
  20338. * Disposes of th webVRCOntroller
  20339. */
  20340. dispose(): void;
  20341. }
  20342. }
  20343. declare module "babylonjs/Lights/hemisphericLight" {
  20344. import { Nullable } from "babylonjs/types";
  20345. import { Scene } from "babylonjs/scene";
  20346. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20347. import { Color3 } from "babylonjs/Maths/math.color";
  20348. import { Effect } from "babylonjs/Materials/effect";
  20349. import { Light } from "babylonjs/Lights/light";
  20350. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20351. /**
  20352. * The HemisphericLight simulates the ambient environment light,
  20353. * so the passed direction is the light reflection direction, not the incoming direction.
  20354. */
  20355. export class HemisphericLight extends Light {
  20356. /**
  20357. * The groundColor is the light in the opposite direction to the one specified during creation.
  20358. * 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.
  20359. */
  20360. groundColor: Color3;
  20361. /**
  20362. * The light reflection direction, not the incoming direction.
  20363. */
  20364. direction: Vector3;
  20365. /**
  20366. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20367. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20368. * The HemisphericLight can't cast shadows.
  20369. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20370. * @param name The friendly name of the light
  20371. * @param direction The direction of the light reflection
  20372. * @param scene The scene the light belongs to
  20373. */
  20374. constructor(name: string, direction: Vector3, scene: Scene);
  20375. protected _buildUniformLayout(): void;
  20376. /**
  20377. * Returns the string "HemisphericLight".
  20378. * @return The class name
  20379. */
  20380. getClassName(): string;
  20381. /**
  20382. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20383. * Returns the updated direction.
  20384. * @param target The target the direction should point to
  20385. * @return The computed direction
  20386. */
  20387. setDirectionToTarget(target: Vector3): Vector3;
  20388. /**
  20389. * Returns the shadow generator associated to the light.
  20390. * @returns Always null for hemispheric lights because it does not support shadows.
  20391. */
  20392. getShadowGenerator(): Nullable<IShadowGenerator>;
  20393. /**
  20394. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20395. * @param effect The effect to update
  20396. * @param lightIndex The index of the light in the effect to update
  20397. * @returns The hemispheric light
  20398. */
  20399. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20400. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20401. /**
  20402. * Computes the world matrix of the node
  20403. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20404. * @param useWasUpdatedFlag defines a reserved property
  20405. * @returns the world matrix
  20406. */
  20407. computeWorldMatrix(): Matrix;
  20408. /**
  20409. * Returns the integer 3.
  20410. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20411. */
  20412. getTypeID(): number;
  20413. /**
  20414. * Prepares the list of defines specific to the light type.
  20415. * @param defines the list of defines
  20416. * @param lightIndex defines the index of the light for the effect
  20417. */
  20418. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20419. }
  20420. }
  20421. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20422. /** @hidden */
  20423. export var vrMultiviewToSingleviewPixelShader: {
  20424. name: string;
  20425. shader: string;
  20426. };
  20427. }
  20428. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20429. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20430. import { Scene } from "babylonjs/scene";
  20431. /**
  20432. * Renders to multiple views with a single draw call
  20433. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20434. */
  20435. export class MultiviewRenderTarget extends RenderTargetTexture {
  20436. /**
  20437. * Creates a multiview render target
  20438. * @param scene scene used with the render target
  20439. * @param size the size of the render target (used for each view)
  20440. */
  20441. constructor(scene: Scene, size?: number | {
  20442. width: number;
  20443. height: number;
  20444. } | {
  20445. ratio: number;
  20446. });
  20447. /**
  20448. * @hidden
  20449. * @param faceIndex the face index, if its a cube texture
  20450. */
  20451. _bindFrameBuffer(faceIndex?: number): void;
  20452. /**
  20453. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20454. * @returns the view count
  20455. */
  20456. getViewCount(): number;
  20457. }
  20458. }
  20459. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20460. import { Camera } from "babylonjs/Cameras/camera";
  20461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20462. import { Nullable } from "babylonjs/types";
  20463. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20464. import { Matrix } from "babylonjs/Maths/math.vector";
  20465. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20466. module "babylonjs/Engines/engine" {
  20467. interface Engine {
  20468. /**
  20469. * Creates a new multiview render target
  20470. * @param width defines the width of the texture
  20471. * @param height defines the height of the texture
  20472. * @returns the created multiview texture
  20473. */
  20474. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20475. /**
  20476. * Binds a multiview framebuffer to be drawn to
  20477. * @param multiviewTexture texture to bind
  20478. */
  20479. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20480. }
  20481. }
  20482. module "babylonjs/Cameras/camera" {
  20483. interface Camera {
  20484. /**
  20485. * @hidden
  20486. * 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)
  20487. */
  20488. _useMultiviewToSingleView: boolean;
  20489. /**
  20490. * @hidden
  20491. * 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)
  20492. */
  20493. _multiviewTexture: Nullable<RenderTargetTexture>;
  20494. /**
  20495. * @hidden
  20496. * ensures the multiview texture of the camera exists and has the specified width/height
  20497. * @param width height to set on the multiview texture
  20498. * @param height width to set on the multiview texture
  20499. */
  20500. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20501. }
  20502. }
  20503. module "babylonjs/scene" {
  20504. interface Scene {
  20505. /** @hidden */
  20506. _transformMatrixR: Matrix;
  20507. /** @hidden */
  20508. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20509. /** @hidden */
  20510. _createMultiviewUbo(): void;
  20511. /** @hidden */
  20512. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20513. /** @hidden */
  20514. _renderMultiviewToSingleView(camera: Camera): void;
  20515. }
  20516. }
  20517. }
  20518. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20519. import { Camera } from "babylonjs/Cameras/camera";
  20520. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20521. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20522. import "babylonjs/Engines/Extensions/engine.multiview";
  20523. /**
  20524. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20525. * This will not be used for webXR as it supports displaying texture arrays directly
  20526. */
  20527. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20528. /**
  20529. * Gets a string identifying the name of the class
  20530. * @returns "VRMultiviewToSingleviewPostProcess" string
  20531. */
  20532. getClassName(): string;
  20533. /**
  20534. * Initializes a VRMultiviewToSingleview
  20535. * @param name name of the post process
  20536. * @param camera camera to be applied to
  20537. * @param scaleFactor scaling factor to the size of the output texture
  20538. */
  20539. constructor(name: string, camera: Camera, scaleFactor: number);
  20540. }
  20541. }
  20542. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20543. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20544. import { Nullable } from "babylonjs/types";
  20545. import { Size } from "babylonjs/Maths/math.size";
  20546. import { Observable } from "babylonjs/Misc/observable";
  20547. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20548. /**
  20549. * Interface used to define additional presentation attributes
  20550. */
  20551. export interface IVRPresentationAttributes {
  20552. /**
  20553. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20554. */
  20555. highRefreshRate: boolean;
  20556. /**
  20557. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20558. */
  20559. foveationLevel: number;
  20560. }
  20561. module "babylonjs/Engines/engine" {
  20562. interface Engine {
  20563. /** @hidden */
  20564. _vrDisplay: any;
  20565. /** @hidden */
  20566. _vrSupported: boolean;
  20567. /** @hidden */
  20568. _oldSize: Size;
  20569. /** @hidden */
  20570. _oldHardwareScaleFactor: number;
  20571. /** @hidden */
  20572. _vrExclusivePointerMode: boolean;
  20573. /** @hidden */
  20574. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20575. /** @hidden */
  20576. _onVRDisplayPointerRestricted: () => void;
  20577. /** @hidden */
  20578. _onVRDisplayPointerUnrestricted: () => void;
  20579. /** @hidden */
  20580. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20581. /** @hidden */
  20582. _onVrDisplayDisconnect: Nullable<() => void>;
  20583. /** @hidden */
  20584. _onVrDisplayPresentChange: Nullable<() => void>;
  20585. /**
  20586. * Observable signaled when VR display mode changes
  20587. */
  20588. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20589. /**
  20590. * Observable signaled when VR request present is complete
  20591. */
  20592. onVRRequestPresentComplete: Observable<boolean>;
  20593. /**
  20594. * Observable signaled when VR request present starts
  20595. */
  20596. onVRRequestPresentStart: Observable<Engine>;
  20597. /**
  20598. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20599. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20600. */
  20601. isInVRExclusivePointerMode: boolean;
  20602. /**
  20603. * Gets a boolean indicating if a webVR device was detected
  20604. * @returns true if a webVR device was detected
  20605. */
  20606. isVRDevicePresent(): boolean;
  20607. /**
  20608. * Gets the current webVR device
  20609. * @returns the current webVR device (or null)
  20610. */
  20611. getVRDevice(): any;
  20612. /**
  20613. * Initializes a webVR display and starts listening to display change events
  20614. * The onVRDisplayChangedObservable will be notified upon these changes
  20615. * @returns A promise containing a VRDisplay and if vr is supported
  20616. */
  20617. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20618. /** @hidden */
  20619. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20620. /**
  20621. * Gets or sets the presentation attributes used to configure VR rendering
  20622. */
  20623. vrPresentationAttributes?: IVRPresentationAttributes;
  20624. /**
  20625. * Call this function to switch to webVR mode
  20626. * Will do nothing if webVR is not supported or if there is no webVR device
  20627. * @param options the webvr options provided to the camera. mainly used for multiview
  20628. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20629. */
  20630. enableVR(options: WebVROptions): void;
  20631. /** @hidden */
  20632. _onVRFullScreenTriggered(): void;
  20633. }
  20634. }
  20635. }
  20636. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20637. import { Nullable } from "babylonjs/types";
  20638. import { Observable } from "babylonjs/Misc/observable";
  20639. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20640. import { Scene } from "babylonjs/scene";
  20641. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20642. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20643. import { Node } from "babylonjs/node";
  20644. import { Ray } from "babylonjs/Culling/ray";
  20645. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20646. import "babylonjs/Engines/Extensions/engine.webVR";
  20647. /**
  20648. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20649. * IMPORTANT!! The data is right-hand data.
  20650. * @export
  20651. * @interface DevicePose
  20652. */
  20653. export interface DevicePose {
  20654. /**
  20655. * The position of the device, values in array are [x,y,z].
  20656. */
  20657. readonly position: Nullable<Float32Array>;
  20658. /**
  20659. * The linearVelocity of the device, values in array are [x,y,z].
  20660. */
  20661. readonly linearVelocity: Nullable<Float32Array>;
  20662. /**
  20663. * The linearAcceleration of the device, values in array are [x,y,z].
  20664. */
  20665. readonly linearAcceleration: Nullable<Float32Array>;
  20666. /**
  20667. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20668. */
  20669. readonly orientation: Nullable<Float32Array>;
  20670. /**
  20671. * The angularVelocity of the device, values in array are [x,y,z].
  20672. */
  20673. readonly angularVelocity: Nullable<Float32Array>;
  20674. /**
  20675. * The angularAcceleration of the device, values in array are [x,y,z].
  20676. */
  20677. readonly angularAcceleration: Nullable<Float32Array>;
  20678. }
  20679. /**
  20680. * Interface representing a pose controlled object in Babylon.
  20681. * A pose controlled object has both regular pose values as well as pose values
  20682. * from an external device such as a VR head mounted display
  20683. */
  20684. export interface PoseControlled {
  20685. /**
  20686. * The position of the object in babylon space.
  20687. */
  20688. position: Vector3;
  20689. /**
  20690. * The rotation quaternion of the object in babylon space.
  20691. */
  20692. rotationQuaternion: Quaternion;
  20693. /**
  20694. * The position of the device in babylon space.
  20695. */
  20696. devicePosition?: Vector3;
  20697. /**
  20698. * The rotation quaternion of the device in babylon space.
  20699. */
  20700. deviceRotationQuaternion: Quaternion;
  20701. /**
  20702. * The raw pose coming from the device.
  20703. */
  20704. rawPose: Nullable<DevicePose>;
  20705. /**
  20706. * The scale of the device to be used when translating from device space to babylon space.
  20707. */
  20708. deviceScaleFactor: number;
  20709. /**
  20710. * Updates the poseControlled values based on the input device pose.
  20711. * @param poseData the pose data to update the object with
  20712. */
  20713. updateFromDevice(poseData: DevicePose): void;
  20714. }
  20715. /**
  20716. * Set of options to customize the webVRCamera
  20717. */
  20718. export interface WebVROptions {
  20719. /**
  20720. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20721. */
  20722. trackPosition?: boolean;
  20723. /**
  20724. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20725. */
  20726. positionScale?: number;
  20727. /**
  20728. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20729. */
  20730. displayName?: string;
  20731. /**
  20732. * Should the native controller meshes be initialized. (default: true)
  20733. */
  20734. controllerMeshes?: boolean;
  20735. /**
  20736. * Creating a default HemiLight only on controllers. (default: true)
  20737. */
  20738. defaultLightingOnControllers?: boolean;
  20739. /**
  20740. * If you don't want to use the default VR button of the helper. (default: false)
  20741. */
  20742. useCustomVRButton?: boolean;
  20743. /**
  20744. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20745. */
  20746. customVRButton?: HTMLButtonElement;
  20747. /**
  20748. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20749. */
  20750. rayLength?: number;
  20751. /**
  20752. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20753. */
  20754. defaultHeight?: number;
  20755. /**
  20756. * If multiview should be used if availible (default: false)
  20757. */
  20758. useMultiview?: boolean;
  20759. }
  20760. /**
  20761. * This represents a WebVR camera.
  20762. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20763. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20764. */
  20765. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20766. private webVROptions;
  20767. /**
  20768. * @hidden
  20769. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20770. */
  20771. _vrDevice: any;
  20772. /**
  20773. * The rawPose of the vrDevice.
  20774. */
  20775. rawPose: Nullable<DevicePose>;
  20776. private _onVREnabled;
  20777. private _specsVersion;
  20778. private _attached;
  20779. private _frameData;
  20780. protected _descendants: Array<Node>;
  20781. private _deviceRoomPosition;
  20782. /** @hidden */
  20783. _deviceRoomRotationQuaternion: Quaternion;
  20784. private _standingMatrix;
  20785. /**
  20786. * Represents device position in babylon space.
  20787. */
  20788. devicePosition: Vector3;
  20789. /**
  20790. * Represents device rotation in babylon space.
  20791. */
  20792. deviceRotationQuaternion: Quaternion;
  20793. /**
  20794. * The scale of the device to be used when translating from device space to babylon space.
  20795. */
  20796. deviceScaleFactor: number;
  20797. private _deviceToWorld;
  20798. private _worldToDevice;
  20799. /**
  20800. * References to the webVR controllers for the vrDevice.
  20801. */
  20802. controllers: Array<WebVRController>;
  20803. /**
  20804. * Emits an event when a controller is attached.
  20805. */
  20806. onControllersAttachedObservable: Observable<WebVRController[]>;
  20807. /**
  20808. * Emits an event when a controller's mesh has been loaded;
  20809. */
  20810. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20811. /**
  20812. * Emits an event when the HMD's pose has been updated.
  20813. */
  20814. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20815. private _poseSet;
  20816. /**
  20817. * If the rig cameras be used as parent instead of this camera.
  20818. */
  20819. rigParenting: boolean;
  20820. private _lightOnControllers;
  20821. private _defaultHeight?;
  20822. /**
  20823. * Instantiates a WebVRFreeCamera.
  20824. * @param name The name of the WebVRFreeCamera
  20825. * @param position The starting anchor position for the camera
  20826. * @param scene The scene the camera belongs to
  20827. * @param webVROptions a set of customizable options for the webVRCamera
  20828. */
  20829. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20830. /**
  20831. * Gets the device distance from the ground in meters.
  20832. * @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.
  20833. */
  20834. deviceDistanceToRoomGround(): number;
  20835. /**
  20836. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20837. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20838. */
  20839. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20840. /**
  20841. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20842. * @returns A promise with a boolean set to if the standing matrix is supported.
  20843. */
  20844. useStandingMatrixAsync(): Promise<boolean>;
  20845. /**
  20846. * Disposes the camera
  20847. */
  20848. dispose(): void;
  20849. /**
  20850. * Gets a vrController by name.
  20851. * @param name The name of the controller to retreive
  20852. * @returns the controller matching the name specified or null if not found
  20853. */
  20854. getControllerByName(name: string): Nullable<WebVRController>;
  20855. private _leftController;
  20856. /**
  20857. * The controller corresponding to the users left hand.
  20858. */
  20859. get leftController(): Nullable<WebVRController>;
  20860. private _rightController;
  20861. /**
  20862. * The controller corresponding to the users right hand.
  20863. */
  20864. get rightController(): Nullable<WebVRController>;
  20865. /**
  20866. * Casts a ray forward from the vrCamera's gaze.
  20867. * @param length Length of the ray (default: 100)
  20868. * @returns the ray corresponding to the gaze
  20869. */
  20870. getForwardRay(length?: number): Ray;
  20871. /**
  20872. * @hidden
  20873. * Updates the camera based on device's frame data
  20874. */
  20875. _checkInputs(): void;
  20876. /**
  20877. * Updates the poseControlled values based on the input device pose.
  20878. * @param poseData Pose coming from the device
  20879. */
  20880. updateFromDevice(poseData: DevicePose): void;
  20881. private _htmlElementAttached;
  20882. private _detachIfAttached;
  20883. /**
  20884. * WebVR's attach control will start broadcasting frames to the device.
  20885. * Note that in certain browsers (chrome for example) this function must be called
  20886. * within a user-interaction callback. Example:
  20887. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20888. *
  20889. * @param element html element to attach the vrDevice to
  20890. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20891. */
  20892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20893. /**
  20894. * Detaches the camera from the html element and disables VR
  20895. *
  20896. * @param element html element to detach from
  20897. */
  20898. detachControl(element: HTMLElement): void;
  20899. /**
  20900. * @returns the name of this class
  20901. */
  20902. getClassName(): string;
  20903. /**
  20904. * Calls resetPose on the vrDisplay
  20905. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20906. */
  20907. resetToCurrentRotation(): void;
  20908. /**
  20909. * @hidden
  20910. * Updates the rig cameras (left and right eye)
  20911. */
  20912. _updateRigCameras(): void;
  20913. private _workingVector;
  20914. private _oneVector;
  20915. private _workingMatrix;
  20916. private updateCacheCalled;
  20917. private _correctPositionIfNotTrackPosition;
  20918. /**
  20919. * @hidden
  20920. * Updates the cached values of the camera
  20921. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20922. */
  20923. _updateCache(ignoreParentClass?: boolean): void;
  20924. /**
  20925. * @hidden
  20926. * Get current device position in babylon world
  20927. */
  20928. _computeDevicePosition(): void;
  20929. /**
  20930. * Updates the current device position and rotation in the babylon world
  20931. */
  20932. update(): void;
  20933. /**
  20934. * @hidden
  20935. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20936. * @returns an identity matrix
  20937. */
  20938. _getViewMatrix(): Matrix;
  20939. private _tmpMatrix;
  20940. /**
  20941. * This function is called by the two RIG cameras.
  20942. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20943. * @hidden
  20944. */
  20945. _getWebVRViewMatrix(): Matrix;
  20946. /** @hidden */
  20947. _getWebVRProjectionMatrix(): Matrix;
  20948. private _onGamepadConnectedObserver;
  20949. private _onGamepadDisconnectedObserver;
  20950. private _updateCacheWhenTrackingDisabledObserver;
  20951. /**
  20952. * Initializes the controllers and their meshes
  20953. */
  20954. initControllers(): void;
  20955. }
  20956. }
  20957. declare module "babylonjs/Materials/materialHelper" {
  20958. import { Nullable } from "babylonjs/types";
  20959. import { Scene } from "babylonjs/scene";
  20960. import { Engine } from "babylonjs/Engines/engine";
  20961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20962. import { Light } from "babylonjs/Lights/light";
  20963. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20964. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20965. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20966. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20967. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20968. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20969. /**
  20970. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20971. *
  20972. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20973. *
  20974. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20975. */
  20976. export class MaterialHelper {
  20977. /**
  20978. * Bind the current view position to an effect.
  20979. * @param effect The effect to be bound
  20980. * @param scene The scene the eyes position is used from
  20981. * @param variableName name of the shader variable that will hold the eye position
  20982. */
  20983. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20984. /**
  20985. * Helps preparing the defines values about the UVs in used in the effect.
  20986. * UVs are shared as much as we can accross channels in the shaders.
  20987. * @param texture The texture we are preparing the UVs for
  20988. * @param defines The defines to update
  20989. * @param key The channel key "diffuse", "specular"... used in the shader
  20990. */
  20991. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20992. /**
  20993. * Binds a texture matrix value to its corrsponding uniform
  20994. * @param texture The texture to bind the matrix for
  20995. * @param uniformBuffer The uniform buffer receivin the data
  20996. * @param key The channel key "diffuse", "specular"... used in the shader
  20997. */
  20998. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20999. /**
  21000. * Gets the current status of the fog (should it be enabled?)
  21001. * @param mesh defines the mesh to evaluate for fog support
  21002. * @param scene defines the hosting scene
  21003. * @returns true if fog must be enabled
  21004. */
  21005. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  21006. /**
  21007. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  21008. * @param mesh defines the current mesh
  21009. * @param scene defines the current scene
  21010. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21011. * @param pointsCloud defines if point cloud rendering has to be turned on
  21012. * @param fogEnabled defines if fog has to be turned on
  21013. * @param alphaTest defines if alpha testing has to be turned on
  21014. * @param defines defines the current list of defines
  21015. */
  21016. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21017. /**
  21018. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21019. * @param scene defines the current scene
  21020. * @param engine defines the current engine
  21021. * @param defines specifies the list of active defines
  21022. * @param useInstances defines if instances have to be turned on
  21023. * @param useClipPlane defines if clip plane have to be turned on
  21024. * @param useInstances defines if instances have to be turned on
  21025. * @param useThinInstances defines if thin instances have to be turned on
  21026. */
  21027. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21028. /**
  21029. * Prepares the defines for bones
  21030. * @param mesh The mesh containing the geometry data we will draw
  21031. * @param defines The defines to update
  21032. */
  21033. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21034. /**
  21035. * Prepares the defines for morph targets
  21036. * @param mesh The mesh containing the geometry data we will draw
  21037. * @param defines The defines to update
  21038. */
  21039. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21040. /**
  21041. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21042. * @param mesh The mesh containing the geometry data we will draw
  21043. * @param defines The defines to update
  21044. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21045. * @param useBones Precise whether bones should be used or not (override mesh info)
  21046. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21047. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21048. * @returns false if defines are considered not dirty and have not been checked
  21049. */
  21050. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21051. /**
  21052. * Prepares the defines related to multiview
  21053. * @param scene The scene we are intending to draw
  21054. * @param defines The defines to update
  21055. */
  21056. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21057. /**
  21058. * Prepares the defines related to the prepass
  21059. * @param scene The scene we are intending to draw
  21060. * @param defines The defines to update
  21061. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21062. */
  21063. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21064. /**
  21065. * Prepares the defines related to the light information passed in parameter
  21066. * @param scene The scene we are intending to draw
  21067. * @param mesh The mesh the effect is compiling for
  21068. * @param light The light the effect is compiling for
  21069. * @param lightIndex The index of the light
  21070. * @param defines The defines to update
  21071. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21072. * @param state Defines the current state regarding what is needed (normals, etc...)
  21073. */
  21074. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21075. needNormals: boolean;
  21076. needRebuild: boolean;
  21077. shadowEnabled: boolean;
  21078. specularEnabled: boolean;
  21079. lightmapMode: boolean;
  21080. }): void;
  21081. /**
  21082. * Prepares the defines related to the light information passed in parameter
  21083. * @param scene The scene we are intending to draw
  21084. * @param mesh The mesh the effect is compiling for
  21085. * @param defines The defines to update
  21086. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21087. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21088. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21089. * @returns true if normals will be required for the rest of the effect
  21090. */
  21091. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21092. /**
  21093. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21094. * @param lightIndex defines the light index
  21095. * @param uniformsList The uniform list
  21096. * @param samplersList The sampler list
  21097. * @param projectedLightTexture defines if projected texture must be used
  21098. * @param uniformBuffersList defines an optional list of uniform buffers
  21099. */
  21100. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21101. /**
  21102. * Prepares the uniforms and samplers list to be used in the effect
  21103. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21104. * @param samplersList The sampler list
  21105. * @param defines The defines helping in the list generation
  21106. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21107. */
  21108. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21109. /**
  21110. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21111. * @param defines The defines to update while falling back
  21112. * @param fallbacks The authorized effect fallbacks
  21113. * @param maxSimultaneousLights The maximum number of lights allowed
  21114. * @param rank the current rank of the Effect
  21115. * @returns The newly affected rank
  21116. */
  21117. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21118. private static _TmpMorphInfluencers;
  21119. /**
  21120. * Prepares the list of attributes required for morph targets according to the effect defines.
  21121. * @param attribs The current list of supported attribs
  21122. * @param mesh The mesh to prepare the morph targets attributes for
  21123. * @param influencers The number of influencers
  21124. */
  21125. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21126. /**
  21127. * Prepares the list of attributes required for morph targets according to the effect defines.
  21128. * @param attribs The current list of supported attribs
  21129. * @param mesh The mesh to prepare the morph targets attributes for
  21130. * @param defines The current Defines of the effect
  21131. */
  21132. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21133. /**
  21134. * Prepares the list of attributes required for bones according to the effect defines.
  21135. * @param attribs The current list of supported attribs
  21136. * @param mesh The mesh to prepare the bones attributes for
  21137. * @param defines The current Defines of the effect
  21138. * @param fallbacks The current efffect fallback strategy
  21139. */
  21140. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21141. /**
  21142. * Check and prepare the list of attributes required for instances according to the effect defines.
  21143. * @param attribs The current list of supported attribs
  21144. * @param defines The current MaterialDefines of the effect
  21145. */
  21146. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21147. /**
  21148. * Add the list of attributes required for instances to the attribs array.
  21149. * @param attribs The current list of supported attribs
  21150. */
  21151. static PushAttributesForInstances(attribs: string[]): void;
  21152. /**
  21153. * Binds the light information to the effect.
  21154. * @param light The light containing the generator
  21155. * @param effect The effect we are binding the data to
  21156. * @param lightIndex The light index in the effect used to render
  21157. */
  21158. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21159. /**
  21160. * Binds the lights information from the scene to the effect for the given mesh.
  21161. * @param light Light to bind
  21162. * @param lightIndex Light index
  21163. * @param scene The scene where the light belongs to
  21164. * @param effect The effect we are binding the data to
  21165. * @param useSpecular Defines if specular is supported
  21166. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21167. */
  21168. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21169. /**
  21170. * Binds the lights information from the scene to the effect for the given mesh.
  21171. * @param scene The scene the lights belongs to
  21172. * @param mesh The mesh we are binding the information to render
  21173. * @param effect The effect we are binding the data to
  21174. * @param defines The generated defines for the effect
  21175. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21176. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21177. */
  21178. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21179. private static _tempFogColor;
  21180. /**
  21181. * Binds the fog information from the scene to the effect for the given mesh.
  21182. * @param scene The scene the lights belongs to
  21183. * @param mesh The mesh we are binding the information to render
  21184. * @param effect The effect we are binding the data to
  21185. * @param linearSpace Defines if the fog effect is applied in linear space
  21186. */
  21187. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21188. /**
  21189. * Binds the bones information from the mesh to the effect.
  21190. * @param mesh The mesh we are binding the information to render
  21191. * @param effect The effect we are binding the data to
  21192. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21193. */
  21194. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21195. private static _CopyBonesTransformationMatrices;
  21196. /**
  21197. * Binds the morph targets information from the mesh to the effect.
  21198. * @param abstractMesh The mesh we are binding the information to render
  21199. * @param effect The effect we are binding the data to
  21200. */
  21201. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21202. /**
  21203. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21204. * @param defines The generated defines used in the effect
  21205. * @param effect The effect we are binding the data to
  21206. * @param scene The scene we are willing to render with logarithmic scale for
  21207. */
  21208. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21209. /**
  21210. * Binds the clip plane information from the scene to the effect.
  21211. * @param scene The scene the clip plane information are extracted from
  21212. * @param effect The effect we are binding the data to
  21213. */
  21214. static BindClipPlane(effect: Effect, scene: Scene): void;
  21215. }
  21216. }
  21217. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21219. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21220. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21221. import { Nullable } from "babylonjs/types";
  21222. import { Effect } from "babylonjs/Materials/effect";
  21223. import { Matrix } from "babylonjs/Maths/math.vector";
  21224. import { Scene } from "babylonjs/scene";
  21225. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21226. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21227. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21228. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21229. import { Observable } from "babylonjs/Misc/observable";
  21230. /**
  21231. * Block used to expose an input value
  21232. */
  21233. export class InputBlock extends NodeMaterialBlock {
  21234. private _mode;
  21235. private _associatedVariableName;
  21236. private _storedValue;
  21237. private _valueCallback;
  21238. private _type;
  21239. private _animationType;
  21240. /** Gets or set a value used to limit the range of float values */
  21241. min: number;
  21242. /** Gets or set a value used to limit the range of float values */
  21243. max: number;
  21244. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21245. isBoolean: boolean;
  21246. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21247. matrixMode: number;
  21248. /** @hidden */
  21249. _systemValue: Nullable<NodeMaterialSystemValues>;
  21250. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21251. isConstant: boolean;
  21252. /** Gets or sets the group to use to display this block in the Inspector */
  21253. groupInInspector: string;
  21254. /** Gets an observable raised when the value is changed */
  21255. onValueChangedObservable: Observable<InputBlock>;
  21256. /**
  21257. * Gets or sets the connection point type (default is float)
  21258. */
  21259. get type(): NodeMaterialBlockConnectionPointTypes;
  21260. /**
  21261. * Creates a new InputBlock
  21262. * @param name defines the block name
  21263. * @param target defines the target of that block (Vertex by default)
  21264. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21265. */
  21266. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21267. /**
  21268. * Validates if a name is a reserve word.
  21269. * @param newName the new name to be given to the node.
  21270. * @returns false if the name is a reserve word, else true.
  21271. */
  21272. validateBlockName(newName: string): boolean;
  21273. /**
  21274. * Gets the output component
  21275. */
  21276. get output(): NodeMaterialConnectionPoint;
  21277. /**
  21278. * Set the source of this connection point to a vertex attribute
  21279. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21280. * @returns the current connection point
  21281. */
  21282. setAsAttribute(attributeName?: string): InputBlock;
  21283. /**
  21284. * Set the source of this connection point to a system value
  21285. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21286. * @returns the current connection point
  21287. */
  21288. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21289. /**
  21290. * Gets or sets the value of that point.
  21291. * Please note that this value will be ignored if valueCallback is defined
  21292. */
  21293. get value(): any;
  21294. set value(value: any);
  21295. /**
  21296. * Gets or sets a callback used to get the value of that point.
  21297. * Please note that setting this value will force the connection point to ignore the value property
  21298. */
  21299. get valueCallback(): () => any;
  21300. set valueCallback(value: () => any);
  21301. /**
  21302. * Gets or sets the associated variable name in the shader
  21303. */
  21304. get associatedVariableName(): string;
  21305. set associatedVariableName(value: string);
  21306. /** Gets or sets the type of animation applied to the input */
  21307. get animationType(): AnimatedInputBlockTypes;
  21308. set animationType(value: AnimatedInputBlockTypes);
  21309. /**
  21310. * Gets a boolean indicating that this connection point not defined yet
  21311. */
  21312. get isUndefined(): boolean;
  21313. /**
  21314. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21315. * In this case the connection point name must be the name of the uniform to use.
  21316. * Can only be set on inputs
  21317. */
  21318. get isUniform(): boolean;
  21319. set isUniform(value: boolean);
  21320. /**
  21321. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21322. * In this case the connection point name must be the name of the attribute to use
  21323. * Can only be set on inputs
  21324. */
  21325. get isAttribute(): boolean;
  21326. set isAttribute(value: boolean);
  21327. /**
  21328. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21329. * Can only be set on exit points
  21330. */
  21331. get isVarying(): boolean;
  21332. set isVarying(value: boolean);
  21333. /**
  21334. * Gets a boolean indicating that the current connection point is a system value
  21335. */
  21336. get isSystemValue(): boolean;
  21337. /**
  21338. * Gets or sets the current well known value or null if not defined as a system value
  21339. */
  21340. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21341. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21342. /**
  21343. * Gets the current class name
  21344. * @returns the class name
  21345. */
  21346. getClassName(): string;
  21347. /**
  21348. * Animate the input if animationType !== None
  21349. * @param scene defines the rendering scene
  21350. */
  21351. animate(scene: Scene): void;
  21352. private _emitDefine;
  21353. initialize(state: NodeMaterialBuildState): void;
  21354. /**
  21355. * Set the input block to its default value (based on its type)
  21356. */
  21357. setDefaultValue(): void;
  21358. private _emitConstant;
  21359. /** @hidden */
  21360. get _noContextSwitch(): boolean;
  21361. private _emit;
  21362. /** @hidden */
  21363. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21364. /** @hidden */
  21365. _transmit(effect: Effect, scene: Scene): void;
  21366. protected _buildBlock(state: NodeMaterialBuildState): void;
  21367. protected _dumpPropertiesCode(): string;
  21368. dispose(): void;
  21369. serialize(): any;
  21370. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21371. }
  21372. }
  21373. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21374. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21375. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21376. import { Nullable } from "babylonjs/types";
  21377. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21378. import { Observable } from "babylonjs/Misc/observable";
  21379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21380. /**
  21381. * Enum used to define the compatibility state between two connection points
  21382. */
  21383. export enum NodeMaterialConnectionPointCompatibilityStates {
  21384. /** Points are compatibles */
  21385. Compatible = 0,
  21386. /** Points are incompatible because of their types */
  21387. TypeIncompatible = 1,
  21388. /** Points are incompatible because of their targets (vertex vs fragment) */
  21389. TargetIncompatible = 2
  21390. }
  21391. /**
  21392. * Defines the direction of a connection point
  21393. */
  21394. export enum NodeMaterialConnectionPointDirection {
  21395. /** Input */
  21396. Input = 0,
  21397. /** Output */
  21398. Output = 1
  21399. }
  21400. /**
  21401. * Defines a connection point for a block
  21402. */
  21403. export class NodeMaterialConnectionPoint {
  21404. /** @hidden */
  21405. _ownerBlock: NodeMaterialBlock;
  21406. /** @hidden */
  21407. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21408. private _endpoints;
  21409. private _associatedVariableName;
  21410. private _direction;
  21411. /** @hidden */
  21412. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21413. /** @hidden */
  21414. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21415. private _type;
  21416. /** @hidden */
  21417. _enforceAssociatedVariableName: boolean;
  21418. /** Gets the direction of the point */
  21419. get direction(): NodeMaterialConnectionPointDirection;
  21420. /** Indicates that this connection point needs dual validation before being connected to another point */
  21421. needDualDirectionValidation: boolean;
  21422. /**
  21423. * Gets or sets the additional types supported by this connection point
  21424. */
  21425. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21426. /**
  21427. * Gets or sets the additional types excluded by this connection point
  21428. */
  21429. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21430. /**
  21431. * Observable triggered when this point is connected
  21432. */
  21433. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21434. /**
  21435. * Gets or sets the associated variable name in the shader
  21436. */
  21437. get associatedVariableName(): string;
  21438. set associatedVariableName(value: string);
  21439. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21440. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21441. /**
  21442. * Gets or sets the connection point type (default is float)
  21443. */
  21444. get type(): NodeMaterialBlockConnectionPointTypes;
  21445. set type(value: NodeMaterialBlockConnectionPointTypes);
  21446. /**
  21447. * Gets or sets the connection point name
  21448. */
  21449. name: string;
  21450. /**
  21451. * Gets or sets the connection point name
  21452. */
  21453. displayName: string;
  21454. /**
  21455. * Gets or sets a boolean indicating that this connection point can be omitted
  21456. */
  21457. isOptional: boolean;
  21458. /**
  21459. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21460. */
  21461. isExposedOnFrame: boolean;
  21462. /**
  21463. * Gets or sets number indicating the position that the port is exposed to on a frame
  21464. */
  21465. exposedPortPosition: number;
  21466. /**
  21467. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21468. */
  21469. define: string;
  21470. /** @hidden */
  21471. _prioritizeVertex: boolean;
  21472. private _target;
  21473. /** Gets or sets the target of that connection point */
  21474. get target(): NodeMaterialBlockTargets;
  21475. set target(value: NodeMaterialBlockTargets);
  21476. /**
  21477. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21478. */
  21479. get isConnected(): boolean;
  21480. /**
  21481. * Gets a boolean indicating that the current point is connected to an input block
  21482. */
  21483. get isConnectedToInputBlock(): boolean;
  21484. /**
  21485. * Gets a the connected input block (if any)
  21486. */
  21487. get connectInputBlock(): Nullable<InputBlock>;
  21488. /** Get the other side of the connection (if any) */
  21489. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21490. /** Get the block that owns this connection point */
  21491. get ownerBlock(): NodeMaterialBlock;
  21492. /** Get the block connected on the other side of this connection (if any) */
  21493. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21494. /** Get the block connected on the endpoints of this connection (if any) */
  21495. get connectedBlocks(): Array<NodeMaterialBlock>;
  21496. /** Gets the list of connected endpoints */
  21497. get endpoints(): NodeMaterialConnectionPoint[];
  21498. /** Gets a boolean indicating if that output point is connected to at least one input */
  21499. get hasEndpoints(): boolean;
  21500. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21501. get isConnectedInVertexShader(): boolean;
  21502. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21503. get isConnectedInFragmentShader(): boolean;
  21504. /**
  21505. * Creates a block suitable to be used as an input for this input point.
  21506. * If null is returned, a block based on the point type will be created.
  21507. * @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
  21508. */
  21509. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21510. /**
  21511. * Creates a new connection point
  21512. * @param name defines the connection point name
  21513. * @param ownerBlock defines the block hosting this connection point
  21514. * @param direction defines the direction of the connection point
  21515. */
  21516. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21517. /**
  21518. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21519. * @returns the class name
  21520. */
  21521. getClassName(): string;
  21522. /**
  21523. * Gets a boolean indicating if the current point can be connected to another point
  21524. * @param connectionPoint defines the other connection point
  21525. * @returns a boolean
  21526. */
  21527. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21528. /**
  21529. * Gets a number indicating if the current point can be connected to another point
  21530. * @param connectionPoint defines the other connection point
  21531. * @returns a number defining the compatibility state
  21532. */
  21533. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21534. /**
  21535. * Connect this point to another connection point
  21536. * @param connectionPoint defines the other connection point
  21537. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21538. * @returns the current connection point
  21539. */
  21540. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21541. /**
  21542. * Disconnect this point from one of his endpoint
  21543. * @param endpoint defines the other connection point
  21544. * @returns the current connection point
  21545. */
  21546. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21547. /**
  21548. * Serializes this point in a JSON representation
  21549. * @param isInput defines if the connection point is an input (default is true)
  21550. * @returns the serialized point object
  21551. */
  21552. serialize(isInput?: boolean): any;
  21553. /**
  21554. * Release resources
  21555. */
  21556. dispose(): void;
  21557. }
  21558. }
  21559. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21560. /**
  21561. * Enum used to define the material modes
  21562. */
  21563. export enum NodeMaterialModes {
  21564. /** Regular material */
  21565. Material = 0,
  21566. /** For post process */
  21567. PostProcess = 1,
  21568. /** For particle system */
  21569. Particle = 2,
  21570. /** For procedural texture */
  21571. ProceduralTexture = 3
  21572. }
  21573. }
  21574. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21576. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21577. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21578. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21580. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21581. import { Effect } from "babylonjs/Materials/effect";
  21582. import { Mesh } from "babylonjs/Meshes/mesh";
  21583. import { Nullable } from "babylonjs/types";
  21584. import { Texture } from "babylonjs/Materials/Textures/texture";
  21585. import { Scene } from "babylonjs/scene";
  21586. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21587. /**
  21588. * Block used to read a texture from a sampler
  21589. */
  21590. export class TextureBlock extends NodeMaterialBlock {
  21591. private _defineName;
  21592. private _linearDefineName;
  21593. private _gammaDefineName;
  21594. private _tempTextureRead;
  21595. private _samplerName;
  21596. private _transformedUVName;
  21597. private _textureTransformName;
  21598. private _textureInfoName;
  21599. private _mainUVName;
  21600. private _mainUVDefineName;
  21601. private _fragmentOnly;
  21602. /**
  21603. * Gets or sets the texture associated with the node
  21604. */
  21605. texture: Nullable<Texture>;
  21606. /**
  21607. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21608. */
  21609. convertToGammaSpace: boolean;
  21610. /**
  21611. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21612. */
  21613. convertToLinearSpace: boolean;
  21614. /**
  21615. * Create a new TextureBlock
  21616. * @param name defines the block name
  21617. */
  21618. constructor(name: string, fragmentOnly?: boolean);
  21619. /**
  21620. * Gets the current class name
  21621. * @returns the class name
  21622. */
  21623. getClassName(): string;
  21624. /**
  21625. * Gets the uv input component
  21626. */
  21627. get uv(): NodeMaterialConnectionPoint;
  21628. /**
  21629. * Gets the rgba output component
  21630. */
  21631. get rgba(): NodeMaterialConnectionPoint;
  21632. /**
  21633. * Gets the rgb output component
  21634. */
  21635. get rgb(): NodeMaterialConnectionPoint;
  21636. /**
  21637. * Gets the r output component
  21638. */
  21639. get r(): NodeMaterialConnectionPoint;
  21640. /**
  21641. * Gets the g output component
  21642. */
  21643. get g(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the b output component
  21646. */
  21647. get b(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the a output component
  21650. */
  21651. get a(): NodeMaterialConnectionPoint;
  21652. get target(): NodeMaterialBlockTargets;
  21653. autoConfigure(material: NodeMaterial): void;
  21654. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21655. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21656. isReady(): boolean;
  21657. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21658. private get _isMixed();
  21659. private _injectVertexCode;
  21660. private _writeTextureRead;
  21661. private _writeOutput;
  21662. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21663. protected _dumpPropertiesCode(): string;
  21664. serialize(): any;
  21665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21666. }
  21667. }
  21668. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21669. /** @hidden */
  21670. export var reflectionFunction: {
  21671. name: string;
  21672. shader: string;
  21673. };
  21674. }
  21675. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21681. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21682. import { Effect } from "babylonjs/Materials/effect";
  21683. import { Mesh } from "babylonjs/Meshes/mesh";
  21684. import { Nullable } from "babylonjs/types";
  21685. import { Scene } from "babylonjs/scene";
  21686. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21687. /**
  21688. * Base block used to read a reflection texture from a sampler
  21689. */
  21690. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21691. /** @hidden */
  21692. _define3DName: string;
  21693. /** @hidden */
  21694. _defineCubicName: string;
  21695. /** @hidden */
  21696. _defineExplicitName: string;
  21697. /** @hidden */
  21698. _defineProjectionName: string;
  21699. /** @hidden */
  21700. _defineLocalCubicName: string;
  21701. /** @hidden */
  21702. _defineSphericalName: string;
  21703. /** @hidden */
  21704. _definePlanarName: string;
  21705. /** @hidden */
  21706. _defineEquirectangularName: string;
  21707. /** @hidden */
  21708. _defineMirroredEquirectangularFixedName: string;
  21709. /** @hidden */
  21710. _defineEquirectangularFixedName: string;
  21711. /** @hidden */
  21712. _defineSkyboxName: string;
  21713. /** @hidden */
  21714. _defineOppositeZ: string;
  21715. /** @hidden */
  21716. _cubeSamplerName: string;
  21717. /** @hidden */
  21718. _2DSamplerName: string;
  21719. protected _positionUVWName: string;
  21720. protected _directionWName: string;
  21721. protected _reflectionVectorName: string;
  21722. /** @hidden */
  21723. _reflectionCoordsName: string;
  21724. /** @hidden */
  21725. _reflectionMatrixName: string;
  21726. protected _reflectionColorName: string;
  21727. /**
  21728. * Gets or sets the texture associated with the node
  21729. */
  21730. texture: Nullable<BaseTexture>;
  21731. /**
  21732. * Create a new ReflectionTextureBaseBlock
  21733. * @param name defines the block name
  21734. */
  21735. constructor(name: string);
  21736. /**
  21737. * Gets the current class name
  21738. * @returns the class name
  21739. */
  21740. getClassName(): string;
  21741. /**
  21742. * Gets the world position input component
  21743. */
  21744. abstract get position(): NodeMaterialConnectionPoint;
  21745. /**
  21746. * Gets the world position input component
  21747. */
  21748. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21749. /**
  21750. * Gets the world normal input component
  21751. */
  21752. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21753. /**
  21754. * Gets the world input component
  21755. */
  21756. abstract get world(): NodeMaterialConnectionPoint;
  21757. /**
  21758. * Gets the camera (or eye) position component
  21759. */
  21760. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21761. /**
  21762. * Gets the view input component
  21763. */
  21764. abstract get view(): NodeMaterialConnectionPoint;
  21765. protected _getTexture(): Nullable<BaseTexture>;
  21766. autoConfigure(material: NodeMaterial): void;
  21767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21768. isReady(): boolean;
  21769. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21770. /**
  21771. * Gets the code to inject in the vertex shader
  21772. * @param state current state of the node material building
  21773. * @returns the shader code
  21774. */
  21775. handleVertexSide(state: NodeMaterialBuildState): string;
  21776. /**
  21777. * Handles the inits for the fragment code path
  21778. * @param state node material build state
  21779. */
  21780. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21781. /**
  21782. * Generates the reflection coords code for the fragment code path
  21783. * @param worldNormalVarName name of the world normal variable
  21784. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21785. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21786. * @returns the shader code
  21787. */
  21788. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21789. /**
  21790. * Generates the reflection color code for the fragment code path
  21791. * @param lodVarName name of the lod variable
  21792. * @param swizzleLookupTexture swizzle to use for the final color variable
  21793. * @returns the shader code
  21794. */
  21795. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21796. /**
  21797. * Generates the code corresponding to the connected output points
  21798. * @param state node material build state
  21799. * @param varName name of the variable to output
  21800. * @returns the shader code
  21801. */
  21802. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21803. protected _buildBlock(state: NodeMaterialBuildState): this;
  21804. protected _dumpPropertiesCode(): string;
  21805. serialize(): any;
  21806. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21807. }
  21808. }
  21809. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21810. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21811. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21812. import { Nullable } from "babylonjs/types";
  21813. /**
  21814. * Defines a connection point to be used for points with a custom object type
  21815. */
  21816. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21817. private _blockType;
  21818. private _blockName;
  21819. private _nameForCheking?;
  21820. /**
  21821. * Creates a new connection point
  21822. * @param name defines the connection point name
  21823. * @param ownerBlock defines the block hosting this connection point
  21824. * @param direction defines the direction of the connection point
  21825. */
  21826. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21827. /**
  21828. * Gets a number indicating if the current point can be connected to another point
  21829. * @param connectionPoint defines the other connection point
  21830. * @returns a number defining the compatibility state
  21831. */
  21832. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21833. /**
  21834. * Creates a block suitable to be used as an input for this input point.
  21835. * If null is returned, a block based on the point type will be created.
  21836. * @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
  21837. */
  21838. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21839. }
  21840. }
  21841. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21842. /**
  21843. * Enum defining the type of properties that can be edited in the property pages in the NME
  21844. */
  21845. export enum PropertyTypeForEdition {
  21846. /** property is a boolean */
  21847. Boolean = 0,
  21848. /** property is a float */
  21849. Float = 1,
  21850. /** property is a Vector2 */
  21851. Vector2 = 2,
  21852. /** property is a list of values */
  21853. List = 3
  21854. }
  21855. /**
  21856. * Interface that defines an option in a variable of type list
  21857. */
  21858. export interface IEditablePropertyListOption {
  21859. /** label of the option */
  21860. "label": string;
  21861. /** value of the option */
  21862. "value": number;
  21863. }
  21864. /**
  21865. * Interface that defines the options available for an editable property
  21866. */
  21867. export interface IEditablePropertyOption {
  21868. /** min value */
  21869. "min"?: number;
  21870. /** max value */
  21871. "max"?: number;
  21872. /** notifiers: indicates which actions to take when the property is changed */
  21873. "notifiers"?: {
  21874. /** the material should be rebuilt */
  21875. "rebuild"?: boolean;
  21876. /** the preview should be updated */
  21877. "update"?: boolean;
  21878. };
  21879. /** list of the options for a variable of type list */
  21880. "options"?: IEditablePropertyListOption[];
  21881. }
  21882. /**
  21883. * Interface that describes an editable property
  21884. */
  21885. export interface IPropertyDescriptionForEdition {
  21886. /** name of the property */
  21887. "propertyName": string;
  21888. /** display name of the property */
  21889. "displayName": string;
  21890. /** type of the property */
  21891. "type": PropertyTypeForEdition;
  21892. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21893. "groupName": string;
  21894. /** options for the property */
  21895. "options": IEditablePropertyOption;
  21896. }
  21897. /**
  21898. * Decorator that flags a property in a node material block as being editable
  21899. */
  21900. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21901. }
  21902. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21905. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21907. import { Nullable } from "babylonjs/types";
  21908. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21909. import { Mesh } from "babylonjs/Meshes/mesh";
  21910. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21911. import { Effect } from "babylonjs/Materials/effect";
  21912. import { Scene } from "babylonjs/scene";
  21913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21914. /**
  21915. * Block used to implement the refraction part of the sub surface module of the PBR material
  21916. */
  21917. export class RefractionBlock extends NodeMaterialBlock {
  21918. /** @hidden */
  21919. _define3DName: string;
  21920. /** @hidden */
  21921. _refractionMatrixName: string;
  21922. /** @hidden */
  21923. _defineLODRefractionAlpha: string;
  21924. /** @hidden */
  21925. _defineLinearSpecularRefraction: string;
  21926. /** @hidden */
  21927. _defineOppositeZ: string;
  21928. /** @hidden */
  21929. _cubeSamplerName: string;
  21930. /** @hidden */
  21931. _2DSamplerName: string;
  21932. /** @hidden */
  21933. _vRefractionMicrosurfaceInfosName: string;
  21934. /** @hidden */
  21935. _vRefractionInfosName: string;
  21936. private _scene;
  21937. /**
  21938. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21939. * Materials half opaque for instance using refraction could benefit from this control.
  21940. */
  21941. linkRefractionWithTransparency: boolean;
  21942. /**
  21943. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21944. */
  21945. invertRefractionY: boolean;
  21946. /**
  21947. * Gets or sets the texture associated with the node
  21948. */
  21949. texture: Nullable<BaseTexture>;
  21950. /**
  21951. * Create a new RefractionBlock
  21952. * @param name defines the block name
  21953. */
  21954. constructor(name: string);
  21955. /**
  21956. * Gets the current class name
  21957. * @returns the class name
  21958. */
  21959. getClassName(): string;
  21960. /**
  21961. * Gets the intensity input component
  21962. */
  21963. get intensity(): NodeMaterialConnectionPoint;
  21964. /**
  21965. * Gets the index of refraction input component
  21966. */
  21967. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21968. /**
  21969. * Gets the tint at distance input component
  21970. */
  21971. get tintAtDistance(): NodeMaterialConnectionPoint;
  21972. /**
  21973. * Gets the view input component
  21974. */
  21975. get view(): NodeMaterialConnectionPoint;
  21976. /**
  21977. * Gets the refraction object output component
  21978. */
  21979. get refraction(): NodeMaterialConnectionPoint;
  21980. /**
  21981. * Returns true if the block has a texture
  21982. */
  21983. get hasTexture(): boolean;
  21984. protected _getTexture(): Nullable<BaseTexture>;
  21985. autoConfigure(material: NodeMaterial): void;
  21986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21987. isReady(): boolean;
  21988. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21989. /**
  21990. * Gets the main code of the block (fragment side)
  21991. * @param state current state of the node material building
  21992. * @returns the shader code
  21993. */
  21994. getCode(state: NodeMaterialBuildState): string;
  21995. protected _buildBlock(state: NodeMaterialBuildState): this;
  21996. protected _dumpPropertiesCode(): string;
  21997. serialize(): any;
  21998. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21999. }
  22000. }
  22001. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  22002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22004. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22007. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22009. import { Nullable } from "babylonjs/types";
  22010. import { Scene } from "babylonjs/scene";
  22011. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22012. /**
  22013. * Base block used as input for post process
  22014. */
  22015. export class CurrentScreenBlock extends NodeMaterialBlock {
  22016. private _samplerName;
  22017. private _linearDefineName;
  22018. private _gammaDefineName;
  22019. private _mainUVName;
  22020. private _tempTextureRead;
  22021. /**
  22022. * Gets or sets the texture associated with the node
  22023. */
  22024. texture: Nullable<BaseTexture>;
  22025. /**
  22026. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22027. */
  22028. convertToGammaSpace: boolean;
  22029. /**
  22030. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22031. */
  22032. convertToLinearSpace: boolean;
  22033. /**
  22034. * Create a new CurrentScreenBlock
  22035. * @param name defines the block name
  22036. */
  22037. constructor(name: string);
  22038. /**
  22039. * Gets the current class name
  22040. * @returns the class name
  22041. */
  22042. getClassName(): string;
  22043. /**
  22044. * Gets the uv input component
  22045. */
  22046. get uv(): NodeMaterialConnectionPoint;
  22047. /**
  22048. * Gets the rgba output component
  22049. */
  22050. get rgba(): NodeMaterialConnectionPoint;
  22051. /**
  22052. * Gets the rgb output component
  22053. */
  22054. get rgb(): NodeMaterialConnectionPoint;
  22055. /**
  22056. * Gets the r output component
  22057. */
  22058. get r(): NodeMaterialConnectionPoint;
  22059. /**
  22060. * Gets the g output component
  22061. */
  22062. get g(): NodeMaterialConnectionPoint;
  22063. /**
  22064. * Gets the b output component
  22065. */
  22066. get b(): NodeMaterialConnectionPoint;
  22067. /**
  22068. * Gets the a output component
  22069. */
  22070. get a(): NodeMaterialConnectionPoint;
  22071. /**
  22072. * Initialize the block and prepare the context for build
  22073. * @param state defines the state that will be used for the build
  22074. */
  22075. initialize(state: NodeMaterialBuildState): void;
  22076. get target(): NodeMaterialBlockTargets;
  22077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22078. isReady(): boolean;
  22079. private _injectVertexCode;
  22080. private _writeTextureRead;
  22081. private _writeOutput;
  22082. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22083. serialize(): any;
  22084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22085. }
  22086. }
  22087. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22092. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22093. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22094. import { Nullable } from "babylonjs/types";
  22095. import { Scene } from "babylonjs/scene";
  22096. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22097. /**
  22098. * Base block used for the particle texture
  22099. */
  22100. export class ParticleTextureBlock extends NodeMaterialBlock {
  22101. private _samplerName;
  22102. private _linearDefineName;
  22103. private _gammaDefineName;
  22104. private _tempTextureRead;
  22105. /**
  22106. * Gets or sets the texture associated with the node
  22107. */
  22108. texture: Nullable<BaseTexture>;
  22109. /**
  22110. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22111. */
  22112. convertToGammaSpace: boolean;
  22113. /**
  22114. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22115. */
  22116. convertToLinearSpace: boolean;
  22117. /**
  22118. * Create a new ParticleTextureBlock
  22119. * @param name defines the block name
  22120. */
  22121. constructor(name: string);
  22122. /**
  22123. * Gets the current class name
  22124. * @returns the class name
  22125. */
  22126. getClassName(): string;
  22127. /**
  22128. * Gets the uv input component
  22129. */
  22130. get uv(): NodeMaterialConnectionPoint;
  22131. /**
  22132. * Gets the rgba output component
  22133. */
  22134. get rgba(): NodeMaterialConnectionPoint;
  22135. /**
  22136. * Gets the rgb output component
  22137. */
  22138. get rgb(): NodeMaterialConnectionPoint;
  22139. /**
  22140. * Gets the r output component
  22141. */
  22142. get r(): NodeMaterialConnectionPoint;
  22143. /**
  22144. * Gets the g output component
  22145. */
  22146. get g(): NodeMaterialConnectionPoint;
  22147. /**
  22148. * Gets the b output component
  22149. */
  22150. get b(): NodeMaterialConnectionPoint;
  22151. /**
  22152. * Gets the a output component
  22153. */
  22154. get a(): NodeMaterialConnectionPoint;
  22155. /**
  22156. * Initialize the block and prepare the context for build
  22157. * @param state defines the state that will be used for the build
  22158. */
  22159. initialize(state: NodeMaterialBuildState): void;
  22160. autoConfigure(material: NodeMaterial): void;
  22161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22162. isReady(): boolean;
  22163. private _writeOutput;
  22164. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22165. serialize(): any;
  22166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22167. }
  22168. }
  22169. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22172. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22173. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22174. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22175. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22176. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22177. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22178. import { Scene } from "babylonjs/scene";
  22179. /**
  22180. * Class used to store shared data between 2 NodeMaterialBuildState
  22181. */
  22182. export class NodeMaterialBuildStateSharedData {
  22183. /**
  22184. * Gets the list of emitted varyings
  22185. */
  22186. temps: string[];
  22187. /**
  22188. * Gets the list of emitted varyings
  22189. */
  22190. varyings: string[];
  22191. /**
  22192. * Gets the varying declaration string
  22193. */
  22194. varyingDeclaration: string;
  22195. /**
  22196. * Input blocks
  22197. */
  22198. inputBlocks: InputBlock[];
  22199. /**
  22200. * Input blocks
  22201. */
  22202. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22203. /**
  22204. * Bindable blocks (Blocks that need to set data to the effect)
  22205. */
  22206. bindableBlocks: NodeMaterialBlock[];
  22207. /**
  22208. * List of blocks that can provide a compilation fallback
  22209. */
  22210. blocksWithFallbacks: NodeMaterialBlock[];
  22211. /**
  22212. * List of blocks that can provide a define update
  22213. */
  22214. blocksWithDefines: NodeMaterialBlock[];
  22215. /**
  22216. * List of blocks that can provide a repeatable content
  22217. */
  22218. repeatableContentBlocks: NodeMaterialBlock[];
  22219. /**
  22220. * List of blocks that can provide a dynamic list of uniforms
  22221. */
  22222. dynamicUniformBlocks: NodeMaterialBlock[];
  22223. /**
  22224. * List of blocks that can block the isReady function for the material
  22225. */
  22226. blockingBlocks: NodeMaterialBlock[];
  22227. /**
  22228. * Gets the list of animated inputs
  22229. */
  22230. animatedInputs: InputBlock[];
  22231. /**
  22232. * Build Id used to avoid multiple recompilations
  22233. */
  22234. buildId: number;
  22235. /** List of emitted variables */
  22236. variableNames: {
  22237. [key: string]: number;
  22238. };
  22239. /** List of emitted defines */
  22240. defineNames: {
  22241. [key: string]: number;
  22242. };
  22243. /** Should emit comments? */
  22244. emitComments: boolean;
  22245. /** Emit build activity */
  22246. verbose: boolean;
  22247. /** Gets or sets the hosting scene */
  22248. scene: Scene;
  22249. /**
  22250. * Gets the compilation hints emitted at compilation time
  22251. */
  22252. hints: {
  22253. needWorldViewMatrix: boolean;
  22254. needWorldViewProjectionMatrix: boolean;
  22255. needAlphaBlending: boolean;
  22256. needAlphaTesting: boolean;
  22257. };
  22258. /**
  22259. * List of compilation checks
  22260. */
  22261. checks: {
  22262. emitVertex: boolean;
  22263. emitFragment: boolean;
  22264. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22265. };
  22266. /**
  22267. * Is vertex program allowed to be empty?
  22268. */
  22269. allowEmptyVertexProgram: boolean;
  22270. /** Creates a new shared data */
  22271. constructor();
  22272. /**
  22273. * Emits console errors and exceptions if there is a failing check
  22274. */
  22275. emitErrors(): void;
  22276. }
  22277. }
  22278. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22279. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22280. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22281. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22282. /**
  22283. * Class used to store node based material build state
  22284. */
  22285. export class NodeMaterialBuildState {
  22286. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22287. supportUniformBuffers: boolean;
  22288. /**
  22289. * Gets the list of emitted attributes
  22290. */
  22291. attributes: string[];
  22292. /**
  22293. * Gets the list of emitted uniforms
  22294. */
  22295. uniforms: string[];
  22296. /**
  22297. * Gets the list of emitted constants
  22298. */
  22299. constants: string[];
  22300. /**
  22301. * Gets the list of emitted samplers
  22302. */
  22303. samplers: string[];
  22304. /**
  22305. * Gets the list of emitted functions
  22306. */
  22307. functions: {
  22308. [key: string]: string;
  22309. };
  22310. /**
  22311. * Gets the list of emitted extensions
  22312. */
  22313. extensions: {
  22314. [key: string]: string;
  22315. };
  22316. /**
  22317. * Gets the target of the compilation state
  22318. */
  22319. target: NodeMaterialBlockTargets;
  22320. /**
  22321. * Gets the list of emitted counters
  22322. */
  22323. counters: {
  22324. [key: string]: number;
  22325. };
  22326. /**
  22327. * Shared data between multiple NodeMaterialBuildState instances
  22328. */
  22329. sharedData: NodeMaterialBuildStateSharedData;
  22330. /** @hidden */
  22331. _vertexState: NodeMaterialBuildState;
  22332. /** @hidden */
  22333. _attributeDeclaration: string;
  22334. /** @hidden */
  22335. _uniformDeclaration: string;
  22336. /** @hidden */
  22337. _constantDeclaration: string;
  22338. /** @hidden */
  22339. _samplerDeclaration: string;
  22340. /** @hidden */
  22341. _varyingTransfer: string;
  22342. /** @hidden */
  22343. _injectAtEnd: string;
  22344. private _repeatableContentAnchorIndex;
  22345. /** @hidden */
  22346. _builtCompilationString: string;
  22347. /**
  22348. * Gets the emitted compilation strings
  22349. */
  22350. compilationString: string;
  22351. /**
  22352. * Finalize the compilation strings
  22353. * @param state defines the current compilation state
  22354. */
  22355. finalize(state: NodeMaterialBuildState): void;
  22356. /** @hidden */
  22357. get _repeatableContentAnchor(): string;
  22358. /** @hidden */
  22359. _getFreeVariableName(prefix: string): string;
  22360. /** @hidden */
  22361. _getFreeDefineName(prefix: string): string;
  22362. /** @hidden */
  22363. _excludeVariableName(name: string): void;
  22364. /** @hidden */
  22365. _emit2DSampler(name: string): void;
  22366. /** @hidden */
  22367. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22368. /** @hidden */
  22369. _emitExtension(name: string, extension: string, define?: string): void;
  22370. /** @hidden */
  22371. _emitFunction(name: string, code: string, comments: string): void;
  22372. /** @hidden */
  22373. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22374. replaceStrings?: {
  22375. search: RegExp;
  22376. replace: string;
  22377. }[];
  22378. repeatKey?: string;
  22379. }): string;
  22380. /** @hidden */
  22381. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22382. repeatKey?: string;
  22383. removeAttributes?: boolean;
  22384. removeUniforms?: boolean;
  22385. removeVaryings?: boolean;
  22386. removeIfDef?: boolean;
  22387. replaceStrings?: {
  22388. search: RegExp;
  22389. replace: string;
  22390. }[];
  22391. }, storeKey?: string): void;
  22392. /** @hidden */
  22393. _registerTempVariable(name: string): boolean;
  22394. /** @hidden */
  22395. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22396. /** @hidden */
  22397. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22398. /** @hidden */
  22399. _emitFloat(value: number): string;
  22400. }
  22401. }
  22402. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22403. /**
  22404. * Helper class used to generate session unique ID
  22405. */
  22406. export class UniqueIdGenerator {
  22407. private static _UniqueIdCounter;
  22408. /**
  22409. * Gets an unique (relatively to the current scene) Id
  22410. */
  22411. static get UniqueId(): number;
  22412. }
  22413. }
  22414. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22415. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22417. import { Nullable } from "babylonjs/types";
  22418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22419. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22420. import { Effect } from "babylonjs/Materials/effect";
  22421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22422. import { Mesh } from "babylonjs/Meshes/mesh";
  22423. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22424. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22425. import { Scene } from "babylonjs/scene";
  22426. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22427. /**
  22428. * Defines a block that can be used inside a node based material
  22429. */
  22430. export class NodeMaterialBlock {
  22431. private _buildId;
  22432. private _buildTarget;
  22433. private _target;
  22434. private _isFinalMerger;
  22435. private _isInput;
  22436. private _name;
  22437. protected _isUnique: boolean;
  22438. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22439. inputsAreExclusive: boolean;
  22440. /** @hidden */
  22441. _codeVariableName: string;
  22442. /** @hidden */
  22443. _inputs: NodeMaterialConnectionPoint[];
  22444. /** @hidden */
  22445. _outputs: NodeMaterialConnectionPoint[];
  22446. /** @hidden */
  22447. _preparationId: number;
  22448. /**
  22449. * Gets the name of the block
  22450. */
  22451. get name(): string;
  22452. /**
  22453. * Sets the name of the block. Will check if the name is valid.
  22454. */
  22455. set name(newName: string);
  22456. /**
  22457. * Gets or sets the unique id of the node
  22458. */
  22459. uniqueId: number;
  22460. /**
  22461. * Gets or sets the comments associated with this block
  22462. */
  22463. comments: string;
  22464. /**
  22465. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22466. */
  22467. get isUnique(): boolean;
  22468. /**
  22469. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22470. */
  22471. get isFinalMerger(): boolean;
  22472. /**
  22473. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22474. */
  22475. get isInput(): boolean;
  22476. /**
  22477. * Gets or sets the build Id
  22478. */
  22479. get buildId(): number;
  22480. set buildId(value: number);
  22481. /**
  22482. * Gets or sets the target of the block
  22483. */
  22484. get target(): NodeMaterialBlockTargets;
  22485. set target(value: NodeMaterialBlockTargets);
  22486. /**
  22487. * Gets the list of input points
  22488. */
  22489. get inputs(): NodeMaterialConnectionPoint[];
  22490. /** Gets the list of output points */
  22491. get outputs(): NodeMaterialConnectionPoint[];
  22492. /**
  22493. * Find an input by its name
  22494. * @param name defines the name of the input to look for
  22495. * @returns the input or null if not found
  22496. */
  22497. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22498. /**
  22499. * Find an output by its name
  22500. * @param name defines the name of the outputto look for
  22501. * @returns the output or null if not found
  22502. */
  22503. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22504. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22505. visibleInInspector: boolean;
  22506. /**
  22507. * Creates a new NodeMaterialBlock
  22508. * @param name defines the block name
  22509. * @param target defines the target of that block (Vertex by default)
  22510. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22511. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22512. */
  22513. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22514. /**
  22515. * Initialize the block and prepare the context for build
  22516. * @param state defines the state that will be used for the build
  22517. */
  22518. initialize(state: NodeMaterialBuildState): void;
  22519. /**
  22520. * Bind data to effect. Will only be called for blocks with isBindable === true
  22521. * @param effect defines the effect to bind data to
  22522. * @param nodeMaterial defines the hosting NodeMaterial
  22523. * @param mesh defines the mesh that will be rendered
  22524. * @param subMesh defines the submesh that will be rendered
  22525. */
  22526. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22527. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22528. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22529. protected _writeFloat(value: number): string;
  22530. /**
  22531. * Gets the current class name e.g. "NodeMaterialBlock"
  22532. * @returns the class name
  22533. */
  22534. getClassName(): string;
  22535. /**
  22536. * Register a new input. Must be called inside a block constructor
  22537. * @param name defines the connection point name
  22538. * @param type defines the connection point type
  22539. * @param isOptional defines a boolean indicating that this input can be omitted
  22540. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22541. * @param point an already created connection point. If not provided, create a new one
  22542. * @returns the current block
  22543. */
  22544. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22545. /**
  22546. * Register a new output. Must be called inside a block constructor
  22547. * @param name defines the connection point name
  22548. * @param type defines the connection point type
  22549. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22550. * @param point an already created connection point. If not provided, create a new one
  22551. * @returns the current block
  22552. */
  22553. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22554. /**
  22555. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22556. * @param forOutput defines an optional connection point to check compatibility with
  22557. * @returns the first available input or null
  22558. */
  22559. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22560. /**
  22561. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22562. * @param forBlock defines an optional block to check compatibility with
  22563. * @returns the first available input or null
  22564. */
  22565. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22566. /**
  22567. * Gets the sibling of the given output
  22568. * @param current defines the current output
  22569. * @returns the next output in the list or null
  22570. */
  22571. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22572. /**
  22573. * Connect current block with another block
  22574. * @param other defines the block to connect with
  22575. * @param options define the various options to help pick the right connections
  22576. * @returns the current block
  22577. */
  22578. connectTo(other: NodeMaterialBlock, options?: {
  22579. input?: string;
  22580. output?: string;
  22581. outputSwizzle?: string;
  22582. }): this | undefined;
  22583. protected _buildBlock(state: NodeMaterialBuildState): void;
  22584. /**
  22585. * Add uniforms, samplers and uniform buffers at compilation time
  22586. * @param state defines the state to update
  22587. * @param nodeMaterial defines the node material requesting the update
  22588. * @param defines defines the material defines to update
  22589. * @param uniformBuffers defines the list of uniform buffer names
  22590. */
  22591. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22592. /**
  22593. * Add potential fallbacks if shader compilation fails
  22594. * @param mesh defines the mesh to be rendered
  22595. * @param fallbacks defines the current prioritized list of fallbacks
  22596. */
  22597. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22598. /**
  22599. * Initialize defines for shader compilation
  22600. * @param mesh defines the mesh to be rendered
  22601. * @param nodeMaterial defines the node material requesting the update
  22602. * @param defines defines the material defines to update
  22603. * @param useInstances specifies that instances should be used
  22604. */
  22605. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22606. /**
  22607. * Update defines for shader compilation
  22608. * @param mesh defines the mesh to be rendered
  22609. * @param nodeMaterial defines the node material requesting the update
  22610. * @param defines defines the material defines to update
  22611. * @param useInstances specifies that instances should be used
  22612. * @param subMesh defines which submesh to render
  22613. */
  22614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22615. /**
  22616. * Lets the block try to connect some inputs automatically
  22617. * @param material defines the hosting NodeMaterial
  22618. */
  22619. autoConfigure(material: NodeMaterial): void;
  22620. /**
  22621. * Function called when a block is declared as repeatable content generator
  22622. * @param vertexShaderState defines the current compilation state for the vertex shader
  22623. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22624. * @param mesh defines the mesh to be rendered
  22625. * @param defines defines the material defines to update
  22626. */
  22627. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22628. /**
  22629. * Checks if the block is ready
  22630. * @param mesh defines the mesh to be rendered
  22631. * @param nodeMaterial defines the node material requesting the update
  22632. * @param defines defines the material defines to update
  22633. * @param useInstances specifies that instances should be used
  22634. * @returns true if the block is ready
  22635. */
  22636. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22637. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22638. private _processBuild;
  22639. /**
  22640. * Validates the new name for the block node.
  22641. * @param newName the new name to be given to the node.
  22642. * @returns false if the name is a reserve word, else true.
  22643. */
  22644. validateBlockName(newName: string): boolean;
  22645. /**
  22646. * Compile the current node and generate the shader code
  22647. * @param state defines the current compilation state (uniforms, samplers, current string)
  22648. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22649. * @returns true if already built
  22650. */
  22651. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22652. protected _inputRename(name: string): string;
  22653. protected _outputRename(name: string): string;
  22654. protected _dumpPropertiesCode(): string;
  22655. /** @hidden */
  22656. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22657. /** @hidden */
  22658. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22659. /**
  22660. * Clone the current block to a new identical block
  22661. * @param scene defines the hosting scene
  22662. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22663. * @returns a copy of the current block
  22664. */
  22665. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22666. /**
  22667. * Serializes this block in a JSON representation
  22668. * @returns the serialized block object
  22669. */
  22670. serialize(): any;
  22671. /** @hidden */
  22672. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22673. private _deserializePortDisplayNamesAndExposedOnFrame;
  22674. /**
  22675. * Release resources
  22676. */
  22677. dispose(): void;
  22678. }
  22679. }
  22680. declare module "babylonjs/Materials/pushMaterial" {
  22681. import { Nullable } from "babylonjs/types";
  22682. import { Scene } from "babylonjs/scene";
  22683. import { Matrix } from "babylonjs/Maths/math.vector";
  22684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22685. import { Mesh } from "babylonjs/Meshes/mesh";
  22686. import { Material } from "babylonjs/Materials/material";
  22687. import { Effect } from "babylonjs/Materials/effect";
  22688. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22689. /**
  22690. * Base class of materials working in push mode in babylon JS
  22691. * @hidden
  22692. */
  22693. export class PushMaterial extends Material {
  22694. protected _activeEffect: Effect;
  22695. protected _normalMatrix: Matrix;
  22696. constructor(name: string, scene: Scene);
  22697. getEffect(): Effect;
  22698. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22699. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22700. /**
  22701. * Binds the given world matrix to the active effect
  22702. *
  22703. * @param world the matrix to bind
  22704. */
  22705. bindOnlyWorldMatrix(world: Matrix): void;
  22706. /**
  22707. * Binds the given normal matrix to the active effect
  22708. *
  22709. * @param normalMatrix the matrix to bind
  22710. */
  22711. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22712. bind(world: Matrix, mesh?: Mesh): void;
  22713. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22714. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22715. }
  22716. }
  22717. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22719. /**
  22720. * Root class for all node material optimizers
  22721. */
  22722. export class NodeMaterialOptimizer {
  22723. /**
  22724. * Function used to optimize a NodeMaterial graph
  22725. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22726. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22727. */
  22728. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22729. }
  22730. }
  22731. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22735. import { Scene } from "babylonjs/scene";
  22736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22737. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22738. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22739. /**
  22740. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22741. */
  22742. export class TransformBlock extends NodeMaterialBlock {
  22743. /**
  22744. * Defines the value to use to complement W value to transform it to a Vector4
  22745. */
  22746. complementW: number;
  22747. /**
  22748. * Defines the value to use to complement z value to transform it to a Vector4
  22749. */
  22750. complementZ: number;
  22751. /**
  22752. * Creates a new TransformBlock
  22753. * @param name defines the block name
  22754. */
  22755. constructor(name: string);
  22756. /**
  22757. * Gets the current class name
  22758. * @returns the class name
  22759. */
  22760. getClassName(): string;
  22761. /**
  22762. * Gets the vector input
  22763. */
  22764. get vector(): NodeMaterialConnectionPoint;
  22765. /**
  22766. * Gets the output component
  22767. */
  22768. get output(): NodeMaterialConnectionPoint;
  22769. /**
  22770. * Gets the xyz output component
  22771. */
  22772. get xyz(): NodeMaterialConnectionPoint;
  22773. /**
  22774. * Gets the matrix transform input
  22775. */
  22776. get transform(): NodeMaterialConnectionPoint;
  22777. protected _buildBlock(state: NodeMaterialBuildState): this;
  22778. /**
  22779. * Update defines for shader compilation
  22780. * @param mesh defines the mesh to be rendered
  22781. * @param nodeMaterial defines the node material requesting the update
  22782. * @param defines defines the material defines to update
  22783. * @param useInstances specifies that instances should be used
  22784. * @param subMesh defines which submesh to render
  22785. */
  22786. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22787. serialize(): any;
  22788. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22789. protected _dumpPropertiesCode(): string;
  22790. }
  22791. }
  22792. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22796. /**
  22797. * Block used to output the vertex position
  22798. */
  22799. export class VertexOutputBlock extends NodeMaterialBlock {
  22800. /**
  22801. * Creates a new VertexOutputBlock
  22802. * @param name defines the block name
  22803. */
  22804. constructor(name: string);
  22805. /**
  22806. * Gets the current class name
  22807. * @returns the class name
  22808. */
  22809. getClassName(): string;
  22810. /**
  22811. * Gets the vector input component
  22812. */
  22813. get vector(): NodeMaterialConnectionPoint;
  22814. protected _buildBlock(state: NodeMaterialBuildState): this;
  22815. }
  22816. }
  22817. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22819. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22820. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22821. /**
  22822. * Block used to output the final color
  22823. */
  22824. export class FragmentOutputBlock extends NodeMaterialBlock {
  22825. /**
  22826. * Create a new FragmentOutputBlock
  22827. * @param name defines the block name
  22828. */
  22829. constructor(name: string);
  22830. /**
  22831. * Gets the current class name
  22832. * @returns the class name
  22833. */
  22834. getClassName(): string;
  22835. /**
  22836. * Gets the rgba input component
  22837. */
  22838. get rgba(): NodeMaterialConnectionPoint;
  22839. /**
  22840. * Gets the rgb input component
  22841. */
  22842. get rgb(): NodeMaterialConnectionPoint;
  22843. /**
  22844. * Gets the a input component
  22845. */
  22846. get a(): NodeMaterialConnectionPoint;
  22847. protected _buildBlock(state: NodeMaterialBuildState): this;
  22848. }
  22849. }
  22850. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22854. /**
  22855. * Block used for the particle ramp gradient section
  22856. */
  22857. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22858. /**
  22859. * Create a new ParticleRampGradientBlock
  22860. * @param name defines the block name
  22861. */
  22862. constructor(name: string);
  22863. /**
  22864. * Gets the current class name
  22865. * @returns the class name
  22866. */
  22867. getClassName(): string;
  22868. /**
  22869. * Gets the color input component
  22870. */
  22871. get color(): NodeMaterialConnectionPoint;
  22872. /**
  22873. * Gets the rampColor output component
  22874. */
  22875. get rampColor(): NodeMaterialConnectionPoint;
  22876. /**
  22877. * Initialize the block and prepare the context for build
  22878. * @param state defines the state that will be used for the build
  22879. */
  22880. initialize(state: NodeMaterialBuildState): void;
  22881. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22882. }
  22883. }
  22884. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22888. /**
  22889. * Block used for the particle blend multiply section
  22890. */
  22891. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22892. /**
  22893. * Create a new ParticleBlendMultiplyBlock
  22894. * @param name defines the block name
  22895. */
  22896. constructor(name: string);
  22897. /**
  22898. * Gets the current class name
  22899. * @returns the class name
  22900. */
  22901. getClassName(): string;
  22902. /**
  22903. * Gets the color input component
  22904. */
  22905. get color(): NodeMaterialConnectionPoint;
  22906. /**
  22907. * Gets the alphaTexture input component
  22908. */
  22909. get alphaTexture(): NodeMaterialConnectionPoint;
  22910. /**
  22911. * Gets the alphaColor input component
  22912. */
  22913. get alphaColor(): NodeMaterialConnectionPoint;
  22914. /**
  22915. * Gets the blendColor output component
  22916. */
  22917. get blendColor(): NodeMaterialConnectionPoint;
  22918. /**
  22919. * Initialize the block and prepare the context for build
  22920. * @param state defines the state that will be used for the build
  22921. */
  22922. initialize(state: NodeMaterialBuildState): void;
  22923. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22924. }
  22925. }
  22926. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22927. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22928. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22929. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22930. /**
  22931. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22932. */
  22933. export class VectorMergerBlock extends NodeMaterialBlock {
  22934. /**
  22935. * Create a new VectorMergerBlock
  22936. * @param name defines the block name
  22937. */
  22938. constructor(name: string);
  22939. /**
  22940. * Gets the current class name
  22941. * @returns the class name
  22942. */
  22943. getClassName(): string;
  22944. /**
  22945. * Gets the xyz component (input)
  22946. */
  22947. get xyzIn(): NodeMaterialConnectionPoint;
  22948. /**
  22949. * Gets the xy component (input)
  22950. */
  22951. get xyIn(): NodeMaterialConnectionPoint;
  22952. /**
  22953. * Gets the x component (input)
  22954. */
  22955. get x(): NodeMaterialConnectionPoint;
  22956. /**
  22957. * Gets the y component (input)
  22958. */
  22959. get y(): NodeMaterialConnectionPoint;
  22960. /**
  22961. * Gets the z component (input)
  22962. */
  22963. get z(): NodeMaterialConnectionPoint;
  22964. /**
  22965. * Gets the w component (input)
  22966. */
  22967. get w(): NodeMaterialConnectionPoint;
  22968. /**
  22969. * Gets the xyzw component (output)
  22970. */
  22971. get xyzw(): NodeMaterialConnectionPoint;
  22972. /**
  22973. * Gets the xyz component (output)
  22974. */
  22975. get xyzOut(): NodeMaterialConnectionPoint;
  22976. /**
  22977. * Gets the xy component (output)
  22978. */
  22979. get xyOut(): NodeMaterialConnectionPoint;
  22980. /**
  22981. * Gets the xy component (output)
  22982. * @deprecated Please use xyOut instead.
  22983. */
  22984. get xy(): NodeMaterialConnectionPoint;
  22985. /**
  22986. * Gets the xyz component (output)
  22987. * @deprecated Please use xyzOut instead.
  22988. */
  22989. get xyz(): NodeMaterialConnectionPoint;
  22990. protected _buildBlock(state: NodeMaterialBuildState): this;
  22991. }
  22992. }
  22993. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22997. import { Vector2 } from "babylonjs/Maths/math.vector";
  22998. import { Scene } from "babylonjs/scene";
  22999. /**
  23000. * Block used to remap a float from a range to a new one
  23001. */
  23002. export class RemapBlock extends NodeMaterialBlock {
  23003. /**
  23004. * Gets or sets the source range
  23005. */
  23006. sourceRange: Vector2;
  23007. /**
  23008. * Gets or sets the target range
  23009. */
  23010. targetRange: Vector2;
  23011. /**
  23012. * Creates a new RemapBlock
  23013. * @param name defines the block name
  23014. */
  23015. constructor(name: string);
  23016. /**
  23017. * Gets the current class name
  23018. * @returns the class name
  23019. */
  23020. getClassName(): string;
  23021. /**
  23022. * Gets the input component
  23023. */
  23024. get input(): NodeMaterialConnectionPoint;
  23025. /**
  23026. * Gets the source min input component
  23027. */
  23028. get sourceMin(): NodeMaterialConnectionPoint;
  23029. /**
  23030. * Gets the source max input component
  23031. */
  23032. get sourceMax(): NodeMaterialConnectionPoint;
  23033. /**
  23034. * Gets the target min input component
  23035. */
  23036. get targetMin(): NodeMaterialConnectionPoint;
  23037. /**
  23038. * Gets the target max input component
  23039. */
  23040. get targetMax(): NodeMaterialConnectionPoint;
  23041. /**
  23042. * Gets the output component
  23043. */
  23044. get output(): NodeMaterialConnectionPoint;
  23045. protected _buildBlock(state: NodeMaterialBuildState): this;
  23046. protected _dumpPropertiesCode(): string;
  23047. serialize(): any;
  23048. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23049. }
  23050. }
  23051. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23055. /**
  23056. * Block used to multiply 2 values
  23057. */
  23058. export class MultiplyBlock extends NodeMaterialBlock {
  23059. /**
  23060. * Creates a new MultiplyBlock
  23061. * @param name defines the block name
  23062. */
  23063. constructor(name: string);
  23064. /**
  23065. * Gets the current class name
  23066. * @returns the class name
  23067. */
  23068. getClassName(): string;
  23069. /**
  23070. * Gets the left operand input component
  23071. */
  23072. get left(): NodeMaterialConnectionPoint;
  23073. /**
  23074. * Gets the right operand input component
  23075. */
  23076. get right(): NodeMaterialConnectionPoint;
  23077. /**
  23078. * Gets the output component
  23079. */
  23080. get output(): NodeMaterialConnectionPoint;
  23081. protected _buildBlock(state: NodeMaterialBuildState): this;
  23082. }
  23083. }
  23084. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23088. /**
  23089. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23090. */
  23091. export class ColorSplitterBlock extends NodeMaterialBlock {
  23092. /**
  23093. * Create a new ColorSplitterBlock
  23094. * @param name defines the block name
  23095. */
  23096. constructor(name: string);
  23097. /**
  23098. * Gets the current class name
  23099. * @returns the class name
  23100. */
  23101. getClassName(): string;
  23102. /**
  23103. * Gets the rgba component (input)
  23104. */
  23105. get rgba(): NodeMaterialConnectionPoint;
  23106. /**
  23107. * Gets the rgb component (input)
  23108. */
  23109. get rgbIn(): NodeMaterialConnectionPoint;
  23110. /**
  23111. * Gets the rgb component (output)
  23112. */
  23113. get rgbOut(): NodeMaterialConnectionPoint;
  23114. /**
  23115. * Gets the r component (output)
  23116. */
  23117. get r(): NodeMaterialConnectionPoint;
  23118. /**
  23119. * Gets the g component (output)
  23120. */
  23121. get g(): NodeMaterialConnectionPoint;
  23122. /**
  23123. * Gets the b component (output)
  23124. */
  23125. get b(): NodeMaterialConnectionPoint;
  23126. /**
  23127. * Gets the a component (output)
  23128. */
  23129. get a(): NodeMaterialConnectionPoint;
  23130. protected _inputRename(name: string): string;
  23131. protected _outputRename(name: string): string;
  23132. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23133. }
  23134. }
  23135. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23136. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23138. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23139. import { Scene } from "babylonjs/scene";
  23140. /**
  23141. * Operations supported by the Trigonometry block
  23142. */
  23143. export enum TrigonometryBlockOperations {
  23144. /** Cos */
  23145. Cos = 0,
  23146. /** Sin */
  23147. Sin = 1,
  23148. /** Abs */
  23149. Abs = 2,
  23150. /** Exp */
  23151. Exp = 3,
  23152. /** Exp2 */
  23153. Exp2 = 4,
  23154. /** Round */
  23155. Round = 5,
  23156. /** Floor */
  23157. Floor = 6,
  23158. /** Ceiling */
  23159. Ceiling = 7,
  23160. /** Square root */
  23161. Sqrt = 8,
  23162. /** Log */
  23163. Log = 9,
  23164. /** Tangent */
  23165. Tan = 10,
  23166. /** Arc tangent */
  23167. ArcTan = 11,
  23168. /** Arc cosinus */
  23169. ArcCos = 12,
  23170. /** Arc sinus */
  23171. ArcSin = 13,
  23172. /** Fraction */
  23173. Fract = 14,
  23174. /** Sign */
  23175. Sign = 15,
  23176. /** To radians (from degrees) */
  23177. Radians = 16,
  23178. /** To degrees (from radians) */
  23179. Degrees = 17
  23180. }
  23181. /**
  23182. * Block used to apply trigonometry operation to floats
  23183. */
  23184. export class TrigonometryBlock extends NodeMaterialBlock {
  23185. /**
  23186. * Gets or sets the operation applied by the block
  23187. */
  23188. operation: TrigonometryBlockOperations;
  23189. /**
  23190. * Creates a new TrigonometryBlock
  23191. * @param name defines the block name
  23192. */
  23193. constructor(name: string);
  23194. /**
  23195. * Gets the current class name
  23196. * @returns the class name
  23197. */
  23198. getClassName(): string;
  23199. /**
  23200. * Gets the input component
  23201. */
  23202. get input(): NodeMaterialConnectionPoint;
  23203. /**
  23204. * Gets the output component
  23205. */
  23206. get output(): NodeMaterialConnectionPoint;
  23207. protected _buildBlock(state: NodeMaterialBuildState): this;
  23208. serialize(): any;
  23209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23210. protected _dumpPropertiesCode(): string;
  23211. }
  23212. }
  23213. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23215. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23216. import { Scene } from "babylonjs/scene";
  23217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23218. import { Matrix } from "babylonjs/Maths/math.vector";
  23219. import { Mesh } from "babylonjs/Meshes/mesh";
  23220. import { Engine } from "babylonjs/Engines/engine";
  23221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23222. import { Observable } from "babylonjs/Misc/observable";
  23223. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23224. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23225. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23226. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23227. import { Nullable } from "babylonjs/types";
  23228. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23229. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23230. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23231. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23232. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23233. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23234. import { Effect } from "babylonjs/Materials/effect";
  23235. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23236. import { Camera } from "babylonjs/Cameras/camera";
  23237. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23238. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23239. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23240. /**
  23241. * Interface used to configure the node material editor
  23242. */
  23243. export interface INodeMaterialEditorOptions {
  23244. /** Define the URl to load node editor script */
  23245. editorURL?: string;
  23246. }
  23247. /** @hidden */
  23248. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23249. NORMAL: boolean;
  23250. TANGENT: boolean;
  23251. UV1: boolean;
  23252. /** BONES */
  23253. NUM_BONE_INFLUENCERS: number;
  23254. BonesPerMesh: number;
  23255. BONETEXTURE: boolean;
  23256. /** MORPH TARGETS */
  23257. MORPHTARGETS: boolean;
  23258. MORPHTARGETS_NORMAL: boolean;
  23259. MORPHTARGETS_TANGENT: boolean;
  23260. MORPHTARGETS_UV: boolean;
  23261. NUM_MORPH_INFLUENCERS: number;
  23262. /** IMAGE PROCESSING */
  23263. IMAGEPROCESSING: boolean;
  23264. VIGNETTE: boolean;
  23265. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23266. VIGNETTEBLENDMODEOPAQUE: boolean;
  23267. TONEMAPPING: boolean;
  23268. TONEMAPPING_ACES: boolean;
  23269. CONTRAST: boolean;
  23270. EXPOSURE: boolean;
  23271. COLORCURVES: boolean;
  23272. COLORGRADING: boolean;
  23273. COLORGRADING3D: boolean;
  23274. SAMPLER3DGREENDEPTH: boolean;
  23275. SAMPLER3DBGRMAP: boolean;
  23276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23277. /** MISC. */
  23278. BUMPDIRECTUV: number;
  23279. constructor();
  23280. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23281. }
  23282. /**
  23283. * Class used to configure NodeMaterial
  23284. */
  23285. export interface INodeMaterialOptions {
  23286. /**
  23287. * Defines if blocks should emit comments
  23288. */
  23289. emitComments: boolean;
  23290. }
  23291. /**
  23292. * Class used to create a node based material built by assembling shader blocks
  23293. */
  23294. export class NodeMaterial extends PushMaterial {
  23295. private static _BuildIdGenerator;
  23296. private _options;
  23297. private _vertexCompilationState;
  23298. private _fragmentCompilationState;
  23299. private _sharedData;
  23300. private _buildId;
  23301. private _buildWasSuccessful;
  23302. private _cachedWorldViewMatrix;
  23303. private _cachedWorldViewProjectionMatrix;
  23304. private _optimizers;
  23305. private _animationFrame;
  23306. /** Define the Url to load node editor script */
  23307. static EditorURL: string;
  23308. /** Define the Url to load snippets */
  23309. static SnippetUrl: string;
  23310. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23311. static IgnoreTexturesAtLoadTime: boolean;
  23312. private BJSNODEMATERIALEDITOR;
  23313. /** Get the inspector from bundle or global */
  23314. private _getGlobalNodeMaterialEditor;
  23315. /**
  23316. * Snippet ID if the material was created from the snippet server
  23317. */
  23318. snippetId: string;
  23319. /**
  23320. * Gets or sets data used by visual editor
  23321. * @see https://nme.babylonjs.com
  23322. */
  23323. editorData: any;
  23324. /**
  23325. * 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)
  23326. */
  23327. ignoreAlpha: boolean;
  23328. /**
  23329. * Defines the maximum number of lights that can be used in the material
  23330. */
  23331. maxSimultaneousLights: number;
  23332. /**
  23333. * Observable raised when the material is built
  23334. */
  23335. onBuildObservable: Observable<NodeMaterial>;
  23336. /**
  23337. * Gets or sets the root nodes of the material vertex shader
  23338. */
  23339. _vertexOutputNodes: NodeMaterialBlock[];
  23340. /**
  23341. * Gets or sets the root nodes of the material fragment (pixel) shader
  23342. */
  23343. _fragmentOutputNodes: NodeMaterialBlock[];
  23344. /** Gets or sets options to control the node material overall behavior */
  23345. get options(): INodeMaterialOptions;
  23346. set options(options: INodeMaterialOptions);
  23347. /**
  23348. * Default configuration related to image processing available in the standard Material.
  23349. */
  23350. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23351. /**
  23352. * Gets the image processing configuration used either in this material.
  23353. */
  23354. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23355. /**
  23356. * Sets the Default image processing configuration used either in the this material.
  23357. *
  23358. * If sets to null, the scene one is in use.
  23359. */
  23360. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23361. /**
  23362. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23363. */
  23364. attachedBlocks: NodeMaterialBlock[];
  23365. /**
  23366. * Specifies the mode of the node material
  23367. * @hidden
  23368. */
  23369. _mode: NodeMaterialModes;
  23370. /**
  23371. * Gets the mode property
  23372. */
  23373. get mode(): NodeMaterialModes;
  23374. /**
  23375. * Create a new node based material
  23376. * @param name defines the material name
  23377. * @param scene defines the hosting scene
  23378. * @param options defines creation option
  23379. */
  23380. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23381. /**
  23382. * Gets the current class name of the material e.g. "NodeMaterial"
  23383. * @returns the class name
  23384. */
  23385. getClassName(): string;
  23386. /**
  23387. * Keep track of the image processing observer to allow dispose and replace.
  23388. */
  23389. private _imageProcessingObserver;
  23390. /**
  23391. * Attaches a new image processing configuration to the Standard Material.
  23392. * @param configuration
  23393. */
  23394. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23395. /**
  23396. * Get a block by its name
  23397. * @param name defines the name of the block to retrieve
  23398. * @returns the required block or null if not found
  23399. */
  23400. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23401. /**
  23402. * Get a block by its name
  23403. * @param predicate defines the predicate used to find the good candidate
  23404. * @returns the required block or null if not found
  23405. */
  23406. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23407. /**
  23408. * Get an input block by its name
  23409. * @param predicate defines the predicate used to find the good candidate
  23410. * @returns the required input block or null if not found
  23411. */
  23412. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23413. /**
  23414. * Gets the list of input blocks attached to this material
  23415. * @returns an array of InputBlocks
  23416. */
  23417. getInputBlocks(): InputBlock[];
  23418. /**
  23419. * Adds a new optimizer to the list of optimizers
  23420. * @param optimizer defines the optimizers to add
  23421. * @returns the current material
  23422. */
  23423. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23424. /**
  23425. * Remove an optimizer from the list of optimizers
  23426. * @param optimizer defines the optimizers to remove
  23427. * @returns the current material
  23428. */
  23429. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23430. /**
  23431. * Add a new block to the list of output nodes
  23432. * @param node defines the node to add
  23433. * @returns the current material
  23434. */
  23435. addOutputNode(node: NodeMaterialBlock): this;
  23436. /**
  23437. * Remove a block from the list of root nodes
  23438. * @param node defines the node to remove
  23439. * @returns the current material
  23440. */
  23441. removeOutputNode(node: NodeMaterialBlock): this;
  23442. private _addVertexOutputNode;
  23443. private _removeVertexOutputNode;
  23444. private _addFragmentOutputNode;
  23445. private _removeFragmentOutputNode;
  23446. /**
  23447. * Specifies if the material will require alpha blending
  23448. * @returns a boolean specifying if alpha blending is needed
  23449. */
  23450. needAlphaBlending(): boolean;
  23451. /**
  23452. * Specifies if this material should be rendered in alpha test mode
  23453. * @returns a boolean specifying if an alpha test is needed.
  23454. */
  23455. needAlphaTesting(): boolean;
  23456. private _initializeBlock;
  23457. private _resetDualBlocks;
  23458. /**
  23459. * Remove a block from the current node material
  23460. * @param block defines the block to remove
  23461. */
  23462. removeBlock(block: NodeMaterialBlock): void;
  23463. /**
  23464. * Build the material and generates the inner effect
  23465. * @param verbose defines if the build should log activity
  23466. */
  23467. build(verbose?: boolean): void;
  23468. /**
  23469. * Runs an otpimization phase to try to improve the shader code
  23470. */
  23471. optimize(): void;
  23472. private _prepareDefinesForAttributes;
  23473. /**
  23474. * Create a post process from the material
  23475. * @param camera The camera to apply the render pass to.
  23476. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23478. * @param engine The engine which the post process will be applied. (default: current engine)
  23479. * @param reusable If the post process can be reused on the same frame. (default: false)
  23480. * @param textureType Type of textures used when performing the post process. (default: 0)
  23481. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23482. * @returns the post process created
  23483. */
  23484. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23485. /**
  23486. * Create the post process effect from the material
  23487. * @param postProcess The post process to create the effect for
  23488. */
  23489. createEffectForPostProcess(postProcess: PostProcess): void;
  23490. private _createEffectForPostProcess;
  23491. /**
  23492. * Create a new procedural texture based on this node material
  23493. * @param size defines the size of the texture
  23494. * @param scene defines the hosting scene
  23495. * @returns the new procedural texture attached to this node material
  23496. */
  23497. createProceduralTexture(size: number | {
  23498. width: number;
  23499. height: number;
  23500. layers?: number;
  23501. }, scene: Scene): Nullable<ProceduralTexture>;
  23502. private _createEffectForParticles;
  23503. private _checkInternals;
  23504. /**
  23505. * Create the effect to be used as the custom effect for a particle system
  23506. * @param particleSystem Particle system to create the effect for
  23507. * @param onCompiled defines a function to call when the effect creation is successful
  23508. * @param onError defines a function to call when the effect creation has failed
  23509. */
  23510. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23511. private _processDefines;
  23512. /**
  23513. * Get if the submesh is ready to be used and all its information available.
  23514. * Child classes can use it to update shaders
  23515. * @param mesh defines the mesh to check
  23516. * @param subMesh defines which submesh to check
  23517. * @param useInstances specifies that instances should be used
  23518. * @returns a boolean indicating that the submesh is ready or not
  23519. */
  23520. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23521. /**
  23522. * Get a string representing the shaders built by the current node graph
  23523. */
  23524. get compiledShaders(): string;
  23525. /**
  23526. * Binds the world matrix to the material
  23527. * @param world defines the world transformation matrix
  23528. */
  23529. bindOnlyWorldMatrix(world: Matrix): void;
  23530. /**
  23531. * Binds the submesh to this material by preparing the effect and shader to draw
  23532. * @param world defines the world transformation matrix
  23533. * @param mesh defines the mesh containing the submesh
  23534. * @param subMesh defines the submesh to bind the material to
  23535. */
  23536. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23537. /**
  23538. * Gets the active textures from the material
  23539. * @returns an array of textures
  23540. */
  23541. getActiveTextures(): BaseTexture[];
  23542. /**
  23543. * Gets the list of texture blocks
  23544. * @returns an array of texture blocks
  23545. */
  23546. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23547. /**
  23548. * Specifies if the material uses a texture
  23549. * @param texture defines the texture to check against the material
  23550. * @returns a boolean specifying if the material uses the texture
  23551. */
  23552. hasTexture(texture: BaseTexture): boolean;
  23553. /**
  23554. * Disposes the material
  23555. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23556. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23557. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23558. */
  23559. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23560. /** Creates the node editor window. */
  23561. private _createNodeEditor;
  23562. /**
  23563. * Launch the node material editor
  23564. * @param config Define the configuration of the editor
  23565. * @return a promise fulfilled when the node editor is visible
  23566. */
  23567. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23568. /**
  23569. * Clear the current material
  23570. */
  23571. clear(): void;
  23572. /**
  23573. * Clear the current material and set it to a default state
  23574. */
  23575. setToDefault(): void;
  23576. /**
  23577. * Clear the current material and set it to a default state for post process
  23578. */
  23579. setToDefaultPostProcess(): void;
  23580. /**
  23581. * Clear the current material and set it to a default state for procedural texture
  23582. */
  23583. setToDefaultProceduralTexture(): void;
  23584. /**
  23585. * Clear the current material and set it to a default state for particle
  23586. */
  23587. setToDefaultParticle(): void;
  23588. /**
  23589. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23590. * @param url defines the url to load from
  23591. * @returns a promise that will fullfil when the material is fully loaded
  23592. */
  23593. loadAsync(url: string): Promise<void>;
  23594. private _gatherBlocks;
  23595. /**
  23596. * Generate a string containing the code declaration required to create an equivalent of this material
  23597. * @returns a string
  23598. */
  23599. generateCode(): string;
  23600. /**
  23601. * Serializes this material in a JSON representation
  23602. * @returns the serialized material object
  23603. */
  23604. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23605. private _restoreConnections;
  23606. /**
  23607. * Clear the current graph and load a new one from a serialization object
  23608. * @param source defines the JSON representation of the material
  23609. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23610. * @param merge defines whether or not the source must be merged or replace the current content
  23611. */
  23612. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23613. /**
  23614. * Makes a duplicate of the current material.
  23615. * @param name - name to use for the new material.
  23616. */
  23617. clone(name: string): NodeMaterial;
  23618. /**
  23619. * Creates a node material from parsed material data
  23620. * @param source defines the JSON representation of the material
  23621. * @param scene defines the hosting scene
  23622. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23623. * @returns a new node material
  23624. */
  23625. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23626. /**
  23627. * Creates a node material from a snippet saved in a remote file
  23628. * @param name defines the name of the material to create
  23629. * @param url defines the url to load from
  23630. * @param scene defines the hosting scene
  23631. * @returns a promise that will resolve to the new node material
  23632. */
  23633. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23634. /**
  23635. * Creates a node material from a snippet saved by the node material editor
  23636. * @param snippetId defines the snippet to load
  23637. * @param scene defines the hosting scene
  23638. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23639. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23640. * @returns a promise that will resolve to the new node material
  23641. */
  23642. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23643. /**
  23644. * Creates a new node material set to default basic configuration
  23645. * @param name defines the name of the material
  23646. * @param scene defines the hosting scene
  23647. * @returns a new NodeMaterial
  23648. */
  23649. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23650. }
  23651. }
  23652. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23653. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23654. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23655. import { Nullable } from "babylonjs/types";
  23656. module "babylonjs/Engines/thinEngine" {
  23657. interface ThinEngine {
  23658. /**
  23659. * Unbind a list of render target textures from the webGL context
  23660. * This is used only when drawBuffer extension or webGL2 are active
  23661. * @param textures defines the render target textures to unbind
  23662. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23663. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23664. */
  23665. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23666. /**
  23667. * Create a multi render target texture
  23668. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23669. * @param size defines the size of the texture
  23670. * @param options defines the creation options
  23671. * @returns the cube texture as an InternalTexture
  23672. */
  23673. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23674. /**
  23675. * Update the sample count for a given multiple render target texture
  23676. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23677. * @param textures defines the textures to update
  23678. * @param samples defines the sample count to set
  23679. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23680. */
  23681. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23682. /**
  23683. * Select a subsets of attachments to draw to.
  23684. * @param attachments gl attachments
  23685. */
  23686. bindAttachments(attachments: number[]): void;
  23687. /**
  23688. * Creates a layout object to draw/clear on specific textures in a MRT
  23689. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23690. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23691. */
  23692. buildTextureLayout(textureStatus: boolean[]): number[];
  23693. /**
  23694. * Restores the webgl state to only draw on the main color attachment
  23695. */
  23696. restoreSingleAttachment(): void;
  23697. }
  23698. }
  23699. }
  23700. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23701. import { Scene } from "babylonjs/scene";
  23702. import { Engine } from "babylonjs/Engines/engine";
  23703. import { Texture } from "babylonjs/Materials/Textures/texture";
  23704. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23705. import "babylonjs/Engines/Extensions/engine.multiRender";
  23706. /**
  23707. * Creation options of the multi render target texture.
  23708. */
  23709. export interface IMultiRenderTargetOptions {
  23710. /**
  23711. * Define if the texture needs to create mip maps after render.
  23712. */
  23713. generateMipMaps?: boolean;
  23714. /**
  23715. * Define the types of all the draw buffers we want to create
  23716. */
  23717. types?: number[];
  23718. /**
  23719. * Define the sampling modes of all the draw buffers we want to create
  23720. */
  23721. samplingModes?: number[];
  23722. /**
  23723. * Define if a depth buffer is required
  23724. */
  23725. generateDepthBuffer?: boolean;
  23726. /**
  23727. * Define if a stencil buffer is required
  23728. */
  23729. generateStencilBuffer?: boolean;
  23730. /**
  23731. * Define if a depth texture is required instead of a depth buffer
  23732. */
  23733. generateDepthTexture?: boolean;
  23734. /**
  23735. * Define the number of desired draw buffers
  23736. */
  23737. textureCount?: number;
  23738. /**
  23739. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23740. */
  23741. doNotChangeAspectRatio?: boolean;
  23742. /**
  23743. * Define the default type of the buffers we are creating
  23744. */
  23745. defaultType?: number;
  23746. }
  23747. /**
  23748. * A multi render target, like a render target provides the ability to render to a texture.
  23749. * Unlike the render target, it can render to several draw buffers in one draw.
  23750. * This is specially interesting in deferred rendering or for any effects requiring more than
  23751. * just one color from a single pass.
  23752. */
  23753. export class MultiRenderTarget extends RenderTargetTexture {
  23754. private _internalTextures;
  23755. private _textures;
  23756. private _multiRenderTargetOptions;
  23757. private _count;
  23758. /**
  23759. * Get if draw buffers are currently supported by the used hardware and browser.
  23760. */
  23761. get isSupported(): boolean;
  23762. /**
  23763. * Get the list of textures generated by the multi render target.
  23764. */
  23765. get textures(): Texture[];
  23766. /**
  23767. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23768. */
  23769. get count(): number;
  23770. /**
  23771. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23772. */
  23773. get depthTexture(): Texture;
  23774. /**
  23775. * Set the wrapping mode on U of all the textures we are rendering to.
  23776. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23777. */
  23778. set wrapU(wrap: number);
  23779. /**
  23780. * Set the wrapping mode on V of all the textures we are rendering to.
  23781. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23782. */
  23783. set wrapV(wrap: number);
  23784. /**
  23785. * Instantiate a new multi render target texture.
  23786. * A multi render target, like a render target provides the ability to render to a texture.
  23787. * Unlike the render target, it can render to several draw buffers in one draw.
  23788. * This is specially interesting in deferred rendering or for any effects requiring more than
  23789. * just one color from a single pass.
  23790. * @param name Define the name of the texture
  23791. * @param size Define the size of the buffers to render to
  23792. * @param count Define the number of target we are rendering into
  23793. * @param scene Define the scene the texture belongs to
  23794. * @param options Define the options used to create the multi render target
  23795. */
  23796. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23797. private _initTypes;
  23798. /** @hidden */
  23799. _rebuild(forceFullRebuild?: boolean): void;
  23800. private _createInternalTextures;
  23801. private _createTextures;
  23802. /**
  23803. * Replaces a texture within the MRT.
  23804. * @param texture The new texture to insert in the MRT
  23805. * @param index The index of the texture to replace
  23806. */
  23807. replaceTexture(texture: Texture, index: number): void;
  23808. /**
  23809. * Define the number of samples used if MSAA is enabled.
  23810. */
  23811. get samples(): number;
  23812. set samples(value: number);
  23813. /**
  23814. * Resize all the textures in the multi render target.
  23815. * Be careful as it will recreate all the data in the new texture.
  23816. * @param size Define the new size
  23817. */
  23818. resize(size: any): void;
  23819. /**
  23820. * Changes the number of render targets in this MRT
  23821. * Be careful as it will recreate all the data in the new texture.
  23822. * @param count new texture count
  23823. * @param options Specifies texture types and sampling modes for new textures
  23824. */
  23825. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23826. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23827. /**
  23828. * Dispose the render targets and their associated resources
  23829. */
  23830. dispose(): void;
  23831. /**
  23832. * Release all the underlying texture used as draw buffers.
  23833. */
  23834. releaseInternalTextures(): void;
  23835. }
  23836. }
  23837. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  23838. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  23839. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  23840. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  23841. /** @hidden */
  23842. export var imageProcessingPixelShader: {
  23843. name: string;
  23844. shader: string;
  23845. };
  23846. }
  23847. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  23848. import { Nullable } from "babylonjs/types";
  23849. import { Color4 } from "babylonjs/Maths/math.color";
  23850. import { Camera } from "babylonjs/Cameras/camera";
  23851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23852. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23853. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23854. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23855. import { Engine } from "babylonjs/Engines/engine";
  23856. import "babylonjs/Shaders/imageProcessing.fragment";
  23857. import "babylonjs/Shaders/postprocess.vertex";
  23858. /**
  23859. * ImageProcessingPostProcess
  23860. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23861. */
  23862. export class ImageProcessingPostProcess extends PostProcess {
  23863. /**
  23864. * Default configuration related to image processing available in the PBR Material.
  23865. */
  23866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23867. /**
  23868. * Gets the image processing configuration used either in this material.
  23869. */
  23870. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23871. /**
  23872. * Sets the Default image processing configuration used either in the this material.
  23873. *
  23874. * If sets to null, the scene one is in use.
  23875. */
  23876. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23877. /**
  23878. * Keep track of the image processing observer to allow dispose and replace.
  23879. */
  23880. private _imageProcessingObserver;
  23881. /**
  23882. * Attaches a new image processing configuration to the PBR Material.
  23883. * @param configuration
  23884. */
  23885. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23886. /**
  23887. * If the post process is supported.
  23888. */
  23889. get isSupported(): boolean;
  23890. /**
  23891. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23892. */
  23893. get colorCurves(): Nullable<ColorCurves>;
  23894. /**
  23895. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23896. */
  23897. set colorCurves(value: Nullable<ColorCurves>);
  23898. /**
  23899. * Gets wether the color curves effect is enabled.
  23900. */
  23901. get colorCurvesEnabled(): boolean;
  23902. /**
  23903. * Sets wether the color curves effect is enabled.
  23904. */
  23905. set colorCurvesEnabled(value: boolean);
  23906. /**
  23907. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23908. */
  23909. get colorGradingTexture(): Nullable<BaseTexture>;
  23910. /**
  23911. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23912. */
  23913. set colorGradingTexture(value: Nullable<BaseTexture>);
  23914. /**
  23915. * Gets wether the color grading effect is enabled.
  23916. */
  23917. get colorGradingEnabled(): boolean;
  23918. /**
  23919. * Gets wether the color grading effect is enabled.
  23920. */
  23921. set colorGradingEnabled(value: boolean);
  23922. /**
  23923. * Gets exposure used in the effect.
  23924. */
  23925. get exposure(): number;
  23926. /**
  23927. * Sets exposure used in the effect.
  23928. */
  23929. set exposure(value: number);
  23930. /**
  23931. * Gets wether tonemapping is enabled or not.
  23932. */
  23933. get toneMappingEnabled(): boolean;
  23934. /**
  23935. * Sets wether tonemapping is enabled or not
  23936. */
  23937. set toneMappingEnabled(value: boolean);
  23938. /**
  23939. * Gets the type of tone mapping effect.
  23940. */
  23941. get toneMappingType(): number;
  23942. /**
  23943. * Sets the type of tone mapping effect.
  23944. */
  23945. set toneMappingType(value: number);
  23946. /**
  23947. * Gets contrast used in the effect.
  23948. */
  23949. get contrast(): number;
  23950. /**
  23951. * Sets contrast used in the effect.
  23952. */
  23953. set contrast(value: number);
  23954. /**
  23955. * Gets Vignette stretch size.
  23956. */
  23957. get vignetteStretch(): number;
  23958. /**
  23959. * Sets Vignette stretch size.
  23960. */
  23961. set vignetteStretch(value: number);
  23962. /**
  23963. * Gets Vignette centre X Offset.
  23964. */
  23965. get vignetteCentreX(): number;
  23966. /**
  23967. * Sets Vignette centre X Offset.
  23968. */
  23969. set vignetteCentreX(value: number);
  23970. /**
  23971. * Gets Vignette centre Y Offset.
  23972. */
  23973. get vignetteCentreY(): number;
  23974. /**
  23975. * Sets Vignette centre Y Offset.
  23976. */
  23977. set vignetteCentreY(value: number);
  23978. /**
  23979. * Gets Vignette weight or intensity of the vignette effect.
  23980. */
  23981. get vignetteWeight(): number;
  23982. /**
  23983. * Sets Vignette weight or intensity of the vignette effect.
  23984. */
  23985. set vignetteWeight(value: number);
  23986. /**
  23987. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23988. * if vignetteEnabled is set to true.
  23989. */
  23990. get vignetteColor(): Color4;
  23991. /**
  23992. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23993. * if vignetteEnabled is set to true.
  23994. */
  23995. set vignetteColor(value: Color4);
  23996. /**
  23997. * Gets Camera field of view used by the Vignette effect.
  23998. */
  23999. get vignetteCameraFov(): number;
  24000. /**
  24001. * Sets Camera field of view used by the Vignette effect.
  24002. */
  24003. set vignetteCameraFov(value: number);
  24004. /**
  24005. * Gets the vignette blend mode allowing different kind of effect.
  24006. */
  24007. get vignetteBlendMode(): number;
  24008. /**
  24009. * Sets the vignette blend mode allowing different kind of effect.
  24010. */
  24011. set vignetteBlendMode(value: number);
  24012. /**
  24013. * Gets wether the vignette effect is enabled.
  24014. */
  24015. get vignetteEnabled(): boolean;
  24016. /**
  24017. * Sets wether the vignette effect is enabled.
  24018. */
  24019. set vignetteEnabled(value: boolean);
  24020. private _fromLinearSpace;
  24021. /**
  24022. * Gets wether the input of the processing is in Gamma or Linear Space.
  24023. */
  24024. get fromLinearSpace(): boolean;
  24025. /**
  24026. * Sets wether the input of the processing is in Gamma or Linear Space.
  24027. */
  24028. set fromLinearSpace(value: boolean);
  24029. /**
  24030. * Defines cache preventing GC.
  24031. */
  24032. private _defines;
  24033. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24034. /**
  24035. * "ImageProcessingPostProcess"
  24036. * @returns "ImageProcessingPostProcess"
  24037. */
  24038. getClassName(): string;
  24039. /**
  24040. * @hidden
  24041. */
  24042. _updateParameters(): void;
  24043. dispose(camera?: Camera): void;
  24044. }
  24045. }
  24046. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24047. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24048. /**
  24049. * Interface for defining prepass effects in the prepass post-process pipeline
  24050. */
  24051. export interface PrePassEffectConfiguration {
  24052. /**
  24053. * Name of the effect
  24054. */
  24055. name: string;
  24056. /**
  24057. * Post process to attach for this effect
  24058. */
  24059. postProcess?: PostProcess;
  24060. /**
  24061. * Textures required in the MRT
  24062. */
  24063. texturesRequired: number[];
  24064. /**
  24065. * Is the effect enabled
  24066. */
  24067. enabled: boolean;
  24068. /**
  24069. * Disposes the effect configuration
  24070. */
  24071. dispose?: () => void;
  24072. /**
  24073. * Creates the associated post process
  24074. */
  24075. createPostProcess?: () => PostProcess;
  24076. }
  24077. }
  24078. declare module "babylonjs/Materials/fresnelParameters" {
  24079. import { DeepImmutable } from "babylonjs/types";
  24080. import { Color3 } from "babylonjs/Maths/math.color";
  24081. /**
  24082. * Options to be used when creating a FresnelParameters.
  24083. */
  24084. export type IFresnelParametersCreationOptions = {
  24085. /**
  24086. * Define the color used on edges (grazing angle)
  24087. */
  24088. leftColor?: Color3;
  24089. /**
  24090. * Define the color used on center
  24091. */
  24092. rightColor?: Color3;
  24093. /**
  24094. * Define bias applied to computed fresnel term
  24095. */
  24096. bias?: number;
  24097. /**
  24098. * Defined the power exponent applied to fresnel term
  24099. */
  24100. power?: number;
  24101. /**
  24102. * Define if the fresnel effect is enable or not.
  24103. */
  24104. isEnabled?: boolean;
  24105. };
  24106. /**
  24107. * Serialized format for FresnelParameters.
  24108. */
  24109. export type IFresnelParametersSerialized = {
  24110. /**
  24111. * Define the color used on edges (grazing angle) [as an array]
  24112. */
  24113. leftColor: number[];
  24114. /**
  24115. * Define the color used on center [as an array]
  24116. */
  24117. rightColor: number[];
  24118. /**
  24119. * Define bias applied to computed fresnel term
  24120. */
  24121. bias: number;
  24122. /**
  24123. * Defined the power exponent applied to fresnel term
  24124. */
  24125. power?: number;
  24126. /**
  24127. * Define if the fresnel effect is enable or not.
  24128. */
  24129. isEnabled: boolean;
  24130. };
  24131. /**
  24132. * This represents all the required information to add a fresnel effect on a material:
  24133. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24134. */
  24135. export class FresnelParameters {
  24136. private _isEnabled;
  24137. /**
  24138. * Define if the fresnel effect is enable or not.
  24139. */
  24140. get isEnabled(): boolean;
  24141. set isEnabled(value: boolean);
  24142. /**
  24143. * Define the color used on edges (grazing angle)
  24144. */
  24145. leftColor: Color3;
  24146. /**
  24147. * Define the color used on center
  24148. */
  24149. rightColor: Color3;
  24150. /**
  24151. * Define bias applied to computed fresnel term
  24152. */
  24153. bias: number;
  24154. /**
  24155. * Defined the power exponent applied to fresnel term
  24156. */
  24157. power: number;
  24158. /**
  24159. * Creates a new FresnelParameters object.
  24160. *
  24161. * @param options provide your own settings to optionally to override defaults
  24162. */
  24163. constructor(options?: IFresnelParametersCreationOptions);
  24164. /**
  24165. * Clones the current fresnel and its valuues
  24166. * @returns a clone fresnel configuration
  24167. */
  24168. clone(): FresnelParameters;
  24169. /**
  24170. * Determines equality between FresnelParameters objects
  24171. * @param otherFresnelParameters defines the second operand
  24172. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24173. */
  24174. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24175. /**
  24176. * Serializes the current fresnel parameters to a JSON representation.
  24177. * @return the JSON serialization
  24178. */
  24179. serialize(): IFresnelParametersSerialized;
  24180. /**
  24181. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24182. * @param parsedFresnelParameters Define the JSON representation
  24183. * @returns the parsed parameters
  24184. */
  24185. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24186. }
  24187. }
  24188. declare module "babylonjs/Materials/materialFlags" {
  24189. /**
  24190. * This groups all the flags used to control the materials channel.
  24191. */
  24192. export class MaterialFlags {
  24193. private static _DiffuseTextureEnabled;
  24194. /**
  24195. * Are diffuse textures enabled in the application.
  24196. */
  24197. static get DiffuseTextureEnabled(): boolean;
  24198. static set DiffuseTextureEnabled(value: boolean);
  24199. private static _DetailTextureEnabled;
  24200. /**
  24201. * Are detail textures enabled in the application.
  24202. */
  24203. static get DetailTextureEnabled(): boolean;
  24204. static set DetailTextureEnabled(value: boolean);
  24205. private static _AmbientTextureEnabled;
  24206. /**
  24207. * Are ambient textures enabled in the application.
  24208. */
  24209. static get AmbientTextureEnabled(): boolean;
  24210. static set AmbientTextureEnabled(value: boolean);
  24211. private static _OpacityTextureEnabled;
  24212. /**
  24213. * Are opacity textures enabled in the application.
  24214. */
  24215. static get OpacityTextureEnabled(): boolean;
  24216. static set OpacityTextureEnabled(value: boolean);
  24217. private static _ReflectionTextureEnabled;
  24218. /**
  24219. * Are reflection textures enabled in the application.
  24220. */
  24221. static get ReflectionTextureEnabled(): boolean;
  24222. static set ReflectionTextureEnabled(value: boolean);
  24223. private static _EmissiveTextureEnabled;
  24224. /**
  24225. * Are emissive textures enabled in the application.
  24226. */
  24227. static get EmissiveTextureEnabled(): boolean;
  24228. static set EmissiveTextureEnabled(value: boolean);
  24229. private static _SpecularTextureEnabled;
  24230. /**
  24231. * Are specular textures enabled in the application.
  24232. */
  24233. static get SpecularTextureEnabled(): boolean;
  24234. static set SpecularTextureEnabled(value: boolean);
  24235. private static _BumpTextureEnabled;
  24236. /**
  24237. * Are bump textures enabled in the application.
  24238. */
  24239. static get BumpTextureEnabled(): boolean;
  24240. static set BumpTextureEnabled(value: boolean);
  24241. private static _LightmapTextureEnabled;
  24242. /**
  24243. * Are lightmap textures enabled in the application.
  24244. */
  24245. static get LightmapTextureEnabled(): boolean;
  24246. static set LightmapTextureEnabled(value: boolean);
  24247. private static _RefractionTextureEnabled;
  24248. /**
  24249. * Are refraction textures enabled in the application.
  24250. */
  24251. static get RefractionTextureEnabled(): boolean;
  24252. static set RefractionTextureEnabled(value: boolean);
  24253. private static _ColorGradingTextureEnabled;
  24254. /**
  24255. * Are color grading textures enabled in the application.
  24256. */
  24257. static get ColorGradingTextureEnabled(): boolean;
  24258. static set ColorGradingTextureEnabled(value: boolean);
  24259. private static _FresnelEnabled;
  24260. /**
  24261. * Are fresnels enabled in the application.
  24262. */
  24263. static get FresnelEnabled(): boolean;
  24264. static set FresnelEnabled(value: boolean);
  24265. private static _ClearCoatTextureEnabled;
  24266. /**
  24267. * Are clear coat textures enabled in the application.
  24268. */
  24269. static get ClearCoatTextureEnabled(): boolean;
  24270. static set ClearCoatTextureEnabled(value: boolean);
  24271. private static _ClearCoatBumpTextureEnabled;
  24272. /**
  24273. * Are clear coat bump textures enabled in the application.
  24274. */
  24275. static get ClearCoatBumpTextureEnabled(): boolean;
  24276. static set ClearCoatBumpTextureEnabled(value: boolean);
  24277. private static _ClearCoatTintTextureEnabled;
  24278. /**
  24279. * Are clear coat tint textures enabled in the application.
  24280. */
  24281. static get ClearCoatTintTextureEnabled(): boolean;
  24282. static set ClearCoatTintTextureEnabled(value: boolean);
  24283. private static _SheenTextureEnabled;
  24284. /**
  24285. * Are sheen textures enabled in the application.
  24286. */
  24287. static get SheenTextureEnabled(): boolean;
  24288. static set SheenTextureEnabled(value: boolean);
  24289. private static _AnisotropicTextureEnabled;
  24290. /**
  24291. * Are anisotropic textures enabled in the application.
  24292. */
  24293. static get AnisotropicTextureEnabled(): boolean;
  24294. static set AnisotropicTextureEnabled(value: boolean);
  24295. private static _ThicknessTextureEnabled;
  24296. /**
  24297. * Are thickness textures enabled in the application.
  24298. */
  24299. static get ThicknessTextureEnabled(): boolean;
  24300. static set ThicknessTextureEnabled(value: boolean);
  24301. }
  24302. }
  24303. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24304. /** @hidden */
  24305. export var defaultFragmentDeclaration: {
  24306. name: string;
  24307. shader: string;
  24308. };
  24309. }
  24310. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24311. /** @hidden */
  24312. export var defaultUboDeclaration: {
  24313. name: string;
  24314. shader: string;
  24315. };
  24316. }
  24317. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24318. /** @hidden */
  24319. export var prePassDeclaration: {
  24320. name: string;
  24321. shader: string;
  24322. };
  24323. }
  24324. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24325. /** @hidden */
  24326. export var lightFragmentDeclaration: {
  24327. name: string;
  24328. shader: string;
  24329. };
  24330. }
  24331. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24332. /** @hidden */
  24333. export var lightUboDeclaration: {
  24334. name: string;
  24335. shader: string;
  24336. };
  24337. }
  24338. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24339. /** @hidden */
  24340. export var lightsFragmentFunctions: {
  24341. name: string;
  24342. shader: string;
  24343. };
  24344. }
  24345. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24346. /** @hidden */
  24347. export var shadowsFragmentFunctions: {
  24348. name: string;
  24349. shader: string;
  24350. };
  24351. }
  24352. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24353. /** @hidden */
  24354. export var fresnelFunction: {
  24355. name: string;
  24356. shader: string;
  24357. };
  24358. }
  24359. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24360. /** @hidden */
  24361. export var bumpFragmentMainFunctions: {
  24362. name: string;
  24363. shader: string;
  24364. };
  24365. }
  24366. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24367. /** @hidden */
  24368. export var bumpFragmentFunctions: {
  24369. name: string;
  24370. shader: string;
  24371. };
  24372. }
  24373. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24374. /** @hidden */
  24375. export var logDepthDeclaration: {
  24376. name: string;
  24377. shader: string;
  24378. };
  24379. }
  24380. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24381. /** @hidden */
  24382. export var bumpFragment: {
  24383. name: string;
  24384. shader: string;
  24385. };
  24386. }
  24387. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24388. /** @hidden */
  24389. export var depthPrePass: {
  24390. name: string;
  24391. shader: string;
  24392. };
  24393. }
  24394. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24395. /** @hidden */
  24396. export var lightFragment: {
  24397. name: string;
  24398. shader: string;
  24399. };
  24400. }
  24401. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24402. /** @hidden */
  24403. export var logDepthFragment: {
  24404. name: string;
  24405. shader: string;
  24406. };
  24407. }
  24408. declare module "babylonjs/Shaders/default.fragment" {
  24409. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24410. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24411. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24412. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24413. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24414. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24415. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24416. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24417. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24418. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24419. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24420. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24421. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24422. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24423. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24424. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24425. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24426. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24427. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24428. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24429. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24430. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24431. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24432. /** @hidden */
  24433. export var defaultPixelShader: {
  24434. name: string;
  24435. shader: string;
  24436. };
  24437. }
  24438. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24439. /** @hidden */
  24440. export var defaultVertexDeclaration: {
  24441. name: string;
  24442. shader: string;
  24443. };
  24444. }
  24445. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24446. /** @hidden */
  24447. export var prePassVertexDeclaration: {
  24448. name: string;
  24449. shader: string;
  24450. };
  24451. }
  24452. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24453. /** @hidden */
  24454. export var bumpVertexDeclaration: {
  24455. name: string;
  24456. shader: string;
  24457. };
  24458. }
  24459. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24460. /** @hidden */
  24461. export var prePassVertex: {
  24462. name: string;
  24463. shader: string;
  24464. };
  24465. }
  24466. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24467. /** @hidden */
  24468. export var bumpVertex: {
  24469. name: string;
  24470. shader: string;
  24471. };
  24472. }
  24473. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24474. /** @hidden */
  24475. export var fogVertex: {
  24476. name: string;
  24477. shader: string;
  24478. };
  24479. }
  24480. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24481. /** @hidden */
  24482. export var shadowsVertex: {
  24483. name: string;
  24484. shader: string;
  24485. };
  24486. }
  24487. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24488. /** @hidden */
  24489. export var pointCloudVertex: {
  24490. name: string;
  24491. shader: string;
  24492. };
  24493. }
  24494. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24495. /** @hidden */
  24496. export var logDepthVertex: {
  24497. name: string;
  24498. shader: string;
  24499. };
  24500. }
  24501. declare module "babylonjs/Shaders/default.vertex" {
  24502. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24503. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24504. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24505. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24506. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24507. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24508. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24509. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24510. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24511. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24512. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24514. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24515. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24516. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24517. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24518. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24519. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24520. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24521. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24522. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24523. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24524. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24525. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24526. /** @hidden */
  24527. export var defaultVertexShader: {
  24528. name: string;
  24529. shader: string;
  24530. };
  24531. }
  24532. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24533. import { Nullable } from "babylonjs/types";
  24534. import { Scene } from "babylonjs/scene";
  24535. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24536. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24537. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24538. /**
  24539. * @hidden
  24540. */
  24541. export interface IMaterialDetailMapDefines {
  24542. DETAIL: boolean;
  24543. DETAILDIRECTUV: number;
  24544. DETAIL_NORMALBLENDMETHOD: number;
  24545. /** @hidden */
  24546. _areTexturesDirty: boolean;
  24547. }
  24548. /**
  24549. * Define the code related to the detail map parameters of a material
  24550. *
  24551. * Inspired from:
  24552. * 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
  24553. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24554. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24555. */
  24556. export class DetailMapConfiguration {
  24557. private _texture;
  24558. /**
  24559. * The detail texture of the material.
  24560. */
  24561. texture: Nullable<BaseTexture>;
  24562. /**
  24563. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24564. * Bigger values mean stronger blending
  24565. */
  24566. diffuseBlendLevel: number;
  24567. /**
  24568. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24569. * Bigger values mean stronger blending. Only used with PBR materials
  24570. */
  24571. roughnessBlendLevel: number;
  24572. /**
  24573. * Defines how strong the bump effect from the detail map is
  24574. * Bigger values mean stronger effect
  24575. */
  24576. bumpLevel: number;
  24577. private _normalBlendMethod;
  24578. /**
  24579. * The method used to blend the bump and detail normals together
  24580. */
  24581. normalBlendMethod: number;
  24582. private _isEnabled;
  24583. /**
  24584. * Enable or disable the detail map on this material
  24585. */
  24586. isEnabled: boolean;
  24587. /** @hidden */
  24588. private _internalMarkAllSubMeshesAsTexturesDirty;
  24589. /** @hidden */
  24590. _markAllSubMeshesAsTexturesDirty(): void;
  24591. /**
  24592. * Instantiate a new detail map
  24593. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24594. */
  24595. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24596. /**
  24597. * Gets whether the submesh is ready to be used or not.
  24598. * @param defines the list of "defines" to update.
  24599. * @param scene defines the scene the material belongs to.
  24600. * @returns - boolean indicating that the submesh is ready or not.
  24601. */
  24602. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24603. /**
  24604. * Update the defines for detail map usage
  24605. * @param defines the list of "defines" to update.
  24606. * @param scene defines the scene the material belongs to.
  24607. */
  24608. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24609. /**
  24610. * Binds the material data.
  24611. * @param uniformBuffer defines the Uniform buffer to fill in.
  24612. * @param scene defines the scene the material belongs to.
  24613. * @param isFrozen defines whether the material is frozen or not.
  24614. */
  24615. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24616. /**
  24617. * Checks to see if a texture is used in the material.
  24618. * @param texture - Base texture to use.
  24619. * @returns - Boolean specifying if a texture is used in the material.
  24620. */
  24621. hasTexture(texture: BaseTexture): boolean;
  24622. /**
  24623. * Returns an array of the actively used textures.
  24624. * @param activeTextures Array of BaseTextures
  24625. */
  24626. getActiveTextures(activeTextures: BaseTexture[]): void;
  24627. /**
  24628. * Returns the animatable textures.
  24629. * @param animatables Array of animatable textures.
  24630. */
  24631. getAnimatables(animatables: IAnimatable[]): void;
  24632. /**
  24633. * Disposes the resources of the material.
  24634. * @param forceDisposeTextures - Forces the disposal of all textures.
  24635. */
  24636. dispose(forceDisposeTextures?: boolean): void;
  24637. /**
  24638. * Get the current class name useful for serialization or dynamic coding.
  24639. * @returns "DetailMap"
  24640. */
  24641. getClassName(): string;
  24642. /**
  24643. * Add the required uniforms to the current list.
  24644. * @param uniforms defines the current uniform list.
  24645. */
  24646. static AddUniforms(uniforms: string[]): void;
  24647. /**
  24648. * Add the required samplers to the current list.
  24649. * @param samplers defines the current sampler list.
  24650. */
  24651. static AddSamplers(samplers: string[]): void;
  24652. /**
  24653. * Add the required uniforms to the current buffer.
  24654. * @param uniformBuffer defines the current uniform buffer.
  24655. */
  24656. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24657. /**
  24658. * Makes a duplicate of the current instance into another one.
  24659. * @param detailMap define the instance where to copy the info
  24660. */
  24661. copyTo(detailMap: DetailMapConfiguration): void;
  24662. /**
  24663. * Serializes this detail map instance
  24664. * @returns - An object with the serialized instance.
  24665. */
  24666. serialize(): any;
  24667. /**
  24668. * Parses a detail map setting from a serialized object.
  24669. * @param source - Serialized object.
  24670. * @param scene Defines the scene we are parsing for
  24671. * @param rootUrl Defines the rootUrl to load from
  24672. */
  24673. parse(source: any, scene: Scene, rootUrl: string): void;
  24674. }
  24675. }
  24676. declare module "babylonjs/Materials/standardMaterial" {
  24677. import { SmartArray } from "babylonjs/Misc/smartArray";
  24678. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24679. import { Nullable } from "babylonjs/types";
  24680. import { Scene } from "babylonjs/scene";
  24681. import { Matrix } from "babylonjs/Maths/math.vector";
  24682. import { Color3 } from "babylonjs/Maths/math.color";
  24683. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24685. import { Mesh } from "babylonjs/Meshes/mesh";
  24686. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24687. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24688. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24689. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24690. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24691. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24692. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24693. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24694. import "babylonjs/Shaders/default.fragment";
  24695. import "babylonjs/Shaders/default.vertex";
  24696. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24697. /** @hidden */
  24698. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24699. MAINUV1: boolean;
  24700. MAINUV2: boolean;
  24701. DIFFUSE: boolean;
  24702. DIFFUSEDIRECTUV: number;
  24703. DETAIL: boolean;
  24704. DETAILDIRECTUV: number;
  24705. DETAIL_NORMALBLENDMETHOD: number;
  24706. AMBIENT: boolean;
  24707. AMBIENTDIRECTUV: number;
  24708. OPACITY: boolean;
  24709. OPACITYDIRECTUV: number;
  24710. OPACITYRGB: boolean;
  24711. REFLECTION: boolean;
  24712. EMISSIVE: boolean;
  24713. EMISSIVEDIRECTUV: number;
  24714. SPECULAR: boolean;
  24715. SPECULARDIRECTUV: number;
  24716. BUMP: boolean;
  24717. BUMPDIRECTUV: number;
  24718. PARALLAX: boolean;
  24719. PARALLAXOCCLUSION: boolean;
  24720. SPECULAROVERALPHA: boolean;
  24721. CLIPPLANE: boolean;
  24722. CLIPPLANE2: boolean;
  24723. CLIPPLANE3: boolean;
  24724. CLIPPLANE4: boolean;
  24725. CLIPPLANE5: boolean;
  24726. CLIPPLANE6: boolean;
  24727. ALPHATEST: boolean;
  24728. DEPTHPREPASS: boolean;
  24729. ALPHAFROMDIFFUSE: boolean;
  24730. POINTSIZE: boolean;
  24731. FOG: boolean;
  24732. SPECULARTERM: boolean;
  24733. DIFFUSEFRESNEL: boolean;
  24734. OPACITYFRESNEL: boolean;
  24735. REFLECTIONFRESNEL: boolean;
  24736. REFRACTIONFRESNEL: boolean;
  24737. EMISSIVEFRESNEL: boolean;
  24738. FRESNEL: boolean;
  24739. NORMAL: boolean;
  24740. UV1: boolean;
  24741. UV2: boolean;
  24742. VERTEXCOLOR: boolean;
  24743. VERTEXALPHA: boolean;
  24744. NUM_BONE_INFLUENCERS: number;
  24745. BonesPerMesh: number;
  24746. BONETEXTURE: boolean;
  24747. BONES_VELOCITY_ENABLED: boolean;
  24748. INSTANCES: boolean;
  24749. THIN_INSTANCES: boolean;
  24750. GLOSSINESS: boolean;
  24751. ROUGHNESS: boolean;
  24752. EMISSIVEASILLUMINATION: boolean;
  24753. LINKEMISSIVEWITHDIFFUSE: boolean;
  24754. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24755. LIGHTMAP: boolean;
  24756. LIGHTMAPDIRECTUV: number;
  24757. OBJECTSPACE_NORMALMAP: boolean;
  24758. USELIGHTMAPASSHADOWMAP: boolean;
  24759. REFLECTIONMAP_3D: boolean;
  24760. REFLECTIONMAP_SPHERICAL: boolean;
  24761. REFLECTIONMAP_PLANAR: boolean;
  24762. REFLECTIONMAP_CUBIC: boolean;
  24763. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24764. REFLECTIONMAP_PROJECTION: boolean;
  24765. REFLECTIONMAP_SKYBOX: boolean;
  24766. REFLECTIONMAP_EXPLICIT: boolean;
  24767. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24768. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24769. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24770. INVERTCUBICMAP: boolean;
  24771. LOGARITHMICDEPTH: boolean;
  24772. REFRACTION: boolean;
  24773. REFRACTIONMAP_3D: boolean;
  24774. REFLECTIONOVERALPHA: boolean;
  24775. TWOSIDEDLIGHTING: boolean;
  24776. SHADOWFLOAT: boolean;
  24777. MORPHTARGETS: boolean;
  24778. MORPHTARGETS_NORMAL: boolean;
  24779. MORPHTARGETS_TANGENT: boolean;
  24780. MORPHTARGETS_UV: boolean;
  24781. NUM_MORPH_INFLUENCERS: number;
  24782. NONUNIFORMSCALING: boolean;
  24783. PREMULTIPLYALPHA: boolean;
  24784. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24785. ALPHABLEND: boolean;
  24786. PREPASS: boolean;
  24787. PREPASS_IRRADIANCE: boolean;
  24788. PREPASS_IRRADIANCE_INDEX: number;
  24789. PREPASS_ALBEDO: boolean;
  24790. PREPASS_ALBEDO_INDEX: number;
  24791. PREPASS_DEPTHNORMAL: boolean;
  24792. PREPASS_DEPTHNORMAL_INDEX: number;
  24793. PREPASS_POSITION: boolean;
  24794. PREPASS_POSITION_INDEX: number;
  24795. PREPASS_VELOCITY: boolean;
  24796. PREPASS_VELOCITY_INDEX: number;
  24797. PREPASS_REFLECTIVITY: boolean;
  24798. PREPASS_REFLECTIVITY_INDEX: number;
  24799. SCENE_MRT_COUNT: number;
  24800. RGBDLIGHTMAP: boolean;
  24801. RGBDREFLECTION: boolean;
  24802. RGBDREFRACTION: boolean;
  24803. IMAGEPROCESSING: boolean;
  24804. VIGNETTE: boolean;
  24805. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24806. VIGNETTEBLENDMODEOPAQUE: boolean;
  24807. TONEMAPPING: boolean;
  24808. TONEMAPPING_ACES: boolean;
  24809. CONTRAST: boolean;
  24810. COLORCURVES: boolean;
  24811. COLORGRADING: boolean;
  24812. COLORGRADING3D: boolean;
  24813. SAMPLER3DGREENDEPTH: boolean;
  24814. SAMPLER3DBGRMAP: boolean;
  24815. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24816. MULTIVIEW: boolean;
  24817. /**
  24818. * If the reflection texture on this material is in linear color space
  24819. * @hidden
  24820. */
  24821. IS_REFLECTION_LINEAR: boolean;
  24822. /**
  24823. * If the refraction texture on this material is in linear color space
  24824. * @hidden
  24825. */
  24826. IS_REFRACTION_LINEAR: boolean;
  24827. EXPOSURE: boolean;
  24828. constructor();
  24829. setReflectionMode(modeToEnable: string): void;
  24830. }
  24831. /**
  24832. * This is the default material used in Babylon. It is the best trade off between quality
  24833. * and performances.
  24834. * @see https://doc.babylonjs.com/babylon101/materials
  24835. */
  24836. export class StandardMaterial extends PushMaterial {
  24837. private _diffuseTexture;
  24838. /**
  24839. * The basic texture of the material as viewed under a light.
  24840. */
  24841. diffuseTexture: Nullable<BaseTexture>;
  24842. private _ambientTexture;
  24843. /**
  24844. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24845. */
  24846. ambientTexture: Nullable<BaseTexture>;
  24847. private _opacityTexture;
  24848. /**
  24849. * Define the transparency of the material from a texture.
  24850. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24851. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24852. */
  24853. opacityTexture: Nullable<BaseTexture>;
  24854. private _reflectionTexture;
  24855. /**
  24856. * Define the texture used to display the reflection.
  24857. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24858. */
  24859. reflectionTexture: Nullable<BaseTexture>;
  24860. private _emissiveTexture;
  24861. /**
  24862. * Define texture of the material as if self lit.
  24863. * This will be mixed in the final result even in the absence of light.
  24864. */
  24865. emissiveTexture: Nullable<BaseTexture>;
  24866. private _specularTexture;
  24867. /**
  24868. * Define how the color and intensity of the highlight given by the light in the material.
  24869. */
  24870. specularTexture: Nullable<BaseTexture>;
  24871. private _bumpTexture;
  24872. /**
  24873. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24874. * 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.
  24875. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24876. */
  24877. bumpTexture: Nullable<BaseTexture>;
  24878. private _lightmapTexture;
  24879. /**
  24880. * Complex lighting can be computationally expensive to compute at runtime.
  24881. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24882. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24883. */
  24884. lightmapTexture: Nullable<BaseTexture>;
  24885. private _refractionTexture;
  24886. /**
  24887. * Define the texture used to display the refraction.
  24888. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24889. */
  24890. refractionTexture: Nullable<BaseTexture>;
  24891. /**
  24892. * The color of the material lit by the environmental background lighting.
  24893. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24894. */
  24895. ambientColor: Color3;
  24896. /**
  24897. * The basic color of the material as viewed under a light.
  24898. */
  24899. diffuseColor: Color3;
  24900. /**
  24901. * Define how the color and intensity of the highlight given by the light in the material.
  24902. */
  24903. specularColor: Color3;
  24904. /**
  24905. * Define the color of the material as if self lit.
  24906. * This will be mixed in the final result even in the absence of light.
  24907. */
  24908. emissiveColor: Color3;
  24909. /**
  24910. * Defines how sharp are the highlights in the material.
  24911. * The bigger the value the sharper giving a more glossy feeling to the result.
  24912. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24913. */
  24914. specularPower: number;
  24915. private _useAlphaFromDiffuseTexture;
  24916. /**
  24917. * Does the transparency come from the diffuse texture alpha channel.
  24918. */
  24919. useAlphaFromDiffuseTexture: boolean;
  24920. private _useEmissiveAsIllumination;
  24921. /**
  24922. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24923. */
  24924. useEmissiveAsIllumination: boolean;
  24925. private _linkEmissiveWithDiffuse;
  24926. /**
  24927. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24928. * the emissive level when the final color is close to one.
  24929. */
  24930. linkEmissiveWithDiffuse: boolean;
  24931. private _useSpecularOverAlpha;
  24932. /**
  24933. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24934. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24935. */
  24936. useSpecularOverAlpha: boolean;
  24937. private _useReflectionOverAlpha;
  24938. /**
  24939. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24940. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24941. */
  24942. useReflectionOverAlpha: boolean;
  24943. private _disableLighting;
  24944. /**
  24945. * Does lights from the scene impacts this material.
  24946. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24947. */
  24948. disableLighting: boolean;
  24949. private _useObjectSpaceNormalMap;
  24950. /**
  24951. * Allows using an object space normal map (instead of tangent space).
  24952. */
  24953. useObjectSpaceNormalMap: boolean;
  24954. private _useParallax;
  24955. /**
  24956. * Is parallax enabled or not.
  24957. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24958. */
  24959. useParallax: boolean;
  24960. private _useParallaxOcclusion;
  24961. /**
  24962. * Is parallax occlusion enabled or not.
  24963. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24964. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24965. */
  24966. useParallaxOcclusion: boolean;
  24967. /**
  24968. * 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.
  24969. */
  24970. parallaxScaleBias: number;
  24971. private _roughness;
  24972. /**
  24973. * Helps to define how blurry the reflections should appears in the material.
  24974. */
  24975. roughness: number;
  24976. /**
  24977. * In case of refraction, define the value of the index of refraction.
  24978. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24979. */
  24980. indexOfRefraction: number;
  24981. /**
  24982. * Invert the refraction texture alongside the y axis.
  24983. * It can be useful with procedural textures or probe for instance.
  24984. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24985. */
  24986. invertRefractionY: boolean;
  24987. /**
  24988. * Defines the alpha limits in alpha test mode.
  24989. */
  24990. alphaCutOff: number;
  24991. private _useLightmapAsShadowmap;
  24992. /**
  24993. * In case of light mapping, define whether the map contains light or shadow informations.
  24994. */
  24995. useLightmapAsShadowmap: boolean;
  24996. private _diffuseFresnelParameters;
  24997. /**
  24998. * Define the diffuse fresnel parameters of the material.
  24999. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25000. */
  25001. diffuseFresnelParameters: FresnelParameters;
  25002. private _opacityFresnelParameters;
  25003. /**
  25004. * Define the opacity fresnel parameters of the material.
  25005. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25006. */
  25007. opacityFresnelParameters: FresnelParameters;
  25008. private _reflectionFresnelParameters;
  25009. /**
  25010. * Define the reflection fresnel parameters of the material.
  25011. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25012. */
  25013. reflectionFresnelParameters: FresnelParameters;
  25014. private _refractionFresnelParameters;
  25015. /**
  25016. * Define the refraction fresnel parameters of the material.
  25017. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25018. */
  25019. refractionFresnelParameters: FresnelParameters;
  25020. private _emissiveFresnelParameters;
  25021. /**
  25022. * Define the emissive fresnel parameters of the material.
  25023. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25024. */
  25025. emissiveFresnelParameters: FresnelParameters;
  25026. private _useReflectionFresnelFromSpecular;
  25027. /**
  25028. * If true automatically deducts the fresnels values from the material specularity.
  25029. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25030. */
  25031. useReflectionFresnelFromSpecular: boolean;
  25032. private _useGlossinessFromSpecularMapAlpha;
  25033. /**
  25034. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25035. */
  25036. useGlossinessFromSpecularMapAlpha: boolean;
  25037. private _maxSimultaneousLights;
  25038. /**
  25039. * Defines the maximum number of lights that can be used in the material
  25040. */
  25041. maxSimultaneousLights: number;
  25042. private _invertNormalMapX;
  25043. /**
  25044. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25045. */
  25046. invertNormalMapX: boolean;
  25047. private _invertNormalMapY;
  25048. /**
  25049. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25050. */
  25051. invertNormalMapY: boolean;
  25052. private _twoSidedLighting;
  25053. /**
  25054. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25055. */
  25056. twoSidedLighting: boolean;
  25057. /**
  25058. * Default configuration related to image processing available in the standard Material.
  25059. */
  25060. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25061. /**
  25062. * Gets the image processing configuration used either in this material.
  25063. */
  25064. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25065. /**
  25066. * Sets the Default image processing configuration used either in the this material.
  25067. *
  25068. * If sets to null, the scene one is in use.
  25069. */
  25070. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25071. /**
  25072. * Keep track of the image processing observer to allow dispose and replace.
  25073. */
  25074. private _imageProcessingObserver;
  25075. /**
  25076. * Attaches a new image processing configuration to the Standard Material.
  25077. * @param configuration
  25078. */
  25079. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25080. /**
  25081. * Defines additionnal PrePass parameters for the material.
  25082. */
  25083. readonly prePassConfiguration: PrePassConfiguration;
  25084. /**
  25085. * Gets wether the color curves effect is enabled.
  25086. */
  25087. get cameraColorCurvesEnabled(): boolean;
  25088. /**
  25089. * Sets wether the color curves effect is enabled.
  25090. */
  25091. set cameraColorCurvesEnabled(value: boolean);
  25092. /**
  25093. * Gets wether the color grading effect is enabled.
  25094. */
  25095. get cameraColorGradingEnabled(): boolean;
  25096. /**
  25097. * Gets wether the color grading effect is enabled.
  25098. */
  25099. set cameraColorGradingEnabled(value: boolean);
  25100. /**
  25101. * Gets wether tonemapping is enabled or not.
  25102. */
  25103. get cameraToneMappingEnabled(): boolean;
  25104. /**
  25105. * Sets wether tonemapping is enabled or not
  25106. */
  25107. set cameraToneMappingEnabled(value: boolean);
  25108. /**
  25109. * The camera exposure used on this material.
  25110. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25111. * This corresponds to a photographic exposure.
  25112. */
  25113. get cameraExposure(): number;
  25114. /**
  25115. * The camera exposure used on this material.
  25116. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25117. * This corresponds to a photographic exposure.
  25118. */
  25119. set cameraExposure(value: number);
  25120. /**
  25121. * Gets The camera contrast used on this material.
  25122. */
  25123. get cameraContrast(): number;
  25124. /**
  25125. * Sets The camera contrast used on this material.
  25126. */
  25127. set cameraContrast(value: number);
  25128. /**
  25129. * Gets the Color Grading 2D Lookup Texture.
  25130. */
  25131. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25132. /**
  25133. * Sets the Color Grading 2D Lookup Texture.
  25134. */
  25135. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25136. /**
  25137. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25138. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25139. * 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;
  25140. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25141. */
  25142. get cameraColorCurves(): Nullable<ColorCurves>;
  25143. /**
  25144. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25145. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25146. * 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;
  25147. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25148. */
  25149. set cameraColorCurves(value: Nullable<ColorCurves>);
  25150. /**
  25151. * Can this material render to several textures at once
  25152. */
  25153. get canRenderToMRT(): boolean;
  25154. /**
  25155. * Defines the detail map parameters for the material.
  25156. */
  25157. readonly detailMap: DetailMapConfiguration;
  25158. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25159. protected _worldViewProjectionMatrix: Matrix;
  25160. protected _globalAmbientColor: Color3;
  25161. protected _useLogarithmicDepth: boolean;
  25162. protected _rebuildInParallel: boolean;
  25163. /**
  25164. * Instantiates a new standard material.
  25165. * This is the default material used in Babylon. It is the best trade off between quality
  25166. * and performances.
  25167. * @see https://doc.babylonjs.com/babylon101/materials
  25168. * @param name Define the name of the material in the scene
  25169. * @param scene Define the scene the material belong to
  25170. */
  25171. constructor(name: string, scene: Scene);
  25172. /**
  25173. * Gets a boolean indicating that current material needs to register RTT
  25174. */
  25175. get hasRenderTargetTextures(): boolean;
  25176. /**
  25177. * Gets the current class name of the material e.g. "StandardMaterial"
  25178. * Mainly use in serialization.
  25179. * @returns the class name
  25180. */
  25181. getClassName(): string;
  25182. /**
  25183. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25184. * You can try switching to logarithmic depth.
  25185. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25186. */
  25187. get useLogarithmicDepth(): boolean;
  25188. set useLogarithmicDepth(value: boolean);
  25189. /**
  25190. * Specifies if the material will require alpha blending
  25191. * @returns a boolean specifying if alpha blending is needed
  25192. */
  25193. needAlphaBlending(): boolean;
  25194. /**
  25195. * Specifies if this material should be rendered in alpha test mode
  25196. * @returns a boolean specifying if an alpha test is needed.
  25197. */
  25198. needAlphaTesting(): boolean;
  25199. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25200. /**
  25201. * Get the texture used for alpha test purpose.
  25202. * @returns the diffuse texture in case of the standard material.
  25203. */
  25204. getAlphaTestTexture(): Nullable<BaseTexture>;
  25205. /**
  25206. * Get if the submesh is ready to be used and all its information available.
  25207. * Child classes can use it to update shaders
  25208. * @param mesh defines the mesh to check
  25209. * @param subMesh defines which submesh to check
  25210. * @param useInstances specifies that instances should be used
  25211. * @returns a boolean indicating that the submesh is ready or not
  25212. */
  25213. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25214. /**
  25215. * Builds the material UBO layouts.
  25216. * Used internally during the effect preparation.
  25217. */
  25218. buildUniformLayout(): void;
  25219. /**
  25220. * Unbinds the material from the mesh
  25221. */
  25222. unbind(): void;
  25223. /**
  25224. * Binds the submesh to this material by preparing the effect and shader to draw
  25225. * @param world defines the world transformation matrix
  25226. * @param mesh defines the mesh containing the submesh
  25227. * @param subMesh defines the submesh to bind the material to
  25228. */
  25229. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25230. /**
  25231. * Get the list of animatables in the material.
  25232. * @returns the list of animatables object used in the material
  25233. */
  25234. getAnimatables(): IAnimatable[];
  25235. /**
  25236. * Gets the active textures from the material
  25237. * @returns an array of textures
  25238. */
  25239. getActiveTextures(): BaseTexture[];
  25240. /**
  25241. * Specifies if the material uses a texture
  25242. * @param texture defines the texture to check against the material
  25243. * @returns a boolean specifying if the material uses the texture
  25244. */
  25245. hasTexture(texture: BaseTexture): boolean;
  25246. /**
  25247. * Disposes the material
  25248. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25249. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25250. */
  25251. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25252. /**
  25253. * Makes a duplicate of the material, and gives it a new name
  25254. * @param name defines the new name for the duplicated material
  25255. * @returns the cloned material
  25256. */
  25257. clone(name: string): StandardMaterial;
  25258. /**
  25259. * Serializes this material in a JSON representation
  25260. * @returns the serialized material object
  25261. */
  25262. serialize(): any;
  25263. /**
  25264. * Creates a standard material from parsed material data
  25265. * @param source defines the JSON representation of the material
  25266. * @param scene defines the hosting scene
  25267. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25268. * @returns a new standard material
  25269. */
  25270. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25271. /**
  25272. * Are diffuse textures enabled in the application.
  25273. */
  25274. static get DiffuseTextureEnabled(): boolean;
  25275. static set DiffuseTextureEnabled(value: boolean);
  25276. /**
  25277. * Are detail textures enabled in the application.
  25278. */
  25279. static get DetailTextureEnabled(): boolean;
  25280. static set DetailTextureEnabled(value: boolean);
  25281. /**
  25282. * Are ambient textures enabled in the application.
  25283. */
  25284. static get AmbientTextureEnabled(): boolean;
  25285. static set AmbientTextureEnabled(value: boolean);
  25286. /**
  25287. * Are opacity textures enabled in the application.
  25288. */
  25289. static get OpacityTextureEnabled(): boolean;
  25290. static set OpacityTextureEnabled(value: boolean);
  25291. /**
  25292. * Are reflection textures enabled in the application.
  25293. */
  25294. static get ReflectionTextureEnabled(): boolean;
  25295. static set ReflectionTextureEnabled(value: boolean);
  25296. /**
  25297. * Are emissive textures enabled in the application.
  25298. */
  25299. static get EmissiveTextureEnabled(): boolean;
  25300. static set EmissiveTextureEnabled(value: boolean);
  25301. /**
  25302. * Are specular textures enabled in the application.
  25303. */
  25304. static get SpecularTextureEnabled(): boolean;
  25305. static set SpecularTextureEnabled(value: boolean);
  25306. /**
  25307. * Are bump textures enabled in the application.
  25308. */
  25309. static get BumpTextureEnabled(): boolean;
  25310. static set BumpTextureEnabled(value: boolean);
  25311. /**
  25312. * Are lightmap textures enabled in the application.
  25313. */
  25314. static get LightmapTextureEnabled(): boolean;
  25315. static set LightmapTextureEnabled(value: boolean);
  25316. /**
  25317. * Are refraction textures enabled in the application.
  25318. */
  25319. static get RefractionTextureEnabled(): boolean;
  25320. static set RefractionTextureEnabled(value: boolean);
  25321. /**
  25322. * Are color grading textures enabled in the application.
  25323. */
  25324. static get ColorGradingTextureEnabled(): boolean;
  25325. static set ColorGradingTextureEnabled(value: boolean);
  25326. /**
  25327. * Are fresnels enabled in the application.
  25328. */
  25329. static get FresnelEnabled(): boolean;
  25330. static set FresnelEnabled(value: boolean);
  25331. }
  25332. }
  25333. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25334. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25335. /** @hidden */
  25336. export var rgbdDecodePixelShader: {
  25337. name: string;
  25338. shader: string;
  25339. };
  25340. }
  25341. declare module "babylonjs/Misc/rgbdTextureTools" {
  25342. import "babylonjs/Shaders/rgbdDecode.fragment";
  25343. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25344. import { Texture } from "babylonjs/Materials/Textures/texture";
  25345. /**
  25346. * Class used to host RGBD texture specific utilities
  25347. */
  25348. export class RGBDTextureTools {
  25349. /**
  25350. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25351. * @param texture the texture to expand.
  25352. */
  25353. static ExpandRGBDTexture(texture: Texture): void;
  25354. }
  25355. }
  25356. declare module "babylonjs/Misc/brdfTextureTools" {
  25357. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25358. import { Scene } from "babylonjs/scene";
  25359. /**
  25360. * Class used to host texture specific utilities
  25361. */
  25362. export class BRDFTextureTools {
  25363. /**
  25364. * Prevents texture cache collision
  25365. */
  25366. private static _instanceNumber;
  25367. /**
  25368. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25369. * @param scene defines the hosting scene
  25370. * @returns the environment BRDF texture
  25371. */
  25372. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25373. private static _environmentBRDFBase64Texture;
  25374. }
  25375. }
  25376. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25377. import { Nullable } from "babylonjs/types";
  25378. import { Color3 } from "babylonjs/Maths/math.color";
  25379. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25380. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25381. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25382. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25384. import { Engine } from "babylonjs/Engines/engine";
  25385. import { Scene } from "babylonjs/scene";
  25386. /**
  25387. * @hidden
  25388. */
  25389. export interface IMaterialClearCoatDefines {
  25390. CLEARCOAT: boolean;
  25391. CLEARCOAT_DEFAULTIOR: boolean;
  25392. CLEARCOAT_TEXTURE: boolean;
  25393. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  25394. CLEARCOAT_TEXTUREDIRECTUV: number;
  25395. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  25396. CLEARCOAT_BUMP: boolean;
  25397. CLEARCOAT_BUMPDIRECTUV: number;
  25398. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25399. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25400. CLEARCOAT_REMAP_F0: boolean;
  25401. CLEARCOAT_TINT: boolean;
  25402. CLEARCOAT_TINT_TEXTURE: boolean;
  25403. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25404. /** @hidden */
  25405. _areTexturesDirty: boolean;
  25406. }
  25407. /**
  25408. * Define the code related to the clear coat parameters of the pbr material.
  25409. */
  25410. export class PBRClearCoatConfiguration {
  25411. /**
  25412. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25413. * The default fits with a polyurethane material.
  25414. */
  25415. private static readonly _DefaultIndexOfRefraction;
  25416. private _isEnabled;
  25417. /**
  25418. * Defines if the clear coat is enabled in the material.
  25419. */
  25420. isEnabled: boolean;
  25421. /**
  25422. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25423. */
  25424. intensity: number;
  25425. /**
  25426. * Defines the clear coat layer roughness.
  25427. */
  25428. roughness: number;
  25429. private _indexOfRefraction;
  25430. /**
  25431. * Defines the index of refraction of the clear coat.
  25432. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25433. * The default fits with a polyurethane material.
  25434. * Changing the default value is more performance intensive.
  25435. */
  25436. indexOfRefraction: number;
  25437. private _texture;
  25438. /**
  25439. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  25440. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  25441. * if textureRoughness is not empty, else no texture roughness is used
  25442. */
  25443. texture: Nullable<BaseTexture>;
  25444. private _useRoughnessFromMainTexture;
  25445. /**
  25446. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  25447. * If false, the green channel from textureRoughness is used for roughness
  25448. */
  25449. useRoughnessFromMainTexture: boolean;
  25450. private _textureRoughness;
  25451. /**
  25452. * Stores the clear coat roughness in a texture (green channel)
  25453. * Not used if useRoughnessFromMainTexture is true
  25454. */
  25455. textureRoughness: Nullable<BaseTexture>;
  25456. private _remapF0OnInterfaceChange;
  25457. /**
  25458. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25459. */
  25460. remapF0OnInterfaceChange: boolean;
  25461. private _bumpTexture;
  25462. /**
  25463. * Define the clear coat specific bump texture.
  25464. */
  25465. bumpTexture: Nullable<BaseTexture>;
  25466. private _isTintEnabled;
  25467. /**
  25468. * Defines if the clear coat tint is enabled in the material.
  25469. */
  25470. isTintEnabled: boolean;
  25471. /**
  25472. * Defines the clear coat tint of the material.
  25473. * This is only use if tint is enabled
  25474. */
  25475. tintColor: Color3;
  25476. /**
  25477. * Defines the distance at which the tint color should be found in the
  25478. * clear coat media.
  25479. * This is only use if tint is enabled
  25480. */
  25481. tintColorAtDistance: number;
  25482. /**
  25483. * Defines the clear coat layer thickness.
  25484. * This is only use if tint is enabled
  25485. */
  25486. tintThickness: number;
  25487. private _tintTexture;
  25488. /**
  25489. * Stores the clear tint values in a texture.
  25490. * rgb is tint
  25491. * a is a thickness factor
  25492. */
  25493. tintTexture: Nullable<BaseTexture>;
  25494. /** @hidden */
  25495. private _internalMarkAllSubMeshesAsTexturesDirty;
  25496. /** @hidden */
  25497. _markAllSubMeshesAsTexturesDirty(): void;
  25498. /**
  25499. * Instantiate a new istance of clear coat configuration.
  25500. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25501. */
  25502. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25503. /**
  25504. * Gets wehter the submesh is ready to be used or not.
  25505. * @param defines the list of "defines" to update.
  25506. * @param scene defines the scene the material belongs to.
  25507. * @param engine defines the engine the material belongs to.
  25508. * @param disableBumpMap defines wether the material disables bump or not.
  25509. * @returns - boolean indicating that the submesh is ready or not.
  25510. */
  25511. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25512. /**
  25513. * Checks to see if a texture is used in the material.
  25514. * @param defines the list of "defines" to update.
  25515. * @param scene defines the scene to the material belongs to.
  25516. */
  25517. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25518. /**
  25519. * Binds the material data.
  25520. * @param uniformBuffer defines the Uniform buffer to fill in.
  25521. * @param scene defines the scene the material belongs to.
  25522. * @param engine defines the engine the material belongs to.
  25523. * @param disableBumpMap defines wether the material disables bump or not.
  25524. * @param isFrozen defines wether the material is frozen or not.
  25525. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25526. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25527. * @param subMesh the submesh to bind data for
  25528. */
  25529. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  25530. /**
  25531. * Checks to see if a texture is used in the material.
  25532. * @param texture - Base texture to use.
  25533. * @returns - Boolean specifying if a texture is used in the material.
  25534. */
  25535. hasTexture(texture: BaseTexture): boolean;
  25536. /**
  25537. * Returns an array of the actively used textures.
  25538. * @param activeTextures Array of BaseTextures
  25539. */
  25540. getActiveTextures(activeTextures: BaseTexture[]): void;
  25541. /**
  25542. * Returns the animatable textures.
  25543. * @param animatables Array of animatable textures.
  25544. */
  25545. getAnimatables(animatables: IAnimatable[]): void;
  25546. /**
  25547. * Disposes the resources of the material.
  25548. * @param forceDisposeTextures - Forces the disposal of all textures.
  25549. */
  25550. dispose(forceDisposeTextures?: boolean): void;
  25551. /**
  25552. * Get the current class name of the texture useful for serialization or dynamic coding.
  25553. * @returns "PBRClearCoatConfiguration"
  25554. */
  25555. getClassName(): string;
  25556. /**
  25557. * Add fallbacks to the effect fallbacks list.
  25558. * @param defines defines the Base texture to use.
  25559. * @param fallbacks defines the current fallback list.
  25560. * @param currentRank defines the current fallback rank.
  25561. * @returns the new fallback rank.
  25562. */
  25563. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25564. /**
  25565. * Add the required uniforms to the current list.
  25566. * @param uniforms defines the current uniform list.
  25567. */
  25568. static AddUniforms(uniforms: string[]): void;
  25569. /**
  25570. * Add the required samplers to the current list.
  25571. * @param samplers defines the current sampler list.
  25572. */
  25573. static AddSamplers(samplers: string[]): void;
  25574. /**
  25575. * Add the required uniforms to the current buffer.
  25576. * @param uniformBuffer defines the current uniform buffer.
  25577. */
  25578. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25579. /**
  25580. * Makes a duplicate of the current configuration into another one.
  25581. * @param clearCoatConfiguration define the config where to copy the info
  25582. */
  25583. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25584. /**
  25585. * Serializes this clear coat configuration.
  25586. * @returns - An object with the serialized config.
  25587. */
  25588. serialize(): any;
  25589. /**
  25590. * Parses a anisotropy Configuration from a serialized object.
  25591. * @param source - Serialized object.
  25592. * @param scene Defines the scene we are parsing for
  25593. * @param rootUrl Defines the rootUrl to load from
  25594. */
  25595. parse(source: any, scene: Scene, rootUrl: string): void;
  25596. }
  25597. }
  25598. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25599. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25601. import { Vector2 } from "babylonjs/Maths/math.vector";
  25602. import { Scene } from "babylonjs/scene";
  25603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25604. import { Nullable } from "babylonjs/types";
  25605. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25606. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25607. /**
  25608. * @hidden
  25609. */
  25610. export interface IMaterialAnisotropicDefines {
  25611. ANISOTROPIC: boolean;
  25612. ANISOTROPIC_TEXTURE: boolean;
  25613. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25614. MAINUV1: boolean;
  25615. _areTexturesDirty: boolean;
  25616. _needUVs: boolean;
  25617. }
  25618. /**
  25619. * Define the code related to the anisotropic parameters of the pbr material.
  25620. */
  25621. export class PBRAnisotropicConfiguration {
  25622. private _isEnabled;
  25623. /**
  25624. * Defines if the anisotropy is enabled in the material.
  25625. */
  25626. isEnabled: boolean;
  25627. /**
  25628. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25629. */
  25630. intensity: number;
  25631. /**
  25632. * Defines if the effect is along the tangents, bitangents or in between.
  25633. * By default, the effect is "strectching" the highlights along the tangents.
  25634. */
  25635. direction: Vector2;
  25636. private _texture;
  25637. /**
  25638. * Stores the anisotropy values in a texture.
  25639. * rg is direction (like normal from -1 to 1)
  25640. * b is a intensity
  25641. */
  25642. texture: Nullable<BaseTexture>;
  25643. /** @hidden */
  25644. private _internalMarkAllSubMeshesAsTexturesDirty;
  25645. /** @hidden */
  25646. _markAllSubMeshesAsTexturesDirty(): void;
  25647. /**
  25648. * Instantiate a new istance of anisotropy configuration.
  25649. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25650. */
  25651. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25652. /**
  25653. * Specifies that the submesh is ready to be used.
  25654. * @param defines the list of "defines" to update.
  25655. * @param scene defines the scene the material belongs to.
  25656. * @returns - boolean indicating that the submesh is ready or not.
  25657. */
  25658. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25659. /**
  25660. * Checks to see if a texture is used in the material.
  25661. * @param defines the list of "defines" to update.
  25662. * @param mesh the mesh we are preparing the defines for.
  25663. * @param scene defines the scene the material belongs to.
  25664. */
  25665. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25666. /**
  25667. * Binds the material data.
  25668. * @param uniformBuffer defines the Uniform buffer to fill in.
  25669. * @param scene defines the scene the material belongs to.
  25670. * @param isFrozen defines wether the material is frozen or not.
  25671. */
  25672. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25673. /**
  25674. * Checks to see if a texture is used in the material.
  25675. * @param texture - Base texture to use.
  25676. * @returns - Boolean specifying if a texture is used in the material.
  25677. */
  25678. hasTexture(texture: BaseTexture): boolean;
  25679. /**
  25680. * Returns an array of the actively used textures.
  25681. * @param activeTextures Array of BaseTextures
  25682. */
  25683. getActiveTextures(activeTextures: BaseTexture[]): void;
  25684. /**
  25685. * Returns the animatable textures.
  25686. * @param animatables Array of animatable textures.
  25687. */
  25688. getAnimatables(animatables: IAnimatable[]): void;
  25689. /**
  25690. * Disposes the resources of the material.
  25691. * @param forceDisposeTextures - Forces the disposal of all textures.
  25692. */
  25693. dispose(forceDisposeTextures?: boolean): void;
  25694. /**
  25695. * Get the current class name of the texture useful for serialization or dynamic coding.
  25696. * @returns "PBRAnisotropicConfiguration"
  25697. */
  25698. getClassName(): string;
  25699. /**
  25700. * Add fallbacks to the effect fallbacks list.
  25701. * @param defines defines the Base texture to use.
  25702. * @param fallbacks defines the current fallback list.
  25703. * @param currentRank defines the current fallback rank.
  25704. * @returns the new fallback rank.
  25705. */
  25706. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25707. /**
  25708. * Add the required uniforms to the current list.
  25709. * @param uniforms defines the current uniform list.
  25710. */
  25711. static AddUniforms(uniforms: string[]): void;
  25712. /**
  25713. * Add the required uniforms to the current buffer.
  25714. * @param uniformBuffer defines the current uniform buffer.
  25715. */
  25716. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25717. /**
  25718. * Add the required samplers to the current list.
  25719. * @param samplers defines the current sampler list.
  25720. */
  25721. static AddSamplers(samplers: string[]): void;
  25722. /**
  25723. * Makes a duplicate of the current configuration into another one.
  25724. * @param anisotropicConfiguration define the config where to copy the info
  25725. */
  25726. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25727. /**
  25728. * Serializes this anisotropy configuration.
  25729. * @returns - An object with the serialized config.
  25730. */
  25731. serialize(): any;
  25732. /**
  25733. * Parses a anisotropy Configuration from a serialized object.
  25734. * @param source - Serialized object.
  25735. * @param scene Defines the scene we are parsing for
  25736. * @param rootUrl Defines the rootUrl to load from
  25737. */
  25738. parse(source: any, scene: Scene, rootUrl: string): void;
  25739. }
  25740. }
  25741. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  25742. import { Scene } from "babylonjs/scene";
  25743. /**
  25744. * @hidden
  25745. */
  25746. export interface IMaterialBRDFDefines {
  25747. BRDF_V_HEIGHT_CORRELATED: boolean;
  25748. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25749. SPHERICAL_HARMONICS: boolean;
  25750. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25751. /** @hidden */
  25752. _areMiscDirty: boolean;
  25753. }
  25754. /**
  25755. * Define the code related to the BRDF parameters of the pbr material.
  25756. */
  25757. export class PBRBRDFConfiguration {
  25758. /**
  25759. * Default value used for the energy conservation.
  25760. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25761. */
  25762. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25763. /**
  25764. * Default value used for the Smith Visibility Height Correlated mode.
  25765. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25766. */
  25767. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25768. /**
  25769. * Default value used for the IBL diffuse part.
  25770. * This can help switching back to the polynomials mode globally which is a tiny bit
  25771. * less GPU intensive at the drawback of a lower quality.
  25772. */
  25773. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25774. /**
  25775. * Default value used for activating energy conservation for the specular workflow.
  25776. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25777. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25778. */
  25779. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25780. private _useEnergyConservation;
  25781. /**
  25782. * Defines if the material uses energy conservation.
  25783. */
  25784. useEnergyConservation: boolean;
  25785. private _useSmithVisibilityHeightCorrelated;
  25786. /**
  25787. * LEGACY Mode set to false
  25788. * Defines if the material uses height smith correlated visibility term.
  25789. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25790. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25791. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25792. * Not relying on height correlated will also disable energy conservation.
  25793. */
  25794. useSmithVisibilityHeightCorrelated: boolean;
  25795. private _useSphericalHarmonics;
  25796. /**
  25797. * LEGACY Mode set to false
  25798. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25799. * diffuse part of the IBL.
  25800. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25801. * to the ground truth.
  25802. */
  25803. useSphericalHarmonics: boolean;
  25804. private _useSpecularGlossinessInputEnergyConservation;
  25805. /**
  25806. * Defines if the material uses energy conservation, when the specular workflow is active.
  25807. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25808. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25809. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25810. */
  25811. useSpecularGlossinessInputEnergyConservation: boolean;
  25812. /** @hidden */
  25813. private _internalMarkAllSubMeshesAsMiscDirty;
  25814. /** @hidden */
  25815. _markAllSubMeshesAsMiscDirty(): void;
  25816. /**
  25817. * Instantiate a new istance of clear coat configuration.
  25818. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25819. */
  25820. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25821. /**
  25822. * Checks to see if a texture is used in the material.
  25823. * @param defines the list of "defines" to update.
  25824. */
  25825. prepareDefines(defines: IMaterialBRDFDefines): void;
  25826. /**
  25827. * Get the current class name of the texture useful for serialization or dynamic coding.
  25828. * @returns "PBRClearCoatConfiguration"
  25829. */
  25830. getClassName(): string;
  25831. /**
  25832. * Makes a duplicate of the current configuration into another one.
  25833. * @param brdfConfiguration define the config where to copy the info
  25834. */
  25835. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25836. /**
  25837. * Serializes this BRDF configuration.
  25838. * @returns - An object with the serialized config.
  25839. */
  25840. serialize(): any;
  25841. /**
  25842. * Parses a anisotropy Configuration from a serialized object.
  25843. * @param source - Serialized object.
  25844. * @param scene Defines the scene we are parsing for
  25845. * @param rootUrl Defines the rootUrl to load from
  25846. */
  25847. parse(source: any, scene: Scene, rootUrl: string): void;
  25848. }
  25849. }
  25850. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  25851. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25852. import { Color3 } from "babylonjs/Maths/math.color";
  25853. import { Scene } from "babylonjs/scene";
  25854. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25855. import { Nullable } from "babylonjs/types";
  25856. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25857. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25858. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25859. /**
  25860. * @hidden
  25861. */
  25862. export interface IMaterialSheenDefines {
  25863. SHEEN: boolean;
  25864. SHEEN_TEXTURE: boolean;
  25865. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25866. SHEEN_TEXTUREDIRECTUV: number;
  25867. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25868. SHEEN_LINKWITHALBEDO: boolean;
  25869. SHEEN_ROUGHNESS: boolean;
  25870. SHEEN_ALBEDOSCALING: boolean;
  25871. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25872. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25873. /** @hidden */
  25874. _areTexturesDirty: boolean;
  25875. }
  25876. /**
  25877. * Define the code related to the Sheen parameters of the pbr material.
  25878. */
  25879. export class PBRSheenConfiguration {
  25880. private _isEnabled;
  25881. /**
  25882. * Defines if the material uses sheen.
  25883. */
  25884. isEnabled: boolean;
  25885. private _linkSheenWithAlbedo;
  25886. /**
  25887. * Defines if the sheen is linked to the sheen color.
  25888. */
  25889. linkSheenWithAlbedo: boolean;
  25890. /**
  25891. * Defines the sheen intensity.
  25892. */
  25893. intensity: number;
  25894. /**
  25895. * Defines the sheen color.
  25896. */
  25897. color: Color3;
  25898. private _texture;
  25899. /**
  25900. * Stores the sheen tint values in a texture.
  25901. * rgb is tint
  25902. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  25903. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25904. */
  25905. texture: Nullable<BaseTexture>;
  25906. private _useRoughnessFromMainTexture;
  25907. /**
  25908. * Indicates that the alpha channel of the texture property will be used for roughness.
  25909. * Has no effect if the roughness (and texture!) property is not defined
  25910. */
  25911. useRoughnessFromMainTexture: boolean;
  25912. private _roughness;
  25913. /**
  25914. * Defines the sheen roughness.
  25915. * It is not taken into account if linkSheenWithAlbedo is true.
  25916. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25917. */
  25918. roughness: Nullable<number>;
  25919. private _textureRoughness;
  25920. /**
  25921. * Stores the sheen roughness in a texture.
  25922. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25923. */
  25924. textureRoughness: Nullable<BaseTexture>;
  25925. private _albedoScaling;
  25926. /**
  25927. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25928. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25929. * making it easier to setup and tweak the effect
  25930. */
  25931. albedoScaling: boolean;
  25932. /** @hidden */
  25933. private _internalMarkAllSubMeshesAsTexturesDirty;
  25934. /** @hidden */
  25935. _markAllSubMeshesAsTexturesDirty(): void;
  25936. /**
  25937. * Instantiate a new istance of clear coat configuration.
  25938. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25939. */
  25940. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25941. /**
  25942. * Specifies that the submesh is ready to be used.
  25943. * @param defines the list of "defines" to update.
  25944. * @param scene defines the scene the material belongs to.
  25945. * @returns - boolean indicating that the submesh is ready or not.
  25946. */
  25947. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25948. /**
  25949. * Checks to see if a texture is used in the material.
  25950. * @param defines the list of "defines" to update.
  25951. * @param scene defines the scene the material belongs to.
  25952. */
  25953. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25954. /**
  25955. * Binds the material data.
  25956. * @param uniformBuffer defines the Uniform buffer to fill in.
  25957. * @param scene defines the scene the material belongs to.
  25958. * @param isFrozen defines wether the material is frozen or not.
  25959. * @param subMesh the submesh to bind data for
  25960. */
  25961. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25962. /**
  25963. * Checks to see if a texture is used in the material.
  25964. * @param texture - Base texture to use.
  25965. * @returns - Boolean specifying if a texture is used in the material.
  25966. */
  25967. hasTexture(texture: BaseTexture): boolean;
  25968. /**
  25969. * Returns an array of the actively used textures.
  25970. * @param activeTextures Array of BaseTextures
  25971. */
  25972. getActiveTextures(activeTextures: BaseTexture[]): void;
  25973. /**
  25974. * Returns the animatable textures.
  25975. * @param animatables Array of animatable textures.
  25976. */
  25977. getAnimatables(animatables: IAnimatable[]): void;
  25978. /**
  25979. * Disposes the resources of the material.
  25980. * @param forceDisposeTextures - Forces the disposal of all textures.
  25981. */
  25982. dispose(forceDisposeTextures?: boolean): void;
  25983. /**
  25984. * Get the current class name of the texture useful for serialization or dynamic coding.
  25985. * @returns "PBRSheenConfiguration"
  25986. */
  25987. getClassName(): string;
  25988. /**
  25989. * Add fallbacks to the effect fallbacks list.
  25990. * @param defines defines the Base texture to use.
  25991. * @param fallbacks defines the current fallback list.
  25992. * @param currentRank defines the current fallback rank.
  25993. * @returns the new fallback rank.
  25994. */
  25995. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25996. /**
  25997. * Add the required uniforms to the current list.
  25998. * @param uniforms defines the current uniform list.
  25999. */
  26000. static AddUniforms(uniforms: string[]): void;
  26001. /**
  26002. * Add the required uniforms to the current buffer.
  26003. * @param uniformBuffer defines the current uniform buffer.
  26004. */
  26005. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26006. /**
  26007. * Add the required samplers to the current list.
  26008. * @param samplers defines the current sampler list.
  26009. */
  26010. static AddSamplers(samplers: string[]): void;
  26011. /**
  26012. * Makes a duplicate of the current configuration into another one.
  26013. * @param sheenConfiguration define the config where to copy the info
  26014. */
  26015. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  26016. /**
  26017. * Serializes this BRDF configuration.
  26018. * @returns - An object with the serialized config.
  26019. */
  26020. serialize(): any;
  26021. /**
  26022. * Parses a anisotropy Configuration from a serialized object.
  26023. * @param source - Serialized object.
  26024. * @param scene Defines the scene we are parsing for
  26025. * @param rootUrl Defines the rootUrl to load from
  26026. */
  26027. parse(source: any, scene: Scene, rootUrl: string): void;
  26028. }
  26029. }
  26030. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  26031. import { Nullable } from "babylonjs/types";
  26032. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26033. import { Color3 } from "babylonjs/Maths/math.color";
  26034. import { SmartArray } from "babylonjs/Misc/smartArray";
  26035. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26036. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26037. import { Effect } from "babylonjs/Materials/effect";
  26038. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26039. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26040. import { Engine } from "babylonjs/Engines/engine";
  26041. import { Scene } from "babylonjs/scene";
  26042. /**
  26043. * @hidden
  26044. */
  26045. export interface IMaterialSubSurfaceDefines {
  26046. SUBSURFACE: boolean;
  26047. SS_REFRACTION: boolean;
  26048. SS_TRANSLUCENCY: boolean;
  26049. SS_SCATTERING: boolean;
  26050. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26051. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26052. SS_REFRACTIONMAP_3D: boolean;
  26053. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26054. SS_LODINREFRACTIONALPHA: boolean;
  26055. SS_GAMMAREFRACTION: boolean;
  26056. SS_RGBDREFRACTION: boolean;
  26057. SS_LINEARSPECULARREFRACTION: boolean;
  26058. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26059. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26060. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26061. /** @hidden */
  26062. _areTexturesDirty: boolean;
  26063. }
  26064. /**
  26065. * Define the code related to the sub surface parameters of the pbr material.
  26066. */
  26067. export class PBRSubSurfaceConfiguration {
  26068. private _isRefractionEnabled;
  26069. /**
  26070. * Defines if the refraction is enabled in the material.
  26071. */
  26072. isRefractionEnabled: boolean;
  26073. private _isTranslucencyEnabled;
  26074. /**
  26075. * Defines if the translucency is enabled in the material.
  26076. */
  26077. isTranslucencyEnabled: boolean;
  26078. private _isScatteringEnabled;
  26079. /**
  26080. * Defines if the sub surface scattering is enabled in the material.
  26081. */
  26082. isScatteringEnabled: boolean;
  26083. private _scatteringDiffusionProfileIndex;
  26084. /**
  26085. * Diffusion profile for subsurface scattering.
  26086. * Useful for better scattering in the skins or foliages.
  26087. */
  26088. get scatteringDiffusionProfile(): Nullable<Color3>;
  26089. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26090. /**
  26091. * Defines the refraction intensity of the material.
  26092. * The refraction when enabled replaces the Diffuse part of the material.
  26093. * The intensity helps transitionning between diffuse and refraction.
  26094. */
  26095. refractionIntensity: number;
  26096. /**
  26097. * Defines the translucency intensity of the material.
  26098. * When translucency has been enabled, this defines how much of the "translucency"
  26099. * is addded to the diffuse part of the material.
  26100. */
  26101. translucencyIntensity: number;
  26102. /**
  26103. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26104. */
  26105. useAlbedoToTintRefraction: boolean;
  26106. private _thicknessTexture;
  26107. /**
  26108. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26109. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26110. * 0 would mean minimumThickness
  26111. * 1 would mean maximumThickness
  26112. * The other channels might be use as a mask to vary the different effects intensity.
  26113. */
  26114. thicknessTexture: Nullable<BaseTexture>;
  26115. private _refractionTexture;
  26116. /**
  26117. * Defines the texture to use for refraction.
  26118. */
  26119. refractionTexture: Nullable<BaseTexture>;
  26120. private _indexOfRefraction;
  26121. /**
  26122. * Index of refraction of the material base layer.
  26123. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26124. *
  26125. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26126. *
  26127. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26128. */
  26129. indexOfRefraction: number;
  26130. private _volumeIndexOfRefraction;
  26131. /**
  26132. * Index of refraction of the material's volume.
  26133. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26134. *
  26135. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26136. * the volume will use the same IOR as the surface.
  26137. */
  26138. get volumeIndexOfRefraction(): number;
  26139. set volumeIndexOfRefraction(value: number);
  26140. private _invertRefractionY;
  26141. /**
  26142. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26143. */
  26144. invertRefractionY: boolean;
  26145. private _linkRefractionWithTransparency;
  26146. /**
  26147. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26148. * Materials half opaque for instance using refraction could benefit from this control.
  26149. */
  26150. linkRefractionWithTransparency: boolean;
  26151. /**
  26152. * Defines the minimum thickness stored in the thickness map.
  26153. * If no thickness map is defined, this value will be used to simulate thickness.
  26154. */
  26155. minimumThickness: number;
  26156. /**
  26157. * Defines the maximum thickness stored in the thickness map.
  26158. */
  26159. maximumThickness: number;
  26160. /**
  26161. * Defines the volume tint of the material.
  26162. * This is used for both translucency and scattering.
  26163. */
  26164. tintColor: Color3;
  26165. /**
  26166. * Defines the distance at which the tint color should be found in the media.
  26167. * This is used for refraction only.
  26168. */
  26169. tintColorAtDistance: number;
  26170. /**
  26171. * Defines how far each channel transmit through the media.
  26172. * It is defined as a color to simplify it selection.
  26173. */
  26174. diffusionDistance: Color3;
  26175. private _useMaskFromThicknessTexture;
  26176. /**
  26177. * Stores the intensity of the different subsurface effects in the thickness texture.
  26178. * * the green channel is the translucency intensity.
  26179. * * the blue channel is the scattering intensity.
  26180. * * the alpha channel is the refraction intensity.
  26181. */
  26182. useMaskFromThicknessTexture: boolean;
  26183. private _scene;
  26184. /** @hidden */
  26185. private _internalMarkAllSubMeshesAsTexturesDirty;
  26186. private _internalMarkScenePrePassDirty;
  26187. /** @hidden */
  26188. _markAllSubMeshesAsTexturesDirty(): void;
  26189. /** @hidden */
  26190. _markScenePrePassDirty(): void;
  26191. /**
  26192. * Instantiate a new istance of sub surface configuration.
  26193. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26194. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26195. * @param scene The scene
  26196. */
  26197. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26198. /**
  26199. * Gets wehter the submesh is ready to be used or not.
  26200. * @param defines the list of "defines" to update.
  26201. * @param scene defines the scene the material belongs to.
  26202. * @returns - boolean indicating that the submesh is ready or not.
  26203. */
  26204. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26205. /**
  26206. * Checks to see if a texture is used in the material.
  26207. * @param defines the list of "defines" to update.
  26208. * @param scene defines the scene to the material belongs to.
  26209. */
  26210. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26211. /**
  26212. * Binds the material data.
  26213. * @param uniformBuffer defines the Uniform buffer to fill in.
  26214. * @param scene defines the scene the material belongs to.
  26215. * @param engine defines the engine the material belongs to.
  26216. * @param isFrozen defines whether the material is frozen or not.
  26217. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26218. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26219. */
  26220. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26221. /**
  26222. * Unbinds the material from the mesh.
  26223. * @param activeEffect defines the effect that should be unbound from.
  26224. * @returns true if unbound, otherwise false
  26225. */
  26226. unbind(activeEffect: Effect): boolean;
  26227. /**
  26228. * Returns the texture used for refraction or null if none is used.
  26229. * @param scene defines the scene the material belongs to.
  26230. * @returns - Refraction texture if present. If no refraction texture and refraction
  26231. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26232. */
  26233. private _getRefractionTexture;
  26234. /**
  26235. * Returns true if alpha blending should be disabled.
  26236. */
  26237. get disableAlphaBlending(): boolean;
  26238. /**
  26239. * Fills the list of render target textures.
  26240. * @param renderTargets the list of render targets to update
  26241. */
  26242. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26243. /**
  26244. * Checks to see if a texture is used in the material.
  26245. * @param texture - Base texture to use.
  26246. * @returns - Boolean specifying if a texture is used in the material.
  26247. */
  26248. hasTexture(texture: BaseTexture): boolean;
  26249. /**
  26250. * Gets a boolean indicating that current material needs to register RTT
  26251. * @returns true if this uses a render target otherwise false.
  26252. */
  26253. hasRenderTargetTextures(): boolean;
  26254. /**
  26255. * Returns an array of the actively used textures.
  26256. * @param activeTextures Array of BaseTextures
  26257. */
  26258. getActiveTextures(activeTextures: BaseTexture[]): void;
  26259. /**
  26260. * Returns the animatable textures.
  26261. * @param animatables Array of animatable textures.
  26262. */
  26263. getAnimatables(animatables: IAnimatable[]): void;
  26264. /**
  26265. * Disposes the resources of the material.
  26266. * @param forceDisposeTextures - Forces the disposal of all textures.
  26267. */
  26268. dispose(forceDisposeTextures?: boolean): void;
  26269. /**
  26270. * Get the current class name of the texture useful for serialization or dynamic coding.
  26271. * @returns "PBRSubSurfaceConfiguration"
  26272. */
  26273. getClassName(): string;
  26274. /**
  26275. * Add fallbacks to the effect fallbacks list.
  26276. * @param defines defines the Base texture to use.
  26277. * @param fallbacks defines the current fallback list.
  26278. * @param currentRank defines the current fallback rank.
  26279. * @returns the new fallback rank.
  26280. */
  26281. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26282. /**
  26283. * Add the required uniforms to the current list.
  26284. * @param uniforms defines the current uniform list.
  26285. */
  26286. static AddUniforms(uniforms: string[]): void;
  26287. /**
  26288. * Add the required samplers to the current list.
  26289. * @param samplers defines the current sampler list.
  26290. */
  26291. static AddSamplers(samplers: string[]): void;
  26292. /**
  26293. * Add the required uniforms to the current buffer.
  26294. * @param uniformBuffer defines the current uniform buffer.
  26295. */
  26296. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26297. /**
  26298. * Makes a duplicate of the current configuration into another one.
  26299. * @param configuration define the config where to copy the info
  26300. */
  26301. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26302. /**
  26303. * Serializes this Sub Surface configuration.
  26304. * @returns - An object with the serialized config.
  26305. */
  26306. serialize(): any;
  26307. /**
  26308. * Parses a anisotropy Configuration from a serialized object.
  26309. * @param source - Serialized object.
  26310. * @param scene Defines the scene we are parsing for
  26311. * @param rootUrl Defines the rootUrl to load from
  26312. */
  26313. parse(source: any, scene: Scene, rootUrl: string): void;
  26314. }
  26315. }
  26316. declare module "babylonjs/Maths/sphericalPolynomial" {
  26317. import { Vector3 } from "babylonjs/Maths/math.vector";
  26318. import { Color3 } from "babylonjs/Maths/math.color";
  26319. /**
  26320. * Class representing spherical harmonics coefficients to the 3rd degree
  26321. */
  26322. export class SphericalHarmonics {
  26323. /**
  26324. * Defines whether or not the harmonics have been prescaled for rendering.
  26325. */
  26326. preScaled: boolean;
  26327. /**
  26328. * The l0,0 coefficients of the spherical harmonics
  26329. */
  26330. l00: Vector3;
  26331. /**
  26332. * The l1,-1 coefficients of the spherical harmonics
  26333. */
  26334. l1_1: Vector3;
  26335. /**
  26336. * The l1,0 coefficients of the spherical harmonics
  26337. */
  26338. l10: Vector3;
  26339. /**
  26340. * The l1,1 coefficients of the spherical harmonics
  26341. */
  26342. l11: Vector3;
  26343. /**
  26344. * The l2,-2 coefficients of the spherical harmonics
  26345. */
  26346. l2_2: Vector3;
  26347. /**
  26348. * The l2,-1 coefficients of the spherical harmonics
  26349. */
  26350. l2_1: Vector3;
  26351. /**
  26352. * The l2,0 coefficients of the spherical harmonics
  26353. */
  26354. l20: Vector3;
  26355. /**
  26356. * The l2,1 coefficients of the spherical harmonics
  26357. */
  26358. l21: Vector3;
  26359. /**
  26360. * The l2,2 coefficients of the spherical harmonics
  26361. */
  26362. l22: Vector3;
  26363. /**
  26364. * Adds a light to the spherical harmonics
  26365. * @param direction the direction of the light
  26366. * @param color the color of the light
  26367. * @param deltaSolidAngle the delta solid angle of the light
  26368. */
  26369. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26370. /**
  26371. * Scales the spherical harmonics by the given amount
  26372. * @param scale the amount to scale
  26373. */
  26374. scaleInPlace(scale: number): void;
  26375. /**
  26376. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26377. *
  26378. * ```
  26379. * E_lm = A_l * L_lm
  26380. * ```
  26381. *
  26382. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26383. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26384. * the scaling factors are given in equation 9.
  26385. */
  26386. convertIncidentRadianceToIrradiance(): void;
  26387. /**
  26388. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26389. *
  26390. * ```
  26391. * L = (1/pi) * E * rho
  26392. * ```
  26393. *
  26394. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26395. */
  26396. convertIrradianceToLambertianRadiance(): void;
  26397. /**
  26398. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26399. * required operations at run time.
  26400. *
  26401. * This is simply done by scaling back the SH with Ylm constants parameter.
  26402. * The trigonometric part being applied by the shader at run time.
  26403. */
  26404. preScaleForRendering(): void;
  26405. /**
  26406. * Constructs a spherical harmonics from an array.
  26407. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26408. * @returns the spherical harmonics
  26409. */
  26410. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26411. /**
  26412. * Gets the spherical harmonics from polynomial
  26413. * @param polynomial the spherical polynomial
  26414. * @returns the spherical harmonics
  26415. */
  26416. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26417. }
  26418. /**
  26419. * Class representing spherical polynomial coefficients to the 3rd degree
  26420. */
  26421. export class SphericalPolynomial {
  26422. private _harmonics;
  26423. /**
  26424. * The spherical harmonics used to create the polynomials.
  26425. */
  26426. get preScaledHarmonics(): SphericalHarmonics;
  26427. /**
  26428. * The x coefficients of the spherical polynomial
  26429. */
  26430. x: Vector3;
  26431. /**
  26432. * The y coefficients of the spherical polynomial
  26433. */
  26434. y: Vector3;
  26435. /**
  26436. * The z coefficients of the spherical polynomial
  26437. */
  26438. z: Vector3;
  26439. /**
  26440. * The xx coefficients of the spherical polynomial
  26441. */
  26442. xx: Vector3;
  26443. /**
  26444. * The yy coefficients of the spherical polynomial
  26445. */
  26446. yy: Vector3;
  26447. /**
  26448. * The zz coefficients of the spherical polynomial
  26449. */
  26450. zz: Vector3;
  26451. /**
  26452. * The xy coefficients of the spherical polynomial
  26453. */
  26454. xy: Vector3;
  26455. /**
  26456. * The yz coefficients of the spherical polynomial
  26457. */
  26458. yz: Vector3;
  26459. /**
  26460. * The zx coefficients of the spherical polynomial
  26461. */
  26462. zx: Vector3;
  26463. /**
  26464. * Adds an ambient color to the spherical polynomial
  26465. * @param color the color to add
  26466. */
  26467. addAmbient(color: Color3): void;
  26468. /**
  26469. * Scales the spherical polynomial by the given amount
  26470. * @param scale the amount to scale
  26471. */
  26472. scaleInPlace(scale: number): void;
  26473. /**
  26474. * Gets the spherical polynomial from harmonics
  26475. * @param harmonics the spherical harmonics
  26476. * @returns the spherical polynomial
  26477. */
  26478. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26479. /**
  26480. * Constructs a spherical polynomial from an array.
  26481. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26482. * @returns the spherical polynomial
  26483. */
  26484. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26485. }
  26486. }
  26487. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26488. import { Nullable } from "babylonjs/types";
  26489. /**
  26490. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26491. */
  26492. export interface CubeMapInfo {
  26493. /**
  26494. * The pixel array for the front face.
  26495. * This is stored in format, left to right, up to down format.
  26496. */
  26497. front: Nullable<ArrayBufferView>;
  26498. /**
  26499. * The pixel array for the back face.
  26500. * This is stored in format, left to right, up to down format.
  26501. */
  26502. back: Nullable<ArrayBufferView>;
  26503. /**
  26504. * The pixel array for the left face.
  26505. * This is stored in format, left to right, up to down format.
  26506. */
  26507. left: Nullable<ArrayBufferView>;
  26508. /**
  26509. * The pixel array for the right face.
  26510. * This is stored in format, left to right, up to down format.
  26511. */
  26512. right: Nullable<ArrayBufferView>;
  26513. /**
  26514. * The pixel array for the up face.
  26515. * This is stored in format, left to right, up to down format.
  26516. */
  26517. up: Nullable<ArrayBufferView>;
  26518. /**
  26519. * The pixel array for the down face.
  26520. * This is stored in format, left to right, up to down format.
  26521. */
  26522. down: Nullable<ArrayBufferView>;
  26523. /**
  26524. * The size of the cubemap stored.
  26525. *
  26526. * Each faces will be size * size pixels.
  26527. */
  26528. size: number;
  26529. /**
  26530. * The format of the texture.
  26531. *
  26532. * RGBA, RGB.
  26533. */
  26534. format: number;
  26535. /**
  26536. * The type of the texture data.
  26537. *
  26538. * UNSIGNED_INT, FLOAT.
  26539. */
  26540. type: number;
  26541. /**
  26542. * Specifies whether the texture is in gamma space.
  26543. */
  26544. gammaSpace: boolean;
  26545. }
  26546. /**
  26547. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26548. */
  26549. export class PanoramaToCubeMapTools {
  26550. private static FACE_LEFT;
  26551. private static FACE_RIGHT;
  26552. private static FACE_FRONT;
  26553. private static FACE_BACK;
  26554. private static FACE_DOWN;
  26555. private static FACE_UP;
  26556. /**
  26557. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26558. *
  26559. * @param float32Array The source data.
  26560. * @param inputWidth The width of the input panorama.
  26561. * @param inputHeight The height of the input panorama.
  26562. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26563. * @return The cubemap data
  26564. */
  26565. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26566. private static CreateCubemapTexture;
  26567. private static CalcProjectionSpherical;
  26568. }
  26569. }
  26570. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26571. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26573. import { Nullable } from "babylonjs/types";
  26574. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26575. /**
  26576. * Helper class dealing with the extraction of spherical polynomial dataArray
  26577. * from a cube map.
  26578. */
  26579. export class CubeMapToSphericalPolynomialTools {
  26580. private static FileFaces;
  26581. /**
  26582. * Converts a texture to the according Spherical Polynomial data.
  26583. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26584. *
  26585. * @param texture The texture to extract the information from.
  26586. * @return The Spherical Polynomial data.
  26587. */
  26588. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26589. /**
  26590. * Converts a cubemap to the according Spherical Polynomial data.
  26591. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26592. *
  26593. * @param cubeInfo The Cube map to extract the information from.
  26594. * @return The Spherical Polynomial data.
  26595. */
  26596. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26597. }
  26598. }
  26599. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26600. import { Nullable } from "babylonjs/types";
  26601. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26602. module "babylonjs/Materials/Textures/baseTexture" {
  26603. interface BaseTexture {
  26604. /**
  26605. * Get the polynomial representation of the texture data.
  26606. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26607. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26608. */
  26609. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26610. }
  26611. }
  26612. }
  26613. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26614. /** @hidden */
  26615. export var pbrFragmentDeclaration: {
  26616. name: string;
  26617. shader: string;
  26618. };
  26619. }
  26620. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26621. /** @hidden */
  26622. export var pbrUboDeclaration: {
  26623. name: string;
  26624. shader: string;
  26625. };
  26626. }
  26627. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26628. /** @hidden */
  26629. export var pbrFragmentExtraDeclaration: {
  26630. name: string;
  26631. shader: string;
  26632. };
  26633. }
  26634. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26635. /** @hidden */
  26636. export var pbrFragmentSamplersDeclaration: {
  26637. name: string;
  26638. shader: string;
  26639. };
  26640. }
  26641. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26642. /** @hidden */
  26643. export var subSurfaceScatteringFunctions: {
  26644. name: string;
  26645. shader: string;
  26646. };
  26647. }
  26648. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26649. /** @hidden */
  26650. export var importanceSampling: {
  26651. name: string;
  26652. shader: string;
  26653. };
  26654. }
  26655. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26656. /** @hidden */
  26657. export var pbrHelperFunctions: {
  26658. name: string;
  26659. shader: string;
  26660. };
  26661. }
  26662. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26663. /** @hidden */
  26664. export var harmonicsFunctions: {
  26665. name: string;
  26666. shader: string;
  26667. };
  26668. }
  26669. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26670. /** @hidden */
  26671. export var pbrDirectLightingSetupFunctions: {
  26672. name: string;
  26673. shader: string;
  26674. };
  26675. }
  26676. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26677. /** @hidden */
  26678. export var pbrDirectLightingFalloffFunctions: {
  26679. name: string;
  26680. shader: string;
  26681. };
  26682. }
  26683. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26684. /** @hidden */
  26685. export var pbrBRDFFunctions: {
  26686. name: string;
  26687. shader: string;
  26688. };
  26689. }
  26690. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26691. /** @hidden */
  26692. export var hdrFilteringFunctions: {
  26693. name: string;
  26694. shader: string;
  26695. };
  26696. }
  26697. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  26698. /** @hidden */
  26699. export var pbrDirectLightingFunctions: {
  26700. name: string;
  26701. shader: string;
  26702. };
  26703. }
  26704. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  26705. /** @hidden */
  26706. export var pbrIBLFunctions: {
  26707. name: string;
  26708. shader: string;
  26709. };
  26710. }
  26711. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  26712. /** @hidden */
  26713. export var pbrBlockAlbedoOpacity: {
  26714. name: string;
  26715. shader: string;
  26716. };
  26717. }
  26718. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  26719. /** @hidden */
  26720. export var pbrBlockReflectivity: {
  26721. name: string;
  26722. shader: string;
  26723. };
  26724. }
  26725. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  26726. /** @hidden */
  26727. export var pbrBlockAmbientOcclusion: {
  26728. name: string;
  26729. shader: string;
  26730. };
  26731. }
  26732. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  26733. /** @hidden */
  26734. export var pbrBlockAlphaFresnel: {
  26735. name: string;
  26736. shader: string;
  26737. };
  26738. }
  26739. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  26740. /** @hidden */
  26741. export var pbrBlockAnisotropic: {
  26742. name: string;
  26743. shader: string;
  26744. };
  26745. }
  26746. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  26747. /** @hidden */
  26748. export var pbrBlockReflection: {
  26749. name: string;
  26750. shader: string;
  26751. };
  26752. }
  26753. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  26754. /** @hidden */
  26755. export var pbrBlockSheen: {
  26756. name: string;
  26757. shader: string;
  26758. };
  26759. }
  26760. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  26761. /** @hidden */
  26762. export var pbrBlockClearcoat: {
  26763. name: string;
  26764. shader: string;
  26765. };
  26766. }
  26767. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  26768. /** @hidden */
  26769. export var pbrBlockSubSurface: {
  26770. name: string;
  26771. shader: string;
  26772. };
  26773. }
  26774. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  26775. /** @hidden */
  26776. export var pbrBlockNormalGeometric: {
  26777. name: string;
  26778. shader: string;
  26779. };
  26780. }
  26781. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  26782. /** @hidden */
  26783. export var pbrBlockNormalFinal: {
  26784. name: string;
  26785. shader: string;
  26786. };
  26787. }
  26788. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  26789. /** @hidden */
  26790. export var pbrBlockLightmapInit: {
  26791. name: string;
  26792. shader: string;
  26793. };
  26794. }
  26795. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  26796. /** @hidden */
  26797. export var pbrBlockGeometryInfo: {
  26798. name: string;
  26799. shader: string;
  26800. };
  26801. }
  26802. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  26803. /** @hidden */
  26804. export var pbrBlockReflectance0: {
  26805. name: string;
  26806. shader: string;
  26807. };
  26808. }
  26809. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  26810. /** @hidden */
  26811. export var pbrBlockReflectance: {
  26812. name: string;
  26813. shader: string;
  26814. };
  26815. }
  26816. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  26817. /** @hidden */
  26818. export var pbrBlockDirectLighting: {
  26819. name: string;
  26820. shader: string;
  26821. };
  26822. }
  26823. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  26824. /** @hidden */
  26825. export var pbrBlockFinalLitComponents: {
  26826. name: string;
  26827. shader: string;
  26828. };
  26829. }
  26830. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  26831. /** @hidden */
  26832. export var pbrBlockFinalUnlitComponents: {
  26833. name: string;
  26834. shader: string;
  26835. };
  26836. }
  26837. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  26838. /** @hidden */
  26839. export var pbrBlockFinalColorComposition: {
  26840. name: string;
  26841. shader: string;
  26842. };
  26843. }
  26844. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  26845. /** @hidden */
  26846. export var pbrBlockImageProcessing: {
  26847. name: string;
  26848. shader: string;
  26849. };
  26850. }
  26851. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  26852. /** @hidden */
  26853. export var pbrDebug: {
  26854. name: string;
  26855. shader: string;
  26856. };
  26857. }
  26858. declare module "babylonjs/Shaders/pbr.fragment" {
  26859. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  26860. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  26861. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26862. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  26863. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26864. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26865. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  26866. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26867. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26868. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26869. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26870. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26871. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  26872. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  26873. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  26874. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26875. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26876. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26877. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  26878. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  26879. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  26880. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  26881. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  26882. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  26883. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  26884. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26885. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26886. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  26887. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  26888. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  26889. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  26890. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  26891. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  26892. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  26893. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  26894. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  26895. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26896. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  26897. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26898. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  26899. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26900. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  26901. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  26902. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  26903. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  26904. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  26905. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26906. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  26907. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  26908. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  26909. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26910. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26911. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  26912. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  26913. /** @hidden */
  26914. export var pbrPixelShader: {
  26915. name: string;
  26916. shader: string;
  26917. };
  26918. }
  26919. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  26920. /** @hidden */
  26921. export var pbrVertexDeclaration: {
  26922. name: string;
  26923. shader: string;
  26924. };
  26925. }
  26926. declare module "babylonjs/Shaders/pbr.vertex" {
  26927. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  26928. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  26929. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26930. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26931. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26932. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  26933. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  26934. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26935. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26936. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26937. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26938. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26939. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26940. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26941. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26943. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26944. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26945. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  26946. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26947. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26948. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26949. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26950. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26951. /** @hidden */
  26952. export var pbrVertexShader: {
  26953. name: string;
  26954. shader: string;
  26955. };
  26956. }
  26957. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  26958. import { Nullable } from "babylonjs/types";
  26959. import { Scene } from "babylonjs/scene";
  26960. import { Matrix } from "babylonjs/Maths/math.vector";
  26961. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26963. import { Mesh } from "babylonjs/Meshes/mesh";
  26964. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  26965. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  26966. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  26967. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  26968. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  26969. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  26970. import { Color3 } from "babylonjs/Maths/math.color";
  26971. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26972. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  26973. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26974. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26975. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26976. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26977. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  26978. import "babylonjs/Shaders/pbr.fragment";
  26979. import "babylonjs/Shaders/pbr.vertex";
  26980. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  26981. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  26982. /**
  26983. * Manages the defines for the PBR Material.
  26984. * @hidden
  26985. */
  26986. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  26987. PBR: boolean;
  26988. NUM_SAMPLES: string;
  26989. REALTIME_FILTERING: boolean;
  26990. MAINUV1: boolean;
  26991. MAINUV2: boolean;
  26992. UV1: boolean;
  26993. UV2: boolean;
  26994. ALBEDO: boolean;
  26995. GAMMAALBEDO: boolean;
  26996. ALBEDODIRECTUV: number;
  26997. VERTEXCOLOR: boolean;
  26998. DETAIL: boolean;
  26999. DETAILDIRECTUV: number;
  27000. DETAIL_NORMALBLENDMETHOD: number;
  27001. AMBIENT: boolean;
  27002. AMBIENTDIRECTUV: number;
  27003. AMBIENTINGRAYSCALE: boolean;
  27004. OPACITY: boolean;
  27005. VERTEXALPHA: boolean;
  27006. OPACITYDIRECTUV: number;
  27007. OPACITYRGB: boolean;
  27008. ALPHATEST: boolean;
  27009. DEPTHPREPASS: boolean;
  27010. ALPHABLEND: boolean;
  27011. ALPHAFROMALBEDO: boolean;
  27012. ALPHATESTVALUE: string;
  27013. SPECULAROVERALPHA: boolean;
  27014. RADIANCEOVERALPHA: boolean;
  27015. ALPHAFRESNEL: boolean;
  27016. LINEARALPHAFRESNEL: boolean;
  27017. PREMULTIPLYALPHA: boolean;
  27018. EMISSIVE: boolean;
  27019. EMISSIVEDIRECTUV: number;
  27020. REFLECTIVITY: boolean;
  27021. REFLECTIVITYDIRECTUV: number;
  27022. SPECULARTERM: boolean;
  27023. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  27024. MICROSURFACEAUTOMATIC: boolean;
  27025. LODBASEDMICROSFURACE: boolean;
  27026. MICROSURFACEMAP: boolean;
  27027. MICROSURFACEMAPDIRECTUV: number;
  27028. METALLICWORKFLOW: boolean;
  27029. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  27030. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  27031. METALLNESSSTOREINMETALMAPBLUE: boolean;
  27032. AOSTOREINMETALMAPRED: boolean;
  27033. METALLIC_REFLECTANCE: boolean;
  27034. METALLIC_REFLECTANCEDIRECTUV: number;
  27035. ENVIRONMENTBRDF: boolean;
  27036. ENVIRONMENTBRDF_RGBD: boolean;
  27037. NORMAL: boolean;
  27038. TANGENT: boolean;
  27039. BUMP: boolean;
  27040. BUMPDIRECTUV: number;
  27041. OBJECTSPACE_NORMALMAP: boolean;
  27042. PARALLAX: boolean;
  27043. PARALLAXOCCLUSION: boolean;
  27044. NORMALXYSCALE: boolean;
  27045. LIGHTMAP: boolean;
  27046. LIGHTMAPDIRECTUV: number;
  27047. USELIGHTMAPASSHADOWMAP: boolean;
  27048. GAMMALIGHTMAP: boolean;
  27049. RGBDLIGHTMAP: boolean;
  27050. REFLECTION: boolean;
  27051. REFLECTIONMAP_3D: boolean;
  27052. REFLECTIONMAP_SPHERICAL: boolean;
  27053. REFLECTIONMAP_PLANAR: boolean;
  27054. REFLECTIONMAP_CUBIC: boolean;
  27055. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27056. REFLECTIONMAP_PROJECTION: boolean;
  27057. REFLECTIONMAP_SKYBOX: boolean;
  27058. REFLECTIONMAP_EXPLICIT: boolean;
  27059. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27060. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27061. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27062. INVERTCUBICMAP: boolean;
  27063. USESPHERICALFROMREFLECTIONMAP: boolean;
  27064. USEIRRADIANCEMAP: boolean;
  27065. SPHERICAL_HARMONICS: boolean;
  27066. USESPHERICALINVERTEX: boolean;
  27067. REFLECTIONMAP_OPPOSITEZ: boolean;
  27068. LODINREFLECTIONALPHA: boolean;
  27069. GAMMAREFLECTION: boolean;
  27070. RGBDREFLECTION: boolean;
  27071. LINEARSPECULARREFLECTION: boolean;
  27072. RADIANCEOCCLUSION: boolean;
  27073. HORIZONOCCLUSION: boolean;
  27074. INSTANCES: boolean;
  27075. THIN_INSTANCES: boolean;
  27076. PREPASS: boolean;
  27077. PREPASS_IRRADIANCE: boolean;
  27078. PREPASS_IRRADIANCE_INDEX: number;
  27079. PREPASS_ALBEDO: boolean;
  27080. PREPASS_ALBEDO_INDEX: number;
  27081. PREPASS_DEPTHNORMAL: boolean;
  27082. PREPASS_DEPTHNORMAL_INDEX: number;
  27083. PREPASS_POSITION: boolean;
  27084. PREPASS_POSITION_INDEX: number;
  27085. PREPASS_VELOCITY: boolean;
  27086. PREPASS_VELOCITY_INDEX: number;
  27087. PREPASS_REFLECTIVITY: boolean;
  27088. PREPASS_REFLECTIVITY_INDEX: number;
  27089. SCENE_MRT_COUNT: number;
  27090. NUM_BONE_INFLUENCERS: number;
  27091. BonesPerMesh: number;
  27092. BONETEXTURE: boolean;
  27093. BONES_VELOCITY_ENABLED: boolean;
  27094. NONUNIFORMSCALING: boolean;
  27095. MORPHTARGETS: boolean;
  27096. MORPHTARGETS_NORMAL: boolean;
  27097. MORPHTARGETS_TANGENT: boolean;
  27098. MORPHTARGETS_UV: boolean;
  27099. NUM_MORPH_INFLUENCERS: number;
  27100. IMAGEPROCESSING: boolean;
  27101. VIGNETTE: boolean;
  27102. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27103. VIGNETTEBLENDMODEOPAQUE: boolean;
  27104. TONEMAPPING: boolean;
  27105. TONEMAPPING_ACES: boolean;
  27106. CONTRAST: boolean;
  27107. COLORCURVES: boolean;
  27108. COLORGRADING: boolean;
  27109. COLORGRADING3D: boolean;
  27110. SAMPLER3DGREENDEPTH: boolean;
  27111. SAMPLER3DBGRMAP: boolean;
  27112. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27113. EXPOSURE: boolean;
  27114. MULTIVIEW: boolean;
  27115. USEPHYSICALLIGHTFALLOFF: boolean;
  27116. USEGLTFLIGHTFALLOFF: boolean;
  27117. TWOSIDEDLIGHTING: boolean;
  27118. SHADOWFLOAT: boolean;
  27119. CLIPPLANE: boolean;
  27120. CLIPPLANE2: boolean;
  27121. CLIPPLANE3: boolean;
  27122. CLIPPLANE4: boolean;
  27123. CLIPPLANE5: boolean;
  27124. CLIPPLANE6: boolean;
  27125. POINTSIZE: boolean;
  27126. FOG: boolean;
  27127. LOGARITHMICDEPTH: boolean;
  27128. FORCENORMALFORWARD: boolean;
  27129. SPECULARAA: boolean;
  27130. CLEARCOAT: boolean;
  27131. CLEARCOAT_DEFAULTIOR: boolean;
  27132. CLEARCOAT_TEXTURE: boolean;
  27133. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  27134. CLEARCOAT_TEXTUREDIRECTUV: number;
  27135. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  27136. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27137. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27138. CLEARCOAT_BUMP: boolean;
  27139. CLEARCOAT_BUMPDIRECTUV: number;
  27140. CLEARCOAT_REMAP_F0: boolean;
  27141. CLEARCOAT_TINT: boolean;
  27142. CLEARCOAT_TINT_TEXTURE: boolean;
  27143. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27144. ANISOTROPIC: boolean;
  27145. ANISOTROPIC_TEXTURE: boolean;
  27146. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27147. BRDF_V_HEIGHT_CORRELATED: boolean;
  27148. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27149. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27150. SHEEN: boolean;
  27151. SHEEN_TEXTURE: boolean;
  27152. SHEEN_TEXTURE_ROUGHNESS: boolean;
  27153. SHEEN_TEXTUREDIRECTUV: number;
  27154. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  27155. SHEEN_LINKWITHALBEDO: boolean;
  27156. SHEEN_ROUGHNESS: boolean;
  27157. SHEEN_ALBEDOSCALING: boolean;
  27158. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27159. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27160. SUBSURFACE: boolean;
  27161. SS_REFRACTION: boolean;
  27162. SS_TRANSLUCENCY: boolean;
  27163. SS_SCATTERING: boolean;
  27164. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27165. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27166. SS_REFRACTIONMAP_3D: boolean;
  27167. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27168. SS_LODINREFRACTIONALPHA: boolean;
  27169. SS_GAMMAREFRACTION: boolean;
  27170. SS_RGBDREFRACTION: boolean;
  27171. SS_LINEARSPECULARREFRACTION: boolean;
  27172. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27173. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27174. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27175. UNLIT: boolean;
  27176. DEBUGMODE: number;
  27177. /**
  27178. * Initializes the PBR Material defines.
  27179. */
  27180. constructor();
  27181. /**
  27182. * Resets the PBR Material defines.
  27183. */
  27184. reset(): void;
  27185. }
  27186. /**
  27187. * The Physically based material base class of BJS.
  27188. *
  27189. * This offers the main features of a standard PBR material.
  27190. * For more information, please refer to the documentation :
  27191. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27192. */
  27193. export abstract class PBRBaseMaterial extends PushMaterial {
  27194. /**
  27195. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27196. */
  27197. static readonly PBRMATERIAL_OPAQUE: number;
  27198. /**
  27199. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27200. */
  27201. static readonly PBRMATERIAL_ALPHATEST: number;
  27202. /**
  27203. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27204. */
  27205. static readonly PBRMATERIAL_ALPHABLEND: number;
  27206. /**
  27207. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27208. * They are also discarded below the alpha cutoff threshold to improve performances.
  27209. */
  27210. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27211. /**
  27212. * Defines the default value of how much AO map is occluding the analytical lights
  27213. * (point spot...).
  27214. */
  27215. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27216. /**
  27217. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27218. */
  27219. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27220. /**
  27221. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27222. * to enhance interoperability with other engines.
  27223. */
  27224. static readonly LIGHTFALLOFF_GLTF: number;
  27225. /**
  27226. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27227. * to enhance interoperability with other materials.
  27228. */
  27229. static readonly LIGHTFALLOFF_STANDARD: number;
  27230. /**
  27231. * Intensity of the direct lights e.g. the four lights available in your scene.
  27232. * This impacts both the direct diffuse and specular highlights.
  27233. */
  27234. protected _directIntensity: number;
  27235. /**
  27236. * Intensity of the emissive part of the material.
  27237. * This helps controlling the emissive effect without modifying the emissive color.
  27238. */
  27239. protected _emissiveIntensity: number;
  27240. /**
  27241. * Intensity of the environment e.g. how much the environment will light the object
  27242. * either through harmonics for rough material or through the refelction for shiny ones.
  27243. */
  27244. protected _environmentIntensity: number;
  27245. /**
  27246. * This is a special control allowing the reduction of the specular highlights coming from the
  27247. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27248. */
  27249. protected _specularIntensity: number;
  27250. /**
  27251. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27252. */
  27253. private _lightingInfos;
  27254. /**
  27255. * Debug Control allowing disabling the bump map on this material.
  27256. */
  27257. protected _disableBumpMap: boolean;
  27258. /**
  27259. * AKA Diffuse Texture in standard nomenclature.
  27260. */
  27261. protected _albedoTexture: Nullable<BaseTexture>;
  27262. /**
  27263. * AKA Occlusion Texture in other nomenclature.
  27264. */
  27265. protected _ambientTexture: Nullable<BaseTexture>;
  27266. /**
  27267. * AKA Occlusion Texture Intensity in other nomenclature.
  27268. */
  27269. protected _ambientTextureStrength: number;
  27270. /**
  27271. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27272. * 1 means it completely occludes it
  27273. * 0 mean it has no impact
  27274. */
  27275. protected _ambientTextureImpactOnAnalyticalLights: number;
  27276. /**
  27277. * Stores the alpha values in a texture.
  27278. */
  27279. protected _opacityTexture: Nullable<BaseTexture>;
  27280. /**
  27281. * Stores the reflection values in a texture.
  27282. */
  27283. protected _reflectionTexture: Nullable<BaseTexture>;
  27284. /**
  27285. * Stores the emissive values in a texture.
  27286. */
  27287. protected _emissiveTexture: Nullable<BaseTexture>;
  27288. /**
  27289. * AKA Specular texture in other nomenclature.
  27290. */
  27291. protected _reflectivityTexture: Nullable<BaseTexture>;
  27292. /**
  27293. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27294. */
  27295. protected _metallicTexture: Nullable<BaseTexture>;
  27296. /**
  27297. * Specifies the metallic scalar of the metallic/roughness workflow.
  27298. * Can also be used to scale the metalness values of the metallic texture.
  27299. */
  27300. protected _metallic: Nullable<number>;
  27301. /**
  27302. * Specifies the roughness scalar of the metallic/roughness workflow.
  27303. * Can also be used to scale the roughness values of the metallic texture.
  27304. */
  27305. protected _roughness: Nullable<number>;
  27306. /**
  27307. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27308. * By default the indexOfrefraction is used to compute F0;
  27309. *
  27310. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27311. *
  27312. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27313. * F90 = metallicReflectanceColor;
  27314. */
  27315. protected _metallicF0Factor: number;
  27316. /**
  27317. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27318. * By default the F90 is always 1;
  27319. *
  27320. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27321. *
  27322. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27323. * F90 = metallicReflectanceColor;
  27324. */
  27325. protected _metallicReflectanceColor: Color3;
  27326. /**
  27327. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27328. * This is multiply against the scalar values defined in the material.
  27329. */
  27330. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27331. /**
  27332. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27333. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27334. */
  27335. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27336. /**
  27337. * Stores surface normal data used to displace a mesh in a texture.
  27338. */
  27339. protected _bumpTexture: Nullable<BaseTexture>;
  27340. /**
  27341. * Stores the pre-calculated light information of a mesh in a texture.
  27342. */
  27343. protected _lightmapTexture: Nullable<BaseTexture>;
  27344. /**
  27345. * The color of a material in ambient lighting.
  27346. */
  27347. protected _ambientColor: Color3;
  27348. /**
  27349. * AKA Diffuse Color in other nomenclature.
  27350. */
  27351. protected _albedoColor: Color3;
  27352. /**
  27353. * AKA Specular Color in other nomenclature.
  27354. */
  27355. protected _reflectivityColor: Color3;
  27356. /**
  27357. * The color applied when light is reflected from a material.
  27358. */
  27359. protected _reflectionColor: Color3;
  27360. /**
  27361. * The color applied when light is emitted from a material.
  27362. */
  27363. protected _emissiveColor: Color3;
  27364. /**
  27365. * AKA Glossiness in other nomenclature.
  27366. */
  27367. protected _microSurface: number;
  27368. /**
  27369. * Specifies that the material will use the light map as a show map.
  27370. */
  27371. protected _useLightmapAsShadowmap: boolean;
  27372. /**
  27373. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27374. * makes the reflect vector face the model (under horizon).
  27375. */
  27376. protected _useHorizonOcclusion: boolean;
  27377. /**
  27378. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27379. * too much the area relying on ambient texture to define their ambient occlusion.
  27380. */
  27381. protected _useRadianceOcclusion: boolean;
  27382. /**
  27383. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27384. */
  27385. protected _useAlphaFromAlbedoTexture: boolean;
  27386. /**
  27387. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27388. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27389. */
  27390. protected _useSpecularOverAlpha: boolean;
  27391. /**
  27392. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27393. */
  27394. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27395. /**
  27396. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27397. */
  27398. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27399. /**
  27400. * Specifies if the metallic texture contains the roughness information in its green channel.
  27401. */
  27402. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27403. /**
  27404. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27405. */
  27406. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27407. /**
  27408. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27409. */
  27410. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27411. /**
  27412. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27413. */
  27414. protected _useAmbientInGrayScale: boolean;
  27415. /**
  27416. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27417. * The material will try to infer what glossiness each pixel should be.
  27418. */
  27419. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27420. /**
  27421. * Defines the falloff type used in this material.
  27422. * It by default is Physical.
  27423. */
  27424. protected _lightFalloff: number;
  27425. /**
  27426. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27427. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27428. */
  27429. protected _useRadianceOverAlpha: boolean;
  27430. /**
  27431. * Allows using an object space normal map (instead of tangent space).
  27432. */
  27433. protected _useObjectSpaceNormalMap: boolean;
  27434. /**
  27435. * Allows using the bump map in parallax mode.
  27436. */
  27437. protected _useParallax: boolean;
  27438. /**
  27439. * Allows using the bump map in parallax occlusion mode.
  27440. */
  27441. protected _useParallaxOcclusion: boolean;
  27442. /**
  27443. * Controls the scale bias of the parallax mode.
  27444. */
  27445. protected _parallaxScaleBias: number;
  27446. /**
  27447. * If sets to true, disables all the lights affecting the material.
  27448. */
  27449. protected _disableLighting: boolean;
  27450. /**
  27451. * Number of Simultaneous lights allowed on the material.
  27452. */
  27453. protected _maxSimultaneousLights: number;
  27454. /**
  27455. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27456. */
  27457. protected _invertNormalMapX: boolean;
  27458. /**
  27459. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27460. */
  27461. protected _invertNormalMapY: boolean;
  27462. /**
  27463. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27464. */
  27465. protected _twoSidedLighting: boolean;
  27466. /**
  27467. * Defines the alpha limits in alpha test mode.
  27468. */
  27469. protected _alphaCutOff: number;
  27470. /**
  27471. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27472. */
  27473. protected _forceAlphaTest: boolean;
  27474. /**
  27475. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27476. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27477. */
  27478. protected _useAlphaFresnel: boolean;
  27479. /**
  27480. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27481. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27482. */
  27483. protected _useLinearAlphaFresnel: boolean;
  27484. /**
  27485. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27486. * from cos thetav and roughness:
  27487. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27488. */
  27489. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27490. /**
  27491. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27492. */
  27493. protected _forceIrradianceInFragment: boolean;
  27494. private _realTimeFiltering;
  27495. /**
  27496. * Enables realtime filtering on the texture.
  27497. */
  27498. get realTimeFiltering(): boolean;
  27499. set realTimeFiltering(b: boolean);
  27500. private _realTimeFilteringQuality;
  27501. /**
  27502. * Quality switch for realtime filtering
  27503. */
  27504. get realTimeFilteringQuality(): number;
  27505. set realTimeFilteringQuality(n: number);
  27506. /**
  27507. * Can this material render to several textures at once
  27508. */
  27509. get canRenderToMRT(): boolean;
  27510. /**
  27511. * Force normal to face away from face.
  27512. */
  27513. protected _forceNormalForward: boolean;
  27514. /**
  27515. * Enables specular anti aliasing in the PBR shader.
  27516. * It will both interacts on the Geometry for analytical and IBL lighting.
  27517. * It also prefilter the roughness map based on the bump values.
  27518. */
  27519. protected _enableSpecularAntiAliasing: boolean;
  27520. /**
  27521. * Default configuration related to image processing available in the PBR Material.
  27522. */
  27523. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27524. /**
  27525. * Keep track of the image processing observer to allow dispose and replace.
  27526. */
  27527. private _imageProcessingObserver;
  27528. /**
  27529. * Attaches a new image processing configuration to the PBR Material.
  27530. * @param configuration
  27531. */
  27532. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27533. /**
  27534. * Stores the available render targets.
  27535. */
  27536. private _renderTargets;
  27537. /**
  27538. * Sets the global ambient color for the material used in lighting calculations.
  27539. */
  27540. private _globalAmbientColor;
  27541. /**
  27542. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27543. */
  27544. private _useLogarithmicDepth;
  27545. /**
  27546. * If set to true, no lighting calculations will be applied.
  27547. */
  27548. private _unlit;
  27549. private _debugMode;
  27550. /**
  27551. * @hidden
  27552. * This is reserved for the inspector.
  27553. * Defines the material debug mode.
  27554. * It helps seeing only some components of the material while troubleshooting.
  27555. */
  27556. debugMode: number;
  27557. /**
  27558. * @hidden
  27559. * This is reserved for the inspector.
  27560. * Specify from where on screen the debug mode should start.
  27561. * The value goes from -1 (full screen) to 1 (not visible)
  27562. * It helps with side by side comparison against the final render
  27563. * This defaults to -1
  27564. */
  27565. private debugLimit;
  27566. /**
  27567. * @hidden
  27568. * This is reserved for the inspector.
  27569. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27570. * You can use the factor to better multiply the final value.
  27571. */
  27572. private debugFactor;
  27573. /**
  27574. * Defines the clear coat layer parameters for the material.
  27575. */
  27576. readonly clearCoat: PBRClearCoatConfiguration;
  27577. /**
  27578. * Defines the anisotropic parameters for the material.
  27579. */
  27580. readonly anisotropy: PBRAnisotropicConfiguration;
  27581. /**
  27582. * Defines the BRDF parameters for the material.
  27583. */
  27584. readonly brdf: PBRBRDFConfiguration;
  27585. /**
  27586. * Defines the Sheen parameters for the material.
  27587. */
  27588. readonly sheen: PBRSheenConfiguration;
  27589. /**
  27590. * Defines the SubSurface parameters for the material.
  27591. */
  27592. readonly subSurface: PBRSubSurfaceConfiguration;
  27593. /**
  27594. * Defines additionnal PrePass parameters for the material.
  27595. */
  27596. readonly prePassConfiguration: PrePassConfiguration;
  27597. /**
  27598. * Defines the detail map parameters for the material.
  27599. */
  27600. readonly detailMap: DetailMapConfiguration;
  27601. protected _rebuildInParallel: boolean;
  27602. /**
  27603. * Instantiates a new PBRMaterial instance.
  27604. *
  27605. * @param name The material name
  27606. * @param scene The scene the material will be use in.
  27607. */
  27608. constructor(name: string, scene: Scene);
  27609. /**
  27610. * Gets a boolean indicating that current material needs to register RTT
  27611. */
  27612. get hasRenderTargetTextures(): boolean;
  27613. /**
  27614. * Gets the name of the material class.
  27615. */
  27616. getClassName(): string;
  27617. /**
  27618. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27619. */
  27620. get useLogarithmicDepth(): boolean;
  27621. /**
  27622. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27623. */
  27624. set useLogarithmicDepth(value: boolean);
  27625. /**
  27626. * Returns true if alpha blending should be disabled.
  27627. */
  27628. protected get _disableAlphaBlending(): boolean;
  27629. /**
  27630. * Specifies whether or not this material should be rendered in alpha blend mode.
  27631. */
  27632. needAlphaBlending(): boolean;
  27633. /**
  27634. * Specifies whether or not this material should be rendered in alpha test mode.
  27635. */
  27636. needAlphaTesting(): boolean;
  27637. /**
  27638. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27639. */
  27640. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27641. /**
  27642. * Gets the texture used for the alpha test.
  27643. */
  27644. getAlphaTestTexture(): Nullable<BaseTexture>;
  27645. /**
  27646. * Specifies that the submesh is ready to be used.
  27647. * @param mesh - BJS mesh.
  27648. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27649. * @param useInstances - Specifies that instances should be used.
  27650. * @returns - boolean indicating that the submesh is ready or not.
  27651. */
  27652. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27653. /**
  27654. * Specifies if the material uses metallic roughness workflow.
  27655. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27656. */
  27657. isMetallicWorkflow(): boolean;
  27658. private _prepareEffect;
  27659. private _prepareDefines;
  27660. /**
  27661. * Force shader compilation
  27662. */
  27663. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27664. /**
  27665. * Initializes the uniform buffer layout for the shader.
  27666. */
  27667. buildUniformLayout(): void;
  27668. /**
  27669. * Unbinds the material from the mesh
  27670. */
  27671. unbind(): void;
  27672. /**
  27673. * Binds the submesh data.
  27674. * @param world - The world matrix.
  27675. * @param mesh - The BJS mesh.
  27676. * @param subMesh - A submesh of the BJS mesh.
  27677. */
  27678. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27679. /**
  27680. * Returns the animatable textures.
  27681. * @returns - Array of animatable textures.
  27682. */
  27683. getAnimatables(): IAnimatable[];
  27684. /**
  27685. * Returns the texture used for reflections.
  27686. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27687. */
  27688. private _getReflectionTexture;
  27689. /**
  27690. * Returns an array of the actively used textures.
  27691. * @returns - Array of BaseTextures
  27692. */
  27693. getActiveTextures(): BaseTexture[];
  27694. /**
  27695. * Checks to see if a texture is used in the material.
  27696. * @param texture - Base texture to use.
  27697. * @returns - Boolean specifying if a texture is used in the material.
  27698. */
  27699. hasTexture(texture: BaseTexture): boolean;
  27700. /**
  27701. * Sets the required values to the prepass renderer.
  27702. * @param prePassRenderer defines the prepass renderer to setup
  27703. */
  27704. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27705. /**
  27706. * Disposes the resources of the material.
  27707. * @param forceDisposeEffect - Forces the disposal of effects.
  27708. * @param forceDisposeTextures - Forces the disposal of all textures.
  27709. */
  27710. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27711. }
  27712. }
  27713. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  27714. import { Nullable } from "babylonjs/types";
  27715. import { Scene } from "babylonjs/scene";
  27716. import { Color3 } from "babylonjs/Maths/math.color";
  27717. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  27718. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27719. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27720. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  27721. /**
  27722. * The Physically based material of BJS.
  27723. *
  27724. * This offers the main features of a standard PBR material.
  27725. * For more information, please refer to the documentation :
  27726. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27727. */
  27728. export class PBRMaterial extends PBRBaseMaterial {
  27729. /**
  27730. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27731. */
  27732. static readonly PBRMATERIAL_OPAQUE: number;
  27733. /**
  27734. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27735. */
  27736. static readonly PBRMATERIAL_ALPHATEST: number;
  27737. /**
  27738. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27739. */
  27740. static readonly PBRMATERIAL_ALPHABLEND: number;
  27741. /**
  27742. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27743. * They are also discarded below the alpha cutoff threshold to improve performances.
  27744. */
  27745. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27746. /**
  27747. * Defines the default value of how much AO map is occluding the analytical lights
  27748. * (point spot...).
  27749. */
  27750. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27751. /**
  27752. * Intensity of the direct lights e.g. the four lights available in your scene.
  27753. * This impacts both the direct diffuse and specular highlights.
  27754. */
  27755. directIntensity: number;
  27756. /**
  27757. * Intensity of the emissive part of the material.
  27758. * This helps controlling the emissive effect without modifying the emissive color.
  27759. */
  27760. emissiveIntensity: number;
  27761. /**
  27762. * Intensity of the environment e.g. how much the environment will light the object
  27763. * either through harmonics for rough material or through the refelction for shiny ones.
  27764. */
  27765. environmentIntensity: number;
  27766. /**
  27767. * This is a special control allowing the reduction of the specular highlights coming from the
  27768. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27769. */
  27770. specularIntensity: number;
  27771. /**
  27772. * Debug Control allowing disabling the bump map on this material.
  27773. */
  27774. disableBumpMap: boolean;
  27775. /**
  27776. * AKA Diffuse Texture in standard nomenclature.
  27777. */
  27778. albedoTexture: BaseTexture;
  27779. /**
  27780. * AKA Occlusion Texture in other nomenclature.
  27781. */
  27782. ambientTexture: BaseTexture;
  27783. /**
  27784. * AKA Occlusion Texture Intensity in other nomenclature.
  27785. */
  27786. ambientTextureStrength: number;
  27787. /**
  27788. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27789. * 1 means it completely occludes it
  27790. * 0 mean it has no impact
  27791. */
  27792. ambientTextureImpactOnAnalyticalLights: number;
  27793. /**
  27794. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27795. */
  27796. opacityTexture: BaseTexture;
  27797. /**
  27798. * Stores the reflection values in a texture.
  27799. */
  27800. reflectionTexture: Nullable<BaseTexture>;
  27801. /**
  27802. * Stores the emissive values in a texture.
  27803. */
  27804. emissiveTexture: BaseTexture;
  27805. /**
  27806. * AKA Specular texture in other nomenclature.
  27807. */
  27808. reflectivityTexture: BaseTexture;
  27809. /**
  27810. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27811. */
  27812. metallicTexture: BaseTexture;
  27813. /**
  27814. * Specifies the metallic scalar of the metallic/roughness workflow.
  27815. * Can also be used to scale the metalness values of the metallic texture.
  27816. */
  27817. metallic: Nullable<number>;
  27818. /**
  27819. * Specifies the roughness scalar of the metallic/roughness workflow.
  27820. * Can also be used to scale the roughness values of the metallic texture.
  27821. */
  27822. roughness: Nullable<number>;
  27823. /**
  27824. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27825. * By default the indexOfrefraction is used to compute F0;
  27826. *
  27827. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27828. *
  27829. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27830. * F90 = metallicReflectanceColor;
  27831. */
  27832. metallicF0Factor: number;
  27833. /**
  27834. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27835. * By default the F90 is always 1;
  27836. *
  27837. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27838. *
  27839. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27840. * F90 = metallicReflectanceColor;
  27841. */
  27842. metallicReflectanceColor: Color3;
  27843. /**
  27844. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27845. * This is multiply against the scalar values defined in the material.
  27846. */
  27847. metallicReflectanceTexture: Nullable<BaseTexture>;
  27848. /**
  27849. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27850. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27851. */
  27852. microSurfaceTexture: BaseTexture;
  27853. /**
  27854. * Stores surface normal data used to displace a mesh in a texture.
  27855. */
  27856. bumpTexture: BaseTexture;
  27857. /**
  27858. * Stores the pre-calculated light information of a mesh in a texture.
  27859. */
  27860. lightmapTexture: BaseTexture;
  27861. /**
  27862. * Stores the refracted light information in a texture.
  27863. */
  27864. get refractionTexture(): Nullable<BaseTexture>;
  27865. set refractionTexture(value: Nullable<BaseTexture>);
  27866. /**
  27867. * The color of a material in ambient lighting.
  27868. */
  27869. ambientColor: Color3;
  27870. /**
  27871. * AKA Diffuse Color in other nomenclature.
  27872. */
  27873. albedoColor: Color3;
  27874. /**
  27875. * AKA Specular Color in other nomenclature.
  27876. */
  27877. reflectivityColor: Color3;
  27878. /**
  27879. * The color reflected from the material.
  27880. */
  27881. reflectionColor: Color3;
  27882. /**
  27883. * The color emitted from the material.
  27884. */
  27885. emissiveColor: Color3;
  27886. /**
  27887. * AKA Glossiness in other nomenclature.
  27888. */
  27889. microSurface: number;
  27890. /**
  27891. * Index of refraction of the material base layer.
  27892. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27893. *
  27894. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27895. *
  27896. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27897. */
  27898. get indexOfRefraction(): number;
  27899. set indexOfRefraction(value: number);
  27900. /**
  27901. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27902. */
  27903. get invertRefractionY(): boolean;
  27904. set invertRefractionY(value: boolean);
  27905. /**
  27906. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27907. * Materials half opaque for instance using refraction could benefit from this control.
  27908. */
  27909. get linkRefractionWithTransparency(): boolean;
  27910. set linkRefractionWithTransparency(value: boolean);
  27911. /**
  27912. * If true, the light map contains occlusion information instead of lighting info.
  27913. */
  27914. useLightmapAsShadowmap: boolean;
  27915. /**
  27916. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27917. */
  27918. useAlphaFromAlbedoTexture: boolean;
  27919. /**
  27920. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27921. */
  27922. forceAlphaTest: boolean;
  27923. /**
  27924. * Defines the alpha limits in alpha test mode.
  27925. */
  27926. alphaCutOff: number;
  27927. /**
  27928. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27929. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27930. */
  27931. useSpecularOverAlpha: boolean;
  27932. /**
  27933. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27934. */
  27935. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27936. /**
  27937. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27938. */
  27939. useRoughnessFromMetallicTextureAlpha: boolean;
  27940. /**
  27941. * Specifies if the metallic texture contains the roughness information in its green channel.
  27942. */
  27943. useRoughnessFromMetallicTextureGreen: boolean;
  27944. /**
  27945. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27946. */
  27947. useMetallnessFromMetallicTextureBlue: boolean;
  27948. /**
  27949. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27950. */
  27951. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27952. /**
  27953. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27954. */
  27955. useAmbientInGrayScale: boolean;
  27956. /**
  27957. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27958. * The material will try to infer what glossiness each pixel should be.
  27959. */
  27960. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27961. /**
  27962. * BJS is using an harcoded light falloff based on a manually sets up range.
  27963. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27964. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27965. */
  27966. get usePhysicalLightFalloff(): boolean;
  27967. /**
  27968. * BJS is using an harcoded light falloff based on a manually sets up range.
  27969. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27970. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27971. */
  27972. set usePhysicalLightFalloff(value: boolean);
  27973. /**
  27974. * In order to support the falloff compatibility with gltf, a special mode has been added
  27975. * to reproduce the gltf light falloff.
  27976. */
  27977. get useGLTFLightFalloff(): boolean;
  27978. /**
  27979. * In order to support the falloff compatibility with gltf, a special mode has been added
  27980. * to reproduce the gltf light falloff.
  27981. */
  27982. set useGLTFLightFalloff(value: boolean);
  27983. /**
  27984. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27985. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27986. */
  27987. useRadianceOverAlpha: boolean;
  27988. /**
  27989. * Allows using an object space normal map (instead of tangent space).
  27990. */
  27991. useObjectSpaceNormalMap: boolean;
  27992. /**
  27993. * Allows using the bump map in parallax mode.
  27994. */
  27995. useParallax: boolean;
  27996. /**
  27997. * Allows using the bump map in parallax occlusion mode.
  27998. */
  27999. useParallaxOcclusion: boolean;
  28000. /**
  28001. * Controls the scale bias of the parallax mode.
  28002. */
  28003. parallaxScaleBias: number;
  28004. /**
  28005. * If sets to true, disables all the lights affecting the material.
  28006. */
  28007. disableLighting: boolean;
  28008. /**
  28009. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  28010. */
  28011. forceIrradianceInFragment: boolean;
  28012. /**
  28013. * Number of Simultaneous lights allowed on the material.
  28014. */
  28015. maxSimultaneousLights: number;
  28016. /**
  28017. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28018. */
  28019. invertNormalMapX: boolean;
  28020. /**
  28021. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28022. */
  28023. invertNormalMapY: boolean;
  28024. /**
  28025. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28026. */
  28027. twoSidedLighting: boolean;
  28028. /**
  28029. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28030. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  28031. */
  28032. useAlphaFresnel: boolean;
  28033. /**
  28034. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28035. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  28036. */
  28037. useLinearAlphaFresnel: boolean;
  28038. /**
  28039. * Let user defines the brdf lookup texture used for IBL.
  28040. * A default 8bit version is embedded but you could point at :
  28041. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  28042. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  28043. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  28044. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  28045. */
  28046. environmentBRDFTexture: Nullable<BaseTexture>;
  28047. /**
  28048. * Force normal to face away from face.
  28049. */
  28050. forceNormalForward: boolean;
  28051. /**
  28052. * Enables specular anti aliasing in the PBR shader.
  28053. * It will both interacts on the Geometry for analytical and IBL lighting.
  28054. * It also prefilter the roughness map based on the bump values.
  28055. */
  28056. enableSpecularAntiAliasing: boolean;
  28057. /**
  28058. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28059. * makes the reflect vector face the model (under horizon).
  28060. */
  28061. useHorizonOcclusion: boolean;
  28062. /**
  28063. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28064. * too much the area relying on ambient texture to define their ambient occlusion.
  28065. */
  28066. useRadianceOcclusion: boolean;
  28067. /**
  28068. * If set to true, no lighting calculations will be applied.
  28069. */
  28070. unlit: boolean;
  28071. /**
  28072. * Gets the image processing configuration used either in this material.
  28073. */
  28074. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28075. /**
  28076. * Sets the Default image processing configuration used either in the this material.
  28077. *
  28078. * If sets to null, the scene one is in use.
  28079. */
  28080. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28081. /**
  28082. * Gets wether the color curves effect is enabled.
  28083. */
  28084. get cameraColorCurvesEnabled(): boolean;
  28085. /**
  28086. * Sets wether the color curves effect is enabled.
  28087. */
  28088. set cameraColorCurvesEnabled(value: boolean);
  28089. /**
  28090. * Gets wether the color grading effect is enabled.
  28091. */
  28092. get cameraColorGradingEnabled(): boolean;
  28093. /**
  28094. * Gets wether the color grading effect is enabled.
  28095. */
  28096. set cameraColorGradingEnabled(value: boolean);
  28097. /**
  28098. * Gets wether tonemapping is enabled or not.
  28099. */
  28100. get cameraToneMappingEnabled(): boolean;
  28101. /**
  28102. * Sets wether tonemapping is enabled or not
  28103. */
  28104. set cameraToneMappingEnabled(value: boolean);
  28105. /**
  28106. * The camera exposure used on this material.
  28107. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28108. * This corresponds to a photographic exposure.
  28109. */
  28110. get cameraExposure(): number;
  28111. /**
  28112. * The camera exposure used on this material.
  28113. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28114. * This corresponds to a photographic exposure.
  28115. */
  28116. set cameraExposure(value: number);
  28117. /**
  28118. * Gets The camera contrast used on this material.
  28119. */
  28120. get cameraContrast(): number;
  28121. /**
  28122. * Sets The camera contrast used on this material.
  28123. */
  28124. set cameraContrast(value: number);
  28125. /**
  28126. * Gets the Color Grading 2D Lookup Texture.
  28127. */
  28128. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28129. /**
  28130. * Sets the Color Grading 2D Lookup Texture.
  28131. */
  28132. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28133. /**
  28134. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28135. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28136. * 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;
  28137. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28138. */
  28139. get cameraColorCurves(): Nullable<ColorCurves>;
  28140. /**
  28141. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28142. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28143. * 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;
  28144. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28145. */
  28146. set cameraColorCurves(value: Nullable<ColorCurves>);
  28147. /**
  28148. * Instantiates a new PBRMaterial instance.
  28149. *
  28150. * @param name The material name
  28151. * @param scene The scene the material will be use in.
  28152. */
  28153. constructor(name: string, scene: Scene);
  28154. /**
  28155. * Returns the name of this material class.
  28156. */
  28157. getClassName(): string;
  28158. /**
  28159. * Makes a duplicate of the current material.
  28160. * @param name - name to use for the new material.
  28161. */
  28162. clone(name: string): PBRMaterial;
  28163. /**
  28164. * Serializes this PBR Material.
  28165. * @returns - An object with the serialized material.
  28166. */
  28167. serialize(): any;
  28168. /**
  28169. * Parses a PBR Material from a serialized object.
  28170. * @param source - Serialized object.
  28171. * @param scene - BJS scene instance.
  28172. * @param rootUrl - url for the scene object
  28173. * @returns - PBRMaterial
  28174. */
  28175. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28176. }
  28177. }
  28178. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28179. /** @hidden */
  28180. export var mrtFragmentDeclaration: {
  28181. name: string;
  28182. shader: string;
  28183. };
  28184. }
  28185. declare module "babylonjs/Shaders/geometry.fragment" {
  28186. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28187. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28188. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28189. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28190. /** @hidden */
  28191. export var geometryPixelShader: {
  28192. name: string;
  28193. shader: string;
  28194. };
  28195. }
  28196. declare module "babylonjs/Shaders/geometry.vertex" {
  28197. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28198. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28199. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28200. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28201. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28202. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28203. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28204. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28205. /** @hidden */
  28206. export var geometryVertexShader: {
  28207. name: string;
  28208. shader: string;
  28209. };
  28210. }
  28211. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28212. import { Matrix } from "babylonjs/Maths/math.vector";
  28213. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28214. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28215. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28216. import { Effect } from "babylonjs/Materials/effect";
  28217. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28218. import { Scene } from "babylonjs/scene";
  28219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28220. import { Nullable } from "babylonjs/types";
  28221. import "babylonjs/Shaders/geometry.fragment";
  28222. import "babylonjs/Shaders/geometry.vertex";
  28223. /** @hidden */
  28224. interface ISavedTransformationMatrix {
  28225. world: Matrix;
  28226. viewProjection: Matrix;
  28227. }
  28228. /**
  28229. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28230. */
  28231. export class GeometryBufferRenderer {
  28232. /**
  28233. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28234. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28235. */
  28236. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28237. /**
  28238. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28239. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28240. */
  28241. static readonly POSITION_TEXTURE_TYPE: number;
  28242. /**
  28243. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28244. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28245. */
  28246. static readonly VELOCITY_TEXTURE_TYPE: number;
  28247. /**
  28248. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28249. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28250. */
  28251. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28252. /**
  28253. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28254. * in order to compute objects velocities when enableVelocity is set to "true"
  28255. * @hidden
  28256. */
  28257. _previousTransformationMatrices: {
  28258. [index: number]: ISavedTransformationMatrix;
  28259. };
  28260. /**
  28261. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28262. * in order to compute objects velocities when enableVelocity is set to "true"
  28263. * @hidden
  28264. */
  28265. _previousBonesTransformationMatrices: {
  28266. [index: number]: Float32Array;
  28267. };
  28268. /**
  28269. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28270. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28271. */
  28272. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28273. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28274. renderTransparentMeshes: boolean;
  28275. private _scene;
  28276. private _resizeObserver;
  28277. private _multiRenderTarget;
  28278. private _ratio;
  28279. private _enablePosition;
  28280. private _enableVelocity;
  28281. private _enableReflectivity;
  28282. private _positionIndex;
  28283. private _velocityIndex;
  28284. private _reflectivityIndex;
  28285. private _depthNormalIndex;
  28286. private _linkedWithPrePass;
  28287. private _prePassRenderer;
  28288. private _attachments;
  28289. protected _effect: Effect;
  28290. protected _cachedDefines: string;
  28291. /**
  28292. * @hidden
  28293. * Sets up internal structures to share outputs with PrePassRenderer
  28294. * This method should only be called by the PrePassRenderer itself
  28295. */
  28296. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28297. /**
  28298. * @hidden
  28299. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28300. * This method should only be called by the PrePassRenderer itself
  28301. */
  28302. _unlinkPrePassRenderer(): void;
  28303. /**
  28304. * @hidden
  28305. * Resets the geometry buffer layout
  28306. */
  28307. _resetLayout(): void;
  28308. /**
  28309. * @hidden
  28310. * Replaces a texture in the geometry buffer renderer
  28311. * Useful when linking textures of the prepass renderer
  28312. */
  28313. _forceTextureType(geometryBufferType: number, index: number): void;
  28314. /**
  28315. * @hidden
  28316. * Sets texture attachments
  28317. * Useful when linking textures of the prepass renderer
  28318. */
  28319. _setAttachments(attachments: number[]): void;
  28320. /**
  28321. * @hidden
  28322. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28323. * Useful when linking textures of the prepass renderer
  28324. */
  28325. _linkInternalTexture(internalTexture: InternalTexture): void;
  28326. /**
  28327. * Gets the render list (meshes to be rendered) used in the G buffer.
  28328. */
  28329. get renderList(): Nullable<AbstractMesh[]>;
  28330. /**
  28331. * Set the render list (meshes to be rendered) used in the G buffer.
  28332. */
  28333. set renderList(meshes: Nullable<AbstractMesh[]>);
  28334. /**
  28335. * Gets wether or not G buffer are supported by the running hardware.
  28336. * This requires draw buffer supports
  28337. */
  28338. get isSupported(): boolean;
  28339. /**
  28340. * Returns the index of the given texture type in the G-Buffer textures array
  28341. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28342. * @returns the index of the given texture type in the G-Buffer textures array
  28343. */
  28344. getTextureIndex(textureType: number): number;
  28345. /**
  28346. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28347. */
  28348. get enablePosition(): boolean;
  28349. /**
  28350. * Sets whether or not objects positions are enabled for the G buffer.
  28351. */
  28352. set enablePosition(enable: boolean);
  28353. /**
  28354. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28355. */
  28356. get enableVelocity(): boolean;
  28357. /**
  28358. * Sets wether or not objects velocities are enabled for the G buffer.
  28359. */
  28360. set enableVelocity(enable: boolean);
  28361. /**
  28362. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28363. */
  28364. get enableReflectivity(): boolean;
  28365. /**
  28366. * Sets wether or not objects roughness are enabled for the G buffer.
  28367. */
  28368. set enableReflectivity(enable: boolean);
  28369. /**
  28370. * Gets the scene associated with the buffer.
  28371. */
  28372. get scene(): Scene;
  28373. /**
  28374. * Gets the ratio used by the buffer during its creation.
  28375. * How big is the buffer related to the main canvas.
  28376. */
  28377. get ratio(): number;
  28378. /** @hidden */
  28379. static _SceneComponentInitialization: (scene: Scene) => void;
  28380. /**
  28381. * Creates a new G Buffer for the scene
  28382. * @param scene The scene the buffer belongs to
  28383. * @param ratio How big is the buffer related to the main canvas.
  28384. */
  28385. constructor(scene: Scene, ratio?: number);
  28386. /**
  28387. * Checks wether everything is ready to render a submesh to the G buffer.
  28388. * @param subMesh the submesh to check readiness for
  28389. * @param useInstances is the mesh drawn using instance or not
  28390. * @returns true if ready otherwise false
  28391. */
  28392. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28393. /**
  28394. * Gets the current underlying G Buffer.
  28395. * @returns the buffer
  28396. */
  28397. getGBuffer(): MultiRenderTarget;
  28398. /**
  28399. * Gets the number of samples used to render the buffer (anti aliasing).
  28400. */
  28401. get samples(): number;
  28402. /**
  28403. * Sets the number of samples used to render the buffer (anti aliasing).
  28404. */
  28405. set samples(value: number);
  28406. /**
  28407. * Disposes the renderer and frees up associated resources.
  28408. */
  28409. dispose(): void;
  28410. private _assignRenderTargetIndices;
  28411. protected _createRenderTargets(): void;
  28412. private _copyBonesTransformationMatrices;
  28413. }
  28414. }
  28415. declare module "babylonjs/Rendering/prePassRenderer" {
  28416. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28417. import { Scene } from "babylonjs/scene";
  28418. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28419. import { Effect } from "babylonjs/Materials/effect";
  28420. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28422. import { Material } from "babylonjs/Materials/material";
  28423. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28424. /**
  28425. * Renders a pre pass of the scene
  28426. * This means every mesh in the scene will be rendered to a render target texture
  28427. * And then this texture will be composited to the rendering canvas with post processes
  28428. * It is necessary for effects like subsurface scattering or deferred shading
  28429. */
  28430. export class PrePassRenderer {
  28431. /** @hidden */
  28432. static _SceneComponentInitialization: (scene: Scene) => void;
  28433. private _textureFormats;
  28434. /**
  28435. * To save performance, we can excluded skinned meshes from the prepass
  28436. */
  28437. excludedSkinnedMesh: AbstractMesh[];
  28438. /**
  28439. * Force material to be excluded from the prepass
  28440. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28441. * and you don't want a material to show in the effect.
  28442. */
  28443. excludedMaterials: Material[];
  28444. private _textureIndices;
  28445. private _scene;
  28446. private _engine;
  28447. private _isDirty;
  28448. /**
  28449. * Number of textures in the multi render target texture where the scene is directly rendered
  28450. */
  28451. mrtCount: number;
  28452. /**
  28453. * The render target where the scene is directly rendered
  28454. */
  28455. prePassRT: MultiRenderTarget;
  28456. private _multiRenderAttachments;
  28457. private _defaultAttachments;
  28458. private _clearAttachments;
  28459. private _postProcesses;
  28460. private readonly _clearColor;
  28461. /**
  28462. * Image processing post process for composition
  28463. */
  28464. imageProcessingPostProcess: ImageProcessingPostProcess;
  28465. /**
  28466. * Configuration for prepass effects
  28467. */
  28468. private _effectConfigurations;
  28469. private _mrtFormats;
  28470. private _mrtLayout;
  28471. private _enabled;
  28472. /**
  28473. * Indicates if the prepass is enabled
  28474. */
  28475. get enabled(): boolean;
  28476. /**
  28477. * How many samples are used for MSAA of the scene render target
  28478. */
  28479. get samples(): number;
  28480. set samples(n: number);
  28481. private _geometryBuffer;
  28482. private _useGeometryBufferFallback;
  28483. /**
  28484. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28485. */
  28486. get useGeometryBufferFallback(): boolean;
  28487. set useGeometryBufferFallback(value: boolean);
  28488. /**
  28489. * Instanciates a prepass renderer
  28490. * @param scene The scene
  28491. */
  28492. constructor(scene: Scene);
  28493. private _initializeAttachments;
  28494. private _createCompositionEffect;
  28495. /**
  28496. * Indicates if rendering a prepass is supported
  28497. */
  28498. get isSupported(): boolean;
  28499. /**
  28500. * Sets the proper output textures to draw in the engine.
  28501. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28502. * @param subMesh Submesh on which the effect is applied
  28503. */
  28504. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28505. /**
  28506. * @hidden
  28507. */
  28508. _beforeCameraDraw(): void;
  28509. /**
  28510. * @hidden
  28511. */
  28512. _afterCameraDraw(): void;
  28513. private _checkRTSize;
  28514. private _bindFrameBuffer;
  28515. /**
  28516. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28517. */
  28518. clear(): void;
  28519. private _setState;
  28520. private _updateGeometryBufferLayout;
  28521. /**
  28522. * Adds an effect configuration to the prepass.
  28523. * If an effect has already been added, it won't add it twice and will return the configuration
  28524. * already present.
  28525. * @param cfg the effect configuration
  28526. * @return the effect configuration now used by the prepass
  28527. */
  28528. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28529. /**
  28530. * Returns the index of a texture in the multi render target texture array.
  28531. * @param type Texture type
  28532. * @return The index
  28533. */
  28534. getIndex(type: number): number;
  28535. private _enable;
  28536. private _disable;
  28537. private _resetLayout;
  28538. private _resetPostProcessChain;
  28539. private _bindPostProcessChain;
  28540. /**
  28541. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28542. */
  28543. markAsDirty(): void;
  28544. /**
  28545. * Enables a texture on the MultiRenderTarget for prepass
  28546. */
  28547. private _enableTextures;
  28548. private _update;
  28549. private _markAllMaterialsAsPrePassDirty;
  28550. /**
  28551. * Disposes the prepass renderer.
  28552. */
  28553. dispose(): void;
  28554. }
  28555. }
  28556. declare module "babylonjs/PostProcesses/postProcess" {
  28557. import { Nullable } from "babylonjs/types";
  28558. import { SmartArray } from "babylonjs/Misc/smartArray";
  28559. import { Observable } from "babylonjs/Misc/observable";
  28560. import { Vector2 } from "babylonjs/Maths/math.vector";
  28561. import { Camera } from "babylonjs/Cameras/camera";
  28562. import { Effect } from "babylonjs/Materials/effect";
  28563. import "babylonjs/Shaders/postprocess.vertex";
  28564. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28565. import { Engine } from "babylonjs/Engines/engine";
  28566. import { Color4 } from "babylonjs/Maths/math.color";
  28567. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28568. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28569. import { Scene } from "babylonjs/scene";
  28570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28571. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28572. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28573. /**
  28574. * Size options for a post process
  28575. */
  28576. export type PostProcessOptions = {
  28577. width: number;
  28578. height: number;
  28579. };
  28580. /**
  28581. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28582. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28583. */
  28584. export class PostProcess {
  28585. /**
  28586. * Gets or sets the unique id of the post process
  28587. */
  28588. uniqueId: number;
  28589. /** Name of the PostProcess. */
  28590. name: string;
  28591. /**
  28592. * Width of the texture to apply the post process on
  28593. */
  28594. width: number;
  28595. /**
  28596. * Height of the texture to apply the post process on
  28597. */
  28598. height: number;
  28599. /**
  28600. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28601. */
  28602. nodeMaterialSource: Nullable<NodeMaterial>;
  28603. /**
  28604. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28605. * @hidden
  28606. */
  28607. _outputTexture: Nullable<InternalTexture>;
  28608. /**
  28609. * Sampling mode used by the shader
  28610. * See https://doc.babylonjs.com/classes/3.1/texture
  28611. */
  28612. renderTargetSamplingMode: number;
  28613. /**
  28614. * Clear color to use when screen clearing
  28615. */
  28616. clearColor: Color4;
  28617. /**
  28618. * If the buffer needs to be cleared before applying the post process. (default: true)
  28619. * Should be set to false if shader will overwrite all previous pixels.
  28620. */
  28621. autoClear: boolean;
  28622. /**
  28623. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28624. */
  28625. alphaMode: number;
  28626. /**
  28627. * Sets the setAlphaBlendConstants of the babylon engine
  28628. */
  28629. alphaConstants: Color4;
  28630. /**
  28631. * Animations to be used for the post processing
  28632. */
  28633. animations: import("babylonjs/Animations/animation").Animation[];
  28634. /**
  28635. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28636. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28637. */
  28638. enablePixelPerfectMode: boolean;
  28639. /**
  28640. * Force the postprocess to be applied without taking in account viewport
  28641. */
  28642. forceFullscreenViewport: boolean;
  28643. /**
  28644. * List of inspectable custom properties (used by the Inspector)
  28645. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28646. */
  28647. inspectableCustomProperties: IInspectable[];
  28648. /**
  28649. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28650. *
  28651. * | Value | Type | Description |
  28652. * | ----- | ----------------------------------- | ----------- |
  28653. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28654. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28655. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28656. *
  28657. */
  28658. scaleMode: number;
  28659. /**
  28660. * Force textures to be a power of two (default: false)
  28661. */
  28662. alwaysForcePOT: boolean;
  28663. private _samples;
  28664. /**
  28665. * Number of sample textures (default: 1)
  28666. */
  28667. get samples(): number;
  28668. set samples(n: number);
  28669. /**
  28670. * Modify the scale of the post process to be the same as the viewport (default: false)
  28671. */
  28672. adaptScaleToCurrentViewport: boolean;
  28673. private _camera;
  28674. protected _scene: Scene;
  28675. private _engine;
  28676. private _options;
  28677. private _reusable;
  28678. private _textureType;
  28679. private _textureFormat;
  28680. /**
  28681. * Smart array of input and output textures for the post process.
  28682. * @hidden
  28683. */
  28684. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28685. /**
  28686. * The index in _textures that corresponds to the output texture.
  28687. * @hidden
  28688. */
  28689. _currentRenderTextureInd: number;
  28690. private _effect;
  28691. private _samplers;
  28692. private _fragmentUrl;
  28693. private _vertexUrl;
  28694. private _parameters;
  28695. private _scaleRatio;
  28696. protected _indexParameters: any;
  28697. private _shareOutputWithPostProcess;
  28698. private _texelSize;
  28699. private _forcedOutputTexture;
  28700. /**
  28701. * Prepass configuration in case this post process needs a texture from prepass
  28702. * @hidden
  28703. */
  28704. _prePassEffectConfiguration: PrePassEffectConfiguration;
  28705. /**
  28706. * Returns the fragment url or shader name used in the post process.
  28707. * @returns the fragment url or name in the shader store.
  28708. */
  28709. getEffectName(): string;
  28710. /**
  28711. * An event triggered when the postprocess is activated.
  28712. */
  28713. onActivateObservable: Observable<Camera>;
  28714. private _onActivateObserver;
  28715. /**
  28716. * A function that is added to the onActivateObservable
  28717. */
  28718. set onActivate(callback: Nullable<(camera: Camera) => void>);
  28719. /**
  28720. * An event triggered when the postprocess changes its size.
  28721. */
  28722. onSizeChangedObservable: Observable<PostProcess>;
  28723. private _onSizeChangedObserver;
  28724. /**
  28725. * A function that is added to the onSizeChangedObservable
  28726. */
  28727. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  28728. /**
  28729. * An event triggered when the postprocess applies its effect.
  28730. */
  28731. onApplyObservable: Observable<Effect>;
  28732. private _onApplyObserver;
  28733. /**
  28734. * A function that is added to the onApplyObservable
  28735. */
  28736. set onApply(callback: (effect: Effect) => void);
  28737. /**
  28738. * An event triggered before rendering the postprocess
  28739. */
  28740. onBeforeRenderObservable: Observable<Effect>;
  28741. private _onBeforeRenderObserver;
  28742. /**
  28743. * A function that is added to the onBeforeRenderObservable
  28744. */
  28745. set onBeforeRender(callback: (effect: Effect) => void);
  28746. /**
  28747. * An event triggered after rendering the postprocess
  28748. */
  28749. onAfterRenderObservable: Observable<Effect>;
  28750. private _onAfterRenderObserver;
  28751. /**
  28752. * A function that is added to the onAfterRenderObservable
  28753. */
  28754. set onAfterRender(callback: (efect: Effect) => void);
  28755. /**
  28756. * 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
  28757. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  28758. */
  28759. get inputTexture(): InternalTexture;
  28760. set inputTexture(value: InternalTexture);
  28761. /**
  28762. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  28763. * the only way to unset it is to use this function to restore its internal state
  28764. */
  28765. restoreDefaultInputTexture(): void;
  28766. /**
  28767. * Gets the camera which post process is applied to.
  28768. * @returns The camera the post process is applied to.
  28769. */
  28770. getCamera(): Camera;
  28771. /**
  28772. * Gets the texel size of the postprocess.
  28773. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  28774. */
  28775. get texelSize(): Vector2;
  28776. /**
  28777. * Creates a new instance PostProcess
  28778. * @param name The name of the PostProcess.
  28779. * @param fragmentUrl The url of the fragment shader to be used.
  28780. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  28781. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  28782. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28783. * @param camera The camera to apply the render pass to.
  28784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28785. * @param engine The engine which the post process will be applied. (default: current engine)
  28786. * @param reusable If the post process can be reused on the same frame. (default: false)
  28787. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  28788. * @param textureType Type of textures used when performing the post process. (default: 0)
  28789. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  28790. * @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
  28791. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  28792. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  28793. */
  28794. 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);
  28795. /**
  28796. * Gets a string identifying the name of the class
  28797. * @returns "PostProcess" string
  28798. */
  28799. getClassName(): string;
  28800. /**
  28801. * Gets the engine which this post process belongs to.
  28802. * @returns The engine the post process was enabled with.
  28803. */
  28804. getEngine(): Engine;
  28805. /**
  28806. * The effect that is created when initializing the post process.
  28807. * @returns The created effect corresponding the the postprocess.
  28808. */
  28809. getEffect(): Effect;
  28810. /**
  28811. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  28812. * @param postProcess The post process to share the output with.
  28813. * @returns This post process.
  28814. */
  28815. shareOutputWith(postProcess: PostProcess): PostProcess;
  28816. /**
  28817. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28818. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28819. */
  28820. useOwnOutput(): void;
  28821. /**
  28822. * Updates the effect with the current post process compile time values and recompiles the shader.
  28823. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28824. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28825. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28826. * @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
  28827. * @param onCompiled Called when the shader has been compiled.
  28828. * @param onError Called if there is an error when compiling a shader.
  28829. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28830. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28831. */
  28832. 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;
  28833. /**
  28834. * The post process is reusable if it can be used multiple times within one frame.
  28835. * @returns If the post process is reusable
  28836. */
  28837. isReusable(): boolean;
  28838. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28839. markTextureDirty(): void;
  28840. /**
  28841. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28842. * 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.
  28843. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28844. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28845. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28846. * @returns The target texture that was bound to be written to.
  28847. */
  28848. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28849. /**
  28850. * If the post process is supported.
  28851. */
  28852. get isSupported(): boolean;
  28853. /**
  28854. * The aspect ratio of the output texture.
  28855. */
  28856. get aspectRatio(): number;
  28857. /**
  28858. * Get a value indicating if the post-process is ready to be used
  28859. * @returns true if the post-process is ready (shader is compiled)
  28860. */
  28861. isReady(): boolean;
  28862. /**
  28863. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28864. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28865. */
  28866. apply(): Nullable<Effect>;
  28867. private _disposeTextures;
  28868. /**
  28869. * Sets the required values to the prepass renderer.
  28870. * @param prePassRenderer defines the prepass renderer to setup.
  28871. * @returns true if the pre pass is needed.
  28872. */
  28873. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28874. /**
  28875. * Disposes the post process.
  28876. * @param camera The camera to dispose the post process on.
  28877. */
  28878. dispose(camera?: Camera): void;
  28879. /**
  28880. * Serializes the particle system to a JSON object
  28881. * @returns the JSON object
  28882. */
  28883. serialize(): any;
  28884. /**
  28885. * Creates a material from parsed material data
  28886. * @param parsedPostProcess defines parsed post process data
  28887. * @param scene defines the hosting scene
  28888. * @param rootUrl defines the root URL to use to load textures
  28889. * @returns a new post process
  28890. */
  28891. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28892. }
  28893. }
  28894. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  28895. /** @hidden */
  28896. export var kernelBlurVaryingDeclaration: {
  28897. name: string;
  28898. shader: string;
  28899. };
  28900. }
  28901. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  28902. /** @hidden */
  28903. export var kernelBlurFragment: {
  28904. name: string;
  28905. shader: string;
  28906. };
  28907. }
  28908. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  28909. /** @hidden */
  28910. export var kernelBlurFragment2: {
  28911. name: string;
  28912. shader: string;
  28913. };
  28914. }
  28915. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  28916. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28917. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28918. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  28919. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  28920. /** @hidden */
  28921. export var kernelBlurPixelShader: {
  28922. name: string;
  28923. shader: string;
  28924. };
  28925. }
  28926. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  28927. /** @hidden */
  28928. export var kernelBlurVertex: {
  28929. name: string;
  28930. shader: string;
  28931. };
  28932. }
  28933. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  28934. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  28935. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  28936. /** @hidden */
  28937. export var kernelBlurVertexShader: {
  28938. name: string;
  28939. shader: string;
  28940. };
  28941. }
  28942. declare module "babylonjs/PostProcesses/blurPostProcess" {
  28943. import { Vector2 } from "babylonjs/Maths/math.vector";
  28944. import { Nullable } from "babylonjs/types";
  28945. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  28946. import { Camera } from "babylonjs/Cameras/camera";
  28947. import { Effect } from "babylonjs/Materials/effect";
  28948. import { Engine } from "babylonjs/Engines/engine";
  28949. import "babylonjs/Shaders/kernelBlur.fragment";
  28950. import "babylonjs/Shaders/kernelBlur.vertex";
  28951. import { Scene } from "babylonjs/scene";
  28952. /**
  28953. * The Blur Post Process which blurs an image based on a kernel and direction.
  28954. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28955. */
  28956. export class BlurPostProcess extends PostProcess {
  28957. private blockCompilation;
  28958. protected _kernel: number;
  28959. protected _idealKernel: number;
  28960. protected _packedFloat: boolean;
  28961. private _staticDefines;
  28962. /** The direction in which to blur the image. */
  28963. direction: Vector2;
  28964. /**
  28965. * Sets the length in pixels of the blur sample region
  28966. */
  28967. set kernel(v: number);
  28968. /**
  28969. * Gets the length in pixels of the blur sample region
  28970. */
  28971. get kernel(): number;
  28972. /**
  28973. * Sets wether or not the blur needs to unpack/repack floats
  28974. */
  28975. set packedFloat(v: boolean);
  28976. /**
  28977. * Gets wether or not the blur is unpacking/repacking floats
  28978. */
  28979. get packedFloat(): boolean;
  28980. /**
  28981. * Gets a string identifying the name of the class
  28982. * @returns "BlurPostProcess" string
  28983. */
  28984. getClassName(): string;
  28985. /**
  28986. * Creates a new instance BlurPostProcess
  28987. * @param name The name of the effect.
  28988. * @param direction The direction in which to blur the image.
  28989. * @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.
  28990. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28991. * @param camera The camera to apply the render pass to.
  28992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28993. * @param engine The engine which the post process will be applied. (default: current engine)
  28994. * @param reusable If the post process can be reused on the same frame. (default: false)
  28995. * @param textureType Type of textures used when performing the post process. (default: 0)
  28996. * @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)
  28997. */
  28998. 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);
  28999. /**
  29000. * Updates the effect with the current post process compile time values and recompiles the shader.
  29001. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29002. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29003. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29004. * @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
  29005. * @param onCompiled Called when the shader has been compiled.
  29006. * @param onError Called if there is an error when compiling a shader.
  29007. */
  29008. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29009. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29010. /**
  29011. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  29012. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  29013. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  29014. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  29015. * The gaps between physical kernels are compensated for in the weighting of the samples
  29016. * @param idealKernel Ideal blur kernel.
  29017. * @return Nearest best kernel.
  29018. */
  29019. protected _nearestBestKernel(idealKernel: number): number;
  29020. /**
  29021. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  29022. * @param x The point on the Gaussian distribution to sample.
  29023. * @return the value of the Gaussian function at x.
  29024. */
  29025. protected _gaussianWeight(x: number): number;
  29026. /**
  29027. * Generates a string that can be used as a floating point number in GLSL.
  29028. * @param x Value to print.
  29029. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  29030. * @return GLSL float string.
  29031. */
  29032. protected _glslFloat(x: number, decimalFigures?: number): string;
  29033. /** @hidden */
  29034. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  29035. }
  29036. }
  29037. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  29038. import { Scene } from "babylonjs/scene";
  29039. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29040. import { Plane } from "babylonjs/Maths/math.plane";
  29041. /**
  29042. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29043. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29044. * You can then easily use it as a reflectionTexture on a flat surface.
  29045. * In case the surface is not a plane, please consider relying on reflection probes.
  29046. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29047. */
  29048. export class MirrorTexture extends RenderTargetTexture {
  29049. private scene;
  29050. /**
  29051. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  29052. * 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.
  29053. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29054. */
  29055. mirrorPlane: Plane;
  29056. /**
  29057. * Define the blur ratio used to blur the reflection if needed.
  29058. */
  29059. set blurRatio(value: number);
  29060. get blurRatio(): number;
  29061. /**
  29062. * Define the adaptive blur kernel used to blur the reflection if needed.
  29063. * This will autocompute the closest best match for the `blurKernel`
  29064. */
  29065. set adaptiveBlurKernel(value: number);
  29066. /**
  29067. * Define the blur kernel used to blur the reflection if needed.
  29068. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29069. */
  29070. set blurKernel(value: number);
  29071. /**
  29072. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29073. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29074. */
  29075. set blurKernelX(value: number);
  29076. get blurKernelX(): number;
  29077. /**
  29078. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29079. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29080. */
  29081. set blurKernelY(value: number);
  29082. get blurKernelY(): number;
  29083. private _autoComputeBlurKernel;
  29084. protected _onRatioRescale(): void;
  29085. private _updateGammaSpace;
  29086. private _imageProcessingConfigChangeObserver;
  29087. private _transformMatrix;
  29088. private _mirrorMatrix;
  29089. private _savedViewMatrix;
  29090. private _blurX;
  29091. private _blurY;
  29092. private _adaptiveBlurKernel;
  29093. private _blurKernelX;
  29094. private _blurKernelY;
  29095. private _blurRatio;
  29096. /**
  29097. * Instantiates a Mirror Texture.
  29098. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29099. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29100. * You can then easily use it as a reflectionTexture on a flat surface.
  29101. * In case the surface is not a plane, please consider relying on reflection probes.
  29102. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29103. * @param name
  29104. * @param size
  29105. * @param scene
  29106. * @param generateMipMaps
  29107. * @param type
  29108. * @param samplingMode
  29109. * @param generateDepthBuffer
  29110. */
  29111. constructor(name: string, size: number | {
  29112. width: number;
  29113. height: number;
  29114. } | {
  29115. ratio: number;
  29116. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29117. private _preparePostProcesses;
  29118. /**
  29119. * Clone the mirror texture.
  29120. * @returns the cloned texture
  29121. */
  29122. clone(): MirrorTexture;
  29123. /**
  29124. * Serialize the texture to a JSON representation you could use in Parse later on
  29125. * @returns the serialized JSON representation
  29126. */
  29127. serialize(): any;
  29128. /**
  29129. * Dispose the texture and release its associated resources.
  29130. */
  29131. dispose(): void;
  29132. }
  29133. }
  29134. declare module "babylonjs/Materials/Textures/texture" {
  29135. import { Observable } from "babylonjs/Misc/observable";
  29136. import { Nullable } from "babylonjs/types";
  29137. import { Matrix } from "babylonjs/Maths/math.vector";
  29138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29139. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29140. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29141. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29142. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29143. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29144. import { Scene } from "babylonjs/scene";
  29145. /**
  29146. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29147. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29148. */
  29149. export class Texture extends BaseTexture {
  29150. /**
  29151. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29152. */
  29153. static SerializeBuffers: boolean;
  29154. /** @hidden */
  29155. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29156. /** @hidden */
  29157. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29158. /** @hidden */
  29159. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29160. /** nearest is mag = nearest and min = nearest and mip = linear */
  29161. static readonly NEAREST_SAMPLINGMODE: number;
  29162. /** nearest is mag = nearest and min = nearest and mip = linear */
  29163. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29164. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29165. static readonly BILINEAR_SAMPLINGMODE: number;
  29166. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29167. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29168. /** Trilinear is mag = linear and min = linear and mip = linear */
  29169. static readonly TRILINEAR_SAMPLINGMODE: number;
  29170. /** Trilinear is mag = linear and min = linear and mip = linear */
  29171. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29172. /** mag = nearest and min = nearest and mip = nearest */
  29173. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29174. /** mag = nearest and min = linear and mip = nearest */
  29175. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29176. /** mag = nearest and min = linear and mip = linear */
  29177. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29178. /** mag = nearest and min = linear and mip = none */
  29179. static readonly NEAREST_LINEAR: number;
  29180. /** mag = nearest and min = nearest and mip = none */
  29181. static readonly NEAREST_NEAREST: number;
  29182. /** mag = linear and min = nearest and mip = nearest */
  29183. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29184. /** mag = linear and min = nearest and mip = linear */
  29185. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29186. /** mag = linear and min = linear and mip = none */
  29187. static readonly LINEAR_LINEAR: number;
  29188. /** mag = linear and min = nearest and mip = none */
  29189. static readonly LINEAR_NEAREST: number;
  29190. /** Explicit coordinates mode */
  29191. static readonly EXPLICIT_MODE: number;
  29192. /** Spherical coordinates mode */
  29193. static readonly SPHERICAL_MODE: number;
  29194. /** Planar coordinates mode */
  29195. static readonly PLANAR_MODE: number;
  29196. /** Cubic coordinates mode */
  29197. static readonly CUBIC_MODE: number;
  29198. /** Projection coordinates mode */
  29199. static readonly PROJECTION_MODE: number;
  29200. /** Inverse Cubic coordinates mode */
  29201. static readonly SKYBOX_MODE: number;
  29202. /** Inverse Cubic coordinates mode */
  29203. static readonly INVCUBIC_MODE: number;
  29204. /** Equirectangular coordinates mode */
  29205. static readonly EQUIRECTANGULAR_MODE: number;
  29206. /** Equirectangular Fixed coordinates mode */
  29207. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29208. /** Equirectangular Fixed Mirrored coordinates mode */
  29209. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29210. /** Texture is not repeating outside of 0..1 UVs */
  29211. static readonly CLAMP_ADDRESSMODE: number;
  29212. /** Texture is repeating outside of 0..1 UVs */
  29213. static readonly WRAP_ADDRESSMODE: number;
  29214. /** Texture is repeating and mirrored */
  29215. static readonly MIRROR_ADDRESSMODE: number;
  29216. /**
  29217. * 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
  29218. */
  29219. static UseSerializedUrlIfAny: boolean;
  29220. /**
  29221. * Define the url of the texture.
  29222. */
  29223. url: Nullable<string>;
  29224. /**
  29225. * Define an offset on the texture to offset the u coordinates of the UVs
  29226. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29227. */
  29228. uOffset: number;
  29229. /**
  29230. * Define an offset on the texture to offset the v coordinates of the UVs
  29231. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29232. */
  29233. vOffset: number;
  29234. /**
  29235. * Define an offset on the texture to scale the u coordinates of the UVs
  29236. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29237. */
  29238. uScale: number;
  29239. /**
  29240. * Define an offset on the texture to scale the v coordinates of the UVs
  29241. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29242. */
  29243. vScale: number;
  29244. /**
  29245. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29246. * @see https://doc.babylonjs.com/how_to/more_materials
  29247. */
  29248. uAng: number;
  29249. /**
  29250. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29251. * @see https://doc.babylonjs.com/how_to/more_materials
  29252. */
  29253. vAng: number;
  29254. /**
  29255. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29256. * @see https://doc.babylonjs.com/how_to/more_materials
  29257. */
  29258. wAng: number;
  29259. /**
  29260. * Defines the center of rotation (U)
  29261. */
  29262. uRotationCenter: number;
  29263. /**
  29264. * Defines the center of rotation (V)
  29265. */
  29266. vRotationCenter: number;
  29267. /**
  29268. * Defines the center of rotation (W)
  29269. */
  29270. wRotationCenter: number;
  29271. /**
  29272. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29273. */
  29274. homogeneousRotationInUVTransform: boolean;
  29275. /**
  29276. * Are mip maps generated for this texture or not.
  29277. */
  29278. get noMipmap(): boolean;
  29279. /**
  29280. * List of inspectable custom properties (used by the Inspector)
  29281. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29282. */
  29283. inspectableCustomProperties: Nullable<IInspectable[]>;
  29284. private _noMipmap;
  29285. /** @hidden */
  29286. _invertY: boolean;
  29287. private _rowGenerationMatrix;
  29288. private _cachedTextureMatrix;
  29289. private _projectionModeMatrix;
  29290. private _t0;
  29291. private _t1;
  29292. private _t2;
  29293. private _cachedUOffset;
  29294. private _cachedVOffset;
  29295. private _cachedUScale;
  29296. private _cachedVScale;
  29297. private _cachedUAng;
  29298. private _cachedVAng;
  29299. private _cachedWAng;
  29300. private _cachedProjectionMatrixId;
  29301. private _cachedURotationCenter;
  29302. private _cachedVRotationCenter;
  29303. private _cachedWRotationCenter;
  29304. private _cachedHomogeneousRotationInUVTransform;
  29305. private _cachedCoordinatesMode;
  29306. /** @hidden */
  29307. protected _initialSamplingMode: number;
  29308. /** @hidden */
  29309. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29310. private _deleteBuffer;
  29311. protected _format: Nullable<number>;
  29312. private _delayedOnLoad;
  29313. private _delayedOnError;
  29314. private _mimeType?;
  29315. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29316. get mimeType(): string | undefined;
  29317. /**
  29318. * Observable triggered once the texture has been loaded.
  29319. */
  29320. onLoadObservable: Observable<Texture>;
  29321. protected _isBlocking: boolean;
  29322. /**
  29323. * Is the texture preventing material to render while loading.
  29324. * If false, a default texture will be used instead of the loading one during the preparation step.
  29325. */
  29326. set isBlocking(value: boolean);
  29327. get isBlocking(): boolean;
  29328. /**
  29329. * Get the current sampling mode associated with the texture.
  29330. */
  29331. get samplingMode(): number;
  29332. /**
  29333. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29334. */
  29335. get invertY(): boolean;
  29336. /**
  29337. * Instantiates a new texture.
  29338. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29339. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29340. * @param url defines the url of the picture to load as a texture
  29341. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29342. * @param noMipmap defines if the texture will require mip maps or not
  29343. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29344. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29345. * @param onLoad defines a callback triggered when the texture has been loaded
  29346. * @param onError defines a callback triggered when an error occurred during the loading session
  29347. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29348. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29349. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29350. * @param mimeType defines an optional mime type information
  29351. */
  29352. 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);
  29353. /**
  29354. * Update the url (and optional buffer) of this texture if url was null during construction.
  29355. * @param url the url of the texture
  29356. * @param buffer the buffer of the texture (defaults to null)
  29357. * @param onLoad callback called when the texture is loaded (defaults to null)
  29358. */
  29359. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29360. /**
  29361. * Finish the loading sequence of a texture flagged as delayed load.
  29362. * @hidden
  29363. */
  29364. delayLoad(): void;
  29365. private _prepareRowForTextureGeneration;
  29366. /**
  29367. * Checks if the texture has the same transform matrix than another texture
  29368. * @param texture texture to check against
  29369. * @returns true if the transforms are the same, else false
  29370. */
  29371. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  29372. /**
  29373. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29374. * @returns the transform matrix of the texture.
  29375. */
  29376. getTextureMatrix(uBase?: number): Matrix;
  29377. /**
  29378. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29379. * @returns The reflection texture transform
  29380. */
  29381. getReflectionTextureMatrix(): Matrix;
  29382. /**
  29383. * Clones the texture.
  29384. * @returns the cloned texture
  29385. */
  29386. clone(): Texture;
  29387. /**
  29388. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29389. * @returns The JSON representation of the texture
  29390. */
  29391. serialize(): any;
  29392. /**
  29393. * Get the current class name of the texture useful for serialization or dynamic coding.
  29394. * @returns "Texture"
  29395. */
  29396. getClassName(): string;
  29397. /**
  29398. * Dispose the texture and release its associated resources.
  29399. */
  29400. dispose(): void;
  29401. /**
  29402. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29403. * @param parsedTexture Define the JSON representation of the texture
  29404. * @param scene Define the scene the parsed texture should be instantiated in
  29405. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29406. * @returns The parsed texture if successful
  29407. */
  29408. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29409. /**
  29410. * Creates a texture from its base 64 representation.
  29411. * @param data Define the base64 payload without the data: prefix
  29412. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29413. * @param scene Define the scene the texture should belong to
  29414. * @param noMipmap Forces the texture to not create mip map information if true
  29415. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29416. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29417. * @param onLoad define a callback triggered when the texture has been loaded
  29418. * @param onError define a callback triggered when an error occurred during the loading session
  29419. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29420. * @returns the created texture
  29421. */
  29422. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29423. /**
  29424. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29425. * @param data Define the base64 payload without the data: prefix
  29426. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29427. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29428. * @param scene Define the scene the texture should belong to
  29429. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29430. * @param noMipmap Forces the texture to not create mip map information if true
  29431. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29432. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29433. * @param onLoad define a callback triggered when the texture has been loaded
  29434. * @param onError define a callback triggered when an error occurred during the loading session
  29435. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29436. * @returns the created texture
  29437. */
  29438. 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;
  29439. }
  29440. }
  29441. declare module "babylonjs/PostProcesses/postProcessManager" {
  29442. import { Nullable } from "babylonjs/types";
  29443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29444. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29445. import { Scene } from "babylonjs/scene";
  29446. /**
  29447. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29448. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29449. */
  29450. export class PostProcessManager {
  29451. private _scene;
  29452. private _indexBuffer;
  29453. private _vertexBuffers;
  29454. /**
  29455. * Creates a new instance PostProcess
  29456. * @param scene The scene that the post process is associated with.
  29457. */
  29458. constructor(scene: Scene);
  29459. private _prepareBuffers;
  29460. private _buildIndexBuffer;
  29461. /**
  29462. * Rebuilds the vertex buffers of the manager.
  29463. * @hidden
  29464. */
  29465. _rebuild(): void;
  29466. /**
  29467. * Prepares a frame to be run through a post process.
  29468. * @param sourceTexture The input texture to the post procesess. (default: null)
  29469. * @param postProcesses An array of post processes to be run. (default: null)
  29470. * @returns True if the post processes were able to be run.
  29471. * @hidden
  29472. */
  29473. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29474. /**
  29475. * Manually render a set of post processes to a texture.
  29476. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29477. * @param postProcesses An array of post processes to be run.
  29478. * @param targetTexture The target texture to render to.
  29479. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29480. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29481. * @param lodLevel defines which lod of the texture to render to
  29482. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29483. */
  29484. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29485. /**
  29486. * Finalize the result of the output of the postprocesses.
  29487. * @param doNotPresent If true the result will not be displayed to the screen.
  29488. * @param targetTexture The target texture to render to.
  29489. * @param faceIndex The index of the face to bind the target texture to.
  29490. * @param postProcesses The array of post processes to render.
  29491. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29492. * @hidden
  29493. */
  29494. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29495. /**
  29496. * Disposes of the post process manager.
  29497. */
  29498. dispose(): void;
  29499. }
  29500. }
  29501. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29502. import { Observable } from "babylonjs/Misc/observable";
  29503. import { SmartArray } from "babylonjs/Misc/smartArray";
  29504. import { Nullable, Immutable } from "babylonjs/types";
  29505. import { Camera } from "babylonjs/Cameras/camera";
  29506. import { Scene } from "babylonjs/scene";
  29507. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29508. import { Color4 } from "babylonjs/Maths/math.color";
  29509. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29511. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29513. import { Texture } from "babylonjs/Materials/Textures/texture";
  29514. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29515. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29516. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29517. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29518. import { Engine } from "babylonjs/Engines/engine";
  29519. /**
  29520. * This Helps creating a texture that will be created from a camera in your scene.
  29521. * It is basically a dynamic texture that could be used to create special effects for instance.
  29522. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29523. */
  29524. export class RenderTargetTexture extends Texture {
  29525. /**
  29526. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29527. */
  29528. static readonly REFRESHRATE_RENDER_ONCE: number;
  29529. /**
  29530. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29531. */
  29532. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29533. /**
  29534. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29535. * the central point of your effect and can save a lot of performances.
  29536. */
  29537. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29538. /**
  29539. * Use this predicate to dynamically define the list of mesh you want to render.
  29540. * If set, the renderList property will be overwritten.
  29541. */
  29542. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29543. private _renderList;
  29544. /**
  29545. * Use this list to define the list of mesh you want to render.
  29546. */
  29547. get renderList(): Nullable<Array<AbstractMesh>>;
  29548. set renderList(value: Nullable<Array<AbstractMesh>>);
  29549. /**
  29550. * Use this function to overload the renderList array at rendering time.
  29551. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29552. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29553. * the cube (if the RTT is a cube, else layerOrFace=0).
  29554. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29555. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29556. * hold dummy elements!
  29557. */
  29558. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29559. private _hookArray;
  29560. /**
  29561. * Define if particles should be rendered in your texture.
  29562. */
  29563. renderParticles: boolean;
  29564. /**
  29565. * Define if sprites should be rendered in your texture.
  29566. */
  29567. renderSprites: boolean;
  29568. /**
  29569. * Define the camera used to render the texture.
  29570. */
  29571. activeCamera: Nullable<Camera>;
  29572. /**
  29573. * Override the mesh isReady function with your own one.
  29574. */
  29575. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29576. /**
  29577. * Override the render function of the texture with your own one.
  29578. */
  29579. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29580. /**
  29581. * Define if camera post processes should be use while rendering the texture.
  29582. */
  29583. useCameraPostProcesses: boolean;
  29584. /**
  29585. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29586. */
  29587. ignoreCameraViewport: boolean;
  29588. private _postProcessManager;
  29589. private _postProcesses;
  29590. private _resizeObserver;
  29591. /**
  29592. * An event triggered when the texture is unbind.
  29593. */
  29594. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29595. /**
  29596. * An event triggered when the texture is unbind.
  29597. */
  29598. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29599. private _onAfterUnbindObserver;
  29600. /**
  29601. * Set a after unbind callback in the texture.
  29602. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29603. */
  29604. set onAfterUnbind(callback: () => void);
  29605. /**
  29606. * An event triggered before rendering the texture
  29607. */
  29608. onBeforeRenderObservable: Observable<number>;
  29609. private _onBeforeRenderObserver;
  29610. /**
  29611. * Set a before render callback in the texture.
  29612. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29613. */
  29614. set onBeforeRender(callback: (faceIndex: number) => void);
  29615. /**
  29616. * An event triggered after rendering the texture
  29617. */
  29618. onAfterRenderObservable: Observable<number>;
  29619. private _onAfterRenderObserver;
  29620. /**
  29621. * Set a after render callback in the texture.
  29622. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29623. */
  29624. set onAfterRender(callback: (faceIndex: number) => void);
  29625. /**
  29626. * An event triggered after the texture clear
  29627. */
  29628. onClearObservable: Observable<Engine>;
  29629. private _onClearObserver;
  29630. /**
  29631. * Set a clear callback in the texture.
  29632. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29633. */
  29634. set onClear(callback: (Engine: Engine) => void);
  29635. /**
  29636. * An event triggered when the texture is resized.
  29637. */
  29638. onResizeObservable: Observable<RenderTargetTexture>;
  29639. /**
  29640. * Define the clear color of the Render Target if it should be different from the scene.
  29641. */
  29642. clearColor: Color4;
  29643. protected _size: number | {
  29644. width: number;
  29645. height: number;
  29646. layers?: number;
  29647. };
  29648. protected _initialSizeParameter: number | {
  29649. width: number;
  29650. height: number;
  29651. } | {
  29652. ratio: number;
  29653. };
  29654. protected _sizeRatio: Nullable<number>;
  29655. /** @hidden */
  29656. _generateMipMaps: boolean;
  29657. protected _renderingManager: RenderingManager;
  29658. /** @hidden */
  29659. _waitingRenderList?: string[];
  29660. protected _doNotChangeAspectRatio: boolean;
  29661. protected _currentRefreshId: number;
  29662. protected _refreshRate: number;
  29663. protected _textureMatrix: Matrix;
  29664. protected _samples: number;
  29665. protected _renderTargetOptions: RenderTargetCreationOptions;
  29666. /**
  29667. * Gets render target creation options that were used.
  29668. */
  29669. get renderTargetOptions(): RenderTargetCreationOptions;
  29670. protected _onRatioRescale(): void;
  29671. /**
  29672. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29673. * It must define where the camera used to render the texture is set
  29674. */
  29675. boundingBoxPosition: Vector3;
  29676. private _boundingBoxSize;
  29677. /**
  29678. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29679. * When defined, the cubemap will switch to local mode
  29680. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29681. * @example https://www.babylonjs-playground.com/#RNASML
  29682. */
  29683. set boundingBoxSize(value: Vector3);
  29684. get boundingBoxSize(): Vector3;
  29685. /**
  29686. * In case the RTT has been created with a depth texture, get the associated
  29687. * depth texture.
  29688. * Otherwise, return null.
  29689. */
  29690. get depthStencilTexture(): Nullable<InternalTexture>;
  29691. /**
  29692. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  29693. * or used a shadow, depth texture...
  29694. * @param name The friendly name of the texture
  29695. * @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)
  29696. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  29697. * @param generateMipMaps True if mip maps need to be generated after render.
  29698. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  29699. * @param type The type of the buffer in the RTT (int, half float, float...)
  29700. * @param isCube True if a cube texture needs to be created
  29701. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  29702. * @param generateDepthBuffer True to generate a depth buffer
  29703. * @param generateStencilBuffer True to generate a stencil buffer
  29704. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  29705. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  29706. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29707. */
  29708. constructor(name: string, size: number | {
  29709. width: number;
  29710. height: number;
  29711. layers?: number;
  29712. } | {
  29713. ratio: number;
  29714. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  29715. /**
  29716. * Creates a depth stencil texture.
  29717. * This is only available in WebGL 2 or with the depth texture extension available.
  29718. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  29719. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  29720. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  29721. */
  29722. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  29723. private _processSizeParameter;
  29724. /**
  29725. * Define the number of samples to use in case of MSAA.
  29726. * It defaults to one meaning no MSAA has been enabled.
  29727. */
  29728. get samples(): number;
  29729. set samples(value: number);
  29730. /**
  29731. * Resets the refresh counter of the texture and start bak from scratch.
  29732. * Could be useful to regenerate the texture if it is setup to render only once.
  29733. */
  29734. resetRefreshCounter(): void;
  29735. /**
  29736. * Define the refresh rate of the texture or the rendering frequency.
  29737. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  29738. */
  29739. get refreshRate(): number;
  29740. set refreshRate(value: number);
  29741. /**
  29742. * Adds a post process to the render target rendering passes.
  29743. * @param postProcess define the post process to add
  29744. */
  29745. addPostProcess(postProcess: PostProcess): void;
  29746. /**
  29747. * Clear all the post processes attached to the render target
  29748. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  29749. */
  29750. clearPostProcesses(dispose?: boolean): void;
  29751. /**
  29752. * Remove one of the post process from the list of attached post processes to the texture
  29753. * @param postProcess define the post process to remove from the list
  29754. */
  29755. removePostProcess(postProcess: PostProcess): void;
  29756. /** @hidden */
  29757. _shouldRender(): boolean;
  29758. /**
  29759. * Gets the actual render size of the texture.
  29760. * @returns the width of the render size
  29761. */
  29762. getRenderSize(): number;
  29763. /**
  29764. * Gets the actual render width of the texture.
  29765. * @returns the width of the render size
  29766. */
  29767. getRenderWidth(): number;
  29768. /**
  29769. * Gets the actual render height of the texture.
  29770. * @returns the height of the render size
  29771. */
  29772. getRenderHeight(): number;
  29773. /**
  29774. * Gets the actual number of layers of the texture.
  29775. * @returns the number of layers
  29776. */
  29777. getRenderLayers(): number;
  29778. /**
  29779. * Get if the texture can be rescaled or not.
  29780. */
  29781. get canRescale(): boolean;
  29782. /**
  29783. * Resize the texture using a ratio.
  29784. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  29785. */
  29786. scale(ratio: number): void;
  29787. /**
  29788. * Get the texture reflection matrix used to rotate/transform the reflection.
  29789. * @returns the reflection matrix
  29790. */
  29791. getReflectionTextureMatrix(): Matrix;
  29792. /**
  29793. * Resize the texture to a new desired size.
  29794. * Be carrefull as it will recreate all the data in the new texture.
  29795. * @param size Define the new size. It can be:
  29796. * - a number for squared texture,
  29797. * - an object containing { width: number, height: number }
  29798. * - or an object containing a ratio { ratio: number }
  29799. */
  29800. resize(size: number | {
  29801. width: number;
  29802. height: number;
  29803. } | {
  29804. ratio: number;
  29805. }): void;
  29806. private _defaultRenderListPrepared;
  29807. /**
  29808. * Renders all the objects from the render list into the texture.
  29809. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  29810. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  29811. */
  29812. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  29813. private _bestReflectionRenderTargetDimension;
  29814. private _prepareRenderingManager;
  29815. /**
  29816. * @hidden
  29817. * @param faceIndex face index to bind to if this is a cubetexture
  29818. * @param layer defines the index of the texture to bind in the array
  29819. */
  29820. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  29821. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  29822. private renderToTarget;
  29823. /**
  29824. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29825. * This allowed control for front to back rendering or reversly depending of the special needs.
  29826. *
  29827. * @param renderingGroupId The rendering group id corresponding to its index
  29828. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29829. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29830. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29831. */
  29832. 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;
  29833. /**
  29834. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29835. *
  29836. * @param renderingGroupId The rendering group id corresponding to its index
  29837. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29838. */
  29839. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  29840. /**
  29841. * Clones the texture.
  29842. * @returns the cloned texture
  29843. */
  29844. clone(): RenderTargetTexture;
  29845. /**
  29846. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29847. * @returns The JSON representation of the texture
  29848. */
  29849. serialize(): any;
  29850. /**
  29851. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  29852. */
  29853. disposeFramebufferObjects(): void;
  29854. /**
  29855. * Dispose the texture and release its associated resources.
  29856. */
  29857. dispose(): void;
  29858. /** @hidden */
  29859. _rebuild(): void;
  29860. /**
  29861. * Clear the info related to rendering groups preventing retention point in material dispose.
  29862. */
  29863. freeRenderingGroups(): void;
  29864. /**
  29865. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29866. * @returns the view count
  29867. */
  29868. getViewCount(): number;
  29869. }
  29870. }
  29871. declare module "babylonjs/Misc/guid" {
  29872. /**
  29873. * Class used to manipulate GUIDs
  29874. */
  29875. export class GUID {
  29876. /**
  29877. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29878. * Be aware Math.random() could cause collisions, but:
  29879. * "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"
  29880. * @returns a pseudo random id
  29881. */
  29882. static RandomId(): string;
  29883. }
  29884. }
  29885. declare module "babylonjs/Materials/shadowDepthWrapper" {
  29886. import { Nullable } from "babylonjs/types";
  29887. import { Scene } from "babylonjs/scene";
  29888. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29889. import { Material } from "babylonjs/Materials/material";
  29890. import { Effect } from "babylonjs/Materials/effect";
  29891. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  29892. /**
  29893. * Options to be used when creating a shadow depth material
  29894. */
  29895. export interface IIOptionShadowDepthMaterial {
  29896. /** Variables in the vertex shader code that need to have their names remapped.
  29897. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29898. * "var_name" should be either: worldPos or vNormalW
  29899. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29900. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29901. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29902. */
  29903. remappedVariables?: string[];
  29904. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29905. standalone?: boolean;
  29906. }
  29907. /**
  29908. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29909. */
  29910. export class ShadowDepthWrapper {
  29911. private _scene;
  29912. private _options?;
  29913. private _baseMaterial;
  29914. private _onEffectCreatedObserver;
  29915. private _subMeshToEffect;
  29916. private _subMeshToDepthEffect;
  29917. private _meshes;
  29918. /** @hidden */
  29919. _matriceNames: any;
  29920. /** Gets the standalone status of the wrapper */
  29921. get standalone(): boolean;
  29922. /** Gets the base material the wrapper is built upon */
  29923. get baseMaterial(): Material;
  29924. /**
  29925. * Instantiate a new shadow depth wrapper.
  29926. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29927. * generate the shadow depth map. For more information, please refer to the documentation:
  29928. * https://doc.babylonjs.com/babylon101/shadows
  29929. * @param baseMaterial Material to wrap
  29930. * @param scene Define the scene the material belongs to
  29931. * @param options Options used to create the wrapper
  29932. */
  29933. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29934. /**
  29935. * Gets the effect to use to generate the depth map
  29936. * @param subMesh subMesh to get the effect for
  29937. * @param shadowGenerator shadow generator to get the effect for
  29938. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29939. */
  29940. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29941. /**
  29942. * Specifies that the submesh is ready to be used for depth rendering
  29943. * @param subMesh submesh to check
  29944. * @param defines the list of defines to take into account when checking the effect
  29945. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29946. * @param useInstances specifies that instances should be used
  29947. * @returns a boolean indicating that the submesh is ready or not
  29948. */
  29949. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29950. /**
  29951. * Disposes the resources
  29952. */
  29953. dispose(): void;
  29954. private _makeEffect;
  29955. }
  29956. }
  29957. declare module "babylonjs/Materials/material" {
  29958. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29959. import { SmartArray } from "babylonjs/Misc/smartArray";
  29960. import { Observable } from "babylonjs/Misc/observable";
  29961. import { Nullable } from "babylonjs/types";
  29962. import { Scene } from "babylonjs/scene";
  29963. import { Matrix } from "babylonjs/Maths/math.vector";
  29964. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29966. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29967. import { Effect } from "babylonjs/Materials/effect";
  29968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29969. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29970. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29971. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29972. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  29973. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  29974. import { Mesh } from "babylonjs/Meshes/mesh";
  29975. import { Animation } from "babylonjs/Animations/animation";
  29976. /**
  29977. * Options for compiling materials.
  29978. */
  29979. export interface IMaterialCompilationOptions {
  29980. /**
  29981. * Defines whether clip planes are enabled.
  29982. */
  29983. clipPlane: boolean;
  29984. /**
  29985. * Defines whether instances are enabled.
  29986. */
  29987. useInstances: boolean;
  29988. }
  29989. /**
  29990. * Options passed when calling customShaderNameResolve
  29991. */
  29992. export interface ICustomShaderNameResolveOptions {
  29993. /**
  29994. * 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
  29995. */
  29996. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29997. }
  29998. /**
  29999. * Base class for the main features of a material in Babylon.js
  30000. */
  30001. export class Material implements IAnimatable {
  30002. /**
  30003. * Returns the triangle fill mode
  30004. */
  30005. static readonly TriangleFillMode: number;
  30006. /**
  30007. * Returns the wireframe mode
  30008. */
  30009. static readonly WireFrameFillMode: number;
  30010. /**
  30011. * Returns the point fill mode
  30012. */
  30013. static readonly PointFillMode: number;
  30014. /**
  30015. * Returns the point list draw mode
  30016. */
  30017. static readonly PointListDrawMode: number;
  30018. /**
  30019. * Returns the line list draw mode
  30020. */
  30021. static readonly LineListDrawMode: number;
  30022. /**
  30023. * Returns the line loop draw mode
  30024. */
  30025. static readonly LineLoopDrawMode: number;
  30026. /**
  30027. * Returns the line strip draw mode
  30028. */
  30029. static readonly LineStripDrawMode: number;
  30030. /**
  30031. * Returns the triangle strip draw mode
  30032. */
  30033. static readonly TriangleStripDrawMode: number;
  30034. /**
  30035. * Returns the triangle fan draw mode
  30036. */
  30037. static readonly TriangleFanDrawMode: number;
  30038. /**
  30039. * Stores the clock-wise side orientation
  30040. */
  30041. static readonly ClockWiseSideOrientation: number;
  30042. /**
  30043. * Stores the counter clock-wise side orientation
  30044. */
  30045. static readonly CounterClockWiseSideOrientation: number;
  30046. /**
  30047. * The dirty texture flag value
  30048. */
  30049. static readonly TextureDirtyFlag: number;
  30050. /**
  30051. * The dirty light flag value
  30052. */
  30053. static readonly LightDirtyFlag: number;
  30054. /**
  30055. * The dirty fresnel flag value
  30056. */
  30057. static readonly FresnelDirtyFlag: number;
  30058. /**
  30059. * The dirty attribute flag value
  30060. */
  30061. static readonly AttributesDirtyFlag: number;
  30062. /**
  30063. * The dirty misc flag value
  30064. */
  30065. static readonly MiscDirtyFlag: number;
  30066. /**
  30067. * The dirty prepass flag value
  30068. */
  30069. static readonly PrePassDirtyFlag: number;
  30070. /**
  30071. * The all dirty flag value
  30072. */
  30073. static readonly AllDirtyFlag: number;
  30074. /**
  30075. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30076. */
  30077. static readonly MATERIAL_OPAQUE: number;
  30078. /**
  30079. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30080. */
  30081. static readonly MATERIAL_ALPHATEST: number;
  30082. /**
  30083. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30084. */
  30085. static readonly MATERIAL_ALPHABLEND: number;
  30086. /**
  30087. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30088. * They are also discarded below the alpha cutoff threshold to improve performances.
  30089. */
  30090. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30091. /**
  30092. * The Whiteout method is used to blend normals.
  30093. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30094. */
  30095. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30096. /**
  30097. * The Reoriented Normal Mapping method is used to blend normals.
  30098. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30099. */
  30100. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30101. /**
  30102. * Custom callback helping to override the default shader used in the material.
  30103. */
  30104. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30105. /**
  30106. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30107. */
  30108. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30109. /**
  30110. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30111. * This means that the material can keep using a previous shader while a new one is being compiled.
  30112. * This is mostly used when shader parallel compilation is supported (true by default)
  30113. */
  30114. allowShaderHotSwapping: boolean;
  30115. /**
  30116. * The ID of the material
  30117. */
  30118. id: string;
  30119. /**
  30120. * Gets or sets the unique id of the material
  30121. */
  30122. uniqueId: number;
  30123. /**
  30124. * The name of the material
  30125. */
  30126. name: string;
  30127. /**
  30128. * Gets or sets user defined metadata
  30129. */
  30130. metadata: any;
  30131. /**
  30132. * For internal use only. Please do not use.
  30133. */
  30134. reservedDataStore: any;
  30135. /**
  30136. * Specifies if the ready state should be checked on each call
  30137. */
  30138. checkReadyOnEveryCall: boolean;
  30139. /**
  30140. * Specifies if the ready state should be checked once
  30141. */
  30142. checkReadyOnlyOnce: boolean;
  30143. /**
  30144. * The state of the material
  30145. */
  30146. state: string;
  30147. /**
  30148. * If the material can be rendered to several textures with MRT extension
  30149. */
  30150. get canRenderToMRT(): boolean;
  30151. /**
  30152. * The alpha value of the material
  30153. */
  30154. protected _alpha: number;
  30155. /**
  30156. * List of inspectable custom properties (used by the Inspector)
  30157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30158. */
  30159. inspectableCustomProperties: IInspectable[];
  30160. /**
  30161. * Sets the alpha value of the material
  30162. */
  30163. set alpha(value: number);
  30164. /**
  30165. * Gets the alpha value of the material
  30166. */
  30167. get alpha(): number;
  30168. /**
  30169. * Specifies if back face culling is enabled
  30170. */
  30171. protected _backFaceCulling: boolean;
  30172. /**
  30173. * Sets the back-face culling state
  30174. */
  30175. set backFaceCulling(value: boolean);
  30176. /**
  30177. * Gets the back-face culling state
  30178. */
  30179. get backFaceCulling(): boolean;
  30180. /**
  30181. * Stores the value for side orientation
  30182. */
  30183. sideOrientation: number;
  30184. /**
  30185. * Callback triggered when the material is compiled
  30186. */
  30187. onCompiled: Nullable<(effect: Effect) => void>;
  30188. /**
  30189. * Callback triggered when an error occurs
  30190. */
  30191. onError: Nullable<(effect: Effect, errors: string) => void>;
  30192. /**
  30193. * Callback triggered to get the render target textures
  30194. */
  30195. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30196. /**
  30197. * Gets a boolean indicating that current material needs to register RTT
  30198. */
  30199. get hasRenderTargetTextures(): boolean;
  30200. /**
  30201. * Specifies if the material should be serialized
  30202. */
  30203. doNotSerialize: boolean;
  30204. /**
  30205. * @hidden
  30206. */
  30207. _storeEffectOnSubMeshes: boolean;
  30208. /**
  30209. * Stores the animations for the material
  30210. */
  30211. animations: Nullable<Array<Animation>>;
  30212. /**
  30213. * An event triggered when the material is disposed
  30214. */
  30215. onDisposeObservable: Observable<Material>;
  30216. /**
  30217. * An observer which watches for dispose events
  30218. */
  30219. private _onDisposeObserver;
  30220. private _onUnBindObservable;
  30221. /**
  30222. * Called during a dispose event
  30223. */
  30224. set onDispose(callback: () => void);
  30225. private _onBindObservable;
  30226. /**
  30227. * An event triggered when the material is bound
  30228. */
  30229. get onBindObservable(): Observable<AbstractMesh>;
  30230. /**
  30231. * An observer which watches for bind events
  30232. */
  30233. private _onBindObserver;
  30234. /**
  30235. * Called during a bind event
  30236. */
  30237. set onBind(callback: (Mesh: AbstractMesh) => void);
  30238. /**
  30239. * An event triggered when the material is unbound
  30240. */
  30241. get onUnBindObservable(): Observable<Material>;
  30242. protected _onEffectCreatedObservable: Nullable<Observable<{
  30243. effect: Effect;
  30244. subMesh: Nullable<SubMesh>;
  30245. }>>;
  30246. /**
  30247. * An event triggered when the effect is (re)created
  30248. */
  30249. get onEffectCreatedObservable(): Observable<{
  30250. effect: Effect;
  30251. subMesh: Nullable<SubMesh>;
  30252. }>;
  30253. /**
  30254. * Stores the value of the alpha mode
  30255. */
  30256. private _alphaMode;
  30257. /**
  30258. * Sets the value of the alpha mode.
  30259. *
  30260. * | Value | Type | Description |
  30261. * | --- | --- | --- |
  30262. * | 0 | ALPHA_DISABLE | |
  30263. * | 1 | ALPHA_ADD | |
  30264. * | 2 | ALPHA_COMBINE | |
  30265. * | 3 | ALPHA_SUBTRACT | |
  30266. * | 4 | ALPHA_MULTIPLY | |
  30267. * | 5 | ALPHA_MAXIMIZED | |
  30268. * | 6 | ALPHA_ONEONE | |
  30269. * | 7 | ALPHA_PREMULTIPLIED | |
  30270. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30271. * | 9 | ALPHA_INTERPOLATE | |
  30272. * | 10 | ALPHA_SCREENMODE | |
  30273. *
  30274. */
  30275. set alphaMode(value: number);
  30276. /**
  30277. * Gets the value of the alpha mode
  30278. */
  30279. get alphaMode(): number;
  30280. /**
  30281. * Stores the state of the need depth pre-pass value
  30282. */
  30283. private _needDepthPrePass;
  30284. /**
  30285. * Sets the need depth pre-pass value
  30286. */
  30287. set needDepthPrePass(value: boolean);
  30288. /**
  30289. * Gets the depth pre-pass value
  30290. */
  30291. get needDepthPrePass(): boolean;
  30292. /**
  30293. * Specifies if depth writing should be disabled
  30294. */
  30295. disableDepthWrite: boolean;
  30296. /**
  30297. * Specifies if color writing should be disabled
  30298. */
  30299. disableColorWrite: boolean;
  30300. /**
  30301. * Specifies if depth writing should be forced
  30302. */
  30303. forceDepthWrite: boolean;
  30304. /**
  30305. * Specifies the depth function that should be used. 0 means the default engine function
  30306. */
  30307. depthFunction: number;
  30308. /**
  30309. * Specifies if there should be a separate pass for culling
  30310. */
  30311. separateCullingPass: boolean;
  30312. /**
  30313. * Stores the state specifing if fog should be enabled
  30314. */
  30315. private _fogEnabled;
  30316. /**
  30317. * Sets the state for enabling fog
  30318. */
  30319. set fogEnabled(value: boolean);
  30320. /**
  30321. * Gets the value of the fog enabled state
  30322. */
  30323. get fogEnabled(): boolean;
  30324. /**
  30325. * Stores the size of points
  30326. */
  30327. pointSize: number;
  30328. /**
  30329. * Stores the z offset value
  30330. */
  30331. zOffset: number;
  30332. get wireframe(): boolean;
  30333. /**
  30334. * Sets the state of wireframe mode
  30335. */
  30336. set wireframe(value: boolean);
  30337. /**
  30338. * Gets the value specifying if point clouds are enabled
  30339. */
  30340. get pointsCloud(): boolean;
  30341. /**
  30342. * Sets the state of point cloud mode
  30343. */
  30344. set pointsCloud(value: boolean);
  30345. /**
  30346. * Gets the material fill mode
  30347. */
  30348. get fillMode(): number;
  30349. /**
  30350. * Sets the material fill mode
  30351. */
  30352. set fillMode(value: number);
  30353. /**
  30354. * @hidden
  30355. * Stores the effects for the material
  30356. */
  30357. _effect: Nullable<Effect>;
  30358. /**
  30359. * Specifies if uniform buffers should be used
  30360. */
  30361. private _useUBO;
  30362. /**
  30363. * Stores a reference to the scene
  30364. */
  30365. private _scene;
  30366. /**
  30367. * Stores the fill mode state
  30368. */
  30369. private _fillMode;
  30370. /**
  30371. * Specifies if the depth write state should be cached
  30372. */
  30373. private _cachedDepthWriteState;
  30374. /**
  30375. * Specifies if the color write state should be cached
  30376. */
  30377. private _cachedColorWriteState;
  30378. /**
  30379. * Specifies if the depth function state should be cached
  30380. */
  30381. private _cachedDepthFunctionState;
  30382. /**
  30383. * Stores the uniform buffer
  30384. */
  30385. protected _uniformBuffer: UniformBuffer;
  30386. /** @hidden */
  30387. _indexInSceneMaterialArray: number;
  30388. /** @hidden */
  30389. meshMap: Nullable<{
  30390. [id: string]: AbstractMesh | undefined;
  30391. }>;
  30392. /**
  30393. * Creates a material instance
  30394. * @param name defines the name of the material
  30395. * @param scene defines the scene to reference
  30396. * @param doNotAdd specifies if the material should be added to the scene
  30397. */
  30398. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30399. /**
  30400. * Returns a string representation of the current material
  30401. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30402. * @returns a string with material information
  30403. */
  30404. toString(fullDetails?: boolean): string;
  30405. /**
  30406. * Gets the class name of the material
  30407. * @returns a string with the class name of the material
  30408. */
  30409. getClassName(): string;
  30410. /**
  30411. * Specifies if updates for the material been locked
  30412. */
  30413. get isFrozen(): boolean;
  30414. /**
  30415. * Locks updates for the material
  30416. */
  30417. freeze(): void;
  30418. /**
  30419. * Unlocks updates for the material
  30420. */
  30421. unfreeze(): void;
  30422. /**
  30423. * Specifies if the material is ready to be used
  30424. * @param mesh defines the mesh to check
  30425. * @param useInstances specifies if instances should be used
  30426. * @returns a boolean indicating if the material is ready to be used
  30427. */
  30428. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30429. /**
  30430. * Specifies that the submesh is ready to be used
  30431. * @param mesh defines the mesh to check
  30432. * @param subMesh defines which submesh to check
  30433. * @param useInstances specifies that instances should be used
  30434. * @returns a boolean indicating that the submesh is ready or not
  30435. */
  30436. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30437. /**
  30438. * Returns the material effect
  30439. * @returns the effect associated with the material
  30440. */
  30441. getEffect(): Nullable<Effect>;
  30442. /**
  30443. * Returns the current scene
  30444. * @returns a Scene
  30445. */
  30446. getScene(): Scene;
  30447. /**
  30448. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30449. */
  30450. protected _forceAlphaTest: boolean;
  30451. /**
  30452. * The transparency mode of the material.
  30453. */
  30454. protected _transparencyMode: Nullable<number>;
  30455. /**
  30456. * Gets the current transparency mode.
  30457. */
  30458. get transparencyMode(): Nullable<number>;
  30459. /**
  30460. * Sets the transparency mode of the material.
  30461. *
  30462. * | Value | Type | Description |
  30463. * | ----- | ----------------------------------- | ----------- |
  30464. * | 0 | OPAQUE | |
  30465. * | 1 | ALPHATEST | |
  30466. * | 2 | ALPHABLEND | |
  30467. * | 3 | ALPHATESTANDBLEND | |
  30468. *
  30469. */
  30470. set transparencyMode(value: Nullable<number>);
  30471. /**
  30472. * Returns true if alpha blending should be disabled.
  30473. */
  30474. protected get _disableAlphaBlending(): boolean;
  30475. /**
  30476. * Specifies whether or not this material should be rendered in alpha blend mode.
  30477. * @returns a boolean specifying if alpha blending is needed
  30478. */
  30479. needAlphaBlending(): boolean;
  30480. /**
  30481. * Specifies if the mesh will require alpha blending
  30482. * @param mesh defines the mesh to check
  30483. * @returns a boolean specifying if alpha blending is needed for the mesh
  30484. */
  30485. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30486. /**
  30487. * Specifies whether or not this material should be rendered in alpha test mode.
  30488. * @returns a boolean specifying if an alpha test is needed.
  30489. */
  30490. needAlphaTesting(): boolean;
  30491. /**
  30492. * Specifies if material alpha testing should be turned on for the mesh
  30493. * @param mesh defines the mesh to check
  30494. */
  30495. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30496. /**
  30497. * Gets the texture used for the alpha test
  30498. * @returns the texture to use for alpha testing
  30499. */
  30500. getAlphaTestTexture(): Nullable<BaseTexture>;
  30501. /**
  30502. * Marks the material to indicate that it needs to be re-calculated
  30503. */
  30504. markDirty(): void;
  30505. /** @hidden */
  30506. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30507. /**
  30508. * Binds the material to the mesh
  30509. * @param world defines the world transformation matrix
  30510. * @param mesh defines the mesh to bind the material to
  30511. */
  30512. bind(world: Matrix, mesh?: Mesh): void;
  30513. /**
  30514. * Binds the submesh to the material
  30515. * @param world defines the world transformation matrix
  30516. * @param mesh defines the mesh containing the submesh
  30517. * @param subMesh defines the submesh to bind the material to
  30518. */
  30519. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30520. /**
  30521. * Binds the world matrix to the material
  30522. * @param world defines the world transformation matrix
  30523. */
  30524. bindOnlyWorldMatrix(world: Matrix): void;
  30525. /**
  30526. * Binds the scene's uniform buffer to the effect.
  30527. * @param effect defines the effect to bind to the scene uniform buffer
  30528. * @param sceneUbo defines the uniform buffer storing scene data
  30529. */
  30530. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30531. /**
  30532. * Binds the view matrix to the effect
  30533. * @param effect defines the effect to bind the view matrix to
  30534. */
  30535. bindView(effect: Effect): void;
  30536. /**
  30537. * Binds the view projection matrix to the effect
  30538. * @param effect defines the effect to bind the view projection matrix to
  30539. */
  30540. bindViewProjection(effect: Effect): void;
  30541. /**
  30542. * Processes to execute after binding the material to a mesh
  30543. * @param mesh defines the rendered mesh
  30544. */
  30545. protected _afterBind(mesh?: Mesh): void;
  30546. /**
  30547. * Unbinds the material from the mesh
  30548. */
  30549. unbind(): void;
  30550. /**
  30551. * Gets the active textures from the material
  30552. * @returns an array of textures
  30553. */
  30554. getActiveTextures(): BaseTexture[];
  30555. /**
  30556. * Specifies if the material uses a texture
  30557. * @param texture defines the texture to check against the material
  30558. * @returns a boolean specifying if the material uses the texture
  30559. */
  30560. hasTexture(texture: BaseTexture): boolean;
  30561. /**
  30562. * Makes a duplicate of the material, and gives it a new name
  30563. * @param name defines the new name for the duplicated material
  30564. * @returns the cloned material
  30565. */
  30566. clone(name: string): Nullable<Material>;
  30567. /**
  30568. * Gets the meshes bound to the material
  30569. * @returns an array of meshes bound to the material
  30570. */
  30571. getBindedMeshes(): AbstractMesh[];
  30572. /**
  30573. * Force shader compilation
  30574. * @param mesh defines the mesh associated with this material
  30575. * @param onCompiled defines a function to execute once the material is compiled
  30576. * @param options defines the options to configure the compilation
  30577. * @param onError defines a function to execute if the material fails compiling
  30578. */
  30579. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30580. /**
  30581. * Force shader compilation
  30582. * @param mesh defines the mesh that will use this material
  30583. * @param options defines additional options for compiling the shaders
  30584. * @returns a promise that resolves when the compilation completes
  30585. */
  30586. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30587. private static readonly _AllDirtyCallBack;
  30588. private static readonly _ImageProcessingDirtyCallBack;
  30589. private static readonly _TextureDirtyCallBack;
  30590. private static readonly _FresnelDirtyCallBack;
  30591. private static readonly _MiscDirtyCallBack;
  30592. private static readonly _PrePassDirtyCallBack;
  30593. private static readonly _LightsDirtyCallBack;
  30594. private static readonly _AttributeDirtyCallBack;
  30595. private static _FresnelAndMiscDirtyCallBack;
  30596. private static _TextureAndMiscDirtyCallBack;
  30597. private static readonly _DirtyCallbackArray;
  30598. private static readonly _RunDirtyCallBacks;
  30599. /**
  30600. * Marks a define in the material to indicate that it needs to be re-computed
  30601. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30602. */
  30603. markAsDirty(flag: number): void;
  30604. /**
  30605. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30606. * @param func defines a function which checks material defines against the submeshes
  30607. */
  30608. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30609. /**
  30610. * Indicates that the scene should check if the rendering now needs a prepass
  30611. */
  30612. protected _markScenePrePassDirty(): void;
  30613. /**
  30614. * Indicates that we need to re-calculated for all submeshes
  30615. */
  30616. protected _markAllSubMeshesAsAllDirty(): void;
  30617. /**
  30618. * Indicates that image processing needs to be re-calculated for all submeshes
  30619. */
  30620. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30621. /**
  30622. * Indicates that textures need to be re-calculated for all submeshes
  30623. */
  30624. protected _markAllSubMeshesAsTexturesDirty(): void;
  30625. /**
  30626. * Indicates that fresnel needs to be re-calculated for all submeshes
  30627. */
  30628. protected _markAllSubMeshesAsFresnelDirty(): void;
  30629. /**
  30630. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30631. */
  30632. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30633. /**
  30634. * Indicates that lights need to be re-calculated for all submeshes
  30635. */
  30636. protected _markAllSubMeshesAsLightsDirty(): void;
  30637. /**
  30638. * Indicates that attributes need to be re-calculated for all submeshes
  30639. */
  30640. protected _markAllSubMeshesAsAttributesDirty(): void;
  30641. /**
  30642. * Indicates that misc needs to be re-calculated for all submeshes
  30643. */
  30644. protected _markAllSubMeshesAsMiscDirty(): void;
  30645. /**
  30646. * Indicates that prepass needs to be re-calculated for all submeshes
  30647. */
  30648. protected _markAllSubMeshesAsPrePassDirty(): void;
  30649. /**
  30650. * Indicates that textures and misc need to be re-calculated for all submeshes
  30651. */
  30652. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30653. /**
  30654. * Sets the required values to the prepass renderer.
  30655. * @param prePassRenderer defines the prepass renderer to setup.
  30656. * @returns true if the pre pass is needed.
  30657. */
  30658. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30659. /**
  30660. * Disposes the material
  30661. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30662. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30663. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30664. */
  30665. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30666. /** @hidden */
  30667. private releaseVertexArrayObject;
  30668. /**
  30669. * Serializes this material
  30670. * @returns the serialized material object
  30671. */
  30672. serialize(): any;
  30673. /**
  30674. * Creates a material from parsed material data
  30675. * @param parsedMaterial defines parsed material data
  30676. * @param scene defines the hosting scene
  30677. * @param rootUrl defines the root URL to use to load textures
  30678. * @returns a new material
  30679. */
  30680. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30681. }
  30682. }
  30683. declare module "babylonjs/Materials/multiMaterial" {
  30684. import { Nullable } from "babylonjs/types";
  30685. import { Scene } from "babylonjs/scene";
  30686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30687. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30688. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30689. import { Material } from "babylonjs/Materials/material";
  30690. /**
  30691. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30692. * separate meshes. This can be use to improve performances.
  30693. * @see https://doc.babylonjs.com/how_to/multi_materials
  30694. */
  30695. export class MultiMaterial extends Material {
  30696. private _subMaterials;
  30697. /**
  30698. * Gets or Sets the list of Materials used within the multi material.
  30699. * They need to be ordered according to the submeshes order in the associated mesh
  30700. */
  30701. get subMaterials(): Nullable<Material>[];
  30702. set subMaterials(value: Nullable<Material>[]);
  30703. /**
  30704. * Function used to align with Node.getChildren()
  30705. * @returns the list of Materials used within the multi material
  30706. */
  30707. getChildren(): Nullable<Material>[];
  30708. /**
  30709. * Instantiates a new Multi Material
  30710. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30711. * separate meshes. This can be use to improve performances.
  30712. * @see https://doc.babylonjs.com/how_to/multi_materials
  30713. * @param name Define the name in the scene
  30714. * @param scene Define the scene the material belongs to
  30715. */
  30716. constructor(name: string, scene: Scene);
  30717. private _hookArray;
  30718. /**
  30719. * Get one of the submaterial by its index in the submaterials array
  30720. * @param index The index to look the sub material at
  30721. * @returns The Material if the index has been defined
  30722. */
  30723. getSubMaterial(index: number): Nullable<Material>;
  30724. /**
  30725. * Get the list of active textures for the whole sub materials list.
  30726. * @returns All the textures that will be used during the rendering
  30727. */
  30728. getActiveTextures(): BaseTexture[];
  30729. /**
  30730. * Gets the current class name of the material e.g. "MultiMaterial"
  30731. * Mainly use in serialization.
  30732. * @returns the class name
  30733. */
  30734. getClassName(): string;
  30735. /**
  30736. * Checks if the material is ready to render the requested sub mesh
  30737. * @param mesh Define the mesh the submesh belongs to
  30738. * @param subMesh Define the sub mesh to look readyness for
  30739. * @param useInstances Define whether or not the material is used with instances
  30740. * @returns true if ready, otherwise false
  30741. */
  30742. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30743. /**
  30744. * Clones the current material and its related sub materials
  30745. * @param name Define the name of the newly cloned material
  30746. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30747. * @returns the cloned material
  30748. */
  30749. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30750. /**
  30751. * Serializes the materials into a JSON representation.
  30752. * @returns the JSON representation
  30753. */
  30754. serialize(): any;
  30755. /**
  30756. * Dispose the material and release its associated resources
  30757. * @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)
  30758. * @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)
  30759. * @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)
  30760. */
  30761. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30762. /**
  30763. * Creates a MultiMaterial from parsed MultiMaterial data.
  30764. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30765. * @param scene defines the hosting scene
  30766. * @returns a new MultiMaterial
  30767. */
  30768. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30769. }
  30770. }
  30771. declare module "babylonjs/Meshes/subMesh" {
  30772. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  30773. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30774. import { Engine } from "babylonjs/Engines/engine";
  30775. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  30776. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  30777. import { Effect } from "babylonjs/Materials/effect";
  30778. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30779. import { Plane } from "babylonjs/Maths/math.plane";
  30780. import { Collider } from "babylonjs/Collisions/collider";
  30781. import { Material } from "babylonjs/Materials/material";
  30782. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30784. import { Mesh } from "babylonjs/Meshes/mesh";
  30785. import { Ray } from "babylonjs/Culling/ray";
  30786. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  30787. /**
  30788. * Defines a subdivision inside a mesh
  30789. */
  30790. export class SubMesh implements ICullable {
  30791. /** the material index to use */
  30792. materialIndex: number;
  30793. /** vertex index start */
  30794. verticesStart: number;
  30795. /** vertices count */
  30796. verticesCount: number;
  30797. /** index start */
  30798. indexStart: number;
  30799. /** indices count */
  30800. indexCount: number;
  30801. /** @hidden */
  30802. _materialDefines: Nullable<MaterialDefines>;
  30803. /** @hidden */
  30804. _materialEffect: Nullable<Effect>;
  30805. /** @hidden */
  30806. _effectOverride: Nullable<Effect>;
  30807. /**
  30808. * Gets material defines used by the effect associated to the sub mesh
  30809. */
  30810. get materialDefines(): Nullable<MaterialDefines>;
  30811. /**
  30812. * Sets material defines used by the effect associated to the sub mesh
  30813. */
  30814. set materialDefines(defines: Nullable<MaterialDefines>);
  30815. /**
  30816. * Gets associated effect
  30817. */
  30818. get effect(): Nullable<Effect>;
  30819. /**
  30820. * Sets associated effect (effect used to render this submesh)
  30821. * @param effect defines the effect to associate with
  30822. * @param defines defines the set of defines used to compile this effect
  30823. */
  30824. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30825. /** @hidden */
  30826. _linesIndexCount: number;
  30827. private _mesh;
  30828. private _renderingMesh;
  30829. private _boundingInfo;
  30830. private _linesIndexBuffer;
  30831. /** @hidden */
  30832. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30833. /** @hidden */
  30834. _trianglePlanes: Plane[];
  30835. /** @hidden */
  30836. _lastColliderTransformMatrix: Nullable<Matrix>;
  30837. /** @hidden */
  30838. _renderId: number;
  30839. /** @hidden */
  30840. _alphaIndex: number;
  30841. /** @hidden */
  30842. _distanceToCamera: number;
  30843. /** @hidden */
  30844. _id: number;
  30845. private _currentMaterial;
  30846. /**
  30847. * Add a new submesh to a mesh
  30848. * @param materialIndex defines the material index to use
  30849. * @param verticesStart defines vertex index start
  30850. * @param verticesCount defines vertices count
  30851. * @param indexStart defines index start
  30852. * @param indexCount defines indices count
  30853. * @param mesh defines the parent mesh
  30854. * @param renderingMesh defines an optional rendering mesh
  30855. * @param createBoundingBox defines if bounding box should be created for this submesh
  30856. * @returns the new submesh
  30857. */
  30858. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30859. /**
  30860. * Creates a new submesh
  30861. * @param materialIndex defines the material index to use
  30862. * @param verticesStart defines vertex index start
  30863. * @param verticesCount defines vertices count
  30864. * @param indexStart defines index start
  30865. * @param indexCount defines indices count
  30866. * @param mesh defines the parent mesh
  30867. * @param renderingMesh defines an optional rendering mesh
  30868. * @param createBoundingBox defines if bounding box should be created for this submesh
  30869. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30870. */
  30871. constructor(
  30872. /** the material index to use */
  30873. materialIndex: number,
  30874. /** vertex index start */
  30875. verticesStart: number,
  30876. /** vertices count */
  30877. verticesCount: number,
  30878. /** index start */
  30879. indexStart: number,
  30880. /** indices count */
  30881. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30882. /**
  30883. * Returns true if this submesh covers the entire parent mesh
  30884. * @ignorenaming
  30885. */
  30886. get IsGlobal(): boolean;
  30887. /**
  30888. * Returns the submesh BoudingInfo object
  30889. * @returns current bounding info (or mesh's one if the submesh is global)
  30890. */
  30891. getBoundingInfo(): BoundingInfo;
  30892. /**
  30893. * Sets the submesh BoundingInfo
  30894. * @param boundingInfo defines the new bounding info to use
  30895. * @returns the SubMesh
  30896. */
  30897. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30898. /**
  30899. * Returns the mesh of the current submesh
  30900. * @return the parent mesh
  30901. */
  30902. getMesh(): AbstractMesh;
  30903. /**
  30904. * Returns the rendering mesh of the submesh
  30905. * @returns the rendering mesh (could be different from parent mesh)
  30906. */
  30907. getRenderingMesh(): Mesh;
  30908. /**
  30909. * Returns the replacement mesh of the submesh
  30910. * @returns the replacement mesh (could be different from parent mesh)
  30911. */
  30912. getReplacementMesh(): Nullable<AbstractMesh>;
  30913. /**
  30914. * Returns the effective mesh of the submesh
  30915. * @returns the effective mesh (could be different from parent mesh)
  30916. */
  30917. getEffectiveMesh(): AbstractMesh;
  30918. /**
  30919. * Returns the submesh material
  30920. * @returns null or the current material
  30921. */
  30922. getMaterial(): Nullable<Material>;
  30923. private _IsMultiMaterial;
  30924. /**
  30925. * Sets a new updated BoundingInfo object to the submesh
  30926. * @param data defines an optional position array to use to determine the bounding info
  30927. * @returns the SubMesh
  30928. */
  30929. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30930. /** @hidden */
  30931. _checkCollision(collider: Collider): boolean;
  30932. /**
  30933. * Updates the submesh BoundingInfo
  30934. * @param world defines the world matrix to use to update the bounding info
  30935. * @returns the submesh
  30936. */
  30937. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30938. /**
  30939. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30940. * @param frustumPlanes defines the frustum planes
  30941. * @returns true if the submesh is intersecting with the frustum
  30942. */
  30943. isInFrustum(frustumPlanes: Plane[]): boolean;
  30944. /**
  30945. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30946. * @param frustumPlanes defines the frustum planes
  30947. * @returns true if the submesh is inside the frustum
  30948. */
  30949. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30950. /**
  30951. * Renders the submesh
  30952. * @param enableAlphaMode defines if alpha needs to be used
  30953. * @returns the submesh
  30954. */
  30955. render(enableAlphaMode: boolean): SubMesh;
  30956. /**
  30957. * @hidden
  30958. */
  30959. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30960. /**
  30961. * Checks if the submesh intersects with a ray
  30962. * @param ray defines the ray to test
  30963. * @returns true is the passed ray intersects the submesh bounding box
  30964. */
  30965. canIntersects(ray: Ray): boolean;
  30966. /**
  30967. * Intersects current submesh with a ray
  30968. * @param ray defines the ray to test
  30969. * @param positions defines mesh's positions array
  30970. * @param indices defines mesh's indices array
  30971. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30972. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30973. * @returns intersection info or null if no intersection
  30974. */
  30975. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30976. /** @hidden */
  30977. private _intersectLines;
  30978. /** @hidden */
  30979. private _intersectUnIndexedLines;
  30980. /** @hidden */
  30981. private _intersectTriangles;
  30982. /** @hidden */
  30983. private _intersectUnIndexedTriangles;
  30984. /** @hidden */
  30985. _rebuild(): void;
  30986. /**
  30987. * Creates a new submesh from the passed mesh
  30988. * @param newMesh defines the new hosting mesh
  30989. * @param newRenderingMesh defines an optional rendering mesh
  30990. * @returns the new submesh
  30991. */
  30992. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30993. /**
  30994. * Release associated resources
  30995. */
  30996. dispose(): void;
  30997. /**
  30998. * Gets the class name
  30999. * @returns the string "SubMesh".
  31000. */
  31001. getClassName(): string;
  31002. /**
  31003. * Creates a new submesh from indices data
  31004. * @param materialIndex the index of the main mesh material
  31005. * @param startIndex the index where to start the copy in the mesh indices array
  31006. * @param indexCount the number of indices to copy then from the startIndex
  31007. * @param mesh the main mesh to create the submesh from
  31008. * @param renderingMesh the optional rendering mesh
  31009. * @returns a new submesh
  31010. */
  31011. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31012. }
  31013. }
  31014. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31015. /**
  31016. * Class used to represent data loading progression
  31017. */
  31018. export class SceneLoaderFlags {
  31019. private static _ForceFullSceneLoadingForIncremental;
  31020. private static _ShowLoadingScreen;
  31021. private static _CleanBoneMatrixWeights;
  31022. private static _loggingLevel;
  31023. /**
  31024. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31025. */
  31026. static get ForceFullSceneLoadingForIncremental(): boolean;
  31027. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31028. /**
  31029. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31030. */
  31031. static get ShowLoadingScreen(): boolean;
  31032. static set ShowLoadingScreen(value: boolean);
  31033. /**
  31034. * Defines the current logging level (while loading the scene)
  31035. * @ignorenaming
  31036. */
  31037. static get loggingLevel(): number;
  31038. static set loggingLevel(value: number);
  31039. /**
  31040. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31041. */
  31042. static get CleanBoneMatrixWeights(): boolean;
  31043. static set CleanBoneMatrixWeights(value: boolean);
  31044. }
  31045. }
  31046. declare module "babylonjs/Meshes/geometry" {
  31047. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31048. import { Scene } from "babylonjs/scene";
  31049. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31050. import { Engine } from "babylonjs/Engines/engine";
  31051. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31052. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31053. import { Effect } from "babylonjs/Materials/effect";
  31054. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31055. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31056. import { Mesh } from "babylonjs/Meshes/mesh";
  31057. /**
  31058. * Class used to store geometry data (vertex buffers + index buffer)
  31059. */
  31060. export class Geometry implements IGetSetVerticesData {
  31061. /**
  31062. * Gets or sets the ID of the geometry
  31063. */
  31064. id: string;
  31065. /**
  31066. * Gets or sets the unique ID of the geometry
  31067. */
  31068. uniqueId: number;
  31069. /**
  31070. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31071. */
  31072. delayLoadState: number;
  31073. /**
  31074. * Gets the file containing the data to load when running in delay load state
  31075. */
  31076. delayLoadingFile: Nullable<string>;
  31077. /**
  31078. * Callback called when the geometry is updated
  31079. */
  31080. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31081. private _scene;
  31082. private _engine;
  31083. private _meshes;
  31084. private _totalVertices;
  31085. /** @hidden */
  31086. _indices: IndicesArray;
  31087. /** @hidden */
  31088. _vertexBuffers: {
  31089. [key: string]: VertexBuffer;
  31090. };
  31091. private _isDisposed;
  31092. private _extend;
  31093. private _boundingBias;
  31094. /** @hidden */
  31095. _delayInfo: Array<string>;
  31096. private _indexBuffer;
  31097. private _indexBufferIsUpdatable;
  31098. /** @hidden */
  31099. _boundingInfo: Nullable<BoundingInfo>;
  31100. /** @hidden */
  31101. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31102. /** @hidden */
  31103. _softwareSkinningFrameId: number;
  31104. private _vertexArrayObjects;
  31105. private _updatable;
  31106. /** @hidden */
  31107. _positions: Nullable<Vector3[]>;
  31108. /**
  31109. * 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
  31110. */
  31111. get boundingBias(): Vector2;
  31112. /**
  31113. * 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
  31114. */
  31115. set boundingBias(value: Vector2);
  31116. /**
  31117. * Static function used to attach a new empty geometry to a mesh
  31118. * @param mesh defines the mesh to attach the geometry to
  31119. * @returns the new Geometry
  31120. */
  31121. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31122. /** Get the list of meshes using this geometry */
  31123. get meshes(): Mesh[];
  31124. /**
  31125. * 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
  31126. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31127. */
  31128. useBoundingInfoFromGeometry: boolean;
  31129. /**
  31130. * Creates a new geometry
  31131. * @param id defines the unique ID
  31132. * @param scene defines the hosting scene
  31133. * @param vertexData defines the VertexData used to get geometry data
  31134. * @param updatable defines if geometry must be updatable (false by default)
  31135. * @param mesh defines the mesh that will be associated with the geometry
  31136. */
  31137. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31138. /**
  31139. * Gets the current extend of the geometry
  31140. */
  31141. get extend(): {
  31142. minimum: Vector3;
  31143. maximum: Vector3;
  31144. };
  31145. /**
  31146. * Gets the hosting scene
  31147. * @returns the hosting Scene
  31148. */
  31149. getScene(): Scene;
  31150. /**
  31151. * Gets the hosting engine
  31152. * @returns the hosting Engine
  31153. */
  31154. getEngine(): Engine;
  31155. /**
  31156. * Defines if the geometry is ready to use
  31157. * @returns true if the geometry is ready to be used
  31158. */
  31159. isReady(): boolean;
  31160. /**
  31161. * Gets a value indicating that the geometry should not be serialized
  31162. */
  31163. get doNotSerialize(): boolean;
  31164. /** @hidden */
  31165. _rebuild(): void;
  31166. /**
  31167. * Affects all geometry data in one call
  31168. * @param vertexData defines the geometry data
  31169. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31170. */
  31171. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31172. /**
  31173. * Set specific vertex data
  31174. * @param kind defines the data kind (Position, normal, etc...)
  31175. * @param data defines the vertex data to use
  31176. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31177. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31178. */
  31179. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31180. /**
  31181. * Removes a specific vertex data
  31182. * @param kind defines the data kind (Position, normal, etc...)
  31183. */
  31184. removeVerticesData(kind: string): void;
  31185. /**
  31186. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31187. * @param buffer defines the vertex buffer to use
  31188. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31189. */
  31190. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31191. /**
  31192. * Update a specific vertex buffer
  31193. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31194. * It will do nothing if the buffer is not updatable
  31195. * @param kind defines the data kind (Position, normal, etc...)
  31196. * @param data defines the data to use
  31197. * @param offset defines the offset in the target buffer where to store the data
  31198. * @param useBytes set to true if the offset is in bytes
  31199. */
  31200. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31201. /**
  31202. * Update a specific vertex buffer
  31203. * This function will create a new buffer if the current one is not updatable
  31204. * @param kind defines the data kind (Position, normal, etc...)
  31205. * @param data defines the data to use
  31206. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31207. */
  31208. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31209. private _updateBoundingInfo;
  31210. /** @hidden */
  31211. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31212. /**
  31213. * Gets total number of vertices
  31214. * @returns the total number of vertices
  31215. */
  31216. getTotalVertices(): number;
  31217. /**
  31218. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31219. * @param kind defines the data kind (Position, normal, etc...)
  31220. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31221. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31222. * @returns a float array containing vertex data
  31223. */
  31224. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31225. /**
  31226. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31227. * @param kind defines the data kind (Position, normal, etc...)
  31228. * @returns true if the vertex buffer with the specified kind is updatable
  31229. */
  31230. isVertexBufferUpdatable(kind: string): boolean;
  31231. /**
  31232. * Gets a specific vertex buffer
  31233. * @param kind defines the data kind (Position, normal, etc...)
  31234. * @returns a VertexBuffer
  31235. */
  31236. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31237. /**
  31238. * Returns all vertex buffers
  31239. * @return an object holding all vertex buffers indexed by kind
  31240. */
  31241. getVertexBuffers(): Nullable<{
  31242. [key: string]: VertexBuffer;
  31243. }>;
  31244. /**
  31245. * Gets a boolean indicating if specific vertex buffer is present
  31246. * @param kind defines the data kind (Position, normal, etc...)
  31247. * @returns true if data is present
  31248. */
  31249. isVerticesDataPresent(kind: string): boolean;
  31250. /**
  31251. * Gets a list of all attached data kinds (Position, normal, etc...)
  31252. * @returns a list of string containing all kinds
  31253. */
  31254. getVerticesDataKinds(): string[];
  31255. /**
  31256. * Update index buffer
  31257. * @param indices defines the indices to store in the index buffer
  31258. * @param offset defines the offset in the target buffer where to store the data
  31259. * @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)
  31260. */
  31261. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31262. /**
  31263. * Creates a new index buffer
  31264. * @param indices defines the indices to store in the index buffer
  31265. * @param totalVertices defines the total number of vertices (could be null)
  31266. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31267. */
  31268. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31269. /**
  31270. * Return the total number of indices
  31271. * @returns the total number of indices
  31272. */
  31273. getTotalIndices(): number;
  31274. /**
  31275. * Gets the index buffer array
  31276. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31277. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31278. * @returns the index buffer array
  31279. */
  31280. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31281. /**
  31282. * Gets the index buffer
  31283. * @return the index buffer
  31284. */
  31285. getIndexBuffer(): Nullable<DataBuffer>;
  31286. /** @hidden */
  31287. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31288. /**
  31289. * Release the associated resources for a specific mesh
  31290. * @param mesh defines the source mesh
  31291. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31292. */
  31293. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31294. /**
  31295. * Apply current geometry to a given mesh
  31296. * @param mesh defines the mesh to apply geometry to
  31297. */
  31298. applyToMesh(mesh: Mesh): void;
  31299. private _updateExtend;
  31300. private _applyToMesh;
  31301. private notifyUpdate;
  31302. /**
  31303. * Load the geometry if it was flagged as delay loaded
  31304. * @param scene defines the hosting scene
  31305. * @param onLoaded defines a callback called when the geometry is loaded
  31306. */
  31307. load(scene: Scene, onLoaded?: () => void): void;
  31308. private _queueLoad;
  31309. /**
  31310. * Invert the geometry to move from a right handed system to a left handed one.
  31311. */
  31312. toLeftHanded(): void;
  31313. /** @hidden */
  31314. _resetPointsArrayCache(): void;
  31315. /** @hidden */
  31316. _generatePointsArray(): boolean;
  31317. /**
  31318. * Gets a value indicating if the geometry is disposed
  31319. * @returns true if the geometry was disposed
  31320. */
  31321. isDisposed(): boolean;
  31322. private _disposeVertexArrayObjects;
  31323. /**
  31324. * Free all associated resources
  31325. */
  31326. dispose(): void;
  31327. /**
  31328. * Clone the current geometry into a new geometry
  31329. * @param id defines the unique ID of the new geometry
  31330. * @returns a new geometry object
  31331. */
  31332. copy(id: string): Geometry;
  31333. /**
  31334. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31335. * @return a JSON representation of the current geometry data (without the vertices data)
  31336. */
  31337. serialize(): any;
  31338. private toNumberArray;
  31339. /**
  31340. * Serialize all vertices data into a JSON oject
  31341. * @returns a JSON representation of the current geometry data
  31342. */
  31343. serializeVerticeData(): any;
  31344. /**
  31345. * Extracts a clone of a mesh geometry
  31346. * @param mesh defines the source mesh
  31347. * @param id defines the unique ID of the new geometry object
  31348. * @returns the new geometry object
  31349. */
  31350. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31351. /**
  31352. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31353. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31354. * Be aware Math.random() could cause collisions, but:
  31355. * "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"
  31356. * @returns a string containing a new GUID
  31357. */
  31358. static RandomId(): string;
  31359. /** @hidden */
  31360. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31361. private static _CleanMatricesWeights;
  31362. /**
  31363. * Create a new geometry from persisted data (Using .babylon file format)
  31364. * @param parsedVertexData defines the persisted data
  31365. * @param scene defines the hosting scene
  31366. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31367. * @returns the new geometry object
  31368. */
  31369. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31370. }
  31371. }
  31372. declare module "babylonjs/Meshes/mesh.vertexData" {
  31373. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31374. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31375. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31376. import { Geometry } from "babylonjs/Meshes/geometry";
  31377. import { Mesh } from "babylonjs/Meshes/mesh";
  31378. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31379. /**
  31380. * Define an interface for all classes that will get and set the data on vertices
  31381. */
  31382. export interface IGetSetVerticesData {
  31383. /**
  31384. * Gets a boolean indicating if specific vertex data is present
  31385. * @param kind defines the vertex data kind to use
  31386. * @returns true is data kind is present
  31387. */
  31388. isVerticesDataPresent(kind: string): boolean;
  31389. /**
  31390. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31391. * @param kind defines the data kind (Position, normal, etc...)
  31392. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31393. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31394. * @returns a float array containing vertex data
  31395. */
  31396. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31397. /**
  31398. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31399. * @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.
  31400. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31401. * @returns the indices array or an empty array if the mesh has no geometry
  31402. */
  31403. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31404. /**
  31405. * Set specific vertex data
  31406. * @param kind defines the data kind (Position, normal, etc...)
  31407. * @param data defines the vertex data to use
  31408. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31409. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31410. */
  31411. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31412. /**
  31413. * Update a specific associated vertex buffer
  31414. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31415. * - VertexBuffer.PositionKind
  31416. * - VertexBuffer.UVKind
  31417. * - VertexBuffer.UV2Kind
  31418. * - VertexBuffer.UV3Kind
  31419. * - VertexBuffer.UV4Kind
  31420. * - VertexBuffer.UV5Kind
  31421. * - VertexBuffer.UV6Kind
  31422. * - VertexBuffer.ColorKind
  31423. * - VertexBuffer.MatricesIndicesKind
  31424. * - VertexBuffer.MatricesIndicesExtraKind
  31425. * - VertexBuffer.MatricesWeightsKind
  31426. * - VertexBuffer.MatricesWeightsExtraKind
  31427. * @param data defines the data source
  31428. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31429. * @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)
  31430. */
  31431. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31432. /**
  31433. * Creates a new index buffer
  31434. * @param indices defines the indices to store in the index buffer
  31435. * @param totalVertices defines the total number of vertices (could be null)
  31436. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31437. */
  31438. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31439. }
  31440. /**
  31441. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31442. */
  31443. export class VertexData {
  31444. /**
  31445. * Mesh side orientation : usually the external or front surface
  31446. */
  31447. static readonly FRONTSIDE: number;
  31448. /**
  31449. * Mesh side orientation : usually the internal or back surface
  31450. */
  31451. static readonly BACKSIDE: number;
  31452. /**
  31453. * Mesh side orientation : both internal and external or front and back surfaces
  31454. */
  31455. static readonly DOUBLESIDE: number;
  31456. /**
  31457. * Mesh side orientation : by default, `FRONTSIDE`
  31458. */
  31459. static readonly DEFAULTSIDE: number;
  31460. /**
  31461. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31462. */
  31463. positions: Nullable<FloatArray>;
  31464. /**
  31465. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31466. */
  31467. normals: Nullable<FloatArray>;
  31468. /**
  31469. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31470. */
  31471. tangents: Nullable<FloatArray>;
  31472. /**
  31473. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31474. */
  31475. uvs: Nullable<FloatArray>;
  31476. /**
  31477. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31478. */
  31479. uvs2: Nullable<FloatArray>;
  31480. /**
  31481. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31482. */
  31483. uvs3: Nullable<FloatArray>;
  31484. /**
  31485. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31486. */
  31487. uvs4: Nullable<FloatArray>;
  31488. /**
  31489. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31490. */
  31491. uvs5: Nullable<FloatArray>;
  31492. /**
  31493. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31494. */
  31495. uvs6: Nullable<FloatArray>;
  31496. /**
  31497. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31498. */
  31499. colors: Nullable<FloatArray>;
  31500. /**
  31501. * 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).
  31502. */
  31503. matricesIndices: Nullable<FloatArray>;
  31504. /**
  31505. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31506. */
  31507. matricesWeights: Nullable<FloatArray>;
  31508. /**
  31509. * An array extending the number of possible indices
  31510. */
  31511. matricesIndicesExtra: Nullable<FloatArray>;
  31512. /**
  31513. * An array extending the number of possible weights when the number of indices is extended
  31514. */
  31515. matricesWeightsExtra: Nullable<FloatArray>;
  31516. /**
  31517. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31518. */
  31519. indices: Nullable<IndicesArray>;
  31520. /**
  31521. * Uses the passed data array to set the set the values for the specified kind of data
  31522. * @param data a linear array of floating numbers
  31523. * @param kind the type of data that is being set, eg positions, colors etc
  31524. */
  31525. set(data: FloatArray, kind: string): void;
  31526. /**
  31527. * Associates the vertexData to the passed Mesh.
  31528. * Sets it as updatable or not (default `false`)
  31529. * @param mesh the mesh the vertexData is applied to
  31530. * @param updatable when used and having the value true allows new data to update the vertexData
  31531. * @returns the VertexData
  31532. */
  31533. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31534. /**
  31535. * Associates the vertexData to the passed Geometry.
  31536. * Sets it as updatable or not (default `false`)
  31537. * @param geometry the geometry the vertexData is applied to
  31538. * @param updatable when used and having the value true allows new data to update the vertexData
  31539. * @returns VertexData
  31540. */
  31541. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31542. /**
  31543. * Updates the associated mesh
  31544. * @param mesh the mesh to be updated
  31545. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31546. * @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
  31547. * @returns VertexData
  31548. */
  31549. updateMesh(mesh: Mesh): VertexData;
  31550. /**
  31551. * Updates the associated geometry
  31552. * @param geometry the geometry to be updated
  31553. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31554. * @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
  31555. * @returns VertexData.
  31556. */
  31557. updateGeometry(geometry: Geometry): VertexData;
  31558. private _applyTo;
  31559. private _update;
  31560. /**
  31561. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31562. * @param matrix the transforming matrix
  31563. * @returns the VertexData
  31564. */
  31565. transform(matrix: Matrix): VertexData;
  31566. /**
  31567. * Merges the passed VertexData into the current one
  31568. * @param other the VertexData to be merged into the current one
  31569. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31570. * @returns the modified VertexData
  31571. */
  31572. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31573. private _mergeElement;
  31574. private _validate;
  31575. /**
  31576. * Serializes the VertexData
  31577. * @returns a serialized object
  31578. */
  31579. serialize(): any;
  31580. /**
  31581. * Extracts the vertexData from a mesh
  31582. * @param mesh the mesh from which to extract the VertexData
  31583. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31584. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31585. * @returns the object VertexData associated to the passed mesh
  31586. */
  31587. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31588. /**
  31589. * Extracts the vertexData from the geometry
  31590. * @param geometry the geometry from which to extract the VertexData
  31591. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31592. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31593. * @returns the object VertexData associated to the passed mesh
  31594. */
  31595. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31596. private static _ExtractFrom;
  31597. /**
  31598. * Creates the VertexData for a Ribbon
  31599. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31600. * * pathArray array of paths, each of which an array of successive Vector3
  31601. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31602. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31603. * * 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
  31604. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31605. * * 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)
  31606. * * 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)
  31607. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31608. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31609. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31610. * @returns the VertexData of the ribbon
  31611. */
  31612. static CreateRibbon(options: {
  31613. pathArray: Vector3[][];
  31614. closeArray?: boolean;
  31615. closePath?: boolean;
  31616. offset?: number;
  31617. sideOrientation?: number;
  31618. frontUVs?: Vector4;
  31619. backUVs?: Vector4;
  31620. invertUV?: boolean;
  31621. uvs?: Vector2[];
  31622. colors?: Color4[];
  31623. }): VertexData;
  31624. /**
  31625. * Creates the VertexData for a box
  31626. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31627. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31628. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31629. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31630. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31631. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31632. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31634. * * 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)
  31635. * * 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)
  31636. * @returns the VertexData of the box
  31637. */
  31638. static CreateBox(options: {
  31639. size?: number;
  31640. width?: number;
  31641. height?: number;
  31642. depth?: number;
  31643. faceUV?: Vector4[];
  31644. faceColors?: Color4[];
  31645. sideOrientation?: number;
  31646. frontUVs?: Vector4;
  31647. backUVs?: Vector4;
  31648. }): VertexData;
  31649. /**
  31650. * Creates the VertexData for a tiled box
  31651. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31652. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31653. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31654. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31656. * @returns the VertexData of the box
  31657. */
  31658. static CreateTiledBox(options: {
  31659. pattern?: number;
  31660. width?: number;
  31661. height?: number;
  31662. depth?: number;
  31663. tileSize?: number;
  31664. tileWidth?: number;
  31665. tileHeight?: number;
  31666. alignHorizontal?: number;
  31667. alignVertical?: number;
  31668. faceUV?: Vector4[];
  31669. faceColors?: Color4[];
  31670. sideOrientation?: number;
  31671. }): VertexData;
  31672. /**
  31673. * Creates the VertexData for a tiled plane
  31674. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31675. * * pattern a limited pattern arrangement depending on the number
  31676. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31677. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31678. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  31679. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31680. * * 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)
  31681. * * 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)
  31682. * @returns the VertexData of the tiled plane
  31683. */
  31684. static CreateTiledPlane(options: {
  31685. pattern?: number;
  31686. tileSize?: number;
  31687. tileWidth?: number;
  31688. tileHeight?: number;
  31689. size?: number;
  31690. width?: number;
  31691. height?: number;
  31692. alignHorizontal?: number;
  31693. alignVertical?: number;
  31694. sideOrientation?: number;
  31695. frontUVs?: Vector4;
  31696. backUVs?: Vector4;
  31697. }): VertexData;
  31698. /**
  31699. * Creates the VertexData for an ellipsoid, defaults to a sphere
  31700. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31701. * * segments sets the number of horizontal strips optional, default 32
  31702. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  31703. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  31704. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  31705. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  31706. * * 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
  31707. * * 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
  31708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31709. * * 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)
  31710. * * 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)
  31711. * @returns the VertexData of the ellipsoid
  31712. */
  31713. static CreateSphere(options: {
  31714. segments?: number;
  31715. diameter?: number;
  31716. diameterX?: number;
  31717. diameterY?: number;
  31718. diameterZ?: number;
  31719. arc?: number;
  31720. slice?: number;
  31721. sideOrientation?: number;
  31722. frontUVs?: Vector4;
  31723. backUVs?: Vector4;
  31724. }): VertexData;
  31725. /**
  31726. * Creates the VertexData for a cylinder, cone or prism
  31727. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31728. * * height sets the height (y direction) of the cylinder, optional, default 2
  31729. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  31730. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  31731. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  31732. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31733. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  31734. * * 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
  31735. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31736. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31737. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  31738. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  31739. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31740. * * 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)
  31741. * * 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)
  31742. * @returns the VertexData of the cylinder, cone or prism
  31743. */
  31744. static CreateCylinder(options: {
  31745. height?: number;
  31746. diameterTop?: number;
  31747. diameterBottom?: number;
  31748. diameter?: number;
  31749. tessellation?: number;
  31750. subdivisions?: number;
  31751. arc?: number;
  31752. faceColors?: Color4[];
  31753. faceUV?: Vector4[];
  31754. hasRings?: boolean;
  31755. enclose?: boolean;
  31756. sideOrientation?: number;
  31757. frontUVs?: Vector4;
  31758. backUVs?: Vector4;
  31759. }): VertexData;
  31760. /**
  31761. * Creates the VertexData for a torus
  31762. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31763. * * diameter the diameter of the torus, optional default 1
  31764. * * thickness the diameter of the tube forming the torus, optional default 0.5
  31765. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  31766. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31767. * * 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)
  31768. * * 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)
  31769. * @returns the VertexData of the torus
  31770. */
  31771. static CreateTorus(options: {
  31772. diameter?: number;
  31773. thickness?: number;
  31774. tessellation?: number;
  31775. sideOrientation?: number;
  31776. frontUVs?: Vector4;
  31777. backUVs?: Vector4;
  31778. }): VertexData;
  31779. /**
  31780. * Creates the VertexData of the LineSystem
  31781. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  31782. * - lines an array of lines, each line being an array of successive Vector3
  31783. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  31784. * @returns the VertexData of the LineSystem
  31785. */
  31786. static CreateLineSystem(options: {
  31787. lines: Vector3[][];
  31788. colors?: Nullable<Color4[][]>;
  31789. }): VertexData;
  31790. /**
  31791. * Create the VertexData for a DashedLines
  31792. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  31793. * - points an array successive Vector3
  31794. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  31795. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  31796. * - dashNb the intended total number of dashes, optional, default 200
  31797. * @returns the VertexData for the DashedLines
  31798. */
  31799. static CreateDashedLines(options: {
  31800. points: Vector3[];
  31801. dashSize?: number;
  31802. gapSize?: number;
  31803. dashNb?: number;
  31804. }): VertexData;
  31805. /**
  31806. * Creates the VertexData for a Ground
  31807. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31808. * - width the width (x direction) of the ground, optional, default 1
  31809. * - height the height (z direction) of the ground, optional, default 1
  31810. * - subdivisions the number of subdivisions per side, optional, default 1
  31811. * @returns the VertexData of the Ground
  31812. */
  31813. static CreateGround(options: {
  31814. width?: number;
  31815. height?: number;
  31816. subdivisions?: number;
  31817. subdivisionsX?: number;
  31818. subdivisionsY?: number;
  31819. }): VertexData;
  31820. /**
  31821. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  31822. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  31823. * * xmin the ground minimum X coordinate, optional, default -1
  31824. * * zmin the ground minimum Z coordinate, optional, default -1
  31825. * * xmax the ground maximum X coordinate, optional, default 1
  31826. * * zmax the ground maximum Z coordinate, optional, default 1
  31827. * * 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}
  31828. * * 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}
  31829. * @returns the VertexData of the TiledGround
  31830. */
  31831. static CreateTiledGround(options: {
  31832. xmin: number;
  31833. zmin: number;
  31834. xmax: number;
  31835. zmax: number;
  31836. subdivisions?: {
  31837. w: number;
  31838. h: number;
  31839. };
  31840. precision?: {
  31841. w: number;
  31842. h: number;
  31843. };
  31844. }): VertexData;
  31845. /**
  31846. * Creates the VertexData of the Ground designed from a heightmap
  31847. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  31848. * * width the width (x direction) of the ground
  31849. * * height the height (z direction) of the ground
  31850. * * subdivisions the number of subdivisions per side
  31851. * * minHeight the minimum altitude on the ground, optional, default 0
  31852. * * maxHeight the maximum altitude on the ground, optional default 1
  31853. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  31854. * * buffer the array holding the image color data
  31855. * * bufferWidth the width of image
  31856. * * bufferHeight the height of image
  31857. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  31858. * @returns the VertexData of the Ground designed from a heightmap
  31859. */
  31860. static CreateGroundFromHeightMap(options: {
  31861. width: number;
  31862. height: number;
  31863. subdivisions: number;
  31864. minHeight: number;
  31865. maxHeight: number;
  31866. colorFilter: Color3;
  31867. buffer: Uint8Array;
  31868. bufferWidth: number;
  31869. bufferHeight: number;
  31870. alphaFilter: number;
  31871. }): VertexData;
  31872. /**
  31873. * Creates the VertexData for a Plane
  31874. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  31875. * * size sets the width and height of the plane to the value of size, optional default 1
  31876. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  31877. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  31878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31879. * * 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)
  31880. * * 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)
  31881. * @returns the VertexData of the box
  31882. */
  31883. static CreatePlane(options: {
  31884. size?: number;
  31885. width?: number;
  31886. height?: number;
  31887. sideOrientation?: number;
  31888. frontUVs?: Vector4;
  31889. backUVs?: Vector4;
  31890. }): VertexData;
  31891. /**
  31892. * Creates the VertexData of the Disc or regular Polygon
  31893. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  31894. * * radius the radius of the disc, optional default 0.5
  31895. * * tessellation the number of polygon sides, optional, default 64
  31896. * * 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
  31897. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31898. * * 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)
  31899. * * 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)
  31900. * @returns the VertexData of the box
  31901. */
  31902. static CreateDisc(options: {
  31903. radius?: number;
  31904. tessellation?: number;
  31905. arc?: number;
  31906. sideOrientation?: number;
  31907. frontUVs?: Vector4;
  31908. backUVs?: Vector4;
  31909. }): VertexData;
  31910. /**
  31911. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  31912. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  31913. * @param polygon a mesh built from polygonTriangulation.build()
  31914. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31915. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31916. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31917. * @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)
  31918. * @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)
  31919. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31920. * @returns the VertexData of the Polygon
  31921. */
  31922. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31923. /**
  31924. * Creates the VertexData of the IcoSphere
  31925. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31926. * * radius the radius of the IcoSphere, optional default 1
  31927. * * radiusX allows stretching in the x direction, optional, default radius
  31928. * * radiusY allows stretching in the y direction, optional, default radius
  31929. * * radiusZ allows stretching in the z direction, optional, default radius
  31930. * * flat when true creates a flat shaded mesh, optional, default true
  31931. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31932. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31933. * * 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)
  31934. * * 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)
  31935. * @returns the VertexData of the IcoSphere
  31936. */
  31937. static CreateIcoSphere(options: {
  31938. radius?: number;
  31939. radiusX?: number;
  31940. radiusY?: number;
  31941. radiusZ?: number;
  31942. flat?: boolean;
  31943. subdivisions?: number;
  31944. sideOrientation?: number;
  31945. frontUVs?: Vector4;
  31946. backUVs?: Vector4;
  31947. }): VertexData;
  31948. /**
  31949. * Creates the VertexData for a Polyhedron
  31950. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31951. * * type provided types are:
  31952. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31953. * * 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)
  31954. * * size the size of the IcoSphere, optional default 1
  31955. * * sizeX allows stretching in the x direction, optional, default size
  31956. * * sizeY allows stretching in the y direction, optional, default size
  31957. * * sizeZ allows stretching in the z direction, optional, default size
  31958. * * 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
  31959. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31960. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31961. * * flat when true creates a flat shaded mesh, optional, default true
  31962. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31964. * * 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)
  31965. * * 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)
  31966. * @returns the VertexData of the Polyhedron
  31967. */
  31968. static CreatePolyhedron(options: {
  31969. type?: number;
  31970. size?: number;
  31971. sizeX?: number;
  31972. sizeY?: number;
  31973. sizeZ?: number;
  31974. custom?: any;
  31975. faceUV?: Vector4[];
  31976. faceColors?: Color4[];
  31977. flat?: boolean;
  31978. sideOrientation?: number;
  31979. frontUVs?: Vector4;
  31980. backUVs?: Vector4;
  31981. }): VertexData;
  31982. /**
  31983. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  31984. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  31985. * @returns the VertexData of the Capsule
  31986. */
  31987. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  31988. /**
  31989. * Creates the VertexData for a TorusKnot
  31990. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  31991. * * radius the radius of the torus knot, optional, default 2
  31992. * * tube the thickness of the tube, optional, default 0.5
  31993. * * radialSegments the number of sides on each tube segments, optional, default 32
  31994. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  31995. * * p the number of windings around the z axis, optional, default 2
  31996. * * q the number of windings around the x axis, optional, default 3
  31997. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31998. * * 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)
  31999. * * 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)
  32000. * @returns the VertexData of the Torus Knot
  32001. */
  32002. static CreateTorusKnot(options: {
  32003. radius?: number;
  32004. tube?: number;
  32005. radialSegments?: number;
  32006. tubularSegments?: number;
  32007. p?: number;
  32008. q?: number;
  32009. sideOrientation?: number;
  32010. frontUVs?: Vector4;
  32011. backUVs?: Vector4;
  32012. }): VertexData;
  32013. /**
  32014. * Compute normals for given positions and indices
  32015. * @param positions an array of vertex positions, [...., x, y, z, ......]
  32016. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  32017. * @param normals an array of vertex normals, [...., x, y, z, ......]
  32018. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  32019. * * facetNormals : optional array of facet normals (vector3)
  32020. * * facetPositions : optional array of facet positions (vector3)
  32021. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  32022. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  32023. * * bInfo : optional bounding info, required for facetPartitioning computation
  32024. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  32025. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  32026. * * useRightHandedSystem: optional boolean to for right handed system computation
  32027. * * depthSort : optional boolean to enable the facet depth sort computation
  32028. * * distanceTo : optional Vector3 to compute the facet depth from this location
  32029. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  32030. */
  32031. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  32032. facetNormals?: any;
  32033. facetPositions?: any;
  32034. facetPartitioning?: any;
  32035. ratio?: number;
  32036. bInfo?: any;
  32037. bbSize?: Vector3;
  32038. subDiv?: any;
  32039. useRightHandedSystem?: boolean;
  32040. depthSort?: boolean;
  32041. distanceTo?: Vector3;
  32042. depthSortedFacets?: any;
  32043. }): void;
  32044. /** @hidden */
  32045. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  32046. /**
  32047. * Applies VertexData created from the imported parameters to the geometry
  32048. * @param parsedVertexData the parsed data from an imported file
  32049. * @param geometry the geometry to apply the VertexData to
  32050. */
  32051. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  32052. }
  32053. }
  32054. declare module "babylonjs/Morph/morphTarget" {
  32055. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32056. import { Observable } from "babylonjs/Misc/observable";
  32057. import { Nullable, FloatArray } from "babylonjs/types";
  32058. import { Scene } from "babylonjs/scene";
  32059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32060. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32061. /**
  32062. * Defines a target to use with MorphTargetManager
  32063. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32064. */
  32065. export class MorphTarget implements IAnimatable {
  32066. /** defines the name of the target */
  32067. name: string;
  32068. /**
  32069. * Gets or sets the list of animations
  32070. */
  32071. animations: import("babylonjs/Animations/animation").Animation[];
  32072. private _scene;
  32073. private _positions;
  32074. private _normals;
  32075. private _tangents;
  32076. private _uvs;
  32077. private _influence;
  32078. private _uniqueId;
  32079. /**
  32080. * Observable raised when the influence changes
  32081. */
  32082. onInfluenceChanged: Observable<boolean>;
  32083. /** @hidden */
  32084. _onDataLayoutChanged: Observable<void>;
  32085. /**
  32086. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32087. */
  32088. get influence(): number;
  32089. set influence(influence: number);
  32090. /**
  32091. * Gets or sets the id of the morph Target
  32092. */
  32093. id: string;
  32094. private _animationPropertiesOverride;
  32095. /**
  32096. * Gets or sets the animation properties override
  32097. */
  32098. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32099. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32100. /**
  32101. * Creates a new MorphTarget
  32102. * @param name defines the name of the target
  32103. * @param influence defines the influence to use
  32104. * @param scene defines the scene the morphtarget belongs to
  32105. */
  32106. constructor(
  32107. /** defines the name of the target */
  32108. name: string, influence?: number, scene?: Nullable<Scene>);
  32109. /**
  32110. * Gets the unique ID of this manager
  32111. */
  32112. get uniqueId(): number;
  32113. /**
  32114. * Gets a boolean defining if the target contains position data
  32115. */
  32116. get hasPositions(): boolean;
  32117. /**
  32118. * Gets a boolean defining if the target contains normal data
  32119. */
  32120. get hasNormals(): boolean;
  32121. /**
  32122. * Gets a boolean defining if the target contains tangent data
  32123. */
  32124. get hasTangents(): boolean;
  32125. /**
  32126. * Gets a boolean defining if the target contains texture coordinates data
  32127. */
  32128. get hasUVs(): boolean;
  32129. /**
  32130. * Affects position data to this target
  32131. * @param data defines the position data to use
  32132. */
  32133. setPositions(data: Nullable<FloatArray>): void;
  32134. /**
  32135. * Gets the position data stored in this target
  32136. * @returns a FloatArray containing the position data (or null if not present)
  32137. */
  32138. getPositions(): Nullable<FloatArray>;
  32139. /**
  32140. * Affects normal data to this target
  32141. * @param data defines the normal data to use
  32142. */
  32143. setNormals(data: Nullable<FloatArray>): void;
  32144. /**
  32145. * Gets the normal data stored in this target
  32146. * @returns a FloatArray containing the normal data (or null if not present)
  32147. */
  32148. getNormals(): Nullable<FloatArray>;
  32149. /**
  32150. * Affects tangent data to this target
  32151. * @param data defines the tangent data to use
  32152. */
  32153. setTangents(data: Nullable<FloatArray>): void;
  32154. /**
  32155. * Gets the tangent data stored in this target
  32156. * @returns a FloatArray containing the tangent data (or null if not present)
  32157. */
  32158. getTangents(): Nullable<FloatArray>;
  32159. /**
  32160. * Affects texture coordinates data to this target
  32161. * @param data defines the texture coordinates data to use
  32162. */
  32163. setUVs(data: Nullable<FloatArray>): void;
  32164. /**
  32165. * Gets the texture coordinates data stored in this target
  32166. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32167. */
  32168. getUVs(): Nullable<FloatArray>;
  32169. /**
  32170. * Clone the current target
  32171. * @returns a new MorphTarget
  32172. */
  32173. clone(): MorphTarget;
  32174. /**
  32175. * Serializes the current target into a Serialization object
  32176. * @returns the serialized object
  32177. */
  32178. serialize(): any;
  32179. /**
  32180. * Returns the string "MorphTarget"
  32181. * @returns "MorphTarget"
  32182. */
  32183. getClassName(): string;
  32184. /**
  32185. * Creates a new target from serialized data
  32186. * @param serializationObject defines the serialized data to use
  32187. * @returns a new MorphTarget
  32188. */
  32189. static Parse(serializationObject: any): MorphTarget;
  32190. /**
  32191. * Creates a MorphTarget from mesh data
  32192. * @param mesh defines the source mesh
  32193. * @param name defines the name to use for the new target
  32194. * @param influence defines the influence to attach to the target
  32195. * @returns a new MorphTarget
  32196. */
  32197. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32198. }
  32199. }
  32200. declare module "babylonjs/Morph/morphTargetManager" {
  32201. import { Nullable } from "babylonjs/types";
  32202. import { Scene } from "babylonjs/scene";
  32203. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32204. /**
  32205. * This class is used to deform meshes using morphing between different targets
  32206. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32207. */
  32208. export class MorphTargetManager {
  32209. private _targets;
  32210. private _targetInfluenceChangedObservers;
  32211. private _targetDataLayoutChangedObservers;
  32212. private _activeTargets;
  32213. private _scene;
  32214. private _influences;
  32215. private _supportsNormals;
  32216. private _supportsTangents;
  32217. private _supportsUVs;
  32218. private _vertexCount;
  32219. private _uniqueId;
  32220. private _tempInfluences;
  32221. /**
  32222. * Gets or sets a boolean indicating if normals must be morphed
  32223. */
  32224. enableNormalMorphing: boolean;
  32225. /**
  32226. * Gets or sets a boolean indicating if tangents must be morphed
  32227. */
  32228. enableTangentMorphing: boolean;
  32229. /**
  32230. * Gets or sets a boolean indicating if UV must be morphed
  32231. */
  32232. enableUVMorphing: boolean;
  32233. /**
  32234. * Creates a new MorphTargetManager
  32235. * @param scene defines the current scene
  32236. */
  32237. constructor(scene?: Nullable<Scene>);
  32238. /**
  32239. * Gets the unique ID of this manager
  32240. */
  32241. get uniqueId(): number;
  32242. /**
  32243. * Gets the number of vertices handled by this manager
  32244. */
  32245. get vertexCount(): number;
  32246. /**
  32247. * Gets a boolean indicating if this manager supports morphing of normals
  32248. */
  32249. get supportsNormals(): boolean;
  32250. /**
  32251. * Gets a boolean indicating if this manager supports morphing of tangents
  32252. */
  32253. get supportsTangents(): boolean;
  32254. /**
  32255. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32256. */
  32257. get supportsUVs(): boolean;
  32258. /**
  32259. * Gets the number of targets stored in this manager
  32260. */
  32261. get numTargets(): number;
  32262. /**
  32263. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32264. */
  32265. get numInfluencers(): number;
  32266. /**
  32267. * Gets the list of influences (one per target)
  32268. */
  32269. get influences(): Float32Array;
  32270. /**
  32271. * Gets the active target at specified index. An active target is a target with an influence > 0
  32272. * @param index defines the index to check
  32273. * @returns the requested target
  32274. */
  32275. getActiveTarget(index: number): MorphTarget;
  32276. /**
  32277. * Gets the target at specified index
  32278. * @param index defines the index to check
  32279. * @returns the requested target
  32280. */
  32281. getTarget(index: number): MorphTarget;
  32282. /**
  32283. * Add a new target to this manager
  32284. * @param target defines the target to add
  32285. */
  32286. addTarget(target: MorphTarget): void;
  32287. /**
  32288. * Removes a target from the manager
  32289. * @param target defines the target to remove
  32290. */
  32291. removeTarget(target: MorphTarget): void;
  32292. /**
  32293. * Clone the current manager
  32294. * @returns a new MorphTargetManager
  32295. */
  32296. clone(): MorphTargetManager;
  32297. /**
  32298. * Serializes the current manager into a Serialization object
  32299. * @returns the serialized object
  32300. */
  32301. serialize(): any;
  32302. private _syncActiveTargets;
  32303. /**
  32304. * Syncrhonize the targets with all the meshes using this morph target manager
  32305. */
  32306. synchronize(): void;
  32307. /**
  32308. * Creates a new MorphTargetManager from serialized data
  32309. * @param serializationObject defines the serialized data
  32310. * @param scene defines the hosting scene
  32311. * @returns the new MorphTargetManager
  32312. */
  32313. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32314. }
  32315. }
  32316. declare module "babylonjs/Meshes/meshLODLevel" {
  32317. import { Mesh } from "babylonjs/Meshes/mesh";
  32318. import { Nullable } from "babylonjs/types";
  32319. /**
  32320. * Class used to represent a specific level of detail of a mesh
  32321. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32322. */
  32323. export class MeshLODLevel {
  32324. /** Defines the distance where this level should start being displayed */
  32325. distance: number;
  32326. /** Defines the mesh to use to render this level */
  32327. mesh: Nullable<Mesh>;
  32328. /**
  32329. * Creates a new LOD level
  32330. * @param distance defines the distance where this level should star being displayed
  32331. * @param mesh defines the mesh to use to render this level
  32332. */
  32333. constructor(
  32334. /** Defines the distance where this level should start being displayed */
  32335. distance: number,
  32336. /** Defines the mesh to use to render this level */
  32337. mesh: Nullable<Mesh>);
  32338. }
  32339. }
  32340. declare module "babylonjs/Misc/canvasGenerator" {
  32341. /**
  32342. * Helper class used to generate a canvas to manipulate images
  32343. */
  32344. export class CanvasGenerator {
  32345. /**
  32346. * Create a new canvas (or offscreen canvas depending on the context)
  32347. * @param width defines the expected width
  32348. * @param height defines the expected height
  32349. * @return a new canvas or offscreen canvas
  32350. */
  32351. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32352. }
  32353. }
  32354. declare module "babylonjs/Meshes/groundMesh" {
  32355. import { Scene } from "babylonjs/scene";
  32356. import { Vector3 } from "babylonjs/Maths/math.vector";
  32357. import { Mesh } from "babylonjs/Meshes/mesh";
  32358. /**
  32359. * Mesh representing the gorund
  32360. */
  32361. export class GroundMesh extends Mesh {
  32362. /** If octree should be generated */
  32363. generateOctree: boolean;
  32364. private _heightQuads;
  32365. /** @hidden */
  32366. _subdivisionsX: number;
  32367. /** @hidden */
  32368. _subdivisionsY: number;
  32369. /** @hidden */
  32370. _width: number;
  32371. /** @hidden */
  32372. _height: number;
  32373. /** @hidden */
  32374. _minX: number;
  32375. /** @hidden */
  32376. _maxX: number;
  32377. /** @hidden */
  32378. _minZ: number;
  32379. /** @hidden */
  32380. _maxZ: number;
  32381. constructor(name: string, scene: Scene);
  32382. /**
  32383. * "GroundMesh"
  32384. * @returns "GroundMesh"
  32385. */
  32386. getClassName(): string;
  32387. /**
  32388. * The minimum of x and y subdivisions
  32389. */
  32390. get subdivisions(): number;
  32391. /**
  32392. * X subdivisions
  32393. */
  32394. get subdivisionsX(): number;
  32395. /**
  32396. * Y subdivisions
  32397. */
  32398. get subdivisionsY(): number;
  32399. /**
  32400. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32401. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32402. * @param chunksCount the number of subdivisions for x and y
  32403. * @param octreeBlocksSize (Default: 32)
  32404. */
  32405. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32406. /**
  32407. * Returns a height (y) value in the Worl system :
  32408. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32409. * @param x x coordinate
  32410. * @param z z coordinate
  32411. * @returns the ground y position if (x, z) are outside the ground surface.
  32412. */
  32413. getHeightAtCoordinates(x: number, z: number): number;
  32414. /**
  32415. * Returns a normalized vector (Vector3) orthogonal to the ground
  32416. * at the ground coordinates (x, z) expressed in the World system.
  32417. * @param x x coordinate
  32418. * @param z z coordinate
  32419. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32420. */
  32421. getNormalAtCoordinates(x: number, z: number): Vector3;
  32422. /**
  32423. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32424. * at the ground coordinates (x, z) expressed in the World system.
  32425. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32426. * @param x x coordinate
  32427. * @param z z coordinate
  32428. * @param ref vector to store the result
  32429. * @returns the GroundMesh.
  32430. */
  32431. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32432. /**
  32433. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32434. * if the ground has been updated.
  32435. * This can be used in the render loop.
  32436. * @returns the GroundMesh.
  32437. */
  32438. updateCoordinateHeights(): GroundMesh;
  32439. private _getFacetAt;
  32440. private _initHeightQuads;
  32441. private _computeHeightQuads;
  32442. /**
  32443. * Serializes this ground mesh
  32444. * @param serializationObject object to write serialization to
  32445. */
  32446. serialize(serializationObject: any): void;
  32447. /**
  32448. * Parses a serialized ground mesh
  32449. * @param parsedMesh the serialized mesh
  32450. * @param scene the scene to create the ground mesh in
  32451. * @returns the created ground mesh
  32452. */
  32453. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32454. }
  32455. }
  32456. declare module "babylonjs/Physics/physicsJoint" {
  32457. import { Vector3 } from "babylonjs/Maths/math.vector";
  32458. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32459. /**
  32460. * Interface for Physics-Joint data
  32461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32462. */
  32463. export interface PhysicsJointData {
  32464. /**
  32465. * The main pivot of the joint
  32466. */
  32467. mainPivot?: Vector3;
  32468. /**
  32469. * The connected pivot of the joint
  32470. */
  32471. connectedPivot?: Vector3;
  32472. /**
  32473. * The main axis of the joint
  32474. */
  32475. mainAxis?: Vector3;
  32476. /**
  32477. * The connected axis of the joint
  32478. */
  32479. connectedAxis?: Vector3;
  32480. /**
  32481. * The collision of the joint
  32482. */
  32483. collision?: boolean;
  32484. /**
  32485. * Native Oimo/Cannon/Energy data
  32486. */
  32487. nativeParams?: any;
  32488. }
  32489. /**
  32490. * This is a holder class for the physics joint created by the physics plugin
  32491. * It holds a set of functions to control the underlying joint
  32492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32493. */
  32494. export class PhysicsJoint {
  32495. /**
  32496. * The type of the physics joint
  32497. */
  32498. type: number;
  32499. /**
  32500. * The data for the physics joint
  32501. */
  32502. jointData: PhysicsJointData;
  32503. private _physicsJoint;
  32504. protected _physicsPlugin: IPhysicsEnginePlugin;
  32505. /**
  32506. * Initializes the physics joint
  32507. * @param type The type of the physics joint
  32508. * @param jointData The data for the physics joint
  32509. */
  32510. constructor(
  32511. /**
  32512. * The type of the physics joint
  32513. */
  32514. type: number,
  32515. /**
  32516. * The data for the physics joint
  32517. */
  32518. jointData: PhysicsJointData);
  32519. /**
  32520. * Gets the physics joint
  32521. */
  32522. get physicsJoint(): any;
  32523. /**
  32524. * Sets the physics joint
  32525. */
  32526. set physicsJoint(newJoint: any);
  32527. /**
  32528. * Sets the physics plugin
  32529. */
  32530. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32531. /**
  32532. * Execute a function that is physics-plugin specific.
  32533. * @param {Function} func the function that will be executed.
  32534. * It accepts two parameters: the physics world and the physics joint
  32535. */
  32536. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32537. /**
  32538. * Distance-Joint type
  32539. */
  32540. static DistanceJoint: number;
  32541. /**
  32542. * Hinge-Joint type
  32543. */
  32544. static HingeJoint: number;
  32545. /**
  32546. * Ball-and-Socket joint type
  32547. */
  32548. static BallAndSocketJoint: number;
  32549. /**
  32550. * Wheel-Joint type
  32551. */
  32552. static WheelJoint: number;
  32553. /**
  32554. * Slider-Joint type
  32555. */
  32556. static SliderJoint: number;
  32557. /**
  32558. * Prismatic-Joint type
  32559. */
  32560. static PrismaticJoint: number;
  32561. /**
  32562. * Universal-Joint type
  32563. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32564. */
  32565. static UniversalJoint: number;
  32566. /**
  32567. * Hinge-Joint 2 type
  32568. */
  32569. static Hinge2Joint: number;
  32570. /**
  32571. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32572. */
  32573. static PointToPointJoint: number;
  32574. /**
  32575. * Spring-Joint type
  32576. */
  32577. static SpringJoint: number;
  32578. /**
  32579. * Lock-Joint type
  32580. */
  32581. static LockJoint: number;
  32582. }
  32583. /**
  32584. * A class representing a physics distance joint
  32585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32586. */
  32587. export class DistanceJoint extends PhysicsJoint {
  32588. /**
  32589. *
  32590. * @param jointData The data for the Distance-Joint
  32591. */
  32592. constructor(jointData: DistanceJointData);
  32593. /**
  32594. * Update the predefined distance.
  32595. * @param maxDistance The maximum preferred distance
  32596. * @param minDistance The minimum preferred distance
  32597. */
  32598. updateDistance(maxDistance: number, minDistance?: number): void;
  32599. }
  32600. /**
  32601. * Represents a Motor-Enabled Joint
  32602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32603. */
  32604. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32605. /**
  32606. * Initializes the Motor-Enabled Joint
  32607. * @param type The type of the joint
  32608. * @param jointData The physica joint data for the joint
  32609. */
  32610. constructor(type: number, jointData: PhysicsJointData);
  32611. /**
  32612. * Set the motor values.
  32613. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32614. * @param force the force to apply
  32615. * @param maxForce max force for this motor.
  32616. */
  32617. setMotor(force?: number, maxForce?: number): void;
  32618. /**
  32619. * Set the motor's limits.
  32620. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32621. * @param upperLimit The upper limit of the motor
  32622. * @param lowerLimit The lower limit of the motor
  32623. */
  32624. setLimit(upperLimit: number, lowerLimit?: number): void;
  32625. }
  32626. /**
  32627. * This class represents a single physics Hinge-Joint
  32628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32629. */
  32630. export class HingeJoint extends MotorEnabledJoint {
  32631. /**
  32632. * Initializes the Hinge-Joint
  32633. * @param jointData The joint data for the Hinge-Joint
  32634. */
  32635. constructor(jointData: PhysicsJointData);
  32636. /**
  32637. * Set the motor values.
  32638. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32639. * @param {number} force the force to apply
  32640. * @param {number} maxForce max force for this motor.
  32641. */
  32642. setMotor(force?: number, maxForce?: number): void;
  32643. /**
  32644. * Set the motor's limits.
  32645. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32646. * @param upperLimit The upper limit of the motor
  32647. * @param lowerLimit The lower limit of the motor
  32648. */
  32649. setLimit(upperLimit: number, lowerLimit?: number): void;
  32650. }
  32651. /**
  32652. * This class represents a dual hinge physics joint (same as wheel joint)
  32653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32654. */
  32655. export class Hinge2Joint extends MotorEnabledJoint {
  32656. /**
  32657. * Initializes the Hinge2-Joint
  32658. * @param jointData The joint data for the Hinge2-Joint
  32659. */
  32660. constructor(jointData: PhysicsJointData);
  32661. /**
  32662. * Set the motor values.
  32663. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32664. * @param {number} targetSpeed the speed the motor is to reach
  32665. * @param {number} maxForce max force for this motor.
  32666. * @param {motorIndex} the motor's index, 0 or 1.
  32667. */
  32668. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32669. /**
  32670. * Set the motor limits.
  32671. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32672. * @param {number} upperLimit the upper limit
  32673. * @param {number} lowerLimit lower limit
  32674. * @param {motorIndex} the motor's index, 0 or 1.
  32675. */
  32676. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32677. }
  32678. /**
  32679. * Interface for a motor enabled joint
  32680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32681. */
  32682. export interface IMotorEnabledJoint {
  32683. /**
  32684. * Physics joint
  32685. */
  32686. physicsJoint: any;
  32687. /**
  32688. * Sets the motor of the motor-enabled joint
  32689. * @param force The force of the motor
  32690. * @param maxForce The maximum force of the motor
  32691. * @param motorIndex The index of the motor
  32692. */
  32693. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32694. /**
  32695. * Sets the limit of the motor
  32696. * @param upperLimit The upper limit of the motor
  32697. * @param lowerLimit The lower limit of the motor
  32698. * @param motorIndex The index of the motor
  32699. */
  32700. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32701. }
  32702. /**
  32703. * Joint data for a Distance-Joint
  32704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32705. */
  32706. export interface DistanceJointData extends PhysicsJointData {
  32707. /**
  32708. * Max distance the 2 joint objects can be apart
  32709. */
  32710. maxDistance: number;
  32711. }
  32712. /**
  32713. * Joint data from a spring joint
  32714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32715. */
  32716. export interface SpringJointData extends PhysicsJointData {
  32717. /**
  32718. * Length of the spring
  32719. */
  32720. length: number;
  32721. /**
  32722. * Stiffness of the spring
  32723. */
  32724. stiffness: number;
  32725. /**
  32726. * Damping of the spring
  32727. */
  32728. damping: number;
  32729. /** this callback will be called when applying the force to the impostors. */
  32730. forceApplicationCallback: () => void;
  32731. }
  32732. }
  32733. declare module "babylonjs/Physics/physicsRaycastResult" {
  32734. import { Vector3 } from "babylonjs/Maths/math.vector";
  32735. /**
  32736. * Holds the data for the raycast result
  32737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32738. */
  32739. export class PhysicsRaycastResult {
  32740. private _hasHit;
  32741. private _hitDistance;
  32742. private _hitNormalWorld;
  32743. private _hitPointWorld;
  32744. private _rayFromWorld;
  32745. private _rayToWorld;
  32746. /**
  32747. * Gets if there was a hit
  32748. */
  32749. get hasHit(): boolean;
  32750. /**
  32751. * Gets the distance from the hit
  32752. */
  32753. get hitDistance(): number;
  32754. /**
  32755. * Gets the hit normal/direction in the world
  32756. */
  32757. get hitNormalWorld(): Vector3;
  32758. /**
  32759. * Gets the hit point in the world
  32760. */
  32761. get hitPointWorld(): Vector3;
  32762. /**
  32763. * Gets the ray "start point" of the ray in the world
  32764. */
  32765. get rayFromWorld(): Vector3;
  32766. /**
  32767. * Gets the ray "end point" of the ray in the world
  32768. */
  32769. get rayToWorld(): Vector3;
  32770. /**
  32771. * Sets the hit data (normal & point in world space)
  32772. * @param hitNormalWorld defines the normal in world space
  32773. * @param hitPointWorld defines the point in world space
  32774. */
  32775. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32776. /**
  32777. * Sets the distance from the start point to the hit point
  32778. * @param distance
  32779. */
  32780. setHitDistance(distance: number): void;
  32781. /**
  32782. * Calculates the distance manually
  32783. */
  32784. calculateHitDistance(): void;
  32785. /**
  32786. * Resets all the values to default
  32787. * @param from The from point on world space
  32788. * @param to The to point on world space
  32789. */
  32790. reset(from?: Vector3, to?: Vector3): void;
  32791. }
  32792. /**
  32793. * Interface for the size containing width and height
  32794. */
  32795. interface IXYZ {
  32796. /**
  32797. * X
  32798. */
  32799. x: number;
  32800. /**
  32801. * Y
  32802. */
  32803. y: number;
  32804. /**
  32805. * Z
  32806. */
  32807. z: number;
  32808. }
  32809. }
  32810. declare module "babylonjs/Physics/IPhysicsEngine" {
  32811. import { Nullable } from "babylonjs/types";
  32812. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32814. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32815. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32816. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32817. /**
  32818. * Interface used to describe a physics joint
  32819. */
  32820. export interface PhysicsImpostorJoint {
  32821. /** Defines the main impostor to which the joint is linked */
  32822. mainImpostor: PhysicsImpostor;
  32823. /** Defines the impostor that is connected to the main impostor using this joint */
  32824. connectedImpostor: PhysicsImpostor;
  32825. /** Defines the joint itself */
  32826. joint: PhysicsJoint;
  32827. }
  32828. /** @hidden */
  32829. export interface IPhysicsEnginePlugin {
  32830. world: any;
  32831. name: string;
  32832. setGravity(gravity: Vector3): void;
  32833. setTimeStep(timeStep: number): void;
  32834. getTimeStep(): number;
  32835. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32836. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32837. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32838. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32839. removePhysicsBody(impostor: PhysicsImpostor): void;
  32840. generateJoint(joint: PhysicsImpostorJoint): void;
  32841. removeJoint(joint: PhysicsImpostorJoint): void;
  32842. isSupported(): boolean;
  32843. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32844. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32845. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32846. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32847. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32848. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32849. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32850. getBodyMass(impostor: PhysicsImpostor): number;
  32851. getBodyFriction(impostor: PhysicsImpostor): number;
  32852. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32853. getBodyRestitution(impostor: PhysicsImpostor): number;
  32854. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32855. getBodyPressure?(impostor: PhysicsImpostor): number;
  32856. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32857. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32858. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32859. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32860. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32861. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32862. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32863. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32864. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32865. sleepBody(impostor: PhysicsImpostor): void;
  32866. wakeUpBody(impostor: PhysicsImpostor): void;
  32867. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32868. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32869. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32870. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32871. getRadius(impostor: PhysicsImpostor): number;
  32872. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32873. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32874. dispose(): void;
  32875. }
  32876. /**
  32877. * Interface used to define a physics engine
  32878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32879. */
  32880. export interface IPhysicsEngine {
  32881. /**
  32882. * Gets the gravity vector used by the simulation
  32883. */
  32884. gravity: Vector3;
  32885. /**
  32886. * Sets the gravity vector used by the simulation
  32887. * @param gravity defines the gravity vector to use
  32888. */
  32889. setGravity(gravity: Vector3): void;
  32890. /**
  32891. * Set the time step of the physics engine.
  32892. * Default is 1/60.
  32893. * To slow it down, enter 1/600 for example.
  32894. * To speed it up, 1/30
  32895. * @param newTimeStep the new timestep to apply to this world.
  32896. */
  32897. setTimeStep(newTimeStep: number): void;
  32898. /**
  32899. * Get the time step of the physics engine.
  32900. * @returns the current time step
  32901. */
  32902. getTimeStep(): number;
  32903. /**
  32904. * Set the sub time step of the physics engine.
  32905. * Default is 0 meaning there is no sub steps
  32906. * To increase physics resolution precision, set a small value (like 1 ms)
  32907. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32908. */
  32909. setSubTimeStep(subTimeStep: number): void;
  32910. /**
  32911. * Get the sub time step of the physics engine.
  32912. * @returns the current sub time step
  32913. */
  32914. getSubTimeStep(): number;
  32915. /**
  32916. * Release all resources
  32917. */
  32918. dispose(): void;
  32919. /**
  32920. * Gets the name of the current physics plugin
  32921. * @returns the name of the plugin
  32922. */
  32923. getPhysicsPluginName(): string;
  32924. /**
  32925. * Adding a new impostor for the impostor tracking.
  32926. * This will be done by the impostor itself.
  32927. * @param impostor the impostor to add
  32928. */
  32929. addImpostor(impostor: PhysicsImpostor): void;
  32930. /**
  32931. * Remove an impostor from the engine.
  32932. * This impostor and its mesh will not longer be updated by the physics engine.
  32933. * @param impostor the impostor to remove
  32934. */
  32935. removeImpostor(impostor: PhysicsImpostor): void;
  32936. /**
  32937. * Add a joint to the physics engine
  32938. * @param mainImpostor defines the main impostor to which the joint is added.
  32939. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32940. * @param joint defines the joint that will connect both impostors.
  32941. */
  32942. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32943. /**
  32944. * Removes a joint from the simulation
  32945. * @param mainImpostor defines the impostor used with the joint
  32946. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32947. * @param joint defines the joint to remove
  32948. */
  32949. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32950. /**
  32951. * Gets the current plugin used to run the simulation
  32952. * @returns current plugin
  32953. */
  32954. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32955. /**
  32956. * Gets the list of physic impostors
  32957. * @returns an array of PhysicsImpostor
  32958. */
  32959. getImpostors(): Array<PhysicsImpostor>;
  32960. /**
  32961. * Gets the impostor for a physics enabled object
  32962. * @param object defines the object impersonated by the impostor
  32963. * @returns the PhysicsImpostor or null if not found
  32964. */
  32965. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32966. /**
  32967. * Gets the impostor for a physics body object
  32968. * @param body defines physics body used by the impostor
  32969. * @returns the PhysicsImpostor or null if not found
  32970. */
  32971. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32972. /**
  32973. * Does a raycast in the physics world
  32974. * @param from when should the ray start?
  32975. * @param to when should the ray end?
  32976. * @returns PhysicsRaycastResult
  32977. */
  32978. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32979. /**
  32980. * Called by the scene. No need to call it.
  32981. * @param delta defines the timespam between frames
  32982. */
  32983. _step(delta: number): void;
  32984. }
  32985. }
  32986. declare module "babylonjs/Physics/physicsImpostor" {
  32987. import { Nullable, IndicesArray } from "babylonjs/types";
  32988. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  32989. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32991. import { Scene } from "babylonjs/scene";
  32992. import { Bone } from "babylonjs/Bones/bone";
  32993. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32994. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  32995. import { Space } from "babylonjs/Maths/math.axis";
  32996. /**
  32997. * The interface for the physics imposter parameters
  32998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32999. */
  33000. export interface PhysicsImpostorParameters {
  33001. /**
  33002. * The mass of the physics imposter
  33003. */
  33004. mass: number;
  33005. /**
  33006. * The friction of the physics imposter
  33007. */
  33008. friction?: number;
  33009. /**
  33010. * The coefficient of restitution of the physics imposter
  33011. */
  33012. restitution?: number;
  33013. /**
  33014. * The native options of the physics imposter
  33015. */
  33016. nativeOptions?: any;
  33017. /**
  33018. * Specifies if the parent should be ignored
  33019. */
  33020. ignoreParent?: boolean;
  33021. /**
  33022. * Specifies if bi-directional transformations should be disabled
  33023. */
  33024. disableBidirectionalTransformation?: boolean;
  33025. /**
  33026. * The pressure inside the physics imposter, soft object only
  33027. */
  33028. pressure?: number;
  33029. /**
  33030. * The stiffness the physics imposter, soft object only
  33031. */
  33032. stiffness?: number;
  33033. /**
  33034. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33035. */
  33036. velocityIterations?: number;
  33037. /**
  33038. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33039. */
  33040. positionIterations?: number;
  33041. /**
  33042. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33043. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33044. * Add to fix multiple points
  33045. */
  33046. fixedPoints?: number;
  33047. /**
  33048. * The collision margin around a soft object
  33049. */
  33050. margin?: number;
  33051. /**
  33052. * The collision margin around a soft object
  33053. */
  33054. damping?: number;
  33055. /**
  33056. * The path for a rope based on an extrusion
  33057. */
  33058. path?: any;
  33059. /**
  33060. * The shape of an extrusion used for a rope based on an extrusion
  33061. */
  33062. shape?: any;
  33063. }
  33064. /**
  33065. * Interface for a physics-enabled object
  33066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33067. */
  33068. export interface IPhysicsEnabledObject {
  33069. /**
  33070. * The position of the physics-enabled object
  33071. */
  33072. position: Vector3;
  33073. /**
  33074. * The rotation of the physics-enabled object
  33075. */
  33076. rotationQuaternion: Nullable<Quaternion>;
  33077. /**
  33078. * The scale of the physics-enabled object
  33079. */
  33080. scaling: Vector3;
  33081. /**
  33082. * The rotation of the physics-enabled object
  33083. */
  33084. rotation?: Vector3;
  33085. /**
  33086. * The parent of the physics-enabled object
  33087. */
  33088. parent?: any;
  33089. /**
  33090. * The bounding info of the physics-enabled object
  33091. * @returns The bounding info of the physics-enabled object
  33092. */
  33093. getBoundingInfo(): BoundingInfo;
  33094. /**
  33095. * Computes the world matrix
  33096. * @param force Specifies if the world matrix should be computed by force
  33097. * @returns A world matrix
  33098. */
  33099. computeWorldMatrix(force: boolean): Matrix;
  33100. /**
  33101. * Gets the world matrix
  33102. * @returns A world matrix
  33103. */
  33104. getWorldMatrix?(): Matrix;
  33105. /**
  33106. * Gets the child meshes
  33107. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33108. * @returns An array of abstract meshes
  33109. */
  33110. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33111. /**
  33112. * Gets the vertex data
  33113. * @param kind The type of vertex data
  33114. * @returns A nullable array of numbers, or a float32 array
  33115. */
  33116. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33117. /**
  33118. * Gets the indices from the mesh
  33119. * @returns A nullable array of index arrays
  33120. */
  33121. getIndices?(): Nullable<IndicesArray>;
  33122. /**
  33123. * Gets the scene from the mesh
  33124. * @returns the indices array or null
  33125. */
  33126. getScene?(): Scene;
  33127. /**
  33128. * Gets the absolute position from the mesh
  33129. * @returns the absolute position
  33130. */
  33131. getAbsolutePosition(): Vector3;
  33132. /**
  33133. * Gets the absolute pivot point from the mesh
  33134. * @returns the absolute pivot point
  33135. */
  33136. getAbsolutePivotPoint(): Vector3;
  33137. /**
  33138. * Rotates the mesh
  33139. * @param axis The axis of rotation
  33140. * @param amount The amount of rotation
  33141. * @param space The space of the rotation
  33142. * @returns The rotation transform node
  33143. */
  33144. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33145. /**
  33146. * Translates the mesh
  33147. * @param axis The axis of translation
  33148. * @param distance The distance of translation
  33149. * @param space The space of the translation
  33150. * @returns The transform node
  33151. */
  33152. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33153. /**
  33154. * Sets the absolute position of the mesh
  33155. * @param absolutePosition The absolute position of the mesh
  33156. * @returns The transform node
  33157. */
  33158. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33159. /**
  33160. * Gets the class name of the mesh
  33161. * @returns The class name
  33162. */
  33163. getClassName(): string;
  33164. }
  33165. /**
  33166. * Represents a physics imposter
  33167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33168. */
  33169. export class PhysicsImpostor {
  33170. /**
  33171. * The physics-enabled object used as the physics imposter
  33172. */
  33173. object: IPhysicsEnabledObject;
  33174. /**
  33175. * The type of the physics imposter
  33176. */
  33177. type: number;
  33178. private _options;
  33179. private _scene?;
  33180. /**
  33181. * The default object size of the imposter
  33182. */
  33183. static DEFAULT_OBJECT_SIZE: Vector3;
  33184. /**
  33185. * The identity quaternion of the imposter
  33186. */
  33187. static IDENTITY_QUATERNION: Quaternion;
  33188. /** @hidden */
  33189. _pluginData: any;
  33190. private _physicsEngine;
  33191. private _physicsBody;
  33192. private _bodyUpdateRequired;
  33193. private _onBeforePhysicsStepCallbacks;
  33194. private _onAfterPhysicsStepCallbacks;
  33195. /** @hidden */
  33196. _onPhysicsCollideCallbacks: Array<{
  33197. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  33198. otherImpostors: Array<PhysicsImpostor>;
  33199. }>;
  33200. private _deltaPosition;
  33201. private _deltaRotation;
  33202. private _deltaRotationConjugated;
  33203. /** @hidden */
  33204. _isFromLine: boolean;
  33205. private _parent;
  33206. private _isDisposed;
  33207. private static _tmpVecs;
  33208. private static _tmpQuat;
  33209. /**
  33210. * Specifies if the physics imposter is disposed
  33211. */
  33212. get isDisposed(): boolean;
  33213. /**
  33214. * Gets the mass of the physics imposter
  33215. */
  33216. get mass(): number;
  33217. set mass(value: number);
  33218. /**
  33219. * Gets the coefficient of friction
  33220. */
  33221. get friction(): number;
  33222. /**
  33223. * Sets the coefficient of friction
  33224. */
  33225. set friction(value: number);
  33226. /**
  33227. * Gets the coefficient of restitution
  33228. */
  33229. get restitution(): number;
  33230. /**
  33231. * Sets the coefficient of restitution
  33232. */
  33233. set restitution(value: number);
  33234. /**
  33235. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33236. */
  33237. get pressure(): number;
  33238. /**
  33239. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33240. */
  33241. set pressure(value: number);
  33242. /**
  33243. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33244. */
  33245. get stiffness(): number;
  33246. /**
  33247. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33248. */
  33249. set stiffness(value: number);
  33250. /**
  33251. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33252. */
  33253. get velocityIterations(): number;
  33254. /**
  33255. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33256. */
  33257. set velocityIterations(value: number);
  33258. /**
  33259. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33260. */
  33261. get positionIterations(): number;
  33262. /**
  33263. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33264. */
  33265. set positionIterations(value: number);
  33266. /**
  33267. * The unique id of the physics imposter
  33268. * set by the physics engine when adding this impostor to the array
  33269. */
  33270. uniqueId: number;
  33271. /**
  33272. * @hidden
  33273. */
  33274. soft: boolean;
  33275. /**
  33276. * @hidden
  33277. */
  33278. segments: number;
  33279. private _joints;
  33280. /**
  33281. * Initializes the physics imposter
  33282. * @param object The physics-enabled object used as the physics imposter
  33283. * @param type The type of the physics imposter
  33284. * @param _options The options for the physics imposter
  33285. * @param _scene The Babylon scene
  33286. */
  33287. constructor(
  33288. /**
  33289. * The physics-enabled object used as the physics imposter
  33290. */
  33291. object: IPhysicsEnabledObject,
  33292. /**
  33293. * The type of the physics imposter
  33294. */
  33295. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33296. /**
  33297. * This function will completly initialize this impostor.
  33298. * It will create a new body - but only if this mesh has no parent.
  33299. * If it has, this impostor will not be used other than to define the impostor
  33300. * of the child mesh.
  33301. * @hidden
  33302. */
  33303. _init(): void;
  33304. private _getPhysicsParent;
  33305. /**
  33306. * Should a new body be generated.
  33307. * @returns boolean specifying if body initialization is required
  33308. */
  33309. isBodyInitRequired(): boolean;
  33310. /**
  33311. * Sets the updated scaling
  33312. * @param updated Specifies if the scaling is updated
  33313. */
  33314. setScalingUpdated(): void;
  33315. /**
  33316. * Force a regeneration of this or the parent's impostor's body.
  33317. * Use under cautious - This will remove all joints already implemented.
  33318. */
  33319. forceUpdate(): void;
  33320. /**
  33321. * Gets the body that holds this impostor. Either its own, or its parent.
  33322. */
  33323. get physicsBody(): any;
  33324. /**
  33325. * Get the parent of the physics imposter
  33326. * @returns Physics imposter or null
  33327. */
  33328. get parent(): Nullable<PhysicsImpostor>;
  33329. /**
  33330. * Sets the parent of the physics imposter
  33331. */
  33332. set parent(value: Nullable<PhysicsImpostor>);
  33333. /**
  33334. * Set the physics body. Used mainly by the physics engine/plugin
  33335. */
  33336. set physicsBody(physicsBody: any);
  33337. /**
  33338. * Resets the update flags
  33339. */
  33340. resetUpdateFlags(): void;
  33341. /**
  33342. * Gets the object extend size
  33343. * @returns the object extend size
  33344. */
  33345. getObjectExtendSize(): Vector3;
  33346. /**
  33347. * Gets the object center
  33348. * @returns The object center
  33349. */
  33350. getObjectCenter(): Vector3;
  33351. /**
  33352. * Get a specific parameter from the options parameters
  33353. * @param paramName The object parameter name
  33354. * @returns The object parameter
  33355. */
  33356. getParam(paramName: string): any;
  33357. /**
  33358. * Sets a specific parameter in the options given to the physics plugin
  33359. * @param paramName The parameter name
  33360. * @param value The value of the parameter
  33361. */
  33362. setParam(paramName: string, value: number): void;
  33363. /**
  33364. * Specifically change the body's mass option. Won't recreate the physics body object
  33365. * @param mass The mass of the physics imposter
  33366. */
  33367. setMass(mass: number): void;
  33368. /**
  33369. * Gets the linear velocity
  33370. * @returns linear velocity or null
  33371. */
  33372. getLinearVelocity(): Nullable<Vector3>;
  33373. /**
  33374. * Sets the linear velocity
  33375. * @param velocity linear velocity or null
  33376. */
  33377. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33378. /**
  33379. * Gets the angular velocity
  33380. * @returns angular velocity or null
  33381. */
  33382. getAngularVelocity(): Nullable<Vector3>;
  33383. /**
  33384. * Sets the angular velocity
  33385. * @param velocity The velocity or null
  33386. */
  33387. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33388. /**
  33389. * Execute a function with the physics plugin native code
  33390. * Provide a function the will have two variables - the world object and the physics body object
  33391. * @param func The function to execute with the physics plugin native code
  33392. */
  33393. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33394. /**
  33395. * Register a function that will be executed before the physics world is stepping forward
  33396. * @param func The function to execute before the physics world is stepped forward
  33397. */
  33398. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33399. /**
  33400. * Unregister a function that will be executed before the physics world is stepping forward
  33401. * @param func The function to execute before the physics world is stepped forward
  33402. */
  33403. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33404. /**
  33405. * Register a function that will be executed after the physics step
  33406. * @param func The function to execute after physics step
  33407. */
  33408. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33409. /**
  33410. * Unregisters a function that will be executed after the physics step
  33411. * @param func The function to execute after physics step
  33412. */
  33413. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33414. /**
  33415. * register a function that will be executed when this impostor collides against a different body
  33416. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33417. * @param func Callback that is executed on collision
  33418. */
  33419. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33420. /**
  33421. * Unregisters the physics imposter on contact
  33422. * @param collideAgainst The physics object to collide against
  33423. * @param func Callback to execute on collision
  33424. */
  33425. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33426. private _tmpQuat;
  33427. private _tmpQuat2;
  33428. /**
  33429. * Get the parent rotation
  33430. * @returns The parent rotation
  33431. */
  33432. getParentsRotation(): Quaternion;
  33433. /**
  33434. * this function is executed by the physics engine.
  33435. */
  33436. beforeStep: () => void;
  33437. /**
  33438. * this function is executed by the physics engine
  33439. */
  33440. afterStep: () => void;
  33441. /**
  33442. * Legacy collision detection event support
  33443. */
  33444. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33445. /**
  33446. * event and body object due to cannon's event-based architecture.
  33447. */
  33448. onCollide: (e: {
  33449. body: any;
  33450. }) => void;
  33451. /**
  33452. * Apply a force
  33453. * @param force The force to apply
  33454. * @param contactPoint The contact point for the force
  33455. * @returns The physics imposter
  33456. */
  33457. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33458. /**
  33459. * Apply an impulse
  33460. * @param force The impulse force
  33461. * @param contactPoint The contact point for the impulse force
  33462. * @returns The physics imposter
  33463. */
  33464. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33465. /**
  33466. * A help function to create a joint
  33467. * @param otherImpostor A physics imposter used to create a joint
  33468. * @param jointType The type of joint
  33469. * @param jointData The data for the joint
  33470. * @returns The physics imposter
  33471. */
  33472. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33473. /**
  33474. * Add a joint to this impostor with a different impostor
  33475. * @param otherImpostor A physics imposter used to add a joint
  33476. * @param joint The joint to add
  33477. * @returns The physics imposter
  33478. */
  33479. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33480. /**
  33481. * Add an anchor to a cloth impostor
  33482. * @param otherImpostor rigid impostor to anchor to
  33483. * @param width ratio across width from 0 to 1
  33484. * @param height ratio up height from 0 to 1
  33485. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33486. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33487. * @returns impostor the soft imposter
  33488. */
  33489. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33490. /**
  33491. * Add a hook to a rope impostor
  33492. * @param otherImpostor rigid impostor to anchor to
  33493. * @param length ratio across rope from 0 to 1
  33494. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33495. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33496. * @returns impostor the rope imposter
  33497. */
  33498. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33499. /**
  33500. * Will keep this body still, in a sleep mode.
  33501. * @returns the physics imposter
  33502. */
  33503. sleep(): PhysicsImpostor;
  33504. /**
  33505. * Wake the body up.
  33506. * @returns The physics imposter
  33507. */
  33508. wakeUp(): PhysicsImpostor;
  33509. /**
  33510. * Clones the physics imposter
  33511. * @param newObject The physics imposter clones to this physics-enabled object
  33512. * @returns A nullable physics imposter
  33513. */
  33514. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33515. /**
  33516. * Disposes the physics imposter
  33517. */
  33518. dispose(): void;
  33519. /**
  33520. * Sets the delta position
  33521. * @param position The delta position amount
  33522. */
  33523. setDeltaPosition(position: Vector3): void;
  33524. /**
  33525. * Sets the delta rotation
  33526. * @param rotation The delta rotation amount
  33527. */
  33528. setDeltaRotation(rotation: Quaternion): void;
  33529. /**
  33530. * Gets the box size of the physics imposter and stores the result in the input parameter
  33531. * @param result Stores the box size
  33532. * @returns The physics imposter
  33533. */
  33534. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33535. /**
  33536. * Gets the radius of the physics imposter
  33537. * @returns Radius of the physics imposter
  33538. */
  33539. getRadius(): number;
  33540. /**
  33541. * Sync a bone with this impostor
  33542. * @param bone The bone to sync to the impostor.
  33543. * @param boneMesh The mesh that the bone is influencing.
  33544. * @param jointPivot The pivot of the joint / bone in local space.
  33545. * @param distToJoint Optional distance from the impostor to the joint.
  33546. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33547. */
  33548. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33549. /**
  33550. * Sync impostor to a bone
  33551. * @param bone The bone that the impostor will be synced to.
  33552. * @param boneMesh The mesh that the bone is influencing.
  33553. * @param jointPivot The pivot of the joint / bone in local space.
  33554. * @param distToJoint Optional distance from the impostor to the joint.
  33555. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33556. * @param boneAxis Optional vector3 axis the bone is aligned with
  33557. */
  33558. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33559. /**
  33560. * No-Imposter type
  33561. */
  33562. static NoImpostor: number;
  33563. /**
  33564. * Sphere-Imposter type
  33565. */
  33566. static SphereImpostor: number;
  33567. /**
  33568. * Box-Imposter type
  33569. */
  33570. static BoxImpostor: number;
  33571. /**
  33572. * Plane-Imposter type
  33573. */
  33574. static PlaneImpostor: number;
  33575. /**
  33576. * Mesh-imposter type
  33577. */
  33578. static MeshImpostor: number;
  33579. /**
  33580. * Capsule-Impostor type (Ammo.js plugin only)
  33581. */
  33582. static CapsuleImpostor: number;
  33583. /**
  33584. * Cylinder-Imposter type
  33585. */
  33586. static CylinderImpostor: number;
  33587. /**
  33588. * Particle-Imposter type
  33589. */
  33590. static ParticleImpostor: number;
  33591. /**
  33592. * Heightmap-Imposter type
  33593. */
  33594. static HeightmapImpostor: number;
  33595. /**
  33596. * ConvexHull-Impostor type (Ammo.js plugin only)
  33597. */
  33598. static ConvexHullImpostor: number;
  33599. /**
  33600. * Custom-Imposter type (Ammo.js plugin only)
  33601. */
  33602. static CustomImpostor: number;
  33603. /**
  33604. * Rope-Imposter type
  33605. */
  33606. static RopeImpostor: number;
  33607. /**
  33608. * Cloth-Imposter type
  33609. */
  33610. static ClothImpostor: number;
  33611. /**
  33612. * Softbody-Imposter type
  33613. */
  33614. static SoftbodyImpostor: number;
  33615. }
  33616. }
  33617. declare module "babylonjs/Meshes/mesh" {
  33618. import { Observable } from "babylonjs/Misc/observable";
  33619. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33620. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33621. import { Camera } from "babylonjs/Cameras/camera";
  33622. import { Scene } from "babylonjs/scene";
  33623. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33624. import { Color4 } from "babylonjs/Maths/math.color";
  33625. import { Engine } from "babylonjs/Engines/engine";
  33626. import { Node } from "babylonjs/node";
  33627. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33628. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33629. import { Buffer } from "babylonjs/Meshes/buffer";
  33630. import { Geometry } from "babylonjs/Meshes/geometry";
  33631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33632. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33633. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33634. import { Effect } from "babylonjs/Materials/effect";
  33635. import { Material } from "babylonjs/Materials/material";
  33636. import { Skeleton } from "babylonjs/Bones/skeleton";
  33637. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33638. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33639. import { Path3D } from "babylonjs/Maths/math.path";
  33640. import { Plane } from "babylonjs/Maths/math.plane";
  33641. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33642. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33643. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33644. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33645. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33646. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33647. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33648. /**
  33649. * @hidden
  33650. **/
  33651. export class _CreationDataStorage {
  33652. closePath?: boolean;
  33653. closeArray?: boolean;
  33654. idx: number[];
  33655. dashSize: number;
  33656. gapSize: number;
  33657. path3D: Path3D;
  33658. pathArray: Vector3[][];
  33659. arc: number;
  33660. radius: number;
  33661. cap: number;
  33662. tessellation: number;
  33663. }
  33664. /**
  33665. * @hidden
  33666. **/
  33667. class _InstanceDataStorage {
  33668. visibleInstances: any;
  33669. batchCache: _InstancesBatch;
  33670. instancesBufferSize: number;
  33671. instancesBuffer: Nullable<Buffer>;
  33672. instancesData: Float32Array;
  33673. overridenInstanceCount: number;
  33674. isFrozen: boolean;
  33675. previousBatch: Nullable<_InstancesBatch>;
  33676. hardwareInstancedRendering: boolean;
  33677. sideOrientation: number;
  33678. manualUpdate: boolean;
  33679. previousRenderId: number;
  33680. }
  33681. /**
  33682. * @hidden
  33683. **/
  33684. export class _InstancesBatch {
  33685. mustReturn: boolean;
  33686. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33687. renderSelf: boolean[];
  33688. hardwareInstancedRendering: boolean[];
  33689. }
  33690. /**
  33691. * @hidden
  33692. **/
  33693. class _ThinInstanceDataStorage {
  33694. instancesCount: number;
  33695. matrixBuffer: Nullable<Buffer>;
  33696. matrixBufferSize: number;
  33697. matrixData: Nullable<Float32Array>;
  33698. boundingVectors: Array<Vector3>;
  33699. worldMatrices: Nullable<Matrix[]>;
  33700. }
  33701. /**
  33702. * Class used to represent renderable models
  33703. */
  33704. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33705. /**
  33706. * Mesh side orientation : usually the external or front surface
  33707. */
  33708. static readonly FRONTSIDE: number;
  33709. /**
  33710. * Mesh side orientation : usually the internal or back surface
  33711. */
  33712. static readonly BACKSIDE: number;
  33713. /**
  33714. * Mesh side orientation : both internal and external or front and back surfaces
  33715. */
  33716. static readonly DOUBLESIDE: number;
  33717. /**
  33718. * Mesh side orientation : by default, `FRONTSIDE`
  33719. */
  33720. static readonly DEFAULTSIDE: number;
  33721. /**
  33722. * Mesh cap setting : no cap
  33723. */
  33724. static readonly NO_CAP: number;
  33725. /**
  33726. * Mesh cap setting : one cap at the beginning of the mesh
  33727. */
  33728. static readonly CAP_START: number;
  33729. /**
  33730. * Mesh cap setting : one cap at the end of the mesh
  33731. */
  33732. static readonly CAP_END: number;
  33733. /**
  33734. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33735. */
  33736. static readonly CAP_ALL: number;
  33737. /**
  33738. * Mesh pattern setting : no flip or rotate
  33739. */
  33740. static readonly NO_FLIP: number;
  33741. /**
  33742. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33743. */
  33744. static readonly FLIP_TILE: number;
  33745. /**
  33746. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33747. */
  33748. static readonly ROTATE_TILE: number;
  33749. /**
  33750. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33751. */
  33752. static readonly FLIP_ROW: number;
  33753. /**
  33754. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33755. */
  33756. static readonly ROTATE_ROW: number;
  33757. /**
  33758. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33759. */
  33760. static readonly FLIP_N_ROTATE_TILE: number;
  33761. /**
  33762. * Mesh pattern setting : rotate pattern and rotate
  33763. */
  33764. static readonly FLIP_N_ROTATE_ROW: number;
  33765. /**
  33766. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33767. */
  33768. static readonly CENTER: number;
  33769. /**
  33770. * Mesh tile positioning : part tiles on left
  33771. */
  33772. static readonly LEFT: number;
  33773. /**
  33774. * Mesh tile positioning : part tiles on right
  33775. */
  33776. static readonly RIGHT: number;
  33777. /**
  33778. * Mesh tile positioning : part tiles on top
  33779. */
  33780. static readonly TOP: number;
  33781. /**
  33782. * Mesh tile positioning : part tiles on bottom
  33783. */
  33784. static readonly BOTTOM: number;
  33785. /**
  33786. * Gets the default side orientation.
  33787. * @param orientation the orientation to value to attempt to get
  33788. * @returns the default orientation
  33789. * @hidden
  33790. */
  33791. static _GetDefaultSideOrientation(orientation?: number): number;
  33792. private _internalMeshDataInfo;
  33793. get computeBonesUsingShaders(): boolean;
  33794. set computeBonesUsingShaders(value: boolean);
  33795. /**
  33796. * An event triggered before rendering the mesh
  33797. */
  33798. get onBeforeRenderObservable(): Observable<Mesh>;
  33799. /**
  33800. * An event triggered before binding the mesh
  33801. */
  33802. get onBeforeBindObservable(): Observable<Mesh>;
  33803. /**
  33804. * An event triggered after rendering the mesh
  33805. */
  33806. get onAfterRenderObservable(): Observable<Mesh>;
  33807. /**
  33808. * An event triggered before drawing the mesh
  33809. */
  33810. get onBeforeDrawObservable(): Observable<Mesh>;
  33811. private _onBeforeDrawObserver;
  33812. /**
  33813. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33814. */
  33815. set onBeforeDraw(callback: () => void);
  33816. get hasInstances(): boolean;
  33817. get hasThinInstances(): boolean;
  33818. /**
  33819. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33820. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33821. */
  33822. delayLoadState: number;
  33823. /**
  33824. * Gets the list of instances created from this mesh
  33825. * it is not supposed to be modified manually.
  33826. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33827. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33828. */
  33829. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33830. /**
  33831. * Gets the file containing delay loading data for this mesh
  33832. */
  33833. delayLoadingFile: string;
  33834. /** @hidden */
  33835. _binaryInfo: any;
  33836. /**
  33837. * User defined function used to change how LOD level selection is done
  33838. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33839. */
  33840. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33841. /**
  33842. * Gets or sets the morph target manager
  33843. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33844. */
  33845. get morphTargetManager(): Nullable<MorphTargetManager>;
  33846. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33847. /** @hidden */
  33848. _creationDataStorage: Nullable<_CreationDataStorage>;
  33849. /** @hidden */
  33850. _geometry: Nullable<Geometry>;
  33851. /** @hidden */
  33852. _delayInfo: Array<string>;
  33853. /** @hidden */
  33854. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33855. /** @hidden */
  33856. _instanceDataStorage: _InstanceDataStorage;
  33857. /** @hidden */
  33858. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33859. private _effectiveMaterial;
  33860. /** @hidden */
  33861. _shouldGenerateFlatShading: boolean;
  33862. /** @hidden */
  33863. _originalBuilderSideOrientation: number;
  33864. /**
  33865. * Use this property to change the original side orientation defined at construction time
  33866. */
  33867. overrideMaterialSideOrientation: Nullable<number>;
  33868. /**
  33869. * Gets the source mesh (the one used to clone this one from)
  33870. */
  33871. get source(): Nullable<Mesh>;
  33872. /**
  33873. * Gets the list of clones of this mesh
  33874. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33875. * Note that useClonedMeshMap=true is the default setting
  33876. */
  33877. get cloneMeshMap(): Nullable<{
  33878. [id: string]: Mesh | undefined;
  33879. }>;
  33880. /**
  33881. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33882. */
  33883. get isUnIndexed(): boolean;
  33884. set isUnIndexed(value: boolean);
  33885. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33886. get worldMatrixInstancedBuffer(): Float32Array;
  33887. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33888. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33889. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33890. /**
  33891. * @constructor
  33892. * @param name The value used by scene.getMeshByName() to do a lookup.
  33893. * @param scene The scene to add this mesh to.
  33894. * @param parent The parent of this mesh, if it has one
  33895. * @param source An optional Mesh from which geometry is shared, cloned.
  33896. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33897. * When false, achieved by calling a clone(), also passing False.
  33898. * This will make creation of children, recursive.
  33899. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33900. */
  33901. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33902. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33903. doNotInstantiate: boolean;
  33904. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33905. /**
  33906. * Gets the class name
  33907. * @returns the string "Mesh".
  33908. */
  33909. getClassName(): string;
  33910. /** @hidden */
  33911. get _isMesh(): boolean;
  33912. /**
  33913. * Returns a description of this mesh
  33914. * @param fullDetails define if full details about this mesh must be used
  33915. * @returns a descriptive string representing this mesh
  33916. */
  33917. toString(fullDetails?: boolean): string;
  33918. /** @hidden */
  33919. _unBindEffect(): void;
  33920. /**
  33921. * Gets a boolean indicating if this mesh has LOD
  33922. */
  33923. get hasLODLevels(): boolean;
  33924. /**
  33925. * Gets the list of MeshLODLevel associated with the current mesh
  33926. * @returns an array of MeshLODLevel
  33927. */
  33928. getLODLevels(): MeshLODLevel[];
  33929. private _sortLODLevels;
  33930. /**
  33931. * Add a mesh as LOD level triggered at the given distance.
  33932. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33933. * @param distance The distance from the center of the object to show this level
  33934. * @param mesh The mesh to be added as LOD level (can be null)
  33935. * @return This mesh (for chaining)
  33936. */
  33937. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33938. /**
  33939. * Returns the LOD level mesh at the passed distance or null if not found.
  33940. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33941. * @param distance The distance from the center of the object to show this level
  33942. * @returns a Mesh or `null`
  33943. */
  33944. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33945. /**
  33946. * Remove a mesh from the LOD array
  33947. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33948. * @param mesh defines the mesh to be removed
  33949. * @return This mesh (for chaining)
  33950. */
  33951. removeLODLevel(mesh: Mesh): Mesh;
  33952. /**
  33953. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33954. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33955. * @param camera defines the camera to use to compute distance
  33956. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33957. * @return This mesh (for chaining)
  33958. */
  33959. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33960. /**
  33961. * Gets the mesh internal Geometry object
  33962. */
  33963. get geometry(): Nullable<Geometry>;
  33964. /**
  33965. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33966. * @returns the total number of vertices
  33967. */
  33968. getTotalVertices(): number;
  33969. /**
  33970. * Returns the content of an associated vertex buffer
  33971. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33972. * - VertexBuffer.PositionKind
  33973. * - VertexBuffer.UVKind
  33974. * - VertexBuffer.UV2Kind
  33975. * - VertexBuffer.UV3Kind
  33976. * - VertexBuffer.UV4Kind
  33977. * - VertexBuffer.UV5Kind
  33978. * - VertexBuffer.UV6Kind
  33979. * - VertexBuffer.ColorKind
  33980. * - VertexBuffer.MatricesIndicesKind
  33981. * - VertexBuffer.MatricesIndicesExtraKind
  33982. * - VertexBuffer.MatricesWeightsKind
  33983. * - VertexBuffer.MatricesWeightsExtraKind
  33984. * @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
  33985. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33986. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33987. */
  33988. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33989. /**
  33990. * Returns the mesh VertexBuffer object from the requested `kind`
  33991. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33992. * - VertexBuffer.PositionKind
  33993. * - VertexBuffer.NormalKind
  33994. * - VertexBuffer.UVKind
  33995. * - VertexBuffer.UV2Kind
  33996. * - VertexBuffer.UV3Kind
  33997. * - VertexBuffer.UV4Kind
  33998. * - VertexBuffer.UV5Kind
  33999. * - VertexBuffer.UV6Kind
  34000. * - VertexBuffer.ColorKind
  34001. * - VertexBuffer.MatricesIndicesKind
  34002. * - VertexBuffer.MatricesIndicesExtraKind
  34003. * - VertexBuffer.MatricesWeightsKind
  34004. * - VertexBuffer.MatricesWeightsExtraKind
  34005. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34006. */
  34007. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34008. /**
  34009. * Tests if a specific vertex buffer is associated with this mesh
  34010. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34011. * - VertexBuffer.PositionKind
  34012. * - VertexBuffer.NormalKind
  34013. * - VertexBuffer.UVKind
  34014. * - VertexBuffer.UV2Kind
  34015. * - VertexBuffer.UV3Kind
  34016. * - VertexBuffer.UV4Kind
  34017. * - VertexBuffer.UV5Kind
  34018. * - VertexBuffer.UV6Kind
  34019. * - VertexBuffer.ColorKind
  34020. * - VertexBuffer.MatricesIndicesKind
  34021. * - VertexBuffer.MatricesIndicesExtraKind
  34022. * - VertexBuffer.MatricesWeightsKind
  34023. * - VertexBuffer.MatricesWeightsExtraKind
  34024. * @returns a boolean
  34025. */
  34026. isVerticesDataPresent(kind: string): boolean;
  34027. /**
  34028. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34029. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34030. * - VertexBuffer.PositionKind
  34031. * - VertexBuffer.UVKind
  34032. * - VertexBuffer.UV2Kind
  34033. * - VertexBuffer.UV3Kind
  34034. * - VertexBuffer.UV4Kind
  34035. * - VertexBuffer.UV5Kind
  34036. * - VertexBuffer.UV6Kind
  34037. * - VertexBuffer.ColorKind
  34038. * - VertexBuffer.MatricesIndicesKind
  34039. * - VertexBuffer.MatricesIndicesExtraKind
  34040. * - VertexBuffer.MatricesWeightsKind
  34041. * - VertexBuffer.MatricesWeightsExtraKind
  34042. * @returns a boolean
  34043. */
  34044. isVertexBufferUpdatable(kind: string): boolean;
  34045. /**
  34046. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34047. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34048. * - VertexBuffer.PositionKind
  34049. * - VertexBuffer.NormalKind
  34050. * - VertexBuffer.UVKind
  34051. * - VertexBuffer.UV2Kind
  34052. * - VertexBuffer.UV3Kind
  34053. * - VertexBuffer.UV4Kind
  34054. * - VertexBuffer.UV5Kind
  34055. * - VertexBuffer.UV6Kind
  34056. * - VertexBuffer.ColorKind
  34057. * - VertexBuffer.MatricesIndicesKind
  34058. * - VertexBuffer.MatricesIndicesExtraKind
  34059. * - VertexBuffer.MatricesWeightsKind
  34060. * - VertexBuffer.MatricesWeightsExtraKind
  34061. * @returns an array of strings
  34062. */
  34063. getVerticesDataKinds(): string[];
  34064. /**
  34065. * Returns a positive integer : the total number of indices in this mesh geometry.
  34066. * @returns the numner of indices or zero if the mesh has no geometry.
  34067. */
  34068. getTotalIndices(): number;
  34069. /**
  34070. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34071. * @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.
  34072. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34073. * @returns the indices array or an empty array if the mesh has no geometry
  34074. */
  34075. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34076. get isBlocked(): boolean;
  34077. /**
  34078. * Determine if the current mesh is ready to be rendered
  34079. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34080. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34081. * @returns true if all associated assets are ready (material, textures, shaders)
  34082. */
  34083. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34084. /**
  34085. * 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.
  34086. */
  34087. get areNormalsFrozen(): boolean;
  34088. /**
  34089. * 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.
  34090. * @returns the current mesh
  34091. */
  34092. freezeNormals(): Mesh;
  34093. /**
  34094. * 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
  34095. * @returns the current mesh
  34096. */
  34097. unfreezeNormals(): Mesh;
  34098. /**
  34099. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34100. */
  34101. set overridenInstanceCount(count: number);
  34102. /** @hidden */
  34103. _preActivate(): Mesh;
  34104. /** @hidden */
  34105. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34106. /** @hidden */
  34107. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34108. protected _afterComputeWorldMatrix(): void;
  34109. /** @hidden */
  34110. _postActivate(): void;
  34111. /**
  34112. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34113. * This means the mesh underlying bounding box and sphere are recomputed.
  34114. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34115. * @returns the current mesh
  34116. */
  34117. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34118. /** @hidden */
  34119. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34120. /**
  34121. * This function will subdivide the mesh into multiple submeshes
  34122. * @param count defines the expected number of submeshes
  34123. */
  34124. subdivide(count: number): void;
  34125. /**
  34126. * Copy a FloatArray into a specific associated vertex buffer
  34127. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34128. * - VertexBuffer.PositionKind
  34129. * - VertexBuffer.UVKind
  34130. * - VertexBuffer.UV2Kind
  34131. * - VertexBuffer.UV3Kind
  34132. * - VertexBuffer.UV4Kind
  34133. * - VertexBuffer.UV5Kind
  34134. * - VertexBuffer.UV6Kind
  34135. * - VertexBuffer.ColorKind
  34136. * - VertexBuffer.MatricesIndicesKind
  34137. * - VertexBuffer.MatricesIndicesExtraKind
  34138. * - VertexBuffer.MatricesWeightsKind
  34139. * - VertexBuffer.MatricesWeightsExtraKind
  34140. * @param data defines the data source
  34141. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34142. * @param stride defines the data stride size (can be null)
  34143. * @returns the current mesh
  34144. */
  34145. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34146. /**
  34147. * Delete a vertex buffer associated with this mesh
  34148. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34149. * - VertexBuffer.PositionKind
  34150. * - VertexBuffer.UVKind
  34151. * - VertexBuffer.UV2Kind
  34152. * - VertexBuffer.UV3Kind
  34153. * - VertexBuffer.UV4Kind
  34154. * - VertexBuffer.UV5Kind
  34155. * - VertexBuffer.UV6Kind
  34156. * - VertexBuffer.ColorKind
  34157. * - VertexBuffer.MatricesIndicesKind
  34158. * - VertexBuffer.MatricesIndicesExtraKind
  34159. * - VertexBuffer.MatricesWeightsKind
  34160. * - VertexBuffer.MatricesWeightsExtraKind
  34161. */
  34162. removeVerticesData(kind: string): void;
  34163. /**
  34164. * Flags an associated vertex buffer as updatable
  34165. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34166. * - VertexBuffer.PositionKind
  34167. * - VertexBuffer.UVKind
  34168. * - VertexBuffer.UV2Kind
  34169. * - VertexBuffer.UV3Kind
  34170. * - VertexBuffer.UV4Kind
  34171. * - VertexBuffer.UV5Kind
  34172. * - VertexBuffer.UV6Kind
  34173. * - VertexBuffer.ColorKind
  34174. * - VertexBuffer.MatricesIndicesKind
  34175. * - VertexBuffer.MatricesIndicesExtraKind
  34176. * - VertexBuffer.MatricesWeightsKind
  34177. * - VertexBuffer.MatricesWeightsExtraKind
  34178. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34179. */
  34180. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34181. /**
  34182. * Sets the mesh global Vertex Buffer
  34183. * @param buffer defines the buffer to use
  34184. * @returns the current mesh
  34185. */
  34186. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34187. /**
  34188. * Update a specific associated vertex buffer
  34189. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34190. * - VertexBuffer.PositionKind
  34191. * - VertexBuffer.UVKind
  34192. * - VertexBuffer.UV2Kind
  34193. * - VertexBuffer.UV3Kind
  34194. * - VertexBuffer.UV4Kind
  34195. * - VertexBuffer.UV5Kind
  34196. * - VertexBuffer.UV6Kind
  34197. * - VertexBuffer.ColorKind
  34198. * - VertexBuffer.MatricesIndicesKind
  34199. * - VertexBuffer.MatricesIndicesExtraKind
  34200. * - VertexBuffer.MatricesWeightsKind
  34201. * - VertexBuffer.MatricesWeightsExtraKind
  34202. * @param data defines the data source
  34203. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34204. * @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)
  34205. * @returns the current mesh
  34206. */
  34207. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34208. /**
  34209. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34210. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34211. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34212. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34213. * @returns the current mesh
  34214. */
  34215. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34216. /**
  34217. * Creates a un-shared specific occurence of the geometry for the mesh.
  34218. * @returns the current mesh
  34219. */
  34220. makeGeometryUnique(): Mesh;
  34221. /**
  34222. * Set the index buffer of this mesh
  34223. * @param indices defines the source data
  34224. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34225. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34226. * @returns the current mesh
  34227. */
  34228. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34229. /**
  34230. * Update the current index buffer
  34231. * @param indices defines the source data
  34232. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34233. * @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)
  34234. * @returns the current mesh
  34235. */
  34236. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34237. /**
  34238. * Invert the geometry to move from a right handed system to a left handed one.
  34239. * @returns the current mesh
  34240. */
  34241. toLeftHanded(): Mesh;
  34242. /** @hidden */
  34243. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34244. /** @hidden */
  34245. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34246. /**
  34247. * Registers for this mesh a javascript function called just before the rendering process
  34248. * @param func defines the function to call before rendering this mesh
  34249. * @returns the current mesh
  34250. */
  34251. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34252. /**
  34253. * Disposes a previously registered javascript function called before the rendering
  34254. * @param func defines the function to remove
  34255. * @returns the current mesh
  34256. */
  34257. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34258. /**
  34259. * Registers for this mesh a javascript function called just after the rendering is complete
  34260. * @param func defines the function to call after rendering this mesh
  34261. * @returns the current mesh
  34262. */
  34263. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34264. /**
  34265. * Disposes a previously registered javascript function called after the rendering.
  34266. * @param func defines the function to remove
  34267. * @returns the current mesh
  34268. */
  34269. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34270. /** @hidden */
  34271. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34272. /** @hidden */
  34273. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34274. /** @hidden */
  34275. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34276. /** @hidden */
  34277. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34278. /** @hidden */
  34279. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34280. /** @hidden */
  34281. _rebuild(): void;
  34282. /** @hidden */
  34283. _freeze(): void;
  34284. /** @hidden */
  34285. _unFreeze(): void;
  34286. /**
  34287. * 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
  34288. * @param subMesh defines the subMesh to render
  34289. * @param enableAlphaMode defines if alpha mode can be changed
  34290. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34291. * @returns the current mesh
  34292. */
  34293. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34294. private _onBeforeDraw;
  34295. /**
  34296. * Renormalize the mesh and patch it up if there are no weights
  34297. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34298. * However in the case of zero weights then we set just a single influence to 1.
  34299. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34300. */
  34301. cleanMatrixWeights(): void;
  34302. private normalizeSkinFourWeights;
  34303. private normalizeSkinWeightsAndExtra;
  34304. /**
  34305. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34306. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34307. * the user know there was an issue with importing the mesh
  34308. * @returns a validation object with skinned, valid and report string
  34309. */
  34310. validateSkinning(): {
  34311. skinned: boolean;
  34312. valid: boolean;
  34313. report: string;
  34314. };
  34315. /** @hidden */
  34316. _checkDelayState(): Mesh;
  34317. private _queueLoad;
  34318. /**
  34319. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34320. * A mesh is in the frustum if its bounding box intersects the frustum
  34321. * @param frustumPlanes defines the frustum to test
  34322. * @returns true if the mesh is in the frustum planes
  34323. */
  34324. isInFrustum(frustumPlanes: Plane[]): boolean;
  34325. /**
  34326. * Sets the mesh material by the material or multiMaterial `id` property
  34327. * @param id is a string identifying the material or the multiMaterial
  34328. * @returns the current mesh
  34329. */
  34330. setMaterialByID(id: string): Mesh;
  34331. /**
  34332. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34333. * @returns an array of IAnimatable
  34334. */
  34335. getAnimatables(): IAnimatable[];
  34336. /**
  34337. * Modifies the mesh geometry according to the passed transformation matrix.
  34338. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34339. * The mesh normals are modified using the same transformation.
  34340. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34341. * @param transform defines the transform matrix to use
  34342. * @see https://doc.babylonjs.com/resources/baking_transformations
  34343. * @returns the current mesh
  34344. */
  34345. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34346. /**
  34347. * Modifies the mesh geometry according to its own current World Matrix.
  34348. * The mesh World Matrix is then reset.
  34349. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34350. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34351. * @see https://doc.babylonjs.com/resources/baking_transformations
  34352. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34353. * @returns the current mesh
  34354. */
  34355. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34356. /** @hidden */
  34357. get _positions(): Nullable<Vector3[]>;
  34358. /** @hidden */
  34359. _resetPointsArrayCache(): Mesh;
  34360. /** @hidden */
  34361. _generatePointsArray(): boolean;
  34362. /**
  34363. * Returns a new Mesh object generated from the current mesh properties.
  34364. * This method must not get confused with createInstance()
  34365. * @param name is a string, the name given to the new mesh
  34366. * @param newParent can be any Node object (default `null`)
  34367. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34368. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34369. * @returns a new mesh
  34370. */
  34371. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34372. /**
  34373. * Releases resources associated with this mesh.
  34374. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34375. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34376. */
  34377. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34378. /** @hidden */
  34379. _disposeInstanceSpecificData(): void;
  34380. /** @hidden */
  34381. _disposeThinInstanceSpecificData(): void;
  34382. /**
  34383. * Modifies the mesh geometry according to a displacement map.
  34384. * 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.
  34385. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34386. * @param url is a string, the URL from the image file is to be downloaded.
  34387. * @param minHeight is the lower limit of the displacement.
  34388. * @param maxHeight is the upper limit of the displacement.
  34389. * @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.
  34390. * @param uvOffset is an optional vector2 used to offset UV.
  34391. * @param uvScale is an optional vector2 used to scale UV.
  34392. * @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.
  34393. * @returns the Mesh.
  34394. */
  34395. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34396. /**
  34397. * Modifies the mesh geometry according to a displacementMap buffer.
  34398. * 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.
  34399. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34400. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34401. * @param heightMapWidth is the width of the buffer image.
  34402. * @param heightMapHeight is the height of the buffer image.
  34403. * @param minHeight is the lower limit of the displacement.
  34404. * @param maxHeight is the upper limit of the displacement.
  34405. * @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.
  34406. * @param uvOffset is an optional vector2 used to offset UV.
  34407. * @param uvScale is an optional vector2 used to scale UV.
  34408. * @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.
  34409. * @returns the Mesh.
  34410. */
  34411. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34412. /**
  34413. * Modify the mesh to get a flat shading rendering.
  34414. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34415. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34416. * @returns current mesh
  34417. */
  34418. convertToFlatShadedMesh(): Mesh;
  34419. /**
  34420. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34421. * In other words, more vertices, no more indices and a single bigger VBO.
  34422. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34423. * @returns current mesh
  34424. */
  34425. convertToUnIndexedMesh(): Mesh;
  34426. /**
  34427. * Inverses facet orientations.
  34428. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34429. * @param flipNormals will also inverts the normals
  34430. * @returns current mesh
  34431. */
  34432. flipFaces(flipNormals?: boolean): Mesh;
  34433. /**
  34434. * Increase the number of facets and hence vertices in a mesh
  34435. * Vertex normals are interpolated from existing vertex normals
  34436. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34437. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34438. */
  34439. increaseVertices(numberPerEdge: number): void;
  34440. /**
  34441. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34442. * This will undo any application of covertToFlatShadedMesh
  34443. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34444. */
  34445. forceSharedVertices(): void;
  34446. /** @hidden */
  34447. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34448. /** @hidden */
  34449. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34450. /**
  34451. * Creates a new InstancedMesh object from the mesh model.
  34452. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34453. * @param name defines the name of the new instance
  34454. * @returns a new InstancedMesh
  34455. */
  34456. createInstance(name: string): InstancedMesh;
  34457. /**
  34458. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34459. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34460. * @returns the current mesh
  34461. */
  34462. synchronizeInstances(): Mesh;
  34463. /**
  34464. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34465. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34466. * This should be used together with the simplification to avoid disappearing triangles.
  34467. * @param successCallback an optional success callback to be called after the optimization finished.
  34468. * @returns the current mesh
  34469. */
  34470. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34471. /**
  34472. * Serialize current mesh
  34473. * @param serializationObject defines the object which will receive the serialization data
  34474. */
  34475. serialize(serializationObject: any): void;
  34476. /** @hidden */
  34477. _syncGeometryWithMorphTargetManager(): void;
  34478. /** @hidden */
  34479. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34480. /**
  34481. * Returns a new Mesh object parsed from the source provided.
  34482. * @param parsedMesh is the source
  34483. * @param scene defines the hosting scene
  34484. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34485. * @returns a new Mesh
  34486. */
  34487. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34488. /**
  34489. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34491. * @param name defines the name of the mesh to create
  34492. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34493. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34494. * @param closePath creates a seam between the first and the last points of each path of the path array
  34495. * @param offset is taken in account only if the `pathArray` is containing a single path
  34496. * @param scene defines the hosting scene
  34497. * @param updatable defines if the mesh must be flagged as updatable
  34498. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34499. * @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)
  34500. * @returns a new Mesh
  34501. */
  34502. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34503. /**
  34504. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34505. * @param name defines the name of the mesh to create
  34506. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34507. * @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
  34508. * @param scene defines the hosting scene
  34509. * @param updatable defines if the mesh must be flagged as updatable
  34510. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34511. * @returns a new Mesh
  34512. */
  34513. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34514. /**
  34515. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34516. * @param name defines the name of the mesh to create
  34517. * @param size sets the size (float) of each box side (default 1)
  34518. * @param scene defines the hosting scene
  34519. * @param updatable defines if the mesh must be flagged as updatable
  34520. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34521. * @returns a new Mesh
  34522. */
  34523. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34524. /**
  34525. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34526. * @param name defines the name of the mesh to create
  34527. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34528. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34529. * @param scene defines the hosting scene
  34530. * @param updatable defines if the mesh must be flagged as updatable
  34531. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34532. * @returns a new Mesh
  34533. */
  34534. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34535. /**
  34536. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34537. * @param name defines the name of the mesh to create
  34538. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34539. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34540. * @param scene defines the hosting scene
  34541. * @returns a new Mesh
  34542. */
  34543. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34544. /**
  34545. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34546. * @param name defines the name of the mesh to create
  34547. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34548. * @param diameterTop set the top cap diameter (floats, default 1)
  34549. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34550. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34551. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34552. * @param scene defines the hosting scene
  34553. * @param updatable defines if the mesh must be flagged as updatable
  34554. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34555. * @returns a new Mesh
  34556. */
  34557. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34558. /**
  34559. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34560. * @param name defines the name of the mesh to create
  34561. * @param diameter sets the diameter size (float) of the torus (default 1)
  34562. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34563. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34564. * @param scene defines the hosting scene
  34565. * @param updatable defines if the mesh must be flagged as updatable
  34566. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34567. * @returns a new Mesh
  34568. */
  34569. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34570. /**
  34571. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34572. * @param name defines the name of the mesh to create
  34573. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34574. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34575. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34576. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34577. * @param p the number of windings on X axis (positive integers, default 2)
  34578. * @param q the number of windings on Y axis (positive integers, default 3)
  34579. * @param scene defines the hosting scene
  34580. * @param updatable defines if the mesh must be flagged as updatable
  34581. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34582. * @returns a new Mesh
  34583. */
  34584. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34585. /**
  34586. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34587. * @param name defines the name of the mesh to create
  34588. * @param points is an array successive Vector3
  34589. * @param scene defines the hosting scene
  34590. * @param updatable defines if the mesh must be flagged as updatable
  34591. * @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).
  34592. * @returns a new Mesh
  34593. */
  34594. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34595. /**
  34596. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34597. * @param name defines the name of the mesh to create
  34598. * @param points is an array successive Vector3
  34599. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34600. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34601. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34602. * @param scene defines the hosting scene
  34603. * @param updatable defines if the mesh must be flagged as updatable
  34604. * @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)
  34605. * @returns a new Mesh
  34606. */
  34607. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34608. /**
  34609. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34610. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34611. * 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.
  34612. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34613. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34614. * Remember you can only change the shape positions, not their number when updating a polygon.
  34615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34616. * @param name defines the name of the mesh to create
  34617. * @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
  34618. * @param scene defines the hosting scene
  34619. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34620. * @param updatable defines if the mesh must be flagged as updatable
  34621. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34622. * @param earcutInjection can be used to inject your own earcut reference
  34623. * @returns a new Mesh
  34624. */
  34625. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34626. /**
  34627. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34629. * @param name defines the name of the mesh to create
  34630. * @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
  34631. * @param depth defines the height of extrusion
  34632. * @param scene defines the hosting scene
  34633. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34634. * @param updatable defines if the mesh must be flagged as updatable
  34635. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34636. * @param earcutInjection can be used to inject your own earcut reference
  34637. * @returns a new Mesh
  34638. */
  34639. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34640. /**
  34641. * Creates an extruded shape mesh.
  34642. * 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
  34643. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34645. * @param name defines the name of the mesh to create
  34646. * @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
  34647. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34648. * @param scale is the value to scale the shape
  34649. * @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
  34650. * @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
  34651. * @param scene defines the hosting scene
  34652. * @param updatable defines if the mesh must be flagged as updatable
  34653. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34654. * @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)
  34655. * @returns a new Mesh
  34656. */
  34657. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34658. /**
  34659. * Creates an custom extruded shape mesh.
  34660. * The custom extrusion is a parametric shape.
  34661. * It has no predefined shape. Its final shape will depend on the input parameters.
  34662. * Please consider using the same method from the MeshBuilder class instead
  34663. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34664. * @param name defines the name of the mesh to create
  34665. * @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
  34666. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34667. * @param scaleFunction is a custom Javascript function called on each path point
  34668. * @param rotationFunction is a custom Javascript function called on each path point
  34669. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34670. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34671. * @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
  34672. * @param scene defines the hosting scene
  34673. * @param updatable defines if the mesh must be flagged as updatable
  34674. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34675. * @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)
  34676. * @returns a new Mesh
  34677. */
  34678. 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;
  34679. /**
  34680. * Creates lathe mesh.
  34681. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34682. * Please consider using the same method from the MeshBuilder class instead
  34683. * @param name defines the name of the mesh to create
  34684. * @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
  34685. * @param radius is the radius value of the lathe
  34686. * @param tessellation is the side number of the lathe.
  34687. * @param scene defines the hosting scene
  34688. * @param updatable defines if the mesh must be flagged as updatable
  34689. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34690. * @returns a new Mesh
  34691. */
  34692. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34693. /**
  34694. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34695. * @param name defines the name of the mesh to create
  34696. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34697. * @param scene defines the hosting scene
  34698. * @param updatable defines if the mesh must be flagged as updatable
  34699. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34700. * @returns a new Mesh
  34701. */
  34702. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34703. /**
  34704. * Creates a ground mesh.
  34705. * Please consider using the same method from the MeshBuilder class instead
  34706. * @param name defines the name of the mesh to create
  34707. * @param width set the width of the ground
  34708. * @param height set the height of the ground
  34709. * @param subdivisions sets the number of subdivisions per side
  34710. * @param scene defines the hosting scene
  34711. * @param updatable defines if the mesh must be flagged as updatable
  34712. * @returns a new Mesh
  34713. */
  34714. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34715. /**
  34716. * Creates a tiled ground mesh.
  34717. * Please consider using the same method from the MeshBuilder class instead
  34718. * @param name defines the name of the mesh to create
  34719. * @param xmin set the ground minimum X coordinate
  34720. * @param zmin set the ground minimum Y coordinate
  34721. * @param xmax set the ground maximum X coordinate
  34722. * @param zmax set the ground maximum Z coordinate
  34723. * @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
  34724. * @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
  34725. * @param scene defines the hosting scene
  34726. * @param updatable defines if the mesh must be flagged as updatable
  34727. * @returns a new Mesh
  34728. */
  34729. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34730. w: number;
  34731. h: number;
  34732. }, precision: {
  34733. w: number;
  34734. h: number;
  34735. }, scene: Scene, updatable?: boolean): Mesh;
  34736. /**
  34737. * Creates a ground mesh from a height map.
  34738. * Please consider using the same method from the MeshBuilder class instead
  34739. * @see https://doc.babylonjs.com/babylon101/height_map
  34740. * @param name defines the name of the mesh to create
  34741. * @param url sets the URL of the height map image resource
  34742. * @param width set the ground width size
  34743. * @param height set the ground height size
  34744. * @param subdivisions sets the number of subdivision per side
  34745. * @param minHeight is the minimum altitude on the ground
  34746. * @param maxHeight is the maximum altitude on the ground
  34747. * @param scene defines the hosting scene
  34748. * @param updatable defines if the mesh must be flagged as updatable
  34749. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34750. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34751. * @returns a new Mesh
  34752. */
  34753. 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;
  34754. /**
  34755. * Creates a tube mesh.
  34756. * The tube is a parametric shape.
  34757. * It has no predefined shape. Its final shape will depend on the input parameters.
  34758. * Please consider using the same method from the MeshBuilder class instead
  34759. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34760. * @param name defines the name of the mesh to create
  34761. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34762. * @param radius sets the tube radius size
  34763. * @param tessellation is the number of sides on the tubular surface
  34764. * @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
  34765. * @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
  34766. * @param scene defines the hosting scene
  34767. * @param updatable defines if the mesh must be flagged as updatable
  34768. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34769. * @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)
  34770. * @returns a new Mesh
  34771. */
  34772. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34773. (i: number, distance: number): number;
  34774. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34775. /**
  34776. * Creates a polyhedron mesh.
  34777. * Please consider using the same method from the MeshBuilder class instead.
  34778. * * 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
  34779. * * The parameter `size` (positive float, default 1) sets the polygon size
  34780. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34781. * * 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`
  34782. * * 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
  34783. * * 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)`)
  34784. * * 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
  34785. * * 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
  34786. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34789. * @param name defines the name of the mesh to create
  34790. * @param options defines the options used to create the mesh
  34791. * @param scene defines the hosting scene
  34792. * @returns a new Mesh
  34793. */
  34794. static CreatePolyhedron(name: string, options: {
  34795. type?: number;
  34796. size?: number;
  34797. sizeX?: number;
  34798. sizeY?: number;
  34799. sizeZ?: number;
  34800. custom?: any;
  34801. faceUV?: Vector4[];
  34802. faceColors?: Color4[];
  34803. updatable?: boolean;
  34804. sideOrientation?: number;
  34805. }, scene: Scene): Mesh;
  34806. /**
  34807. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34808. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34809. * * 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`)
  34810. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34811. * * 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
  34812. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34815. * @param name defines the name of the mesh
  34816. * @param options defines the options used to create the mesh
  34817. * @param scene defines the hosting scene
  34818. * @returns a new Mesh
  34819. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34820. */
  34821. static CreateIcoSphere(name: string, options: {
  34822. radius?: number;
  34823. flat?: boolean;
  34824. subdivisions?: number;
  34825. sideOrientation?: number;
  34826. updatable?: boolean;
  34827. }, scene: Scene): Mesh;
  34828. /**
  34829. * Creates a decal mesh.
  34830. * Please consider using the same method from the MeshBuilder class instead.
  34831. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34832. * @param name defines the name of the mesh
  34833. * @param sourceMesh defines the mesh receiving the decal
  34834. * @param position sets the position of the decal in world coordinates
  34835. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34836. * @param size sets the decal scaling
  34837. * @param angle sets the angle to rotate the decal
  34838. * @returns a new Mesh
  34839. */
  34840. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34841. /** Creates a Capsule Mesh
  34842. * @param name defines the name of the mesh.
  34843. * @param options the constructors options used to shape the mesh.
  34844. * @param scene defines the scene the mesh is scoped to.
  34845. * @returns the capsule mesh
  34846. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34847. */
  34848. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34849. /**
  34850. * Prepare internal position array for software CPU skinning
  34851. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34852. */
  34853. setPositionsForCPUSkinning(): Float32Array;
  34854. /**
  34855. * Prepare internal normal array for software CPU skinning
  34856. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34857. */
  34858. setNormalsForCPUSkinning(): Float32Array;
  34859. /**
  34860. * Updates the vertex buffer by applying transformation from the bones
  34861. * @param skeleton defines the skeleton to apply to current mesh
  34862. * @returns the current mesh
  34863. */
  34864. applySkeleton(skeleton: Skeleton): Mesh;
  34865. /**
  34866. * 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
  34867. * @param meshes defines the list of meshes to scan
  34868. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34869. */
  34870. static MinMax(meshes: AbstractMesh[]): {
  34871. min: Vector3;
  34872. max: Vector3;
  34873. };
  34874. /**
  34875. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34876. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34877. * @returns a vector3
  34878. */
  34879. static Center(meshesOrMinMaxVector: {
  34880. min: Vector3;
  34881. max: Vector3;
  34882. } | AbstractMesh[]): Vector3;
  34883. /**
  34884. * Merge the array of meshes into a single mesh for performance reasons.
  34885. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34886. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34887. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34888. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34889. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34890. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34891. * @returns a new mesh
  34892. */
  34893. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34894. /** @hidden */
  34895. addInstance(instance: InstancedMesh): void;
  34896. /** @hidden */
  34897. removeInstance(instance: InstancedMesh): void;
  34898. }
  34899. }
  34900. declare module "babylonjs/Cameras/camera" {
  34901. import { SmartArray } from "babylonjs/Misc/smartArray";
  34902. import { Observable } from "babylonjs/Misc/observable";
  34903. import { Nullable } from "babylonjs/types";
  34904. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34905. import { Scene } from "babylonjs/scene";
  34906. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  34907. import { Node } from "babylonjs/node";
  34908. import { Mesh } from "babylonjs/Meshes/mesh";
  34909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34910. import { ICullable } from "babylonjs/Culling/boundingInfo";
  34911. import { Viewport } from "babylonjs/Maths/math.viewport";
  34912. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34913. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34914. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  34915. import { Ray } from "babylonjs/Culling/ray";
  34916. /**
  34917. * This is the base class of all the camera used in the application.
  34918. * @see https://doc.babylonjs.com/features/cameras
  34919. */
  34920. export class Camera extends Node {
  34921. /** @hidden */
  34922. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  34923. /**
  34924. * This is the default projection mode used by the cameras.
  34925. * It helps recreating a feeling of perspective and better appreciate depth.
  34926. * This is the best way to simulate real life cameras.
  34927. */
  34928. static readonly PERSPECTIVE_CAMERA: number;
  34929. /**
  34930. * This helps creating camera with an orthographic mode.
  34931. * 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.
  34932. */
  34933. static readonly ORTHOGRAPHIC_CAMERA: number;
  34934. /**
  34935. * This is the default FOV mode for perspective cameras.
  34936. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  34937. */
  34938. static readonly FOVMODE_VERTICAL_FIXED: number;
  34939. /**
  34940. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  34941. */
  34942. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  34943. /**
  34944. * This specifies ther is no need for a camera rig.
  34945. * Basically only one eye is rendered corresponding to the camera.
  34946. */
  34947. static readonly RIG_MODE_NONE: number;
  34948. /**
  34949. * Simulates a camera Rig with one blue eye and one red eye.
  34950. * This can be use with 3d blue and red glasses.
  34951. */
  34952. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  34953. /**
  34954. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  34955. */
  34956. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  34957. /**
  34958. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  34959. */
  34960. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  34961. /**
  34962. * Defines that both eyes of the camera will be rendered over under each other.
  34963. */
  34964. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  34965. /**
  34966. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  34967. */
  34968. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  34969. /**
  34970. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  34971. */
  34972. static readonly RIG_MODE_VR: number;
  34973. /**
  34974. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  34975. */
  34976. static readonly RIG_MODE_WEBVR: number;
  34977. /**
  34978. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  34979. */
  34980. static readonly RIG_MODE_CUSTOM: number;
  34981. /**
  34982. * Defines if by default attaching controls should prevent the default javascript event to continue.
  34983. */
  34984. static ForceAttachControlToAlwaysPreventDefault: boolean;
  34985. /**
  34986. * Define the input manager associated with the camera.
  34987. */
  34988. inputs: CameraInputsManager<Camera>;
  34989. /** @hidden */
  34990. _position: Vector3;
  34991. /**
  34992. * Define the current local position of the camera in the scene
  34993. */
  34994. get position(): Vector3;
  34995. set position(newPosition: Vector3);
  34996. protected _upVector: Vector3;
  34997. /**
  34998. * The vector the camera should consider as up.
  34999. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  35000. */
  35001. set upVector(vec: Vector3);
  35002. get upVector(): Vector3;
  35003. /**
  35004. * Define the current limit on the left side for an orthographic camera
  35005. * In scene unit
  35006. */
  35007. orthoLeft: Nullable<number>;
  35008. /**
  35009. * Define the current limit on the right side for an orthographic camera
  35010. * In scene unit
  35011. */
  35012. orthoRight: Nullable<number>;
  35013. /**
  35014. * Define the current limit on the bottom side for an orthographic camera
  35015. * In scene unit
  35016. */
  35017. orthoBottom: Nullable<number>;
  35018. /**
  35019. * Define the current limit on the top side for an orthographic camera
  35020. * In scene unit
  35021. */
  35022. orthoTop: Nullable<number>;
  35023. /**
  35024. * Field Of View is set in Radians. (default is 0.8)
  35025. */
  35026. fov: number;
  35027. /**
  35028. * Define the minimum distance the camera can see from.
  35029. * This is important to note that the depth buffer are not infinite and the closer it starts
  35030. * the more your scene might encounter depth fighting issue.
  35031. */
  35032. minZ: number;
  35033. /**
  35034. * Define the maximum distance the camera can see to.
  35035. * This is important to note that the depth buffer are not infinite and the further it end
  35036. * the more your scene might encounter depth fighting issue.
  35037. */
  35038. maxZ: number;
  35039. /**
  35040. * Define the default inertia of the camera.
  35041. * This helps giving a smooth feeling to the camera movement.
  35042. */
  35043. inertia: number;
  35044. /**
  35045. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  35046. */
  35047. mode: number;
  35048. /**
  35049. * Define whether the camera is intermediate.
  35050. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  35051. */
  35052. isIntermediate: boolean;
  35053. /**
  35054. * Define the viewport of the camera.
  35055. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  35056. */
  35057. viewport: Viewport;
  35058. /**
  35059. * Restricts the camera to viewing objects with the same layerMask.
  35060. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  35061. */
  35062. layerMask: number;
  35063. /**
  35064. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35065. */
  35066. fovMode: number;
  35067. /**
  35068. * Rig mode of the camera.
  35069. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35070. * This is normally controlled byt the camera themselves as internal use.
  35071. */
  35072. cameraRigMode: number;
  35073. /**
  35074. * Defines the distance between both "eyes" in case of a RIG
  35075. */
  35076. interaxialDistance: number;
  35077. /**
  35078. * Defines if stereoscopic rendering is done side by side or over under.
  35079. */
  35080. isStereoscopicSideBySide: boolean;
  35081. /**
  35082. * 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
  35083. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35084. * else in the scene. (Eg. security camera)
  35085. *
  35086. * 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)
  35087. */
  35088. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35089. /**
  35090. * When set, the camera will render to this render target instead of the default canvas
  35091. *
  35092. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35093. */
  35094. outputRenderTarget: Nullable<RenderTargetTexture>;
  35095. /**
  35096. * Observable triggered when the camera view matrix has changed.
  35097. */
  35098. onViewMatrixChangedObservable: Observable<Camera>;
  35099. /**
  35100. * Observable triggered when the camera Projection matrix has changed.
  35101. */
  35102. onProjectionMatrixChangedObservable: Observable<Camera>;
  35103. /**
  35104. * Observable triggered when the inputs have been processed.
  35105. */
  35106. onAfterCheckInputsObservable: Observable<Camera>;
  35107. /**
  35108. * Observable triggered when reset has been called and applied to the camera.
  35109. */
  35110. onRestoreStateObservable: Observable<Camera>;
  35111. /**
  35112. * Is this camera a part of a rig system?
  35113. */
  35114. isRigCamera: boolean;
  35115. /**
  35116. * If isRigCamera set to true this will be set with the parent camera.
  35117. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35118. */
  35119. rigParent?: Camera;
  35120. /** @hidden */
  35121. _cameraRigParams: any;
  35122. /** @hidden */
  35123. _rigCameras: Camera[];
  35124. /** @hidden */
  35125. _rigPostProcess: Nullable<PostProcess>;
  35126. protected _webvrViewMatrix: Matrix;
  35127. /** @hidden */
  35128. _skipRendering: boolean;
  35129. /** @hidden */
  35130. _projectionMatrix: Matrix;
  35131. /** @hidden */
  35132. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35133. /** @hidden */
  35134. _activeMeshes: SmartArray<AbstractMesh>;
  35135. protected _globalPosition: Vector3;
  35136. /** @hidden */
  35137. _computedViewMatrix: Matrix;
  35138. private _doNotComputeProjectionMatrix;
  35139. private _transformMatrix;
  35140. private _frustumPlanes;
  35141. private _refreshFrustumPlanes;
  35142. private _storedFov;
  35143. private _stateStored;
  35144. /**
  35145. * Instantiates a new camera object.
  35146. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35147. * @see https://doc.babylonjs.com/features/cameras
  35148. * @param name Defines the name of the camera in the scene
  35149. * @param position Defines the position of the camera
  35150. * @param scene Defines the scene the camera belongs too
  35151. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35152. */
  35153. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35154. /**
  35155. * Store current camera state (fov, position, etc..)
  35156. * @returns the camera
  35157. */
  35158. storeState(): Camera;
  35159. /**
  35160. * Restores the camera state values if it has been stored. You must call storeState() first
  35161. */
  35162. protected _restoreStateValues(): boolean;
  35163. /**
  35164. * Restored camera state. You must call storeState() first.
  35165. * @returns true if restored and false otherwise
  35166. */
  35167. restoreState(): boolean;
  35168. /**
  35169. * Gets the class name of the camera.
  35170. * @returns the class name
  35171. */
  35172. getClassName(): string;
  35173. /** @hidden */
  35174. readonly _isCamera: boolean;
  35175. /**
  35176. * Gets a string representation of the camera useful for debug purpose.
  35177. * @param fullDetails Defines that a more verboe level of logging is required
  35178. * @returns the string representation
  35179. */
  35180. toString(fullDetails?: boolean): string;
  35181. /**
  35182. * Gets the current world space position of the camera.
  35183. */
  35184. get globalPosition(): Vector3;
  35185. /**
  35186. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35187. * @returns the active meshe list
  35188. */
  35189. getActiveMeshes(): SmartArray<AbstractMesh>;
  35190. /**
  35191. * Check whether a mesh is part of the current active mesh list of the camera
  35192. * @param mesh Defines the mesh to check
  35193. * @returns true if active, false otherwise
  35194. */
  35195. isActiveMesh(mesh: Mesh): boolean;
  35196. /**
  35197. * Is this camera ready to be used/rendered
  35198. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35199. * @return true if the camera is ready
  35200. */
  35201. isReady(completeCheck?: boolean): boolean;
  35202. /** @hidden */
  35203. _initCache(): void;
  35204. /** @hidden */
  35205. _updateCache(ignoreParentClass?: boolean): void;
  35206. /** @hidden */
  35207. _isSynchronized(): boolean;
  35208. /** @hidden */
  35209. _isSynchronizedViewMatrix(): boolean;
  35210. /** @hidden */
  35211. _isSynchronizedProjectionMatrix(): boolean;
  35212. /**
  35213. * Attach the input controls to a specific dom element to get the input from.
  35214. * @param element Defines the element the controls should be listened from
  35215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35216. */
  35217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35218. /**
  35219. * Detach the current controls from the specified dom element.
  35220. * @param element Defines the element to stop listening the inputs from
  35221. */
  35222. detachControl(element: HTMLElement): void;
  35223. /**
  35224. * Update the camera state according to the different inputs gathered during the frame.
  35225. */
  35226. update(): void;
  35227. /** @hidden */
  35228. _checkInputs(): void;
  35229. /** @hidden */
  35230. get rigCameras(): Camera[];
  35231. /**
  35232. * Gets the post process used by the rig cameras
  35233. */
  35234. get rigPostProcess(): Nullable<PostProcess>;
  35235. /**
  35236. * Internal, gets the first post proces.
  35237. * @returns the first post process to be run on this camera.
  35238. */
  35239. _getFirstPostProcess(): Nullable<PostProcess>;
  35240. private _cascadePostProcessesToRigCams;
  35241. /**
  35242. * Attach a post process to the camera.
  35243. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35244. * @param postProcess The post process to attach to the camera
  35245. * @param insertAt The position of the post process in case several of them are in use in the scene
  35246. * @returns the position the post process has been inserted at
  35247. */
  35248. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35249. /**
  35250. * Detach a post process to the camera.
  35251. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35252. * @param postProcess The post process to detach from the camera
  35253. */
  35254. detachPostProcess(postProcess: PostProcess): void;
  35255. /**
  35256. * Gets the current world matrix of the camera
  35257. */
  35258. getWorldMatrix(): Matrix;
  35259. /** @hidden */
  35260. _getViewMatrix(): Matrix;
  35261. /**
  35262. * Gets the current view matrix of the camera.
  35263. * @param force forces the camera to recompute the matrix without looking at the cached state
  35264. * @returns the view matrix
  35265. */
  35266. getViewMatrix(force?: boolean): Matrix;
  35267. /**
  35268. * Freeze the projection matrix.
  35269. * It will prevent the cache check of the camera projection compute and can speed up perf
  35270. * if no parameter of the camera are meant to change
  35271. * @param projection Defines manually a projection if necessary
  35272. */
  35273. freezeProjectionMatrix(projection?: Matrix): void;
  35274. /**
  35275. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35276. */
  35277. unfreezeProjectionMatrix(): void;
  35278. /**
  35279. * Gets the current projection matrix of the camera.
  35280. * @param force forces the camera to recompute the matrix without looking at the cached state
  35281. * @returns the projection matrix
  35282. */
  35283. getProjectionMatrix(force?: boolean): Matrix;
  35284. /**
  35285. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35286. * @returns a Matrix
  35287. */
  35288. getTransformationMatrix(): Matrix;
  35289. private _updateFrustumPlanes;
  35290. /**
  35291. * Checks if a cullable object (mesh...) is in the camera frustum
  35292. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35293. * @param target The object to check
  35294. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35295. * @returns true if the object is in frustum otherwise false
  35296. */
  35297. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35298. /**
  35299. * Checks if a cullable object (mesh...) is in the camera frustum
  35300. * Unlike isInFrustum this cheks the full bounding box
  35301. * @param target The object to check
  35302. * @returns true if the object is in frustum otherwise false
  35303. */
  35304. isCompletelyInFrustum(target: ICullable): boolean;
  35305. /**
  35306. * Gets a ray in the forward direction from the camera.
  35307. * @param length Defines the length of the ray to create
  35308. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35309. * @param origin Defines the start point of the ray which defaults to the camera position
  35310. * @returns the forward ray
  35311. */
  35312. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35313. /**
  35314. * Gets a ray in the forward direction from the camera.
  35315. * @param refRay the ray to (re)use when setting the values
  35316. * @param length Defines the length of the ray to create
  35317. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35318. * @param origin Defines the start point of the ray which defaults to the camera position
  35319. * @returns the forward ray
  35320. */
  35321. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35322. /**
  35323. * Releases resources associated with this node.
  35324. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35325. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35326. */
  35327. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35328. /** @hidden */
  35329. _isLeftCamera: boolean;
  35330. /**
  35331. * Gets the left camera of a rig setup in case of Rigged Camera
  35332. */
  35333. get isLeftCamera(): boolean;
  35334. /** @hidden */
  35335. _isRightCamera: boolean;
  35336. /**
  35337. * Gets the right camera of a rig setup in case of Rigged Camera
  35338. */
  35339. get isRightCamera(): boolean;
  35340. /**
  35341. * Gets the left camera of a rig setup in case of Rigged Camera
  35342. */
  35343. get leftCamera(): Nullable<FreeCamera>;
  35344. /**
  35345. * Gets the right camera of a rig setup in case of Rigged Camera
  35346. */
  35347. get rightCamera(): Nullable<FreeCamera>;
  35348. /**
  35349. * Gets the left camera target of a rig setup in case of Rigged Camera
  35350. * @returns the target position
  35351. */
  35352. getLeftTarget(): Nullable<Vector3>;
  35353. /**
  35354. * Gets the right camera target of a rig setup in case of Rigged Camera
  35355. * @returns the target position
  35356. */
  35357. getRightTarget(): Nullable<Vector3>;
  35358. /**
  35359. * @hidden
  35360. */
  35361. setCameraRigMode(mode: number, rigParams: any): void;
  35362. /** @hidden */
  35363. static _setStereoscopicRigMode(camera: Camera): void;
  35364. /** @hidden */
  35365. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35366. /** @hidden */
  35367. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35368. /** @hidden */
  35369. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35370. /** @hidden */
  35371. _getVRProjectionMatrix(): Matrix;
  35372. protected _updateCameraRotationMatrix(): void;
  35373. protected _updateWebVRCameraRotationMatrix(): void;
  35374. /**
  35375. * This function MUST be overwritten by the different WebVR cameras available.
  35376. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35377. * @hidden
  35378. */
  35379. _getWebVRProjectionMatrix(): Matrix;
  35380. /**
  35381. * This function MUST be overwritten by the different WebVR cameras available.
  35382. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35383. * @hidden
  35384. */
  35385. _getWebVRViewMatrix(): Matrix;
  35386. /** @hidden */
  35387. setCameraRigParameter(name: string, value: any): void;
  35388. /**
  35389. * needs to be overridden by children so sub has required properties to be copied
  35390. * @hidden
  35391. */
  35392. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35393. /**
  35394. * May need to be overridden by children
  35395. * @hidden
  35396. */
  35397. _updateRigCameras(): void;
  35398. /** @hidden */
  35399. _setupInputs(): void;
  35400. /**
  35401. * Serialiaze the camera setup to a json represention
  35402. * @returns the JSON representation
  35403. */
  35404. serialize(): any;
  35405. /**
  35406. * Clones the current camera.
  35407. * @param name The cloned camera name
  35408. * @returns the cloned camera
  35409. */
  35410. clone(name: string): Camera;
  35411. /**
  35412. * Gets the direction of the camera relative to a given local axis.
  35413. * @param localAxis Defines the reference axis to provide a relative direction.
  35414. * @return the direction
  35415. */
  35416. getDirection(localAxis: Vector3): Vector3;
  35417. /**
  35418. * Returns the current camera absolute rotation
  35419. */
  35420. get absoluteRotation(): Quaternion;
  35421. /**
  35422. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35423. * @param localAxis Defines the reference axis to provide a relative direction.
  35424. * @param result Defines the vector to store the result in
  35425. */
  35426. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35427. /**
  35428. * Gets a camera constructor for a given camera type
  35429. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35430. * @param name The name of the camera the result will be able to instantiate
  35431. * @param scene The scene the result will construct the camera in
  35432. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35433. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35434. * @returns a factory method to construc the camera
  35435. */
  35436. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35437. /**
  35438. * Compute the world matrix of the camera.
  35439. * @returns the camera world matrix
  35440. */
  35441. computeWorldMatrix(): Matrix;
  35442. /**
  35443. * Parse a JSON and creates the camera from the parsed information
  35444. * @param parsedCamera The JSON to parse
  35445. * @param scene The scene to instantiate the camera in
  35446. * @returns the newly constructed camera
  35447. */
  35448. static Parse(parsedCamera: any, scene: Scene): Camera;
  35449. }
  35450. }
  35451. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35452. import { Nullable } from "babylonjs/types";
  35453. import { Scene } from "babylonjs/scene";
  35454. import { Vector4 } from "babylonjs/Maths/math.vector";
  35455. import { Mesh } from "babylonjs/Meshes/mesh";
  35456. /**
  35457. * Class containing static functions to help procedurally build meshes
  35458. */
  35459. export class DiscBuilder {
  35460. /**
  35461. * Creates a plane polygonal mesh. By default, this is a disc
  35462. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35463. * * 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
  35464. * * 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
  35465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35468. * @param name defines the name of the mesh
  35469. * @param options defines the options used to create the mesh
  35470. * @param scene defines the hosting scene
  35471. * @returns the plane polygonal mesh
  35472. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35473. */
  35474. static CreateDisc(name: string, options: {
  35475. radius?: number;
  35476. tessellation?: number;
  35477. arc?: number;
  35478. updatable?: boolean;
  35479. sideOrientation?: number;
  35480. frontUVs?: Vector4;
  35481. backUVs?: Vector4;
  35482. }, scene?: Nullable<Scene>): Mesh;
  35483. }
  35484. }
  35485. declare module "babylonjs/Particles/solidParticleSystem" {
  35486. import { Nullable } from "babylonjs/types";
  35487. import { Mesh } from "babylonjs/Meshes/mesh";
  35488. import { Scene, IDisposable } from "babylonjs/scene";
  35489. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35490. import { Material } from "babylonjs/Materials/material";
  35491. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35492. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35493. /**
  35494. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35495. *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.
  35496. * The SPS is also a particle system. It provides some methods to manage the particles.
  35497. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35498. *
  35499. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35500. */
  35501. export class SolidParticleSystem implements IDisposable {
  35502. /**
  35503. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35504. * Example : var p = SPS.particles[i];
  35505. */
  35506. particles: SolidParticle[];
  35507. /**
  35508. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35509. */
  35510. nbParticles: number;
  35511. /**
  35512. * If the particles must ever face the camera (default false). Useful for planar particles.
  35513. */
  35514. billboard: boolean;
  35515. /**
  35516. * Recompute normals when adding a shape
  35517. */
  35518. recomputeNormals: boolean;
  35519. /**
  35520. * This a counter ofr your own usage. It's not set by any SPS functions.
  35521. */
  35522. counter: number;
  35523. /**
  35524. * The SPS name. This name is also given to the underlying mesh.
  35525. */
  35526. name: string;
  35527. /**
  35528. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35529. */
  35530. mesh: Mesh;
  35531. /**
  35532. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35533. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35534. */
  35535. vars: any;
  35536. /**
  35537. * This array is populated when the SPS is set as 'pickable'.
  35538. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35539. * Each element of this array is an object `{idx: int, faceId: int}`.
  35540. * `idx` is the picked particle index in the `SPS.particles` array
  35541. * `faceId` is the picked face index counted within this particle.
  35542. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35543. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35544. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35545. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35546. */
  35547. pickedParticles: {
  35548. idx: number;
  35549. faceId: number;
  35550. }[];
  35551. /**
  35552. * This array is populated when the SPS is set as 'pickable'
  35553. * Each key of this array is a submesh index.
  35554. * Each element of this array is a second array defined like this :
  35555. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35556. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35557. * `idx` is the picked particle index in the `SPS.particles` array
  35558. * `faceId` is the picked face index counted within this particle.
  35559. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35560. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35561. */
  35562. pickedBySubMesh: {
  35563. idx: number;
  35564. faceId: number;
  35565. }[][];
  35566. /**
  35567. * This array is populated when `enableDepthSort` is set to true.
  35568. * Each element of this array is an instance of the class DepthSortedParticle.
  35569. */
  35570. depthSortedParticles: DepthSortedParticle[];
  35571. /**
  35572. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35573. * @hidden
  35574. */
  35575. _bSphereOnly: boolean;
  35576. /**
  35577. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35578. * @hidden
  35579. */
  35580. _bSphereRadiusFactor: number;
  35581. private _scene;
  35582. private _positions;
  35583. private _indices;
  35584. private _normals;
  35585. private _colors;
  35586. private _uvs;
  35587. private _indices32;
  35588. private _positions32;
  35589. private _normals32;
  35590. private _fixedNormal32;
  35591. private _colors32;
  35592. private _uvs32;
  35593. private _index;
  35594. private _updatable;
  35595. private _pickable;
  35596. private _isVisibilityBoxLocked;
  35597. private _alwaysVisible;
  35598. private _depthSort;
  35599. private _expandable;
  35600. private _shapeCounter;
  35601. private _copy;
  35602. private _color;
  35603. private _computeParticleColor;
  35604. private _computeParticleTexture;
  35605. private _computeParticleRotation;
  35606. private _computeParticleVertex;
  35607. private _computeBoundingBox;
  35608. private _depthSortParticles;
  35609. private _camera;
  35610. private _mustUnrotateFixedNormals;
  35611. private _particlesIntersect;
  35612. private _needs32Bits;
  35613. private _isNotBuilt;
  35614. private _lastParticleId;
  35615. private _idxOfId;
  35616. private _multimaterialEnabled;
  35617. private _useModelMaterial;
  35618. private _indicesByMaterial;
  35619. private _materialIndexes;
  35620. private _depthSortFunction;
  35621. private _materialSortFunction;
  35622. private _materials;
  35623. private _multimaterial;
  35624. private _materialIndexesById;
  35625. private _defaultMaterial;
  35626. private _autoUpdateSubMeshes;
  35627. private _tmpVertex;
  35628. /**
  35629. * Creates a SPS (Solid Particle System) object.
  35630. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35631. * @param scene (Scene) is the scene in which the SPS is added.
  35632. * @param options defines the options of the sps e.g.
  35633. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35634. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35635. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35636. * * 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.
  35637. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35638. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35639. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35640. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35641. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35642. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35643. */
  35644. constructor(name: string, scene: Scene, options?: {
  35645. updatable?: boolean;
  35646. isPickable?: boolean;
  35647. enableDepthSort?: boolean;
  35648. particleIntersection?: boolean;
  35649. boundingSphereOnly?: boolean;
  35650. bSphereRadiusFactor?: number;
  35651. expandable?: boolean;
  35652. useModelMaterial?: boolean;
  35653. enableMultiMaterial?: boolean;
  35654. });
  35655. /**
  35656. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35657. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35658. * @returns the created mesh
  35659. */
  35660. buildMesh(): Mesh;
  35661. /**
  35662. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35663. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35664. * Thus the particles generated from `digest()` have their property `position` set yet.
  35665. * @param mesh ( Mesh ) is the mesh to be digested
  35666. * @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
  35667. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35668. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35669. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35670. * @returns the current SPS
  35671. */
  35672. digest(mesh: Mesh, options?: {
  35673. facetNb?: number;
  35674. number?: number;
  35675. delta?: number;
  35676. storage?: [];
  35677. }): SolidParticleSystem;
  35678. /**
  35679. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35680. * @hidden
  35681. */
  35682. private _unrotateFixedNormals;
  35683. /**
  35684. * Resets the temporary working copy particle
  35685. * @hidden
  35686. */
  35687. private _resetCopy;
  35688. /**
  35689. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35690. * @param p the current index in the positions array to be updated
  35691. * @param ind the current index in the indices array
  35692. * @param shape a Vector3 array, the shape geometry
  35693. * @param positions the positions array to be updated
  35694. * @param meshInd the shape indices array
  35695. * @param indices the indices array to be updated
  35696. * @param meshUV the shape uv array
  35697. * @param uvs the uv array to be updated
  35698. * @param meshCol the shape color array
  35699. * @param colors the color array to be updated
  35700. * @param meshNor the shape normals array
  35701. * @param normals the normals array to be updated
  35702. * @param idx the particle index
  35703. * @param idxInShape the particle index in its shape
  35704. * @param options the addShape() method passed options
  35705. * @model the particle model
  35706. * @hidden
  35707. */
  35708. private _meshBuilder;
  35709. /**
  35710. * Returns a shape Vector3 array from positions float array
  35711. * @param positions float array
  35712. * @returns a vector3 array
  35713. * @hidden
  35714. */
  35715. private _posToShape;
  35716. /**
  35717. * Returns a shapeUV array from a float uvs (array deep copy)
  35718. * @param uvs as a float array
  35719. * @returns a shapeUV array
  35720. * @hidden
  35721. */
  35722. private _uvsToShapeUV;
  35723. /**
  35724. * Adds a new particle object in the particles array
  35725. * @param idx particle index in particles array
  35726. * @param id particle id
  35727. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35728. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35729. * @param model particle ModelShape object
  35730. * @param shapeId model shape identifier
  35731. * @param idxInShape index of the particle in the current model
  35732. * @param bInfo model bounding info object
  35733. * @param storage target storage array, if any
  35734. * @hidden
  35735. */
  35736. private _addParticle;
  35737. /**
  35738. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35739. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35740. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35741. * @param nb (positive integer) the number of particles to be created from this model
  35742. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35743. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35744. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35745. * @returns the number of shapes in the system
  35746. */
  35747. addShape(mesh: Mesh, nb: number, options?: {
  35748. positionFunction?: any;
  35749. vertexFunction?: any;
  35750. storage?: [];
  35751. }): number;
  35752. /**
  35753. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35754. * @hidden
  35755. */
  35756. private _rebuildParticle;
  35757. /**
  35758. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35759. * @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.
  35760. * @returns the SPS.
  35761. */
  35762. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35763. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35764. * Returns an array with the removed particles.
  35765. * 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.
  35766. * The SPS can't be empty so at least one particle needs to remain in place.
  35767. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35768. * @param start index of the first particle to remove
  35769. * @param end index of the last particle to remove (included)
  35770. * @returns an array populated with the removed particles
  35771. */
  35772. removeParticles(start: number, end: number): SolidParticle[];
  35773. /**
  35774. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35775. * @param solidParticleArray an array populated with Solid Particles objects
  35776. * @returns the SPS
  35777. */
  35778. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35779. /**
  35780. * Creates a new particle and modifies the SPS mesh geometry :
  35781. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35782. * - calls _addParticle() to populate the particle array
  35783. * factorized code from addShape() and insertParticlesFromArray()
  35784. * @param idx particle index in the particles array
  35785. * @param i particle index in its shape
  35786. * @param modelShape particle ModelShape object
  35787. * @param shape shape vertex array
  35788. * @param meshInd shape indices array
  35789. * @param meshUV shape uv array
  35790. * @param meshCol shape color array
  35791. * @param meshNor shape normals array
  35792. * @param bbInfo shape bounding info
  35793. * @param storage target particle storage
  35794. * @options addShape() passed options
  35795. * @hidden
  35796. */
  35797. private _insertNewParticle;
  35798. /**
  35799. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35800. * This method calls `updateParticle()` for each particle of the SPS.
  35801. * For an animated SPS, it is usually called within the render loop.
  35802. * 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.
  35803. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35804. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35805. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35806. * @returns the SPS.
  35807. */
  35808. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35809. /**
  35810. * Disposes the SPS.
  35811. */
  35812. dispose(): void;
  35813. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35814. * idx is the particle index in the SPS
  35815. * faceId is the picked face index counted within this particle.
  35816. * Returns null if the pickInfo can't identify a picked particle.
  35817. * @param pickingInfo (PickingInfo object)
  35818. * @returns {idx: number, faceId: number} or null
  35819. */
  35820. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35821. idx: number;
  35822. faceId: number;
  35823. }>;
  35824. /**
  35825. * Returns a SolidParticle object from its identifier : particle.id
  35826. * @param id (integer) the particle Id
  35827. * @returns the searched particle or null if not found in the SPS.
  35828. */
  35829. getParticleById(id: number): Nullable<SolidParticle>;
  35830. /**
  35831. * Returns a new array populated with the particles having the passed shapeId.
  35832. * @param shapeId (integer) the shape identifier
  35833. * @returns a new solid particle array
  35834. */
  35835. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35836. /**
  35837. * Populates the passed array "ref" with the particles having the passed shapeId.
  35838. * @param shapeId the shape identifier
  35839. * @returns the SPS
  35840. * @param ref
  35841. */
  35842. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35843. /**
  35844. * Computes the required SubMeshes according the materials assigned to the particles.
  35845. * @returns the solid particle system.
  35846. * Does nothing if called before the SPS mesh is built.
  35847. */
  35848. computeSubMeshes(): SolidParticleSystem;
  35849. /**
  35850. * Sorts the solid particles by material when MultiMaterial is enabled.
  35851. * Updates the indices32 array.
  35852. * Updates the indicesByMaterial array.
  35853. * Updates the mesh indices array.
  35854. * @returns the SPS
  35855. * @hidden
  35856. */
  35857. private _sortParticlesByMaterial;
  35858. /**
  35859. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35860. * @hidden
  35861. */
  35862. private _setMaterialIndexesById;
  35863. /**
  35864. * Returns an array with unique values of Materials from the passed array
  35865. * @param array the material array to be checked and filtered
  35866. * @hidden
  35867. */
  35868. private _filterUniqueMaterialId;
  35869. /**
  35870. * Sets a new Standard Material as _defaultMaterial if not already set.
  35871. * @hidden
  35872. */
  35873. private _setDefaultMaterial;
  35874. /**
  35875. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35876. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35877. * @returns the SPS.
  35878. */
  35879. refreshVisibleSize(): SolidParticleSystem;
  35880. /**
  35881. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35882. * @param size the size (float) of the visibility box
  35883. * note : this doesn't lock the SPS mesh bounding box.
  35884. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35885. */
  35886. setVisibilityBox(size: number): void;
  35887. /**
  35888. * Gets whether the SPS as always visible or not
  35889. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35890. */
  35891. get isAlwaysVisible(): boolean;
  35892. /**
  35893. * Sets the SPS as always visible or not
  35894. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35895. */
  35896. set isAlwaysVisible(val: boolean);
  35897. /**
  35898. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35899. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35900. */
  35901. set isVisibilityBoxLocked(val: boolean);
  35902. /**
  35903. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35904. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35905. */
  35906. get isVisibilityBoxLocked(): boolean;
  35907. /**
  35908. * Tells to `setParticles()` to compute the particle rotations or not.
  35909. * Default value : true. The SPS is faster when it's set to false.
  35910. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35911. */
  35912. set computeParticleRotation(val: boolean);
  35913. /**
  35914. * Tells to `setParticles()` to compute the particle colors or not.
  35915. * Default value : true. The SPS is faster when it's set to false.
  35916. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35917. */
  35918. set computeParticleColor(val: boolean);
  35919. set computeParticleTexture(val: boolean);
  35920. /**
  35921. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35922. * Default value : false. The SPS is faster when it's set to false.
  35923. * Note : the particle custom vertex positions aren't stored values.
  35924. */
  35925. set computeParticleVertex(val: boolean);
  35926. /**
  35927. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35928. */
  35929. set computeBoundingBox(val: boolean);
  35930. /**
  35931. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35932. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35933. * Default : `true`
  35934. */
  35935. set depthSortParticles(val: boolean);
  35936. /**
  35937. * Gets if `setParticles()` computes the particle rotations or not.
  35938. * Default value : true. The SPS is faster when it's set to false.
  35939. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35940. */
  35941. get computeParticleRotation(): boolean;
  35942. /**
  35943. * Gets if `setParticles()` computes the particle colors or not.
  35944. * Default value : true. The SPS is faster when it's set to false.
  35945. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35946. */
  35947. get computeParticleColor(): boolean;
  35948. /**
  35949. * Gets if `setParticles()` computes the particle textures or not.
  35950. * Default value : true. The SPS is faster when it's set to false.
  35951. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35952. */
  35953. get computeParticleTexture(): boolean;
  35954. /**
  35955. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35956. * Default value : false. The SPS is faster when it's set to false.
  35957. * Note : the particle custom vertex positions aren't stored values.
  35958. */
  35959. get computeParticleVertex(): boolean;
  35960. /**
  35961. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35962. */
  35963. get computeBoundingBox(): boolean;
  35964. /**
  35965. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35966. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35967. * Default : `true`
  35968. */
  35969. get depthSortParticles(): boolean;
  35970. /**
  35971. * Gets if the SPS is created as expandable at construction time.
  35972. * Default : `false`
  35973. */
  35974. get expandable(): boolean;
  35975. /**
  35976. * Gets if the SPS supports the Multi Materials
  35977. */
  35978. get multimaterialEnabled(): boolean;
  35979. /**
  35980. * Gets if the SPS uses the model materials for its own multimaterial.
  35981. */
  35982. get useModelMaterial(): boolean;
  35983. /**
  35984. * The SPS used material array.
  35985. */
  35986. get materials(): Material[];
  35987. /**
  35988. * Sets the SPS MultiMaterial from the passed materials.
  35989. * Note : the passed array is internally copied and not used then by reference.
  35990. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35991. */
  35992. setMultiMaterial(materials: Material[]): void;
  35993. /**
  35994. * The SPS computed multimaterial object
  35995. */
  35996. get multimaterial(): MultiMaterial;
  35997. set multimaterial(mm: MultiMaterial);
  35998. /**
  35999. * If the subMeshes must be updated on the next call to setParticles()
  36000. */
  36001. get autoUpdateSubMeshes(): boolean;
  36002. set autoUpdateSubMeshes(val: boolean);
  36003. /**
  36004. * This function does nothing. It may be overwritten to set all the particle first values.
  36005. * The SPS doesn't call this function, you may have to call it by your own.
  36006. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36007. */
  36008. initParticles(): void;
  36009. /**
  36010. * This function does nothing. It may be overwritten to recycle a particle.
  36011. * The SPS doesn't call this function, you may have to call it by your own.
  36012. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36013. * @param particle The particle to recycle
  36014. * @returns the recycled particle
  36015. */
  36016. recycleParticle(particle: SolidParticle): SolidParticle;
  36017. /**
  36018. * Updates a particle : this function should be overwritten by the user.
  36019. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36020. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36021. * @example : just set a particle position or velocity and recycle conditions
  36022. * @param particle The particle to update
  36023. * @returns the updated particle
  36024. */
  36025. updateParticle(particle: SolidParticle): SolidParticle;
  36026. /**
  36027. * Updates a vertex of a particle : it can be overwritten by the user.
  36028. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36029. * @param particle the current particle
  36030. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36031. * @param pt the index of the current vertex in the particle shape
  36032. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36033. * @example : just set a vertex particle position or color
  36034. * @returns the sps
  36035. */
  36036. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36037. /**
  36038. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36039. * This does nothing and may be overwritten by the user.
  36040. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36041. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36042. * @param update the boolean update value actually passed to setParticles()
  36043. */
  36044. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36045. /**
  36046. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36047. * This will be passed three parameters.
  36048. * This does nothing and may be overwritten by the user.
  36049. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36050. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36051. * @param update the boolean update value actually passed to setParticles()
  36052. */
  36053. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36054. }
  36055. }
  36056. declare module "babylonjs/Particles/solidParticle" {
  36057. import { Nullable } from "babylonjs/types";
  36058. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36059. import { Color4 } from "babylonjs/Maths/math.color";
  36060. import { Mesh } from "babylonjs/Meshes/mesh";
  36061. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36062. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36063. import { Plane } from "babylonjs/Maths/math.plane";
  36064. import { Material } from "babylonjs/Materials/material";
  36065. /**
  36066. * Represents one particle of a solid particle system.
  36067. */
  36068. export class SolidParticle {
  36069. /**
  36070. * particle global index
  36071. */
  36072. idx: number;
  36073. /**
  36074. * particle identifier
  36075. */
  36076. id: number;
  36077. /**
  36078. * The color of the particle
  36079. */
  36080. color: Nullable<Color4>;
  36081. /**
  36082. * The world space position of the particle.
  36083. */
  36084. position: Vector3;
  36085. /**
  36086. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36087. */
  36088. rotation: Vector3;
  36089. /**
  36090. * The world space rotation quaternion of the particle.
  36091. */
  36092. rotationQuaternion: Nullable<Quaternion>;
  36093. /**
  36094. * The scaling of the particle.
  36095. */
  36096. scaling: Vector3;
  36097. /**
  36098. * The uvs of the particle.
  36099. */
  36100. uvs: Vector4;
  36101. /**
  36102. * The current speed of the particle.
  36103. */
  36104. velocity: Vector3;
  36105. /**
  36106. * The pivot point in the particle local space.
  36107. */
  36108. pivot: Vector3;
  36109. /**
  36110. * Must the particle be translated from its pivot point in its local space ?
  36111. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36112. * Default : false
  36113. */
  36114. translateFromPivot: boolean;
  36115. /**
  36116. * Is the particle active or not ?
  36117. */
  36118. alive: boolean;
  36119. /**
  36120. * Is the particle visible or not ?
  36121. */
  36122. isVisible: boolean;
  36123. /**
  36124. * Index of this particle in the global "positions" array (Internal use)
  36125. * @hidden
  36126. */
  36127. _pos: number;
  36128. /**
  36129. * @hidden Index of this particle in the global "indices" array (Internal use)
  36130. */
  36131. _ind: number;
  36132. /**
  36133. * @hidden ModelShape of this particle (Internal use)
  36134. */
  36135. _model: ModelShape;
  36136. /**
  36137. * ModelShape id of this particle
  36138. */
  36139. shapeId: number;
  36140. /**
  36141. * Index of the particle in its shape id
  36142. */
  36143. idxInShape: number;
  36144. /**
  36145. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36146. */
  36147. _modelBoundingInfo: BoundingInfo;
  36148. /**
  36149. * @hidden Particle BoundingInfo object (Internal use)
  36150. */
  36151. _boundingInfo: BoundingInfo;
  36152. /**
  36153. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36154. */
  36155. _sps: SolidParticleSystem;
  36156. /**
  36157. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36158. */
  36159. _stillInvisible: boolean;
  36160. /**
  36161. * @hidden Last computed particle rotation matrix
  36162. */
  36163. _rotationMatrix: number[];
  36164. /**
  36165. * Parent particle Id, if any.
  36166. * Default null.
  36167. */
  36168. parentId: Nullable<number>;
  36169. /**
  36170. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36171. */
  36172. materialIndex: Nullable<number>;
  36173. /**
  36174. * Custom object or properties.
  36175. */
  36176. props: Nullable<any>;
  36177. /**
  36178. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36179. * The possible values are :
  36180. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36181. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36182. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36183. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36184. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36185. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36186. * */
  36187. cullingStrategy: number;
  36188. /**
  36189. * @hidden Internal global position in the SPS.
  36190. */
  36191. _globalPosition: Vector3;
  36192. /**
  36193. * Creates a Solid Particle object.
  36194. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36195. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36196. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36197. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36198. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36199. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36200. * @param shapeId (integer) is the model shape identifier in the SPS.
  36201. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36202. * @param sps defines the sps it is associated to
  36203. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36204. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36205. */
  36206. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36207. /**
  36208. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36209. * @param target the particle target
  36210. * @returns the current particle
  36211. */
  36212. copyToRef(target: SolidParticle): SolidParticle;
  36213. /**
  36214. * Legacy support, changed scale to scaling
  36215. */
  36216. get scale(): Vector3;
  36217. /**
  36218. * Legacy support, changed scale to scaling
  36219. */
  36220. set scale(scale: Vector3);
  36221. /**
  36222. * Legacy support, changed quaternion to rotationQuaternion
  36223. */
  36224. get quaternion(): Nullable<Quaternion>;
  36225. /**
  36226. * Legacy support, changed quaternion to rotationQuaternion
  36227. */
  36228. set quaternion(q: Nullable<Quaternion>);
  36229. /**
  36230. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36231. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36232. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36233. * @returns true if it intersects
  36234. */
  36235. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36236. /**
  36237. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36238. * A particle is in the frustum if its bounding box intersects the frustum
  36239. * @param frustumPlanes defines the frustum to test
  36240. * @returns true if the particle is in the frustum planes
  36241. */
  36242. isInFrustum(frustumPlanes: Plane[]): boolean;
  36243. /**
  36244. * get the rotation matrix of the particle
  36245. * @hidden
  36246. */
  36247. getRotationMatrix(m: Matrix): void;
  36248. }
  36249. /**
  36250. * Represents the shape of the model used by one particle of a solid particle system.
  36251. * SPS internal tool, don't use it manually.
  36252. */
  36253. export class ModelShape {
  36254. /**
  36255. * The shape id
  36256. * @hidden
  36257. */
  36258. shapeID: number;
  36259. /**
  36260. * flat array of model positions (internal use)
  36261. * @hidden
  36262. */
  36263. _shape: Vector3[];
  36264. /**
  36265. * flat array of model UVs (internal use)
  36266. * @hidden
  36267. */
  36268. _shapeUV: number[];
  36269. /**
  36270. * color array of the model
  36271. * @hidden
  36272. */
  36273. _shapeColors: number[];
  36274. /**
  36275. * indices array of the model
  36276. * @hidden
  36277. */
  36278. _indices: number[];
  36279. /**
  36280. * normals array of the model
  36281. * @hidden
  36282. */
  36283. _normals: number[];
  36284. /**
  36285. * length of the shape in the model indices array (internal use)
  36286. * @hidden
  36287. */
  36288. _indicesLength: number;
  36289. /**
  36290. * Custom position function (internal use)
  36291. * @hidden
  36292. */
  36293. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36294. /**
  36295. * Custom vertex function (internal use)
  36296. * @hidden
  36297. */
  36298. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36299. /**
  36300. * Model material (internal use)
  36301. * @hidden
  36302. */
  36303. _material: Nullable<Material>;
  36304. /**
  36305. * 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.
  36306. * SPS internal tool, don't use it manually.
  36307. * @hidden
  36308. */
  36309. 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>);
  36310. }
  36311. /**
  36312. * Represents a Depth Sorted Particle in the solid particle system.
  36313. * @hidden
  36314. */
  36315. export class DepthSortedParticle {
  36316. /**
  36317. * Particle index
  36318. */
  36319. idx: number;
  36320. /**
  36321. * Index of the particle in the "indices" array
  36322. */
  36323. ind: number;
  36324. /**
  36325. * Length of the particle shape in the "indices" array
  36326. */
  36327. indicesLength: number;
  36328. /**
  36329. * Squared distance from the particle to the camera
  36330. */
  36331. sqDistance: number;
  36332. /**
  36333. * Material index when used with MultiMaterials
  36334. */
  36335. materialIndex: number;
  36336. /**
  36337. * Creates a new sorted particle
  36338. * @param materialIndex
  36339. */
  36340. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36341. }
  36342. /**
  36343. * Represents a solid particle vertex
  36344. */
  36345. export class SolidParticleVertex {
  36346. /**
  36347. * Vertex position
  36348. */
  36349. position: Vector3;
  36350. /**
  36351. * Vertex color
  36352. */
  36353. color: Color4;
  36354. /**
  36355. * Vertex UV
  36356. */
  36357. uv: Vector2;
  36358. /**
  36359. * Creates a new solid particle vertex
  36360. */
  36361. constructor();
  36362. /** Vertex x coordinate */
  36363. get x(): number;
  36364. set x(val: number);
  36365. /** Vertex y coordinate */
  36366. get y(): number;
  36367. set y(val: number);
  36368. /** Vertex z coordinate */
  36369. get z(): number;
  36370. set z(val: number);
  36371. }
  36372. }
  36373. declare module "babylonjs/Collisions/meshCollisionData" {
  36374. import { Collider } from "babylonjs/Collisions/collider";
  36375. import { Vector3 } from "babylonjs/Maths/math.vector";
  36376. import { Nullable } from "babylonjs/types";
  36377. import { Observer } from "babylonjs/Misc/observable";
  36378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36379. /**
  36380. * @hidden
  36381. */
  36382. export class _MeshCollisionData {
  36383. _checkCollisions: boolean;
  36384. _collisionMask: number;
  36385. _collisionGroup: number;
  36386. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36387. _collider: Nullable<Collider>;
  36388. _oldPositionForCollisions: Vector3;
  36389. _diffPositionForCollisions: Vector3;
  36390. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36391. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36392. _collisionResponse: boolean;
  36393. }
  36394. }
  36395. declare module "babylonjs/Meshes/abstractMesh" {
  36396. import { Observable } from "babylonjs/Misc/observable";
  36397. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36398. import { Camera } from "babylonjs/Cameras/camera";
  36399. import { Scene, IDisposable } from "babylonjs/scene";
  36400. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36401. import { Node } from "babylonjs/node";
  36402. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36403. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36404. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36405. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36406. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36407. import { Material } from "babylonjs/Materials/material";
  36408. import { Light } from "babylonjs/Lights/light";
  36409. import { Skeleton } from "babylonjs/Bones/skeleton";
  36410. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36411. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36412. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36413. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36414. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36415. import { Plane } from "babylonjs/Maths/math.plane";
  36416. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36417. import { Ray } from "babylonjs/Culling/ray";
  36418. import { Collider } from "babylonjs/Collisions/collider";
  36419. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36420. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36421. /** @hidden */
  36422. class _FacetDataStorage {
  36423. facetPositions: Vector3[];
  36424. facetNormals: Vector3[];
  36425. facetPartitioning: number[][];
  36426. facetNb: number;
  36427. partitioningSubdivisions: number;
  36428. partitioningBBoxRatio: number;
  36429. facetDataEnabled: boolean;
  36430. facetParameters: any;
  36431. bbSize: Vector3;
  36432. subDiv: {
  36433. max: number;
  36434. X: number;
  36435. Y: number;
  36436. Z: number;
  36437. };
  36438. facetDepthSort: boolean;
  36439. facetDepthSortEnabled: boolean;
  36440. depthSortedIndices: IndicesArray;
  36441. depthSortedFacets: {
  36442. ind: number;
  36443. sqDistance: number;
  36444. }[];
  36445. facetDepthSortFunction: (f1: {
  36446. ind: number;
  36447. sqDistance: number;
  36448. }, f2: {
  36449. ind: number;
  36450. sqDistance: number;
  36451. }) => number;
  36452. facetDepthSortFrom: Vector3;
  36453. facetDepthSortOrigin: Vector3;
  36454. invertedMatrix: Matrix;
  36455. }
  36456. /**
  36457. * @hidden
  36458. **/
  36459. class _InternalAbstractMeshDataInfo {
  36460. _hasVertexAlpha: boolean;
  36461. _useVertexColors: boolean;
  36462. _numBoneInfluencers: number;
  36463. _applyFog: boolean;
  36464. _receiveShadows: boolean;
  36465. _facetData: _FacetDataStorage;
  36466. _visibility: number;
  36467. _skeleton: Nullable<Skeleton>;
  36468. _layerMask: number;
  36469. _computeBonesUsingShaders: boolean;
  36470. _isActive: boolean;
  36471. _onlyForInstances: boolean;
  36472. _isActiveIntermediate: boolean;
  36473. _onlyForInstancesIntermediate: boolean;
  36474. _actAsRegularMesh: boolean;
  36475. }
  36476. /**
  36477. * Class used to store all common mesh properties
  36478. */
  36479. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36480. /** No occlusion */
  36481. static OCCLUSION_TYPE_NONE: number;
  36482. /** Occlusion set to optimisitic */
  36483. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36484. /** Occlusion set to strict */
  36485. static OCCLUSION_TYPE_STRICT: number;
  36486. /** Use an accurante occlusion algorithm */
  36487. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36488. /** Use a conservative occlusion algorithm */
  36489. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36490. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36491. * Test order :
  36492. * Is the bounding sphere outside the frustum ?
  36493. * If not, are the bounding box vertices outside the frustum ?
  36494. * It not, then the cullable object is in the frustum.
  36495. */
  36496. static readonly CULLINGSTRATEGY_STANDARD: number;
  36497. /** Culling strategy : Bounding Sphere Only.
  36498. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36499. * It's also less accurate than the standard because some not visible objects can still be selected.
  36500. * Test : is the bounding sphere outside the frustum ?
  36501. * If not, then the cullable object is in the frustum.
  36502. */
  36503. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36504. /** Culling strategy : Optimistic Inclusion.
  36505. * This in an inclusion test first, then the standard exclusion test.
  36506. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36507. * 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.
  36508. * Anyway, it's as accurate as the standard strategy.
  36509. * Test :
  36510. * Is the cullable object bounding sphere center in the frustum ?
  36511. * If not, apply the default culling strategy.
  36512. */
  36513. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36514. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36515. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36516. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36517. * 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.
  36518. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36519. * Test :
  36520. * Is the cullable object bounding sphere center in the frustum ?
  36521. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36522. */
  36523. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36524. /**
  36525. * No billboard
  36526. */
  36527. static get BILLBOARDMODE_NONE(): number;
  36528. /** Billboard on X axis */
  36529. static get BILLBOARDMODE_X(): number;
  36530. /** Billboard on Y axis */
  36531. static get BILLBOARDMODE_Y(): number;
  36532. /** Billboard on Z axis */
  36533. static get BILLBOARDMODE_Z(): number;
  36534. /** Billboard on all axes */
  36535. static get BILLBOARDMODE_ALL(): number;
  36536. /** Billboard on using position instead of orientation */
  36537. static get BILLBOARDMODE_USE_POSITION(): number;
  36538. /** @hidden */
  36539. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36540. /**
  36541. * The culling strategy to use to check whether the mesh must be rendered or not.
  36542. * This value can be changed at any time and will be used on the next render mesh selection.
  36543. * The possible values are :
  36544. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36545. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36546. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36547. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36548. * Please read each static variable documentation to get details about the culling process.
  36549. * */
  36550. cullingStrategy: number;
  36551. /**
  36552. * Gets the number of facets in the mesh
  36553. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36554. */
  36555. get facetNb(): number;
  36556. /**
  36557. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36558. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36559. */
  36560. get partitioningSubdivisions(): number;
  36561. set partitioningSubdivisions(nb: number);
  36562. /**
  36563. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36564. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36565. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36566. */
  36567. get partitioningBBoxRatio(): number;
  36568. set partitioningBBoxRatio(ratio: number);
  36569. /**
  36570. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36571. * Works only for updatable meshes.
  36572. * Doesn't work with multi-materials
  36573. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36574. */
  36575. get mustDepthSortFacets(): boolean;
  36576. set mustDepthSortFacets(sort: boolean);
  36577. /**
  36578. * The location (Vector3) where the facet depth sort must be computed from.
  36579. * By default, the active camera position.
  36580. * Used only when facet depth sort is enabled
  36581. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36582. */
  36583. get facetDepthSortFrom(): Vector3;
  36584. set facetDepthSortFrom(location: Vector3);
  36585. /**
  36586. * gets a boolean indicating if facetData is enabled
  36587. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36588. */
  36589. get isFacetDataEnabled(): boolean;
  36590. /** @hidden */
  36591. _updateNonUniformScalingState(value: boolean): boolean;
  36592. /**
  36593. * An event triggered when this mesh collides with another one
  36594. */
  36595. onCollideObservable: Observable<AbstractMesh>;
  36596. /** Set a function to call when this mesh collides with another one */
  36597. set onCollide(callback: () => void);
  36598. /**
  36599. * An event triggered when the collision's position changes
  36600. */
  36601. onCollisionPositionChangeObservable: Observable<Vector3>;
  36602. /** Set a function to call when the collision's position changes */
  36603. set onCollisionPositionChange(callback: () => void);
  36604. /**
  36605. * An event triggered when material is changed
  36606. */
  36607. onMaterialChangedObservable: Observable<AbstractMesh>;
  36608. /**
  36609. * Gets or sets the orientation for POV movement & rotation
  36610. */
  36611. definedFacingForward: boolean;
  36612. /** @hidden */
  36613. _occlusionQuery: Nullable<WebGLQuery>;
  36614. /** @hidden */
  36615. _renderingGroup: Nullable<RenderingGroup>;
  36616. /**
  36617. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36618. */
  36619. get visibility(): number;
  36620. /**
  36621. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36622. */
  36623. set visibility(value: number);
  36624. /** Gets or sets the alpha index used to sort transparent meshes
  36625. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36626. */
  36627. alphaIndex: number;
  36628. /**
  36629. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36630. */
  36631. isVisible: boolean;
  36632. /**
  36633. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36634. */
  36635. isPickable: boolean;
  36636. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36637. showSubMeshesBoundingBox: boolean;
  36638. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36639. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36640. */
  36641. isBlocker: boolean;
  36642. /**
  36643. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36644. */
  36645. enablePointerMoveEvents: boolean;
  36646. private _renderingGroupId;
  36647. /**
  36648. * Specifies the rendering group id for this mesh (0 by default)
  36649. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36650. */
  36651. get renderingGroupId(): number;
  36652. set renderingGroupId(value: number);
  36653. private _material;
  36654. /** Gets or sets current material */
  36655. get material(): Nullable<Material>;
  36656. set material(value: Nullable<Material>);
  36657. /**
  36658. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36659. * @see https://doc.babylonjs.com/babylon101/shadows
  36660. */
  36661. get receiveShadows(): boolean;
  36662. set receiveShadows(value: boolean);
  36663. /** Defines color to use when rendering outline */
  36664. outlineColor: Color3;
  36665. /** Define width to use when rendering outline */
  36666. outlineWidth: number;
  36667. /** Defines color to use when rendering overlay */
  36668. overlayColor: Color3;
  36669. /** Defines alpha to use when rendering overlay */
  36670. overlayAlpha: number;
  36671. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36672. get hasVertexAlpha(): boolean;
  36673. set hasVertexAlpha(value: boolean);
  36674. /** 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) */
  36675. get useVertexColors(): boolean;
  36676. set useVertexColors(value: boolean);
  36677. /**
  36678. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36679. */
  36680. get computeBonesUsingShaders(): boolean;
  36681. set computeBonesUsingShaders(value: boolean);
  36682. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36683. get numBoneInfluencers(): number;
  36684. set numBoneInfluencers(value: number);
  36685. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36686. get applyFog(): boolean;
  36687. set applyFog(value: boolean);
  36688. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36689. useOctreeForRenderingSelection: boolean;
  36690. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36691. useOctreeForPicking: boolean;
  36692. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36693. useOctreeForCollisions: boolean;
  36694. /**
  36695. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36696. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36697. */
  36698. get layerMask(): number;
  36699. set layerMask(value: number);
  36700. /**
  36701. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36702. */
  36703. alwaysSelectAsActiveMesh: boolean;
  36704. /**
  36705. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36706. */
  36707. doNotSyncBoundingInfo: boolean;
  36708. /**
  36709. * Gets or sets the current action manager
  36710. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36711. */
  36712. actionManager: Nullable<AbstractActionManager>;
  36713. private _meshCollisionData;
  36714. /**
  36715. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36716. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36717. */
  36718. ellipsoid: Vector3;
  36719. /**
  36720. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36721. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36722. */
  36723. ellipsoidOffset: Vector3;
  36724. /**
  36725. * Gets or sets a collision mask used to mask collisions (default is -1).
  36726. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36727. */
  36728. get collisionMask(): number;
  36729. set collisionMask(mask: number);
  36730. /**
  36731. * Gets or sets a collision response flag (default is true).
  36732. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36733. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36734. * to respond to the collision.
  36735. */
  36736. get collisionResponse(): boolean;
  36737. set collisionResponse(response: boolean);
  36738. /**
  36739. * Gets or sets the current collision group mask (-1 by default).
  36740. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36741. */
  36742. get collisionGroup(): number;
  36743. set collisionGroup(mask: number);
  36744. /**
  36745. * Gets or sets current surrounding meshes (null by default).
  36746. *
  36747. * By default collision detection is tested against every mesh in the scene.
  36748. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36749. * meshes will be tested for the collision.
  36750. *
  36751. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36752. */
  36753. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36754. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36755. /**
  36756. * Defines edge width used when edgesRenderer is enabled
  36757. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36758. */
  36759. edgesWidth: number;
  36760. /**
  36761. * Defines edge color used when edgesRenderer is enabled
  36762. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36763. */
  36764. edgesColor: Color4;
  36765. /** @hidden */
  36766. _edgesRenderer: Nullable<IEdgesRenderer>;
  36767. /** @hidden */
  36768. _masterMesh: Nullable<AbstractMesh>;
  36769. /** @hidden */
  36770. _boundingInfo: Nullable<BoundingInfo>;
  36771. /** @hidden */
  36772. _renderId: number;
  36773. /**
  36774. * Gets or sets the list of subMeshes
  36775. * @see https://doc.babylonjs.com/how_to/multi_materials
  36776. */
  36777. subMeshes: SubMesh[];
  36778. /** @hidden */
  36779. _intersectionsInProgress: AbstractMesh[];
  36780. /** @hidden */
  36781. _unIndexed: boolean;
  36782. /** @hidden */
  36783. _lightSources: Light[];
  36784. /** Gets the list of lights affecting that mesh */
  36785. get lightSources(): Light[];
  36786. /** @hidden */
  36787. get _positions(): Nullable<Vector3[]>;
  36788. /** @hidden */
  36789. _waitingData: {
  36790. lods: Nullable<any>;
  36791. actions: Nullable<any>;
  36792. freezeWorldMatrix: Nullable<boolean>;
  36793. };
  36794. /** @hidden */
  36795. _bonesTransformMatrices: Nullable<Float32Array>;
  36796. /** @hidden */
  36797. _transformMatrixTexture: Nullable<RawTexture>;
  36798. /**
  36799. * Gets or sets a skeleton to apply skining transformations
  36800. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36801. */
  36802. set skeleton(value: Nullable<Skeleton>);
  36803. get skeleton(): Nullable<Skeleton>;
  36804. /**
  36805. * An event triggered when the mesh is rebuilt.
  36806. */
  36807. onRebuildObservable: Observable<AbstractMesh>;
  36808. /**
  36809. * Creates a new AbstractMesh
  36810. * @param name defines the name of the mesh
  36811. * @param scene defines the hosting scene
  36812. */
  36813. constructor(name: string, scene?: Nullable<Scene>);
  36814. /**
  36815. * Returns the string "AbstractMesh"
  36816. * @returns "AbstractMesh"
  36817. */
  36818. getClassName(): string;
  36819. /**
  36820. * Gets a string representation of the current mesh
  36821. * @param fullDetails defines a boolean indicating if full details must be included
  36822. * @returns a string representation of the current mesh
  36823. */
  36824. toString(fullDetails?: boolean): string;
  36825. /**
  36826. * @hidden
  36827. */
  36828. protected _getEffectiveParent(): Nullable<Node>;
  36829. /** @hidden */
  36830. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36831. /** @hidden */
  36832. _rebuild(): void;
  36833. /** @hidden */
  36834. _resyncLightSources(): void;
  36835. /** @hidden */
  36836. _resyncLightSource(light: Light): void;
  36837. /** @hidden */
  36838. _unBindEffect(): void;
  36839. /** @hidden */
  36840. _removeLightSource(light: Light, dispose: boolean): void;
  36841. private _markSubMeshesAsDirty;
  36842. /** @hidden */
  36843. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36844. /** @hidden */
  36845. _markSubMeshesAsAttributesDirty(): void;
  36846. /** @hidden */
  36847. _markSubMeshesAsMiscDirty(): void;
  36848. /**
  36849. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36850. */
  36851. get scaling(): Vector3;
  36852. set scaling(newScaling: Vector3);
  36853. /**
  36854. * Returns true if the mesh is blocked. Implemented by child classes
  36855. */
  36856. get isBlocked(): boolean;
  36857. /**
  36858. * Returns the mesh itself by default. Implemented by child classes
  36859. * @param camera defines the camera to use to pick the right LOD level
  36860. * @returns the currentAbstractMesh
  36861. */
  36862. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36863. /**
  36864. * Returns 0 by default. Implemented by child classes
  36865. * @returns an integer
  36866. */
  36867. getTotalVertices(): number;
  36868. /**
  36869. * Returns a positive integer : the total number of indices in this mesh geometry.
  36870. * @returns the numner of indices or zero if the mesh has no geometry.
  36871. */
  36872. getTotalIndices(): number;
  36873. /**
  36874. * Returns null by default. Implemented by child classes
  36875. * @returns null
  36876. */
  36877. getIndices(): Nullable<IndicesArray>;
  36878. /**
  36879. * Returns the array of the requested vertex data kind. Implemented by child classes
  36880. * @param kind defines the vertex data kind to use
  36881. * @returns null
  36882. */
  36883. getVerticesData(kind: string): Nullable<FloatArray>;
  36884. /**
  36885. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36886. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36887. * Note that a new underlying VertexBuffer object is created each call.
  36888. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36889. * @param kind defines vertex data kind:
  36890. * * VertexBuffer.PositionKind
  36891. * * VertexBuffer.UVKind
  36892. * * VertexBuffer.UV2Kind
  36893. * * VertexBuffer.UV3Kind
  36894. * * VertexBuffer.UV4Kind
  36895. * * VertexBuffer.UV5Kind
  36896. * * VertexBuffer.UV6Kind
  36897. * * VertexBuffer.ColorKind
  36898. * * VertexBuffer.MatricesIndicesKind
  36899. * * VertexBuffer.MatricesIndicesExtraKind
  36900. * * VertexBuffer.MatricesWeightsKind
  36901. * * VertexBuffer.MatricesWeightsExtraKind
  36902. * @param data defines the data source
  36903. * @param updatable defines if the data must be flagged as updatable (or static)
  36904. * @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
  36905. * @returns the current mesh
  36906. */
  36907. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36908. /**
  36909. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36910. * If the mesh has no geometry, it is simply returned as it is.
  36911. * @param kind defines vertex data kind:
  36912. * * VertexBuffer.PositionKind
  36913. * * VertexBuffer.UVKind
  36914. * * VertexBuffer.UV2Kind
  36915. * * VertexBuffer.UV3Kind
  36916. * * VertexBuffer.UV4Kind
  36917. * * VertexBuffer.UV5Kind
  36918. * * VertexBuffer.UV6Kind
  36919. * * VertexBuffer.ColorKind
  36920. * * VertexBuffer.MatricesIndicesKind
  36921. * * VertexBuffer.MatricesIndicesExtraKind
  36922. * * VertexBuffer.MatricesWeightsKind
  36923. * * VertexBuffer.MatricesWeightsExtraKind
  36924. * @param data defines the data source
  36925. * @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
  36926. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36927. * @returns the current mesh
  36928. */
  36929. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36930. /**
  36931. * Sets the mesh indices,
  36932. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36933. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36934. * @param totalVertices Defines the total number of vertices
  36935. * @returns the current mesh
  36936. */
  36937. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36938. /**
  36939. * Gets a boolean indicating if specific vertex data is present
  36940. * @param kind defines the vertex data kind to use
  36941. * @returns true is data kind is present
  36942. */
  36943. isVerticesDataPresent(kind: string): boolean;
  36944. /**
  36945. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36946. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36947. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36948. * @returns a BoundingInfo
  36949. */
  36950. getBoundingInfo(): BoundingInfo;
  36951. /**
  36952. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36953. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36954. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36955. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36956. * @returns the current mesh
  36957. */
  36958. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36959. /**
  36960. * Overwrite the current bounding info
  36961. * @param boundingInfo defines the new bounding info
  36962. * @returns the current mesh
  36963. */
  36964. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36965. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36966. get useBones(): boolean;
  36967. /** @hidden */
  36968. _preActivate(): void;
  36969. /** @hidden */
  36970. _preActivateForIntermediateRendering(renderId: number): void;
  36971. /** @hidden */
  36972. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36973. /** @hidden */
  36974. _postActivate(): void;
  36975. /** @hidden */
  36976. _freeze(): void;
  36977. /** @hidden */
  36978. _unFreeze(): void;
  36979. /**
  36980. * Gets the current world matrix
  36981. * @returns a Matrix
  36982. */
  36983. getWorldMatrix(): Matrix;
  36984. /** @hidden */
  36985. _getWorldMatrixDeterminant(): number;
  36986. /**
  36987. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36988. */
  36989. get isAnInstance(): boolean;
  36990. /**
  36991. * Gets a boolean indicating if this mesh has instances
  36992. */
  36993. get hasInstances(): boolean;
  36994. /**
  36995. * Gets a boolean indicating if this mesh has thin instances
  36996. */
  36997. get hasThinInstances(): boolean;
  36998. /**
  36999. * Perform relative position change from the point of view of behind the front of the mesh.
  37000. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37001. * Supports definition of mesh facing forward or backward
  37002. * @param amountRight defines the distance on the right axis
  37003. * @param amountUp defines the distance on the up axis
  37004. * @param amountForward defines the distance on the forward axis
  37005. * @returns the current mesh
  37006. */
  37007. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37008. /**
  37009. * Calculate relative position change from the point of view of behind the front of the mesh.
  37010. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37011. * Supports definition of mesh facing forward or backward
  37012. * @param amountRight defines the distance on the right axis
  37013. * @param amountUp defines the distance on the up axis
  37014. * @param amountForward defines the distance on the forward axis
  37015. * @returns the new displacement vector
  37016. */
  37017. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37018. /**
  37019. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37020. * Supports definition of mesh facing forward or backward
  37021. * @param flipBack defines the flip
  37022. * @param twirlClockwise defines the twirl
  37023. * @param tiltRight defines the tilt
  37024. * @returns the current mesh
  37025. */
  37026. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37027. /**
  37028. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37029. * Supports definition of mesh facing forward or backward.
  37030. * @param flipBack defines the flip
  37031. * @param twirlClockwise defines the twirl
  37032. * @param tiltRight defines the tilt
  37033. * @returns the new rotation vector
  37034. */
  37035. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37036. /**
  37037. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37038. * This means the mesh underlying bounding box and sphere are recomputed.
  37039. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37040. * @returns the current mesh
  37041. */
  37042. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37043. /** @hidden */
  37044. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37045. /** @hidden */
  37046. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37047. /** @hidden */
  37048. _updateBoundingInfo(): AbstractMesh;
  37049. /** @hidden */
  37050. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37051. /** @hidden */
  37052. protected _afterComputeWorldMatrix(): void;
  37053. /** @hidden */
  37054. get _effectiveMesh(): AbstractMesh;
  37055. /**
  37056. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37057. * A mesh is in the frustum if its bounding box intersects the frustum
  37058. * @param frustumPlanes defines the frustum to test
  37059. * @returns true if the mesh is in the frustum planes
  37060. */
  37061. isInFrustum(frustumPlanes: Plane[]): boolean;
  37062. /**
  37063. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37064. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37065. * @param frustumPlanes defines the frustum to test
  37066. * @returns true if the mesh is completely in the frustum planes
  37067. */
  37068. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37069. /**
  37070. * True if the mesh intersects another mesh or a SolidParticle object
  37071. * @param mesh defines a target mesh or SolidParticle to test
  37072. * @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)
  37073. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37074. * @returns true if there is an intersection
  37075. */
  37076. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37077. /**
  37078. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37079. * @param point defines the point to test
  37080. * @returns true if there is an intersection
  37081. */
  37082. intersectsPoint(point: Vector3): boolean;
  37083. /**
  37084. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37085. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37086. */
  37087. get checkCollisions(): boolean;
  37088. set checkCollisions(collisionEnabled: boolean);
  37089. /**
  37090. * Gets Collider object used to compute collisions (not physics)
  37091. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37092. */
  37093. get collider(): Nullable<Collider>;
  37094. /**
  37095. * Move the mesh using collision engine
  37096. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37097. * @param displacement defines the requested displacement vector
  37098. * @returns the current mesh
  37099. */
  37100. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37101. private _onCollisionPositionChange;
  37102. /** @hidden */
  37103. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37104. /** @hidden */
  37105. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37106. /** @hidden */
  37107. _checkCollision(collider: Collider): AbstractMesh;
  37108. /** @hidden */
  37109. _generatePointsArray(): boolean;
  37110. /**
  37111. * Checks if the passed Ray intersects with the mesh
  37112. * @param ray defines the ray to use
  37113. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37114. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37115. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37116. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37117. * @returns the picking info
  37118. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37119. */
  37120. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  37121. /**
  37122. * Clones the current mesh
  37123. * @param name defines the mesh name
  37124. * @param newParent defines the new mesh parent
  37125. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37126. * @returns the new mesh
  37127. */
  37128. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37129. /**
  37130. * Disposes all the submeshes of the current meshnp
  37131. * @returns the current mesh
  37132. */
  37133. releaseSubMeshes(): AbstractMesh;
  37134. /**
  37135. * Releases resources associated with this abstract mesh.
  37136. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37137. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37138. */
  37139. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37140. /**
  37141. * Adds the passed mesh as a child to the current mesh
  37142. * @param mesh defines the child mesh
  37143. * @returns the current mesh
  37144. */
  37145. addChild(mesh: AbstractMesh): AbstractMesh;
  37146. /**
  37147. * Removes the passed mesh from the current mesh children list
  37148. * @param mesh defines the child mesh
  37149. * @returns the current mesh
  37150. */
  37151. removeChild(mesh: AbstractMesh): AbstractMesh;
  37152. /** @hidden */
  37153. private _initFacetData;
  37154. /**
  37155. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37156. * This method can be called within the render loop.
  37157. * 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
  37158. * @returns the current mesh
  37159. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37160. */
  37161. updateFacetData(): AbstractMesh;
  37162. /**
  37163. * Returns the facetLocalNormals array.
  37164. * The normals are expressed in the mesh local spac
  37165. * @returns an array of Vector3
  37166. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37167. */
  37168. getFacetLocalNormals(): Vector3[];
  37169. /**
  37170. * Returns the facetLocalPositions array.
  37171. * The facet positions are expressed in the mesh local space
  37172. * @returns an array of Vector3
  37173. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37174. */
  37175. getFacetLocalPositions(): Vector3[];
  37176. /**
  37177. * Returns the facetLocalPartioning array
  37178. * @returns an array of array of numbers
  37179. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37180. */
  37181. getFacetLocalPartitioning(): number[][];
  37182. /**
  37183. * Returns the i-th facet position in the world system.
  37184. * This method allocates a new Vector3 per call
  37185. * @param i defines the facet index
  37186. * @returns a new Vector3
  37187. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37188. */
  37189. getFacetPosition(i: number): Vector3;
  37190. /**
  37191. * Sets the reference Vector3 with the i-th facet position in the world system
  37192. * @param i defines the facet index
  37193. * @param ref defines the target vector
  37194. * @returns the current mesh
  37195. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37196. */
  37197. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37198. /**
  37199. * Returns the i-th facet normal in the world system.
  37200. * This method allocates a new Vector3 per call
  37201. * @param i defines the facet index
  37202. * @returns a new Vector3
  37203. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37204. */
  37205. getFacetNormal(i: number): Vector3;
  37206. /**
  37207. * Sets the reference Vector3 with the i-th facet normal in the world system
  37208. * @param i defines the facet index
  37209. * @param ref defines the target vector
  37210. * @returns the current mesh
  37211. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37212. */
  37213. getFacetNormalToRef(i: number, ref: Vector3): this;
  37214. /**
  37215. * 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)
  37216. * @param x defines x coordinate
  37217. * @param y defines y coordinate
  37218. * @param z defines z coordinate
  37219. * @returns the array of facet indexes
  37220. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37221. */
  37222. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37223. /**
  37224. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37225. * @param projected sets as the (x,y,z) world projection on the facet
  37226. * @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
  37227. * @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
  37228. * @param x defines x coordinate
  37229. * @param y defines y coordinate
  37230. * @param z defines z coordinate
  37231. * @returns the face index if found (or null instead)
  37232. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37233. */
  37234. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37235. /**
  37236. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37237. * @param projected sets as the (x,y,z) local projection on the facet
  37238. * @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
  37239. * @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
  37240. * @param x defines x coordinate
  37241. * @param y defines y coordinate
  37242. * @param z defines z coordinate
  37243. * @returns the face index if found (or null instead)
  37244. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37245. */
  37246. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37247. /**
  37248. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37249. * @returns the parameters
  37250. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37251. */
  37252. getFacetDataParameters(): any;
  37253. /**
  37254. * Disables the feature FacetData and frees the related memory
  37255. * @returns the current mesh
  37256. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37257. */
  37258. disableFacetData(): AbstractMesh;
  37259. /**
  37260. * Updates the AbstractMesh indices array
  37261. * @param indices defines the data source
  37262. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37263. * @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)
  37264. * @returns the current mesh
  37265. */
  37266. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37267. /**
  37268. * Creates new normals data for the mesh
  37269. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37270. * @returns the current mesh
  37271. */
  37272. createNormals(updatable: boolean): AbstractMesh;
  37273. /**
  37274. * Align the mesh with a normal
  37275. * @param normal defines the normal to use
  37276. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37277. * @returns the current mesh
  37278. */
  37279. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37280. /** @hidden */
  37281. _checkOcclusionQuery(): boolean;
  37282. /**
  37283. * Disables the mesh edge rendering mode
  37284. * @returns the currentAbstractMesh
  37285. */
  37286. disableEdgesRendering(): AbstractMesh;
  37287. /**
  37288. * Enables the edge rendering mode on the mesh.
  37289. * This mode makes the mesh edges visible
  37290. * @param epsilon defines the maximal distance between two angles to detect a face
  37291. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37292. * @returns the currentAbstractMesh
  37293. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37294. */
  37295. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37296. /**
  37297. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37298. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37299. */
  37300. getConnectedParticleSystems(): IParticleSystem[];
  37301. }
  37302. }
  37303. declare module "babylonjs/Actions/actionEvent" {
  37304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37305. import { Nullable } from "babylonjs/types";
  37306. import { Sprite } from "babylonjs/Sprites/sprite";
  37307. import { Scene } from "babylonjs/scene";
  37308. import { Vector2 } from "babylonjs/Maths/math.vector";
  37309. /**
  37310. * Interface used to define ActionEvent
  37311. */
  37312. export interface IActionEvent {
  37313. /** The mesh or sprite that triggered the action */
  37314. source: any;
  37315. /** The X mouse cursor position at the time of the event */
  37316. pointerX: number;
  37317. /** The Y mouse cursor position at the time of the event */
  37318. pointerY: number;
  37319. /** The mesh that is currently pointed at (can be null) */
  37320. meshUnderPointer: Nullable<AbstractMesh>;
  37321. /** the original (browser) event that triggered the ActionEvent */
  37322. sourceEvent?: any;
  37323. /** additional data for the event */
  37324. additionalData?: any;
  37325. }
  37326. /**
  37327. * ActionEvent is the event being sent when an action is triggered.
  37328. */
  37329. export class ActionEvent implements IActionEvent {
  37330. /** The mesh or sprite that triggered the action */
  37331. source: any;
  37332. /** The X mouse cursor position at the time of the event */
  37333. pointerX: number;
  37334. /** The Y mouse cursor position at the time of the event */
  37335. pointerY: number;
  37336. /** The mesh that is currently pointed at (can be null) */
  37337. meshUnderPointer: Nullable<AbstractMesh>;
  37338. /** the original (browser) event that triggered the ActionEvent */
  37339. sourceEvent?: any;
  37340. /** additional data for the event */
  37341. additionalData?: any;
  37342. /**
  37343. * Creates a new ActionEvent
  37344. * @param source The mesh or sprite that triggered the action
  37345. * @param pointerX The X mouse cursor position at the time of the event
  37346. * @param pointerY The Y mouse cursor position at the time of the event
  37347. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37348. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37349. * @param additionalData additional data for the event
  37350. */
  37351. constructor(
  37352. /** The mesh or sprite that triggered the action */
  37353. source: any,
  37354. /** The X mouse cursor position at the time of the event */
  37355. pointerX: number,
  37356. /** The Y mouse cursor position at the time of the event */
  37357. pointerY: number,
  37358. /** The mesh that is currently pointed at (can be null) */
  37359. meshUnderPointer: Nullable<AbstractMesh>,
  37360. /** the original (browser) event that triggered the ActionEvent */
  37361. sourceEvent?: any,
  37362. /** additional data for the event */
  37363. additionalData?: any);
  37364. /**
  37365. * Helper function to auto-create an ActionEvent from a source mesh.
  37366. * @param source The source mesh that triggered the event
  37367. * @param evt The original (browser) event
  37368. * @param additionalData additional data for the event
  37369. * @returns the new ActionEvent
  37370. */
  37371. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37372. /**
  37373. * Helper function to auto-create an ActionEvent from a source sprite
  37374. * @param source The source sprite that triggered the event
  37375. * @param scene Scene associated with the sprite
  37376. * @param evt The original (browser) event
  37377. * @param additionalData additional data for the event
  37378. * @returns the new ActionEvent
  37379. */
  37380. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37381. /**
  37382. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37383. * @param scene the scene where the event occurred
  37384. * @param evt The original (browser) event
  37385. * @returns the new ActionEvent
  37386. */
  37387. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37388. /**
  37389. * Helper function to auto-create an ActionEvent from a primitive
  37390. * @param prim defines the target primitive
  37391. * @param pointerPos defines the pointer position
  37392. * @param evt The original (browser) event
  37393. * @param additionalData additional data for the event
  37394. * @returns the new ActionEvent
  37395. */
  37396. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37397. }
  37398. }
  37399. declare module "babylonjs/Actions/abstractActionManager" {
  37400. import { IDisposable } from "babylonjs/scene";
  37401. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37402. import { IAction } from "babylonjs/Actions/action";
  37403. import { Nullable } from "babylonjs/types";
  37404. /**
  37405. * Abstract class used to decouple action Manager from scene and meshes.
  37406. * Do not instantiate.
  37407. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37408. */
  37409. export abstract class AbstractActionManager implements IDisposable {
  37410. /** Gets the list of active triggers */
  37411. static Triggers: {
  37412. [key: string]: number;
  37413. };
  37414. /** Gets the cursor to use when hovering items */
  37415. hoverCursor: string;
  37416. /** Gets the list of actions */
  37417. actions: IAction[];
  37418. /**
  37419. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37420. */
  37421. isRecursive: boolean;
  37422. /**
  37423. * Releases all associated resources
  37424. */
  37425. abstract dispose(): void;
  37426. /**
  37427. * Does this action manager has pointer triggers
  37428. */
  37429. abstract get hasPointerTriggers(): boolean;
  37430. /**
  37431. * Does this action manager has pick triggers
  37432. */
  37433. abstract get hasPickTriggers(): boolean;
  37434. /**
  37435. * Process a specific trigger
  37436. * @param trigger defines the trigger to process
  37437. * @param evt defines the event details to be processed
  37438. */
  37439. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37440. /**
  37441. * Does this action manager handles actions of any of the given triggers
  37442. * @param triggers defines the triggers to be tested
  37443. * @return a boolean indicating whether one (or more) of the triggers is handled
  37444. */
  37445. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37446. /**
  37447. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37448. * speed.
  37449. * @param triggerA defines the trigger to be tested
  37450. * @param triggerB defines the trigger to be tested
  37451. * @return a boolean indicating whether one (or more) of the triggers is handled
  37452. */
  37453. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37454. /**
  37455. * Does this action manager handles actions of a given trigger
  37456. * @param trigger defines the trigger to be tested
  37457. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37458. * @return whether the trigger is handled
  37459. */
  37460. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37461. /**
  37462. * Serialize this manager to a JSON object
  37463. * @param name defines the property name to store this manager
  37464. * @returns a JSON representation of this manager
  37465. */
  37466. abstract serialize(name: string): any;
  37467. /**
  37468. * Registers an action to this action manager
  37469. * @param action defines the action to be registered
  37470. * @return the action amended (prepared) after registration
  37471. */
  37472. abstract registerAction(action: IAction): Nullable<IAction>;
  37473. /**
  37474. * Unregisters an action to this action manager
  37475. * @param action defines the action to be unregistered
  37476. * @return a boolean indicating whether the action has been unregistered
  37477. */
  37478. abstract unregisterAction(action: IAction): Boolean;
  37479. /**
  37480. * Does exist one action manager with at least one trigger
  37481. **/
  37482. static get HasTriggers(): boolean;
  37483. /**
  37484. * Does exist one action manager with at least one pick trigger
  37485. **/
  37486. static get HasPickTriggers(): boolean;
  37487. /**
  37488. * Does exist one action manager that handles actions of a given trigger
  37489. * @param trigger defines the trigger to be tested
  37490. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37491. **/
  37492. static HasSpecificTrigger(trigger: number): boolean;
  37493. }
  37494. }
  37495. declare module "babylonjs/node" {
  37496. import { Scene } from "babylonjs/scene";
  37497. import { Nullable } from "babylonjs/types";
  37498. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37499. import { Engine } from "babylonjs/Engines/engine";
  37500. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37501. import { Observable } from "babylonjs/Misc/observable";
  37502. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37503. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37504. import { Animatable } from "babylonjs/Animations/animatable";
  37505. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37506. import { Animation } from "babylonjs/Animations/animation";
  37507. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37509. /**
  37510. * Defines how a node can be built from a string name.
  37511. */
  37512. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37513. /**
  37514. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37515. */
  37516. export class Node implements IBehaviorAware<Node> {
  37517. /** @hidden */
  37518. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37519. private static _NodeConstructors;
  37520. /**
  37521. * Add a new node constructor
  37522. * @param type defines the type name of the node to construct
  37523. * @param constructorFunc defines the constructor function
  37524. */
  37525. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37526. /**
  37527. * Returns a node constructor based on type name
  37528. * @param type defines the type name
  37529. * @param name defines the new node name
  37530. * @param scene defines the hosting scene
  37531. * @param options defines optional options to transmit to constructors
  37532. * @returns the new constructor or null
  37533. */
  37534. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37535. /**
  37536. * Gets or sets the name of the node
  37537. */
  37538. name: string;
  37539. /**
  37540. * Gets or sets the id of the node
  37541. */
  37542. id: string;
  37543. /**
  37544. * Gets or sets the unique id of the node
  37545. */
  37546. uniqueId: number;
  37547. /**
  37548. * Gets or sets a string used to store user defined state for the node
  37549. */
  37550. state: string;
  37551. /**
  37552. * Gets or sets an object used to store user defined information for the node
  37553. */
  37554. metadata: any;
  37555. /**
  37556. * For internal use only. Please do not use.
  37557. */
  37558. reservedDataStore: any;
  37559. /**
  37560. * List of inspectable custom properties (used by the Inspector)
  37561. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37562. */
  37563. inspectableCustomProperties: IInspectable[];
  37564. private _doNotSerialize;
  37565. /**
  37566. * Gets or sets a boolean used to define if the node must be serialized
  37567. */
  37568. get doNotSerialize(): boolean;
  37569. set doNotSerialize(value: boolean);
  37570. /** @hidden */
  37571. _isDisposed: boolean;
  37572. /**
  37573. * Gets a list of Animations associated with the node
  37574. */
  37575. animations: import("babylonjs/Animations/animation").Animation[];
  37576. protected _ranges: {
  37577. [name: string]: Nullable<AnimationRange>;
  37578. };
  37579. /**
  37580. * Callback raised when the node is ready to be used
  37581. */
  37582. onReady: Nullable<(node: Node) => void>;
  37583. private _isEnabled;
  37584. private _isParentEnabled;
  37585. private _isReady;
  37586. /** @hidden */
  37587. _currentRenderId: number;
  37588. private _parentUpdateId;
  37589. /** @hidden */
  37590. _childUpdateId: number;
  37591. /** @hidden */
  37592. _waitingParentId: Nullable<string>;
  37593. /** @hidden */
  37594. _scene: Scene;
  37595. /** @hidden */
  37596. _cache: any;
  37597. private _parentNode;
  37598. private _children;
  37599. /** @hidden */
  37600. _worldMatrix: Matrix;
  37601. /** @hidden */
  37602. _worldMatrixDeterminant: number;
  37603. /** @hidden */
  37604. _worldMatrixDeterminantIsDirty: boolean;
  37605. /** @hidden */
  37606. private _sceneRootNodesIndex;
  37607. /**
  37608. * Gets a boolean indicating if the node has been disposed
  37609. * @returns true if the node was disposed
  37610. */
  37611. isDisposed(): boolean;
  37612. /**
  37613. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37614. * @see https://doc.babylonjs.com/how_to/parenting
  37615. */
  37616. set parent(parent: Nullable<Node>);
  37617. get parent(): Nullable<Node>;
  37618. /** @hidden */
  37619. _addToSceneRootNodes(): void;
  37620. /** @hidden */
  37621. _removeFromSceneRootNodes(): void;
  37622. private _animationPropertiesOverride;
  37623. /**
  37624. * Gets or sets the animation properties override
  37625. */
  37626. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37627. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37628. /**
  37629. * Gets a string identifying the name of the class
  37630. * @returns "Node" string
  37631. */
  37632. getClassName(): string;
  37633. /** @hidden */
  37634. readonly _isNode: boolean;
  37635. /**
  37636. * An event triggered when the mesh is disposed
  37637. */
  37638. onDisposeObservable: Observable<Node>;
  37639. private _onDisposeObserver;
  37640. /**
  37641. * Sets a callback that will be raised when the node will be disposed
  37642. */
  37643. set onDispose(callback: () => void);
  37644. /**
  37645. * Creates a new Node
  37646. * @param name the name and id to be given to this node
  37647. * @param scene the scene this node will be added to
  37648. */
  37649. constructor(name: string, scene?: Nullable<Scene>);
  37650. /**
  37651. * Gets the scene of the node
  37652. * @returns a scene
  37653. */
  37654. getScene(): Scene;
  37655. /**
  37656. * Gets the engine of the node
  37657. * @returns a Engine
  37658. */
  37659. getEngine(): Engine;
  37660. private _behaviors;
  37661. /**
  37662. * Attach a behavior to the node
  37663. * @see https://doc.babylonjs.com/features/behaviour
  37664. * @param behavior defines the behavior to attach
  37665. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37666. * @returns the current Node
  37667. */
  37668. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37669. /**
  37670. * Remove an attached behavior
  37671. * @see https://doc.babylonjs.com/features/behaviour
  37672. * @param behavior defines the behavior to attach
  37673. * @returns the current Node
  37674. */
  37675. removeBehavior(behavior: Behavior<Node>): Node;
  37676. /**
  37677. * Gets the list of attached behaviors
  37678. * @see https://doc.babylonjs.com/features/behaviour
  37679. */
  37680. get behaviors(): Behavior<Node>[];
  37681. /**
  37682. * Gets an attached behavior by name
  37683. * @param name defines the name of the behavior to look for
  37684. * @see https://doc.babylonjs.com/features/behaviour
  37685. * @returns null if behavior was not found else the requested behavior
  37686. */
  37687. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37688. /**
  37689. * Returns the latest update of the World matrix
  37690. * @returns a Matrix
  37691. */
  37692. getWorldMatrix(): Matrix;
  37693. /** @hidden */
  37694. _getWorldMatrixDeterminant(): number;
  37695. /**
  37696. * Returns directly the latest state of the mesh World matrix.
  37697. * A Matrix is returned.
  37698. */
  37699. get worldMatrixFromCache(): Matrix;
  37700. /** @hidden */
  37701. _initCache(): void;
  37702. /** @hidden */
  37703. updateCache(force?: boolean): void;
  37704. /** @hidden */
  37705. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37706. /** @hidden */
  37707. _updateCache(ignoreParentClass?: boolean): void;
  37708. /** @hidden */
  37709. _isSynchronized(): boolean;
  37710. /** @hidden */
  37711. _markSyncedWithParent(): void;
  37712. /** @hidden */
  37713. isSynchronizedWithParent(): boolean;
  37714. /** @hidden */
  37715. isSynchronized(): boolean;
  37716. /**
  37717. * Is this node ready to be used/rendered
  37718. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37719. * @return true if the node is ready
  37720. */
  37721. isReady(completeCheck?: boolean): boolean;
  37722. /**
  37723. * Is this node enabled?
  37724. * 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
  37725. * @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
  37726. * @return whether this node (and its parent) is enabled
  37727. */
  37728. isEnabled(checkAncestors?: boolean): boolean;
  37729. /** @hidden */
  37730. protected _syncParentEnabledState(): void;
  37731. /**
  37732. * Set the enabled state of this node
  37733. * @param value defines the new enabled state
  37734. */
  37735. setEnabled(value: boolean): void;
  37736. /**
  37737. * Is this node a descendant of the given node?
  37738. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37739. * @param ancestor defines the parent node to inspect
  37740. * @returns a boolean indicating if this node is a descendant of the given node
  37741. */
  37742. isDescendantOf(ancestor: Node): boolean;
  37743. /** @hidden */
  37744. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37745. /**
  37746. * Will return all nodes that have this node as ascendant
  37747. * @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
  37748. * @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
  37749. * @return all children nodes of all types
  37750. */
  37751. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37752. /**
  37753. * Get all child-meshes of this node
  37754. * @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)
  37755. * @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
  37756. * @returns an array of AbstractMesh
  37757. */
  37758. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37759. /**
  37760. * Get all direct children of this node
  37761. * @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
  37762. * @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)
  37763. * @returns an array of Node
  37764. */
  37765. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37766. /** @hidden */
  37767. _setReady(state: boolean): void;
  37768. /**
  37769. * Get an animation by name
  37770. * @param name defines the name of the animation to look for
  37771. * @returns null if not found else the requested animation
  37772. */
  37773. getAnimationByName(name: string): Nullable<Animation>;
  37774. /**
  37775. * Creates an animation range for this node
  37776. * @param name defines the name of the range
  37777. * @param from defines the starting key
  37778. * @param to defines the end key
  37779. */
  37780. createAnimationRange(name: string, from: number, to: number): void;
  37781. /**
  37782. * Delete a specific animation range
  37783. * @param name defines the name of the range to delete
  37784. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37785. */
  37786. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37787. /**
  37788. * Get an animation range by name
  37789. * @param name defines the name of the animation range to look for
  37790. * @returns null if not found else the requested animation range
  37791. */
  37792. getAnimationRange(name: string): Nullable<AnimationRange>;
  37793. /**
  37794. * Gets the list of all animation ranges defined on this node
  37795. * @returns an array
  37796. */
  37797. getAnimationRanges(): Nullable<AnimationRange>[];
  37798. /**
  37799. * Will start the animation sequence
  37800. * @param name defines the range frames for animation sequence
  37801. * @param loop defines if the animation should loop (false by default)
  37802. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37803. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37804. * @returns the object created for this animation. If range does not exist, it will return null
  37805. */
  37806. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37807. /**
  37808. * Serialize animation ranges into a JSON compatible object
  37809. * @returns serialization object
  37810. */
  37811. serializeAnimationRanges(): any;
  37812. /**
  37813. * Computes the world matrix of the node
  37814. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37815. * @returns the world matrix
  37816. */
  37817. computeWorldMatrix(force?: boolean): Matrix;
  37818. /**
  37819. * Releases resources associated with this node.
  37820. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37821. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37822. */
  37823. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37824. /**
  37825. * Parse animation range data from a serialization object and store them into a given node
  37826. * @param node defines where to store the animation ranges
  37827. * @param parsedNode defines the serialization object to read data from
  37828. * @param scene defines the hosting scene
  37829. */
  37830. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37831. /**
  37832. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37833. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37834. * @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
  37835. * @returns the new bounding vectors
  37836. */
  37837. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37838. min: Vector3;
  37839. max: Vector3;
  37840. };
  37841. }
  37842. }
  37843. declare module "babylonjs/Animations/animation" {
  37844. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37845. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37846. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37847. import { Nullable } from "babylonjs/types";
  37848. import { Scene } from "babylonjs/scene";
  37849. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37850. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37851. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37852. import { Node } from "babylonjs/node";
  37853. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37854. import { Size } from "babylonjs/Maths/math.size";
  37855. import { Animatable } from "babylonjs/Animations/animatable";
  37856. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37857. /**
  37858. * @hidden
  37859. */
  37860. export class _IAnimationState {
  37861. key: number;
  37862. repeatCount: number;
  37863. workValue?: any;
  37864. loopMode?: number;
  37865. offsetValue?: any;
  37866. highLimitValue?: any;
  37867. }
  37868. /**
  37869. * Class used to store any kind of animation
  37870. */
  37871. export class Animation {
  37872. /**Name of the animation */
  37873. name: string;
  37874. /**Property to animate */
  37875. targetProperty: string;
  37876. /**The frames per second of the animation */
  37877. framePerSecond: number;
  37878. /**The data type of the animation */
  37879. dataType: number;
  37880. /**The loop mode of the animation */
  37881. loopMode?: number | undefined;
  37882. /**Specifies if blending should be enabled */
  37883. enableBlending?: boolean | undefined;
  37884. /**
  37885. * Use matrix interpolation instead of using direct key value when animating matrices
  37886. */
  37887. static AllowMatricesInterpolation: boolean;
  37888. /**
  37889. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37890. */
  37891. static AllowMatrixDecomposeForInterpolation: boolean;
  37892. /** Define the Url to load snippets */
  37893. static SnippetUrl: string;
  37894. /** Snippet ID if the animation was created from the snippet server */
  37895. snippetId: string;
  37896. /**
  37897. * Stores the key frames of the animation
  37898. */
  37899. private _keys;
  37900. /**
  37901. * Stores the easing function of the animation
  37902. */
  37903. private _easingFunction;
  37904. /**
  37905. * @hidden Internal use only
  37906. */
  37907. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37908. /**
  37909. * The set of event that will be linked to this animation
  37910. */
  37911. private _events;
  37912. /**
  37913. * Stores an array of target property paths
  37914. */
  37915. targetPropertyPath: string[];
  37916. /**
  37917. * Stores the blending speed of the animation
  37918. */
  37919. blendingSpeed: number;
  37920. /**
  37921. * Stores the animation ranges for the animation
  37922. */
  37923. private _ranges;
  37924. /**
  37925. * @hidden Internal use
  37926. */
  37927. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37928. /**
  37929. * Sets up an animation
  37930. * @param property The property to animate
  37931. * @param animationType The animation type to apply
  37932. * @param framePerSecond The frames per second of the animation
  37933. * @param easingFunction The easing function used in the animation
  37934. * @returns The created animation
  37935. */
  37936. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37937. /**
  37938. * Create and start an animation on a node
  37939. * @param name defines the name of the global animation that will be run on all nodes
  37940. * @param node defines the root node where the animation will take place
  37941. * @param targetProperty defines property to animate
  37942. * @param framePerSecond defines the number of frame per second yo use
  37943. * @param totalFrame defines the number of frames in total
  37944. * @param from defines the initial value
  37945. * @param to defines the final value
  37946. * @param loopMode defines which loop mode you want to use (off by default)
  37947. * @param easingFunction defines the easing function to use (linear by default)
  37948. * @param onAnimationEnd defines the callback to call when animation end
  37949. * @returns the animatable created for this animation
  37950. */
  37951. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37952. /**
  37953. * Create and start an animation on a node and its descendants
  37954. * @param name defines the name of the global animation that will be run on all nodes
  37955. * @param node defines the root node where the animation will take place
  37956. * @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
  37957. * @param targetProperty defines property to animate
  37958. * @param framePerSecond defines the number of frame per second to use
  37959. * @param totalFrame defines the number of frames in total
  37960. * @param from defines the initial value
  37961. * @param to defines the final value
  37962. * @param loopMode defines which loop mode you want to use (off by default)
  37963. * @param easingFunction defines the easing function to use (linear by default)
  37964. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37965. * @returns the list of animatables created for all nodes
  37966. * @example https://www.babylonjs-playground.com/#MH0VLI
  37967. */
  37968. 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[]>;
  37969. /**
  37970. * Creates a new animation, merges it with the existing animations and starts it
  37971. * @param name Name of the animation
  37972. * @param node Node which contains the scene that begins the animations
  37973. * @param targetProperty Specifies which property to animate
  37974. * @param framePerSecond The frames per second of the animation
  37975. * @param totalFrame The total number of frames
  37976. * @param from The frame at the beginning of the animation
  37977. * @param to The frame at the end of the animation
  37978. * @param loopMode Specifies the loop mode of the animation
  37979. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37980. * @param onAnimationEnd Callback to run once the animation is complete
  37981. * @returns Nullable animation
  37982. */
  37983. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37984. /**
  37985. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37986. * @param sourceAnimation defines the Animation containing keyframes to convert
  37987. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37988. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37989. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37990. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37991. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37992. */
  37993. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37994. /**
  37995. * Transition property of an host to the target Value
  37996. * @param property The property to transition
  37997. * @param targetValue The target Value of the property
  37998. * @param host The object where the property to animate belongs
  37999. * @param scene Scene used to run the animation
  38000. * @param frameRate Framerate (in frame/s) to use
  38001. * @param transition The transition type we want to use
  38002. * @param duration The duration of the animation, in milliseconds
  38003. * @param onAnimationEnd Callback trigger at the end of the animation
  38004. * @returns Nullable animation
  38005. */
  38006. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38007. /**
  38008. * Return the array of runtime animations currently using this animation
  38009. */
  38010. get runtimeAnimations(): RuntimeAnimation[];
  38011. /**
  38012. * Specifies if any of the runtime animations are currently running
  38013. */
  38014. get hasRunningRuntimeAnimations(): boolean;
  38015. /**
  38016. * Initializes the animation
  38017. * @param name Name of the animation
  38018. * @param targetProperty Property to animate
  38019. * @param framePerSecond The frames per second of the animation
  38020. * @param dataType The data type of the animation
  38021. * @param loopMode The loop mode of the animation
  38022. * @param enableBlending Specifies if blending should be enabled
  38023. */
  38024. constructor(
  38025. /**Name of the animation */
  38026. name: string,
  38027. /**Property to animate */
  38028. targetProperty: string,
  38029. /**The frames per second of the animation */
  38030. framePerSecond: number,
  38031. /**The data type of the animation */
  38032. dataType: number,
  38033. /**The loop mode of the animation */
  38034. loopMode?: number | undefined,
  38035. /**Specifies if blending should be enabled */
  38036. enableBlending?: boolean | undefined);
  38037. /**
  38038. * Converts the animation to a string
  38039. * @param fullDetails support for multiple levels of logging within scene loading
  38040. * @returns String form of the animation
  38041. */
  38042. toString(fullDetails?: boolean): string;
  38043. /**
  38044. * Add an event to this animation
  38045. * @param event Event to add
  38046. */
  38047. addEvent(event: AnimationEvent): void;
  38048. /**
  38049. * Remove all events found at the given frame
  38050. * @param frame The frame to remove events from
  38051. */
  38052. removeEvents(frame: number): void;
  38053. /**
  38054. * Retrieves all the events from the animation
  38055. * @returns Events from the animation
  38056. */
  38057. getEvents(): AnimationEvent[];
  38058. /**
  38059. * Creates an animation range
  38060. * @param name Name of the animation range
  38061. * @param from Starting frame of the animation range
  38062. * @param to Ending frame of the animation
  38063. */
  38064. createRange(name: string, from: number, to: number): void;
  38065. /**
  38066. * Deletes an animation range by name
  38067. * @param name Name of the animation range to delete
  38068. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38069. */
  38070. deleteRange(name: string, deleteFrames?: boolean): void;
  38071. /**
  38072. * Gets the animation range by name, or null if not defined
  38073. * @param name Name of the animation range
  38074. * @returns Nullable animation range
  38075. */
  38076. getRange(name: string): Nullable<AnimationRange>;
  38077. /**
  38078. * Gets the key frames from the animation
  38079. * @returns The key frames of the animation
  38080. */
  38081. getKeys(): Array<IAnimationKey>;
  38082. /**
  38083. * Gets the highest frame rate of the animation
  38084. * @returns Highest frame rate of the animation
  38085. */
  38086. getHighestFrame(): number;
  38087. /**
  38088. * Gets the easing function of the animation
  38089. * @returns Easing function of the animation
  38090. */
  38091. getEasingFunction(): IEasingFunction;
  38092. /**
  38093. * Sets the easing function of the animation
  38094. * @param easingFunction A custom mathematical formula for animation
  38095. */
  38096. setEasingFunction(easingFunction: EasingFunction): void;
  38097. /**
  38098. * Interpolates a scalar linearly
  38099. * @param startValue Start value of the animation curve
  38100. * @param endValue End value of the animation curve
  38101. * @param gradient Scalar amount to interpolate
  38102. * @returns Interpolated scalar value
  38103. */
  38104. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38105. /**
  38106. * Interpolates a scalar cubically
  38107. * @param startValue Start value of the animation curve
  38108. * @param outTangent End tangent of the animation
  38109. * @param endValue End value of the animation curve
  38110. * @param inTangent Start tangent of the animation curve
  38111. * @param gradient Scalar amount to interpolate
  38112. * @returns Interpolated scalar value
  38113. */
  38114. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38115. /**
  38116. * Interpolates a quaternion using a spherical linear interpolation
  38117. * @param startValue Start value of the animation curve
  38118. * @param endValue End value of the animation curve
  38119. * @param gradient Scalar amount to interpolate
  38120. * @returns Interpolated quaternion value
  38121. */
  38122. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38123. /**
  38124. * Interpolates a quaternion cubically
  38125. * @param startValue Start value of the animation curve
  38126. * @param outTangent End tangent of the animation curve
  38127. * @param endValue End value of the animation curve
  38128. * @param inTangent Start tangent of the animation curve
  38129. * @param gradient Scalar amount to interpolate
  38130. * @returns Interpolated quaternion value
  38131. */
  38132. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38133. /**
  38134. * Interpolates a Vector3 linearl
  38135. * @param startValue Start value of the animation curve
  38136. * @param endValue End value of the animation curve
  38137. * @param gradient Scalar amount to interpolate
  38138. * @returns Interpolated scalar value
  38139. */
  38140. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38141. /**
  38142. * Interpolates a Vector3 cubically
  38143. * @param startValue Start value of the animation curve
  38144. * @param outTangent End tangent of the animation
  38145. * @param endValue End value of the animation curve
  38146. * @param inTangent Start tangent of the animation curve
  38147. * @param gradient Scalar amount to interpolate
  38148. * @returns InterpolatedVector3 value
  38149. */
  38150. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38151. /**
  38152. * Interpolates a Vector2 linearly
  38153. * @param startValue Start value of the animation curve
  38154. * @param endValue End value of the animation curve
  38155. * @param gradient Scalar amount to interpolate
  38156. * @returns Interpolated Vector2 value
  38157. */
  38158. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38159. /**
  38160. * Interpolates a Vector2 cubically
  38161. * @param startValue Start value of the animation curve
  38162. * @param outTangent End tangent of the animation
  38163. * @param endValue End value of the animation curve
  38164. * @param inTangent Start tangent of the animation curve
  38165. * @param gradient Scalar amount to interpolate
  38166. * @returns Interpolated Vector2 value
  38167. */
  38168. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38169. /**
  38170. * Interpolates a size linearly
  38171. * @param startValue Start value of the animation curve
  38172. * @param endValue End value of the animation curve
  38173. * @param gradient Scalar amount to interpolate
  38174. * @returns Interpolated Size value
  38175. */
  38176. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38177. /**
  38178. * Interpolates a Color3 linearly
  38179. * @param startValue Start value of the animation curve
  38180. * @param endValue End value of the animation curve
  38181. * @param gradient Scalar amount to interpolate
  38182. * @returns Interpolated Color3 value
  38183. */
  38184. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38185. /**
  38186. * Interpolates a Color4 linearly
  38187. * @param startValue Start value of the animation curve
  38188. * @param endValue End value of the animation curve
  38189. * @param gradient Scalar amount to interpolate
  38190. * @returns Interpolated Color3 value
  38191. */
  38192. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38193. /**
  38194. * @hidden Internal use only
  38195. */
  38196. _getKeyValue(value: any): any;
  38197. /**
  38198. * @hidden Internal use only
  38199. */
  38200. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38201. /**
  38202. * Defines the function to use to interpolate matrices
  38203. * @param startValue defines the start matrix
  38204. * @param endValue defines the end matrix
  38205. * @param gradient defines the gradient between both matrices
  38206. * @param result defines an optional target matrix where to store the interpolation
  38207. * @returns the interpolated matrix
  38208. */
  38209. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38210. /**
  38211. * Makes a copy of the animation
  38212. * @returns Cloned animation
  38213. */
  38214. clone(): Animation;
  38215. /**
  38216. * Sets the key frames of the animation
  38217. * @param values The animation key frames to set
  38218. */
  38219. setKeys(values: Array<IAnimationKey>): void;
  38220. /**
  38221. * Serializes the animation to an object
  38222. * @returns Serialized object
  38223. */
  38224. serialize(): any;
  38225. /**
  38226. * Float animation type
  38227. */
  38228. static readonly ANIMATIONTYPE_FLOAT: number;
  38229. /**
  38230. * Vector3 animation type
  38231. */
  38232. static readonly ANIMATIONTYPE_VECTOR3: number;
  38233. /**
  38234. * Quaternion animation type
  38235. */
  38236. static readonly ANIMATIONTYPE_QUATERNION: number;
  38237. /**
  38238. * Matrix animation type
  38239. */
  38240. static readonly ANIMATIONTYPE_MATRIX: number;
  38241. /**
  38242. * Color3 animation type
  38243. */
  38244. static readonly ANIMATIONTYPE_COLOR3: number;
  38245. /**
  38246. * Color3 animation type
  38247. */
  38248. static readonly ANIMATIONTYPE_COLOR4: number;
  38249. /**
  38250. * Vector2 animation type
  38251. */
  38252. static readonly ANIMATIONTYPE_VECTOR2: number;
  38253. /**
  38254. * Size animation type
  38255. */
  38256. static readonly ANIMATIONTYPE_SIZE: number;
  38257. /**
  38258. * Relative Loop Mode
  38259. */
  38260. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38261. /**
  38262. * Cycle Loop Mode
  38263. */
  38264. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38265. /**
  38266. * Constant Loop Mode
  38267. */
  38268. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38269. /** @hidden */
  38270. static _UniversalLerp(left: any, right: any, amount: number): any;
  38271. /**
  38272. * Parses an animation object and creates an animation
  38273. * @param parsedAnimation Parsed animation object
  38274. * @returns Animation object
  38275. */
  38276. static Parse(parsedAnimation: any): Animation;
  38277. /**
  38278. * Appends the serialized animations from the source animations
  38279. * @param source Source containing the animations
  38280. * @param destination Target to store the animations
  38281. */
  38282. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38283. /**
  38284. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38285. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38286. * @param url defines the url to load from
  38287. * @returns a promise that will resolve to the new animation or an array of animations
  38288. */
  38289. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38290. /**
  38291. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38292. * @param snippetId defines the snippet to load
  38293. * @returns a promise that will resolve to the new animation or a new array of animations
  38294. */
  38295. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38296. }
  38297. }
  38298. declare module "babylonjs/Animations/animatable.interface" {
  38299. import { Nullable } from "babylonjs/types";
  38300. import { Animation } from "babylonjs/Animations/animation";
  38301. /**
  38302. * Interface containing an array of animations
  38303. */
  38304. export interface IAnimatable {
  38305. /**
  38306. * Array of animations
  38307. */
  38308. animations: Nullable<Array<Animation>>;
  38309. }
  38310. }
  38311. declare module "babylonjs/Misc/decorators" {
  38312. import { Nullable } from "babylonjs/types";
  38313. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38314. import { Scene } from "babylonjs/scene";
  38315. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38316. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38317. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38318. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38319. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38320. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38321. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38322. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38323. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38324. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38325. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38326. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38327. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38328. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38329. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38330. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38331. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38332. /**
  38333. * Decorator used to define property that can be serialized as reference to a camera
  38334. * @param sourceName defines the name of the property to decorate
  38335. */
  38336. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38337. /**
  38338. * Class used to help serialization objects
  38339. */
  38340. export class SerializationHelper {
  38341. /** @hidden */
  38342. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38343. /** @hidden */
  38344. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38345. /** @hidden */
  38346. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38347. /** @hidden */
  38348. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38349. /**
  38350. * Appends the serialized animations from the source animations
  38351. * @param source Source containing the animations
  38352. * @param destination Target to store the animations
  38353. */
  38354. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38355. /**
  38356. * Static function used to serialized a specific entity
  38357. * @param entity defines the entity to serialize
  38358. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38359. * @returns a JSON compatible object representing the serialization of the entity
  38360. */
  38361. static Serialize<T>(entity: T, serializationObject?: any): any;
  38362. /**
  38363. * Creates a new entity from a serialization data object
  38364. * @param creationFunction defines a function used to instanciated the new entity
  38365. * @param source defines the source serialization data
  38366. * @param scene defines the hosting scene
  38367. * @param rootUrl defines the root url for resources
  38368. * @returns a new entity
  38369. */
  38370. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38371. /**
  38372. * Clones an object
  38373. * @param creationFunction defines the function used to instanciate the new object
  38374. * @param source defines the source object
  38375. * @returns the cloned object
  38376. */
  38377. static Clone<T>(creationFunction: () => T, source: T): T;
  38378. /**
  38379. * Instanciates a new object based on a source one (some data will be shared between both object)
  38380. * @param creationFunction defines the function used to instanciate the new object
  38381. * @param source defines the source object
  38382. * @returns the new object
  38383. */
  38384. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38385. }
  38386. }
  38387. declare module "babylonjs/Materials/Textures/baseTexture" {
  38388. import { Observable } from "babylonjs/Misc/observable";
  38389. import { Nullable } from "babylonjs/types";
  38390. import { Scene } from "babylonjs/scene";
  38391. import { Matrix } from "babylonjs/Maths/math.vector";
  38392. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38393. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38394. import { ISize } from "babylonjs/Maths/math.size";
  38395. import "babylonjs/Misc/fileTools";
  38396. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38397. /**
  38398. * Base class of all the textures in babylon.
  38399. * It groups all the common properties the materials, post process, lights... might need
  38400. * in order to make a correct use of the texture.
  38401. */
  38402. export class BaseTexture implements IAnimatable {
  38403. /**
  38404. * Default anisotropic filtering level for the application.
  38405. * It is set to 4 as a good tradeoff between perf and quality.
  38406. */
  38407. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38408. /**
  38409. * Gets or sets the unique id of the texture
  38410. */
  38411. uniqueId: number;
  38412. /**
  38413. * Define the name of the texture.
  38414. */
  38415. name: string;
  38416. /**
  38417. * Gets or sets an object used to store user defined information.
  38418. */
  38419. metadata: any;
  38420. /**
  38421. * For internal use only. Please do not use.
  38422. */
  38423. reservedDataStore: any;
  38424. private _hasAlpha;
  38425. /**
  38426. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38427. */
  38428. set hasAlpha(value: boolean);
  38429. get hasAlpha(): boolean;
  38430. /**
  38431. * Defines if the alpha value should be determined via the rgb values.
  38432. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38433. */
  38434. getAlphaFromRGB: boolean;
  38435. /**
  38436. * Intensity or strength of the texture.
  38437. * It is commonly used by materials to fine tune the intensity of the texture
  38438. */
  38439. level: number;
  38440. /**
  38441. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38442. * This is part of the texture as textures usually maps to one uv set.
  38443. */
  38444. coordinatesIndex: number;
  38445. protected _coordinatesMode: number;
  38446. /**
  38447. * How a texture is mapped.
  38448. *
  38449. * | Value | Type | Description |
  38450. * | ----- | ----------------------------------- | ----------- |
  38451. * | 0 | EXPLICIT_MODE | |
  38452. * | 1 | SPHERICAL_MODE | |
  38453. * | 2 | PLANAR_MODE | |
  38454. * | 3 | CUBIC_MODE | |
  38455. * | 4 | PROJECTION_MODE | |
  38456. * | 5 | SKYBOX_MODE | |
  38457. * | 6 | INVCUBIC_MODE | |
  38458. * | 7 | EQUIRECTANGULAR_MODE | |
  38459. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38460. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38461. */
  38462. set coordinatesMode(value: number);
  38463. get coordinatesMode(): number;
  38464. private _wrapU;
  38465. /**
  38466. * | Value | Type | Description |
  38467. * | ----- | ------------------ | ----------- |
  38468. * | 0 | CLAMP_ADDRESSMODE | |
  38469. * | 1 | WRAP_ADDRESSMODE | |
  38470. * | 2 | MIRROR_ADDRESSMODE | |
  38471. */
  38472. get wrapU(): number;
  38473. set wrapU(value: number);
  38474. private _wrapV;
  38475. /**
  38476. * | Value | Type | Description |
  38477. * | ----- | ------------------ | ----------- |
  38478. * | 0 | CLAMP_ADDRESSMODE | |
  38479. * | 1 | WRAP_ADDRESSMODE | |
  38480. * | 2 | MIRROR_ADDRESSMODE | |
  38481. */
  38482. get wrapV(): number;
  38483. set wrapV(value: number);
  38484. /**
  38485. * | Value | Type | Description |
  38486. * | ----- | ------------------ | ----------- |
  38487. * | 0 | CLAMP_ADDRESSMODE | |
  38488. * | 1 | WRAP_ADDRESSMODE | |
  38489. * | 2 | MIRROR_ADDRESSMODE | |
  38490. */
  38491. wrapR: number;
  38492. /**
  38493. * With compliant hardware and browser (supporting anisotropic filtering)
  38494. * this defines the level of anisotropic filtering in the texture.
  38495. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38496. */
  38497. anisotropicFilteringLevel: number;
  38498. /**
  38499. * Define if the texture is a cube texture or if false a 2d texture.
  38500. */
  38501. get isCube(): boolean;
  38502. set isCube(value: boolean);
  38503. /**
  38504. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38505. */
  38506. get is3D(): boolean;
  38507. set is3D(value: boolean);
  38508. /**
  38509. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38510. */
  38511. get is2DArray(): boolean;
  38512. set is2DArray(value: boolean);
  38513. private _gammaSpace;
  38514. /**
  38515. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38516. * HDR texture are usually stored in linear space.
  38517. * This only impacts the PBR and Background materials
  38518. */
  38519. get gammaSpace(): boolean;
  38520. set gammaSpace(gamma: boolean);
  38521. /**
  38522. * Gets or sets whether or not the texture contains RGBD data.
  38523. */
  38524. get isRGBD(): boolean;
  38525. set isRGBD(value: boolean);
  38526. /**
  38527. * Is Z inverted in the texture (useful in a cube texture).
  38528. */
  38529. invertZ: boolean;
  38530. /**
  38531. * Are mip maps generated for this texture or not.
  38532. */
  38533. get noMipmap(): boolean;
  38534. /**
  38535. * @hidden
  38536. */
  38537. lodLevelInAlpha: boolean;
  38538. /**
  38539. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38540. */
  38541. get lodGenerationOffset(): number;
  38542. set lodGenerationOffset(value: number);
  38543. /**
  38544. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38545. */
  38546. get lodGenerationScale(): number;
  38547. set lodGenerationScale(value: number);
  38548. /**
  38549. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38550. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38551. * average roughness values.
  38552. */
  38553. get linearSpecularLOD(): boolean;
  38554. set linearSpecularLOD(value: boolean);
  38555. /**
  38556. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38557. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38558. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38559. */
  38560. get irradianceTexture(): Nullable<BaseTexture>;
  38561. set irradianceTexture(value: Nullable<BaseTexture>);
  38562. /**
  38563. * Define if the texture is a render target.
  38564. */
  38565. isRenderTarget: boolean;
  38566. /**
  38567. * Define the unique id of the texture in the scene.
  38568. */
  38569. get uid(): string;
  38570. /** @hidden */
  38571. _prefiltered: boolean;
  38572. /**
  38573. * Return a string representation of the texture.
  38574. * @returns the texture as a string
  38575. */
  38576. toString(): string;
  38577. /**
  38578. * Get the class name of the texture.
  38579. * @returns "BaseTexture"
  38580. */
  38581. getClassName(): string;
  38582. /**
  38583. * Define the list of animation attached to the texture.
  38584. */
  38585. animations: import("babylonjs/Animations/animation").Animation[];
  38586. /**
  38587. * An event triggered when the texture is disposed.
  38588. */
  38589. onDisposeObservable: Observable<BaseTexture>;
  38590. private _onDisposeObserver;
  38591. /**
  38592. * Callback triggered when the texture has been disposed.
  38593. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38594. */
  38595. set onDispose(callback: () => void);
  38596. /**
  38597. * Define the current state of the loading sequence when in delayed load mode.
  38598. */
  38599. delayLoadState: number;
  38600. protected _scene: Nullable<Scene>;
  38601. protected _engine: Nullable<ThinEngine>;
  38602. /** @hidden */
  38603. _texture: Nullable<InternalTexture>;
  38604. private _uid;
  38605. /**
  38606. * Define if the texture is preventinga material to render or not.
  38607. * If not and the texture is not ready, the engine will use a default black texture instead.
  38608. */
  38609. get isBlocking(): boolean;
  38610. /**
  38611. * Instantiates a new BaseTexture.
  38612. * Base class of all the textures in babylon.
  38613. * It groups all the common properties the materials, post process, lights... might need
  38614. * in order to make a correct use of the texture.
  38615. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38616. */
  38617. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38618. /**
  38619. * Get the scene the texture belongs to.
  38620. * @returns the scene or null if undefined
  38621. */
  38622. getScene(): Nullable<Scene>;
  38623. /** @hidden */
  38624. protected _getEngine(): Nullable<ThinEngine>;
  38625. /**
  38626. * Checks if the texture has the same transform matrix than another texture
  38627. * @param texture texture to check against
  38628. * @returns true if the transforms are the same, else false
  38629. */
  38630. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  38631. /**
  38632. * Get the texture transform matrix used to offset tile the texture for istance.
  38633. * @returns the transformation matrix
  38634. */
  38635. getTextureMatrix(): Matrix;
  38636. /**
  38637. * Get the texture reflection matrix used to rotate/transform the reflection.
  38638. * @returns the reflection matrix
  38639. */
  38640. getReflectionTextureMatrix(): Matrix;
  38641. /**
  38642. * Get the underlying lower level texture from Babylon.
  38643. * @returns the insternal texture
  38644. */
  38645. getInternalTexture(): Nullable<InternalTexture>;
  38646. /**
  38647. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38648. * @returns true if ready or not blocking
  38649. */
  38650. isReadyOrNotBlocking(): boolean;
  38651. /**
  38652. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38653. * @returns true if fully ready
  38654. */
  38655. isReady(): boolean;
  38656. private _cachedSize;
  38657. /**
  38658. * Get the size of the texture.
  38659. * @returns the texture size.
  38660. */
  38661. getSize(): ISize;
  38662. /**
  38663. * Get the base size of the texture.
  38664. * It can be different from the size if the texture has been resized for POT for instance
  38665. * @returns the base size
  38666. */
  38667. getBaseSize(): ISize;
  38668. /**
  38669. * Update the sampling mode of the texture.
  38670. * Default is Trilinear mode.
  38671. *
  38672. * | Value | Type | Description |
  38673. * | ----- | ------------------ | ----------- |
  38674. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38675. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38676. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38677. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38678. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38679. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38680. * | 7 | NEAREST_LINEAR | |
  38681. * | 8 | NEAREST_NEAREST | |
  38682. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38683. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38684. * | 11 | LINEAR_LINEAR | |
  38685. * | 12 | LINEAR_NEAREST | |
  38686. *
  38687. * > _mag_: magnification filter (close to the viewer)
  38688. * > _min_: minification filter (far from the viewer)
  38689. * > _mip_: filter used between mip map levels
  38690. *@param samplingMode Define the new sampling mode of the texture
  38691. */
  38692. updateSamplingMode(samplingMode: number): void;
  38693. /**
  38694. * Scales the texture if is `canRescale()`
  38695. * @param ratio the resize factor we want to use to rescale
  38696. */
  38697. scale(ratio: number): void;
  38698. /**
  38699. * Get if the texture can rescale.
  38700. */
  38701. get canRescale(): boolean;
  38702. /** @hidden */
  38703. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  38704. /** @hidden */
  38705. _rebuild(): void;
  38706. /**
  38707. * Triggers the load sequence in delayed load mode.
  38708. */
  38709. delayLoad(): void;
  38710. /**
  38711. * Clones the texture.
  38712. * @returns the cloned texture
  38713. */
  38714. clone(): Nullable<BaseTexture>;
  38715. /**
  38716. * Get the texture underlying type (INT, FLOAT...)
  38717. */
  38718. get textureType(): number;
  38719. /**
  38720. * Get the texture underlying format (RGB, RGBA...)
  38721. */
  38722. get textureFormat(): number;
  38723. /**
  38724. * Indicates that textures need to be re-calculated for all materials
  38725. */
  38726. protected _markAllSubMeshesAsTexturesDirty(): void;
  38727. /**
  38728. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  38729. * This will returns an RGBA array buffer containing either in values (0-255) or
  38730. * float values (0-1) depending of the underlying buffer type.
  38731. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  38732. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  38733. * @param buffer defines a user defined buffer to fill with data (can be null)
  38734. * @returns The Array buffer containing the pixels data.
  38735. */
  38736. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  38737. /**
  38738. * Release and destroy the underlying lower level texture aka internalTexture.
  38739. */
  38740. releaseInternalTexture(): void;
  38741. /** @hidden */
  38742. get _lodTextureHigh(): Nullable<BaseTexture>;
  38743. /** @hidden */
  38744. get _lodTextureMid(): Nullable<BaseTexture>;
  38745. /** @hidden */
  38746. get _lodTextureLow(): Nullable<BaseTexture>;
  38747. /**
  38748. * Dispose the texture and release its associated resources.
  38749. */
  38750. dispose(): void;
  38751. /**
  38752. * Serialize the texture into a JSON representation that can be parsed later on.
  38753. * @returns the JSON representation of the texture
  38754. */
  38755. serialize(): any;
  38756. /**
  38757. * Helper function to be called back once a list of texture contains only ready textures.
  38758. * @param textures Define the list of textures to wait for
  38759. * @param callback Define the callback triggered once the entire list will be ready
  38760. */
  38761. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  38762. private static _isScene;
  38763. }
  38764. }
  38765. declare module "babylonjs/Materials/effect" {
  38766. import { Observable } from "babylonjs/Misc/observable";
  38767. import { Nullable } from "babylonjs/types";
  38768. import { IDisposable } from "babylonjs/scene";
  38769. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38770. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38771. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  38772. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38773. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  38774. import { Engine } from "babylonjs/Engines/engine";
  38775. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38778. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38779. /**
  38780. * Options to be used when creating an effect.
  38781. */
  38782. export interface IEffectCreationOptions {
  38783. /**
  38784. * Atrributes that will be used in the shader.
  38785. */
  38786. attributes: string[];
  38787. /**
  38788. * Uniform varible names that will be set in the shader.
  38789. */
  38790. uniformsNames: string[];
  38791. /**
  38792. * Uniform buffer variable names that will be set in the shader.
  38793. */
  38794. uniformBuffersNames: string[];
  38795. /**
  38796. * Sampler texture variable names that will be set in the shader.
  38797. */
  38798. samplers: string[];
  38799. /**
  38800. * Define statements that will be set in the shader.
  38801. */
  38802. defines: any;
  38803. /**
  38804. * Possible fallbacks for this effect to improve performance when needed.
  38805. */
  38806. fallbacks: Nullable<IEffectFallbacks>;
  38807. /**
  38808. * Callback that will be called when the shader is compiled.
  38809. */
  38810. onCompiled: Nullable<(effect: Effect) => void>;
  38811. /**
  38812. * Callback that will be called if an error occurs during shader compilation.
  38813. */
  38814. onError: Nullable<(effect: Effect, errors: string) => void>;
  38815. /**
  38816. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38817. */
  38818. indexParameters?: any;
  38819. /**
  38820. * Max number of lights that can be used in the shader.
  38821. */
  38822. maxSimultaneousLights?: number;
  38823. /**
  38824. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38825. */
  38826. transformFeedbackVaryings?: Nullable<string[]>;
  38827. /**
  38828. * 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
  38829. */
  38830. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38831. /**
  38832. * Is this effect rendering to several color attachments ?
  38833. */
  38834. multiTarget?: boolean;
  38835. }
  38836. /**
  38837. * Effect containing vertex and fragment shader that can be executed on an object.
  38838. */
  38839. export class Effect implements IDisposable {
  38840. /**
  38841. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38842. */
  38843. static ShadersRepository: string;
  38844. /**
  38845. * Enable logging of the shader code when a compilation error occurs
  38846. */
  38847. static LogShaderCodeOnCompilationError: boolean;
  38848. /**
  38849. * Name of the effect.
  38850. */
  38851. name: any;
  38852. /**
  38853. * String container all the define statements that should be set on the shader.
  38854. */
  38855. defines: string;
  38856. /**
  38857. * Callback that will be called when the shader is compiled.
  38858. */
  38859. onCompiled: Nullable<(effect: Effect) => void>;
  38860. /**
  38861. * Callback that will be called if an error occurs during shader compilation.
  38862. */
  38863. onError: Nullable<(effect: Effect, errors: string) => void>;
  38864. /**
  38865. * Callback that will be called when effect is bound.
  38866. */
  38867. onBind: Nullable<(effect: Effect) => void>;
  38868. /**
  38869. * Unique ID of the effect.
  38870. */
  38871. uniqueId: number;
  38872. /**
  38873. * Observable that will be called when the shader is compiled.
  38874. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38875. */
  38876. onCompileObservable: Observable<Effect>;
  38877. /**
  38878. * Observable that will be called if an error occurs during shader compilation.
  38879. */
  38880. onErrorObservable: Observable<Effect>;
  38881. /** @hidden */
  38882. _onBindObservable: Nullable<Observable<Effect>>;
  38883. /**
  38884. * @hidden
  38885. * Specifies if the effect was previously ready
  38886. */
  38887. _wasPreviouslyReady: boolean;
  38888. /**
  38889. * Observable that will be called when effect is bound.
  38890. */
  38891. get onBindObservable(): Observable<Effect>;
  38892. /** @hidden */
  38893. _bonesComputationForcedToCPU: boolean;
  38894. /** @hidden */
  38895. _multiTarget: boolean;
  38896. private static _uniqueIdSeed;
  38897. private _engine;
  38898. private _uniformBuffersNames;
  38899. private _uniformBuffersNamesList;
  38900. private _uniformsNames;
  38901. private _samplerList;
  38902. private _samplers;
  38903. private _isReady;
  38904. private _compilationError;
  38905. private _allFallbacksProcessed;
  38906. private _attributesNames;
  38907. private _attributes;
  38908. private _attributeLocationByName;
  38909. private _uniforms;
  38910. /**
  38911. * Key for the effect.
  38912. * @hidden
  38913. */
  38914. _key: string;
  38915. private _indexParameters;
  38916. private _fallbacks;
  38917. private _vertexSourceCode;
  38918. private _fragmentSourceCode;
  38919. private _vertexSourceCodeOverride;
  38920. private _fragmentSourceCodeOverride;
  38921. private _transformFeedbackVaryings;
  38922. /**
  38923. * Compiled shader to webGL program.
  38924. * @hidden
  38925. */
  38926. _pipelineContext: Nullable<IPipelineContext>;
  38927. private _valueCache;
  38928. private static _baseCache;
  38929. /**
  38930. * Instantiates an effect.
  38931. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38932. * @param baseName Name of the effect.
  38933. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38934. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38935. * @param samplers List of sampler variables that will be passed to the shader.
  38936. * @param engine Engine to be used to render the effect
  38937. * @param defines Define statements to be added to the shader.
  38938. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38939. * @param onCompiled Callback that will be called when the shader is compiled.
  38940. * @param onError Callback that will be called if an error occurs during shader compilation.
  38941. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38942. */
  38943. 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);
  38944. private _useFinalCode;
  38945. /**
  38946. * Unique key for this effect
  38947. */
  38948. get key(): string;
  38949. /**
  38950. * If the effect has been compiled and prepared.
  38951. * @returns if the effect is compiled and prepared.
  38952. */
  38953. isReady(): boolean;
  38954. private _isReadyInternal;
  38955. /**
  38956. * The engine the effect was initialized with.
  38957. * @returns the engine.
  38958. */
  38959. getEngine(): Engine;
  38960. /**
  38961. * The pipeline context for this effect
  38962. * @returns the associated pipeline context
  38963. */
  38964. getPipelineContext(): Nullable<IPipelineContext>;
  38965. /**
  38966. * The set of names of attribute variables for the shader.
  38967. * @returns An array of attribute names.
  38968. */
  38969. getAttributesNames(): string[];
  38970. /**
  38971. * Returns the attribute at the given index.
  38972. * @param index The index of the attribute.
  38973. * @returns The location of the attribute.
  38974. */
  38975. getAttributeLocation(index: number): number;
  38976. /**
  38977. * Returns the attribute based on the name of the variable.
  38978. * @param name of the attribute to look up.
  38979. * @returns the attribute location.
  38980. */
  38981. getAttributeLocationByName(name: string): number;
  38982. /**
  38983. * The number of attributes.
  38984. * @returns the numnber of attributes.
  38985. */
  38986. getAttributesCount(): number;
  38987. /**
  38988. * Gets the index of a uniform variable.
  38989. * @param uniformName of the uniform to look up.
  38990. * @returns the index.
  38991. */
  38992. getUniformIndex(uniformName: string): number;
  38993. /**
  38994. * Returns the attribute based on the name of the variable.
  38995. * @param uniformName of the uniform to look up.
  38996. * @returns the location of the uniform.
  38997. */
  38998. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38999. /**
  39000. * Returns an array of sampler variable names
  39001. * @returns The array of sampler variable names.
  39002. */
  39003. getSamplers(): string[];
  39004. /**
  39005. * Returns an array of uniform variable names
  39006. * @returns The array of uniform variable names.
  39007. */
  39008. getUniformNames(): string[];
  39009. /**
  39010. * Returns an array of uniform buffer variable names
  39011. * @returns The array of uniform buffer variable names.
  39012. */
  39013. getUniformBuffersNames(): string[];
  39014. /**
  39015. * Returns the index parameters used to create the effect
  39016. * @returns The index parameters object
  39017. */
  39018. getIndexParameters(): any;
  39019. /**
  39020. * The error from the last compilation.
  39021. * @returns the error string.
  39022. */
  39023. getCompilationError(): string;
  39024. /**
  39025. * Gets a boolean indicating that all fallbacks were used during compilation
  39026. * @returns true if all fallbacks were used
  39027. */
  39028. allFallbacksProcessed(): boolean;
  39029. /**
  39030. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39031. * @param func The callback to be used.
  39032. */
  39033. executeWhenCompiled(func: (effect: Effect) => void): void;
  39034. private _checkIsReady;
  39035. private _loadShader;
  39036. /**
  39037. * Gets the vertex shader source code of this effect
  39038. */
  39039. get vertexSourceCode(): string;
  39040. /**
  39041. * Gets the fragment shader source code of this effect
  39042. */
  39043. get fragmentSourceCode(): string;
  39044. /**
  39045. * Recompiles the webGL program
  39046. * @param vertexSourceCode The source code for the vertex shader.
  39047. * @param fragmentSourceCode The source code for the fragment shader.
  39048. * @param onCompiled Callback called when completed.
  39049. * @param onError Callback called on error.
  39050. * @hidden
  39051. */
  39052. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39053. /**
  39054. * Prepares the effect
  39055. * @hidden
  39056. */
  39057. _prepareEffect(): void;
  39058. private _getShaderCodeAndErrorLine;
  39059. private _processCompilationErrors;
  39060. /**
  39061. * Checks if the effect is supported. (Must be called after compilation)
  39062. */
  39063. get isSupported(): boolean;
  39064. /**
  39065. * Binds a texture to the engine to be used as output of the shader.
  39066. * @param channel Name of the output variable.
  39067. * @param texture Texture to bind.
  39068. * @hidden
  39069. */
  39070. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39071. /**
  39072. * Sets a texture on the engine to be used in the shader.
  39073. * @param channel Name of the sampler variable.
  39074. * @param texture Texture to set.
  39075. */
  39076. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39077. /**
  39078. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39079. * @param channel Name of the sampler variable.
  39080. * @param texture Texture to set.
  39081. */
  39082. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39083. /**
  39084. * Sets an array of textures on the engine to be used in the shader.
  39085. * @param channel Name of the variable.
  39086. * @param textures Textures to set.
  39087. */
  39088. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39089. /**
  39090. * 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)
  39091. * @param channel Name of the sampler variable.
  39092. * @param postProcess Post process to get the input texture from.
  39093. */
  39094. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39095. /**
  39096. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39097. * 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)
  39098. * @param channel Name of the sampler variable.
  39099. * @param postProcess Post process to get the output texture from.
  39100. */
  39101. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39102. /** @hidden */
  39103. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39104. /** @hidden */
  39105. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39106. /** @hidden */
  39107. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39108. /** @hidden */
  39109. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39110. /**
  39111. * Binds a buffer to a uniform.
  39112. * @param buffer Buffer to bind.
  39113. * @param name Name of the uniform variable to bind to.
  39114. */
  39115. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39116. /**
  39117. * Binds block to a uniform.
  39118. * @param blockName Name of the block to bind.
  39119. * @param index Index to bind.
  39120. */
  39121. bindUniformBlock(blockName: string, index: number): void;
  39122. /**
  39123. * Sets an interger value on a uniform variable.
  39124. * @param uniformName Name of the variable.
  39125. * @param value Value to be set.
  39126. * @returns this effect.
  39127. */
  39128. setInt(uniformName: string, value: number): Effect;
  39129. /**
  39130. * Sets an int array on a uniform variable.
  39131. * @param uniformName Name of the variable.
  39132. * @param array array to be set.
  39133. * @returns this effect.
  39134. */
  39135. setIntArray(uniformName: string, array: Int32Array): Effect;
  39136. /**
  39137. * 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)
  39138. * @param uniformName Name of the variable.
  39139. * @param array array to be set.
  39140. * @returns this effect.
  39141. */
  39142. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39143. /**
  39144. * 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)
  39145. * @param uniformName Name of the variable.
  39146. * @param array array to be set.
  39147. * @returns this effect.
  39148. */
  39149. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39150. /**
  39151. * 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)
  39152. * @param uniformName Name of the variable.
  39153. * @param array array to be set.
  39154. * @returns this effect.
  39155. */
  39156. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39157. /**
  39158. * Sets an float array on a uniform variable.
  39159. * @param uniformName Name of the variable.
  39160. * @param array array to be set.
  39161. * @returns this effect.
  39162. */
  39163. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39164. /**
  39165. * 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)
  39166. * @param uniformName Name of the variable.
  39167. * @param array array to be set.
  39168. * @returns this effect.
  39169. */
  39170. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39171. /**
  39172. * 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)
  39173. * @param uniformName Name of the variable.
  39174. * @param array array to be set.
  39175. * @returns this effect.
  39176. */
  39177. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39178. /**
  39179. * 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)
  39180. * @param uniformName Name of the variable.
  39181. * @param array array to be set.
  39182. * @returns this effect.
  39183. */
  39184. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39185. /**
  39186. * Sets an array on a uniform variable.
  39187. * @param uniformName Name of the variable.
  39188. * @param array array to be set.
  39189. * @returns this effect.
  39190. */
  39191. setArray(uniformName: string, array: number[]): Effect;
  39192. /**
  39193. * 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)
  39194. * @param uniformName Name of the variable.
  39195. * @param array array to be set.
  39196. * @returns this effect.
  39197. */
  39198. setArray2(uniformName: string, array: number[]): Effect;
  39199. /**
  39200. * 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)
  39201. * @param uniformName Name of the variable.
  39202. * @param array array to be set.
  39203. * @returns this effect.
  39204. */
  39205. setArray3(uniformName: string, array: number[]): Effect;
  39206. /**
  39207. * 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)
  39208. * @param uniformName Name of the variable.
  39209. * @param array array to be set.
  39210. * @returns this effect.
  39211. */
  39212. setArray4(uniformName: string, array: number[]): Effect;
  39213. /**
  39214. * Sets matrices on a uniform variable.
  39215. * @param uniformName Name of the variable.
  39216. * @param matrices matrices to be set.
  39217. * @returns this effect.
  39218. */
  39219. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39220. /**
  39221. * Sets matrix on a uniform variable.
  39222. * @param uniformName Name of the variable.
  39223. * @param matrix matrix to be set.
  39224. * @returns this effect.
  39225. */
  39226. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39227. /**
  39228. * 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)
  39229. * @param uniformName Name of the variable.
  39230. * @param matrix matrix to be set.
  39231. * @returns this effect.
  39232. */
  39233. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39234. /**
  39235. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39236. * @param uniformName Name of the variable.
  39237. * @param matrix matrix to be set.
  39238. * @returns this effect.
  39239. */
  39240. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39241. /**
  39242. * Sets a float on a uniform variable.
  39243. * @param uniformName Name of the variable.
  39244. * @param value value to be set.
  39245. * @returns this effect.
  39246. */
  39247. setFloat(uniformName: string, value: number): Effect;
  39248. /**
  39249. * Sets a boolean on a uniform variable.
  39250. * @param uniformName Name of the variable.
  39251. * @param bool value to be set.
  39252. * @returns this effect.
  39253. */
  39254. setBool(uniformName: string, bool: boolean): Effect;
  39255. /**
  39256. * Sets a Vector2 on a uniform variable.
  39257. * @param uniformName Name of the variable.
  39258. * @param vector2 vector2 to be set.
  39259. * @returns this effect.
  39260. */
  39261. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39262. /**
  39263. * Sets a float2 on a uniform variable.
  39264. * @param uniformName Name of the variable.
  39265. * @param x First float in float2.
  39266. * @param y Second float in float2.
  39267. * @returns this effect.
  39268. */
  39269. setFloat2(uniformName: string, x: number, y: number): Effect;
  39270. /**
  39271. * Sets a Vector3 on a uniform variable.
  39272. * @param uniformName Name of the variable.
  39273. * @param vector3 Value to be set.
  39274. * @returns this effect.
  39275. */
  39276. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39277. /**
  39278. * Sets a float3 on a uniform variable.
  39279. * @param uniformName Name of the variable.
  39280. * @param x First float in float3.
  39281. * @param y Second float in float3.
  39282. * @param z Third float in float3.
  39283. * @returns this effect.
  39284. */
  39285. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39286. /**
  39287. * Sets a Vector4 on a uniform variable.
  39288. * @param uniformName Name of the variable.
  39289. * @param vector4 Value to be set.
  39290. * @returns this effect.
  39291. */
  39292. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39293. /**
  39294. * Sets a float4 on a uniform variable.
  39295. * @param uniformName Name of the variable.
  39296. * @param x First float in float4.
  39297. * @param y Second float in float4.
  39298. * @param z Third float in float4.
  39299. * @param w Fourth float in float4.
  39300. * @returns this effect.
  39301. */
  39302. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39303. /**
  39304. * Sets a Color3 on a uniform variable.
  39305. * @param uniformName Name of the variable.
  39306. * @param color3 Value to be set.
  39307. * @returns this effect.
  39308. */
  39309. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39310. /**
  39311. * Sets a Color4 on a uniform variable.
  39312. * @param uniformName Name of the variable.
  39313. * @param color3 Value to be set.
  39314. * @param alpha Alpha value to be set.
  39315. * @returns this effect.
  39316. */
  39317. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39318. /**
  39319. * Sets a Color4 on a uniform variable
  39320. * @param uniformName defines the name of the variable
  39321. * @param color4 defines the value to be set
  39322. * @returns this effect.
  39323. */
  39324. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39325. /** Release all associated resources */
  39326. dispose(): void;
  39327. /**
  39328. * This function will add a new shader to the shader store
  39329. * @param name the name of the shader
  39330. * @param pixelShader optional pixel shader content
  39331. * @param vertexShader optional vertex shader content
  39332. */
  39333. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39334. /**
  39335. * Store of each shader (The can be looked up using effect.key)
  39336. */
  39337. static ShadersStore: {
  39338. [key: string]: string;
  39339. };
  39340. /**
  39341. * Store of each included file for a shader (The can be looked up using effect.key)
  39342. */
  39343. static IncludesShadersStore: {
  39344. [key: string]: string;
  39345. };
  39346. /**
  39347. * Resets the cache of effects.
  39348. */
  39349. static ResetCache(): void;
  39350. }
  39351. }
  39352. declare module "babylonjs/Engines/engineCapabilities" {
  39353. /**
  39354. * Interface used to describe the capabilities of the engine relatively to the current browser
  39355. */
  39356. export interface EngineCapabilities {
  39357. /** Maximum textures units per fragment shader */
  39358. maxTexturesImageUnits: number;
  39359. /** Maximum texture units per vertex shader */
  39360. maxVertexTextureImageUnits: number;
  39361. /** Maximum textures units in the entire pipeline */
  39362. maxCombinedTexturesImageUnits: number;
  39363. /** Maximum texture size */
  39364. maxTextureSize: number;
  39365. /** Maximum texture samples */
  39366. maxSamples?: number;
  39367. /** Maximum cube texture size */
  39368. maxCubemapTextureSize: number;
  39369. /** Maximum render texture size */
  39370. maxRenderTextureSize: number;
  39371. /** Maximum number of vertex attributes */
  39372. maxVertexAttribs: number;
  39373. /** Maximum number of varyings */
  39374. maxVaryingVectors: number;
  39375. /** Maximum number of uniforms per vertex shader */
  39376. maxVertexUniformVectors: number;
  39377. /** Maximum number of uniforms per fragment shader */
  39378. maxFragmentUniformVectors: number;
  39379. /** Defines if standard derivates (dx/dy) are supported */
  39380. standardDerivatives: boolean;
  39381. /** Defines if s3tc texture compression is supported */
  39382. s3tc?: WEBGL_compressed_texture_s3tc;
  39383. /** Defines if pvrtc texture compression is supported */
  39384. pvrtc: any;
  39385. /** Defines if etc1 texture compression is supported */
  39386. etc1: any;
  39387. /** Defines if etc2 texture compression is supported */
  39388. etc2: any;
  39389. /** Defines if astc texture compression is supported */
  39390. astc: any;
  39391. /** Defines if bptc texture compression is supported */
  39392. bptc: any;
  39393. /** Defines if float textures are supported */
  39394. textureFloat: boolean;
  39395. /** Defines if vertex array objects are supported */
  39396. vertexArrayObject: boolean;
  39397. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39398. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39399. /** Gets the maximum level of anisotropy supported */
  39400. maxAnisotropy: number;
  39401. /** Defines if instancing is supported */
  39402. instancedArrays: boolean;
  39403. /** Defines if 32 bits indices are supported */
  39404. uintIndices: boolean;
  39405. /** Defines if high precision shaders are supported */
  39406. highPrecisionShaderSupported: boolean;
  39407. /** Defines if depth reading in the fragment shader is supported */
  39408. fragmentDepthSupported: boolean;
  39409. /** Defines if float texture linear filtering is supported*/
  39410. textureFloatLinearFiltering: boolean;
  39411. /** Defines if rendering to float textures is supported */
  39412. textureFloatRender: boolean;
  39413. /** Defines if half float textures are supported*/
  39414. textureHalfFloat: boolean;
  39415. /** Defines if half float texture linear filtering is supported*/
  39416. textureHalfFloatLinearFiltering: boolean;
  39417. /** Defines if rendering to half float textures is supported */
  39418. textureHalfFloatRender: boolean;
  39419. /** Defines if textureLOD shader command is supported */
  39420. textureLOD: boolean;
  39421. /** Defines if draw buffers extension is supported */
  39422. drawBuffersExtension: boolean;
  39423. /** Defines if depth textures are supported */
  39424. depthTextureExtension: boolean;
  39425. /** Defines if float color buffer are supported */
  39426. colorBufferFloat: boolean;
  39427. /** Gets disjoint timer query extension (null if not supported) */
  39428. timerQuery?: EXT_disjoint_timer_query;
  39429. /** Defines if timestamp can be used with timer query */
  39430. canUseTimestampForTimerQuery: boolean;
  39431. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39432. multiview?: any;
  39433. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39434. oculusMultiview?: any;
  39435. /** Function used to let the system compiles shaders in background */
  39436. parallelShaderCompile?: {
  39437. COMPLETION_STATUS_KHR: number;
  39438. };
  39439. /** Max number of texture samples for MSAA */
  39440. maxMSAASamples: number;
  39441. /** Defines if the blend min max extension is supported */
  39442. blendMinMax: boolean;
  39443. }
  39444. }
  39445. declare module "babylonjs/States/depthCullingState" {
  39446. import { Nullable } from "babylonjs/types";
  39447. /**
  39448. * @hidden
  39449. **/
  39450. export class DepthCullingState {
  39451. private _isDepthTestDirty;
  39452. private _isDepthMaskDirty;
  39453. private _isDepthFuncDirty;
  39454. private _isCullFaceDirty;
  39455. private _isCullDirty;
  39456. private _isZOffsetDirty;
  39457. private _isFrontFaceDirty;
  39458. private _depthTest;
  39459. private _depthMask;
  39460. private _depthFunc;
  39461. private _cull;
  39462. private _cullFace;
  39463. private _zOffset;
  39464. private _frontFace;
  39465. /**
  39466. * Initializes the state.
  39467. */
  39468. constructor();
  39469. get isDirty(): boolean;
  39470. get zOffset(): number;
  39471. set zOffset(value: number);
  39472. get cullFace(): Nullable<number>;
  39473. set cullFace(value: Nullable<number>);
  39474. get cull(): Nullable<boolean>;
  39475. set cull(value: Nullable<boolean>);
  39476. get depthFunc(): Nullable<number>;
  39477. set depthFunc(value: Nullable<number>);
  39478. get depthMask(): boolean;
  39479. set depthMask(value: boolean);
  39480. get depthTest(): boolean;
  39481. set depthTest(value: boolean);
  39482. get frontFace(): Nullable<number>;
  39483. set frontFace(value: Nullable<number>);
  39484. reset(): void;
  39485. apply(gl: WebGLRenderingContext): void;
  39486. }
  39487. }
  39488. declare module "babylonjs/States/stencilState" {
  39489. /**
  39490. * @hidden
  39491. **/
  39492. export class StencilState {
  39493. /** 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 */
  39494. static readonly ALWAYS: number;
  39495. /** Passed to stencilOperation to specify that stencil value must be kept */
  39496. static readonly KEEP: number;
  39497. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39498. static readonly REPLACE: number;
  39499. private _isStencilTestDirty;
  39500. private _isStencilMaskDirty;
  39501. private _isStencilFuncDirty;
  39502. private _isStencilOpDirty;
  39503. private _stencilTest;
  39504. private _stencilMask;
  39505. private _stencilFunc;
  39506. private _stencilFuncRef;
  39507. private _stencilFuncMask;
  39508. private _stencilOpStencilFail;
  39509. private _stencilOpDepthFail;
  39510. private _stencilOpStencilDepthPass;
  39511. get isDirty(): boolean;
  39512. get stencilFunc(): number;
  39513. set stencilFunc(value: number);
  39514. get stencilFuncRef(): number;
  39515. set stencilFuncRef(value: number);
  39516. get stencilFuncMask(): number;
  39517. set stencilFuncMask(value: number);
  39518. get stencilOpStencilFail(): number;
  39519. set stencilOpStencilFail(value: number);
  39520. get stencilOpDepthFail(): number;
  39521. set stencilOpDepthFail(value: number);
  39522. get stencilOpStencilDepthPass(): number;
  39523. set stencilOpStencilDepthPass(value: number);
  39524. get stencilMask(): number;
  39525. set stencilMask(value: number);
  39526. get stencilTest(): boolean;
  39527. set stencilTest(value: boolean);
  39528. constructor();
  39529. reset(): void;
  39530. apply(gl: WebGLRenderingContext): void;
  39531. }
  39532. }
  39533. declare module "babylonjs/States/alphaCullingState" {
  39534. /**
  39535. * @hidden
  39536. **/
  39537. export class AlphaState {
  39538. private _isAlphaBlendDirty;
  39539. private _isBlendFunctionParametersDirty;
  39540. private _isBlendEquationParametersDirty;
  39541. private _isBlendConstantsDirty;
  39542. private _alphaBlend;
  39543. private _blendFunctionParameters;
  39544. private _blendEquationParameters;
  39545. private _blendConstants;
  39546. /**
  39547. * Initializes the state.
  39548. */
  39549. constructor();
  39550. get isDirty(): boolean;
  39551. get alphaBlend(): boolean;
  39552. set alphaBlend(value: boolean);
  39553. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39554. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39555. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39556. reset(): void;
  39557. apply(gl: WebGLRenderingContext): void;
  39558. }
  39559. }
  39560. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39561. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39562. /** @hidden */
  39563. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39564. attributeProcessor(attribute: string): string;
  39565. varyingProcessor(varying: string, isFragment: boolean): string;
  39566. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39567. }
  39568. }
  39569. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39570. /**
  39571. * Interface for attribute information associated with buffer instanciation
  39572. */
  39573. export interface InstancingAttributeInfo {
  39574. /**
  39575. * Name of the GLSL attribute
  39576. * if attribute index is not specified, this is used to retrieve the index from the effect
  39577. */
  39578. attributeName: string;
  39579. /**
  39580. * Index/offset of the attribute in the vertex shader
  39581. * if not specified, this will be computes from the name.
  39582. */
  39583. index?: number;
  39584. /**
  39585. * size of the attribute, 1, 2, 3 or 4
  39586. */
  39587. attributeSize: number;
  39588. /**
  39589. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39590. */
  39591. offset: number;
  39592. /**
  39593. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39594. * default to 1
  39595. */
  39596. divisor?: number;
  39597. /**
  39598. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39599. * default is FLOAT
  39600. */
  39601. attributeType?: number;
  39602. /**
  39603. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39604. */
  39605. normalized?: boolean;
  39606. }
  39607. }
  39608. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39609. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39610. import { Nullable } from "babylonjs/types";
  39611. module "babylonjs/Engines/thinEngine" {
  39612. interface ThinEngine {
  39613. /**
  39614. * Update a video texture
  39615. * @param texture defines the texture to update
  39616. * @param video defines the video element to use
  39617. * @param invertY defines if data must be stored with Y axis inverted
  39618. */
  39619. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39620. }
  39621. }
  39622. }
  39623. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39624. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39625. import { Nullable } from "babylonjs/types";
  39626. module "babylonjs/Engines/thinEngine" {
  39627. interface ThinEngine {
  39628. /**
  39629. * Creates a dynamic texture
  39630. * @param width defines the width of the texture
  39631. * @param height defines the height of the texture
  39632. * @param generateMipMaps defines if the engine should generate the mip levels
  39633. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39634. * @returns the dynamic texture inside an InternalTexture
  39635. */
  39636. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39637. /**
  39638. * Update the content of a dynamic texture
  39639. * @param texture defines the texture to update
  39640. * @param canvas defines the canvas containing the source
  39641. * @param invertY defines if data must be stored with Y axis inverted
  39642. * @param premulAlpha defines if alpha is stored as premultiplied
  39643. * @param format defines the format of the data
  39644. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39645. */
  39646. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39647. }
  39648. }
  39649. }
  39650. declare module "babylonjs/Materials/Textures/videoTexture" {
  39651. import { Observable } from "babylonjs/Misc/observable";
  39652. import { Nullable } from "babylonjs/types";
  39653. import { Scene } from "babylonjs/scene";
  39654. import { Texture } from "babylonjs/Materials/Textures/texture";
  39655. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39656. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39657. /**
  39658. * Settings for finer control over video usage
  39659. */
  39660. export interface VideoTextureSettings {
  39661. /**
  39662. * Applies `autoplay` to video, if specified
  39663. */
  39664. autoPlay?: boolean;
  39665. /**
  39666. * Applies `muted` to video, if specified
  39667. */
  39668. muted?: boolean;
  39669. /**
  39670. * Applies `loop` to video, if specified
  39671. */
  39672. loop?: boolean;
  39673. /**
  39674. * Automatically updates internal texture from video at every frame in the render loop
  39675. */
  39676. autoUpdateTexture: boolean;
  39677. /**
  39678. * Image src displayed during the video loading or until the user interacts with the video.
  39679. */
  39680. poster?: string;
  39681. }
  39682. /**
  39683. * If you want to display a video in your scene, this is the special texture for that.
  39684. * This special texture works similar to other textures, with the exception of a few parameters.
  39685. * @see https://doc.babylonjs.com/how_to/video_texture
  39686. */
  39687. export class VideoTexture extends Texture {
  39688. /**
  39689. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39690. */
  39691. readonly autoUpdateTexture: boolean;
  39692. /**
  39693. * The video instance used by the texture internally
  39694. */
  39695. readonly video: HTMLVideoElement;
  39696. private _onUserActionRequestedObservable;
  39697. /**
  39698. * Event triggerd when a dom action is required by the user to play the video.
  39699. * This happens due to recent changes in browser policies preventing video to auto start.
  39700. */
  39701. get onUserActionRequestedObservable(): Observable<Texture>;
  39702. private _generateMipMaps;
  39703. private _stillImageCaptured;
  39704. private _displayingPosterTexture;
  39705. private _settings;
  39706. private _createInternalTextureOnEvent;
  39707. private _frameId;
  39708. private _currentSrc;
  39709. /**
  39710. * Creates a video texture.
  39711. * If you want to display a video in your scene, this is the special texture for that.
  39712. * This special texture works similar to other textures, with the exception of a few parameters.
  39713. * @see https://doc.babylonjs.com/how_to/video_texture
  39714. * @param name optional name, will detect from video source, if not defined
  39715. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39716. * @param scene is obviously the current scene.
  39717. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39718. * @param invertY is false by default but can be used to invert video on Y axis
  39719. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39720. * @param settings allows finer control over video usage
  39721. */
  39722. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39723. private _getName;
  39724. private _getVideo;
  39725. private _createInternalTexture;
  39726. private reset;
  39727. /**
  39728. * @hidden Internal method to initiate `update`.
  39729. */
  39730. _rebuild(): void;
  39731. /**
  39732. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39733. */
  39734. update(): void;
  39735. /**
  39736. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39737. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39738. */
  39739. updateTexture(isVisible: boolean): void;
  39740. protected _updateInternalTexture: () => void;
  39741. /**
  39742. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39743. * @param url New url.
  39744. */
  39745. updateURL(url: string): void;
  39746. /**
  39747. * Clones the texture.
  39748. * @returns the cloned texture
  39749. */
  39750. clone(): VideoTexture;
  39751. /**
  39752. * Dispose the texture and release its associated resources.
  39753. */
  39754. dispose(): void;
  39755. /**
  39756. * Creates a video texture straight from a stream.
  39757. * @param scene Define the scene the texture should be created in
  39758. * @param stream Define the stream the texture should be created from
  39759. * @returns The created video texture as a promise
  39760. */
  39761. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39762. /**
  39763. * Creates a video texture straight from your WebCam video feed.
  39764. * @param scene Define the scene the texture should be created in
  39765. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39766. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39767. * @returns The created video texture as a promise
  39768. */
  39769. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39770. minWidth: number;
  39771. maxWidth: number;
  39772. minHeight: number;
  39773. maxHeight: number;
  39774. deviceId: string;
  39775. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39776. /**
  39777. * Creates a video texture straight from your WebCam video feed.
  39778. * @param scene Define the scene the texture should be created in
  39779. * @param onReady Define a callback to triggered once the texture will be ready
  39780. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39781. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39782. */
  39783. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39784. minWidth: number;
  39785. maxWidth: number;
  39786. minHeight: number;
  39787. maxHeight: number;
  39788. deviceId: string;
  39789. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39790. }
  39791. }
  39792. declare module "babylonjs/Engines/thinEngine" {
  39793. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  39794. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  39795. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39796. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39797. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  39798. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  39799. import { Observable } from "babylonjs/Misc/observable";
  39800. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  39801. import { StencilState } from "babylonjs/States/stencilState";
  39802. import { AlphaState } from "babylonjs/States/alphaCullingState";
  39803. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39804. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  39805. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39806. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39807. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39808. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  39809. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  39810. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  39811. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39812. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39813. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39814. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  39815. import { WebRequest } from "babylonjs/Misc/webRequest";
  39816. import { LoadFileError } from "babylonjs/Misc/fileTools";
  39817. /**
  39818. * Defines the interface used by objects working like Scene
  39819. * @hidden
  39820. */
  39821. export interface ISceneLike {
  39822. _addPendingData(data: any): void;
  39823. _removePendingData(data: any): void;
  39824. offlineProvider: IOfflineProvider;
  39825. }
  39826. /**
  39827. * Information about the current host
  39828. */
  39829. export interface HostInformation {
  39830. /**
  39831. * Defines if the current host is a mobile
  39832. */
  39833. isMobile: boolean;
  39834. }
  39835. /** Interface defining initialization parameters for Engine class */
  39836. export interface EngineOptions extends WebGLContextAttributes {
  39837. /**
  39838. * Defines if the engine should no exceed a specified device ratio
  39839. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39840. */
  39841. limitDeviceRatio?: number;
  39842. /**
  39843. * Defines if webvr should be enabled automatically
  39844. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39845. */
  39846. autoEnableWebVR?: boolean;
  39847. /**
  39848. * Defines if webgl2 should be turned off even if supported
  39849. * @see https://doc.babylonjs.com/features/webgl2
  39850. */
  39851. disableWebGL2Support?: boolean;
  39852. /**
  39853. * Defines if webaudio should be initialized as well
  39854. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39855. */
  39856. audioEngine?: boolean;
  39857. /**
  39858. * Defines if animations should run using a deterministic lock step
  39859. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39860. */
  39861. deterministicLockstep?: boolean;
  39862. /** Defines the maximum steps to use with deterministic lock step mode */
  39863. lockstepMaxSteps?: number;
  39864. /** Defines the seconds between each deterministic lock step */
  39865. timeStep?: number;
  39866. /**
  39867. * Defines that engine should ignore context lost events
  39868. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39869. */
  39870. doNotHandleContextLost?: boolean;
  39871. /**
  39872. * Defines that engine should ignore modifying touch action attribute and style
  39873. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39874. */
  39875. doNotHandleTouchAction?: boolean;
  39876. /**
  39877. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39878. */
  39879. useHighPrecisionFloats?: boolean;
  39880. /**
  39881. * Make the canvas XR Compatible for XR sessions
  39882. */
  39883. xrCompatible?: boolean;
  39884. /**
  39885. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39886. */
  39887. useHighPrecisionMatrix?: boolean;
  39888. /**
  39889. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39890. */
  39891. failIfMajorPerformanceCaveat?: boolean;
  39892. }
  39893. /**
  39894. * The base engine class (root of all engines)
  39895. */
  39896. export class ThinEngine {
  39897. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39898. static ExceptionList: ({
  39899. key: string;
  39900. capture: string;
  39901. captureConstraint: number;
  39902. targets: string[];
  39903. } | {
  39904. key: string;
  39905. capture: null;
  39906. captureConstraint: null;
  39907. targets: string[];
  39908. })[];
  39909. /** @hidden */
  39910. static _TextureLoaders: IInternalTextureLoader[];
  39911. /**
  39912. * Returns the current npm package of the sdk
  39913. */
  39914. static get NpmPackage(): string;
  39915. /**
  39916. * Returns the current version of the framework
  39917. */
  39918. static get Version(): string;
  39919. /**
  39920. * Returns a string describing the current engine
  39921. */
  39922. get description(): string;
  39923. /**
  39924. * Gets or sets the epsilon value used by collision engine
  39925. */
  39926. static CollisionsEpsilon: number;
  39927. /**
  39928. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39929. */
  39930. static get ShadersRepository(): string;
  39931. static set ShadersRepository(value: string);
  39932. /** @hidden */
  39933. _shaderProcessor: IShaderProcessor;
  39934. /**
  39935. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39936. */
  39937. forcePOTTextures: boolean;
  39938. /**
  39939. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39940. */
  39941. isFullscreen: boolean;
  39942. /**
  39943. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39944. */
  39945. cullBackFaces: boolean;
  39946. /**
  39947. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39948. */
  39949. renderEvenInBackground: boolean;
  39950. /**
  39951. * Gets or sets a boolean indicating that cache can be kept between frames
  39952. */
  39953. preventCacheWipeBetweenFrames: boolean;
  39954. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39955. validateShaderPrograms: boolean;
  39956. /**
  39957. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39958. * This can provide greater z depth for distant objects.
  39959. */
  39960. useReverseDepthBuffer: boolean;
  39961. /**
  39962. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39963. */
  39964. disableUniformBuffers: boolean;
  39965. /** @hidden */
  39966. _uniformBuffers: UniformBuffer[];
  39967. /**
  39968. * Gets a boolean indicating that the engine supports uniform buffers
  39969. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39970. */
  39971. get supportsUniformBuffers(): boolean;
  39972. /** @hidden */
  39973. _gl: WebGLRenderingContext;
  39974. /** @hidden */
  39975. _webGLVersion: number;
  39976. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39977. protected _windowIsBackground: boolean;
  39978. protected _creationOptions: EngineOptions;
  39979. protected _highPrecisionShadersAllowed: boolean;
  39980. /** @hidden */
  39981. get _shouldUseHighPrecisionShader(): boolean;
  39982. /**
  39983. * Gets a boolean indicating that only power of 2 textures are supported
  39984. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39985. */
  39986. get needPOTTextures(): boolean;
  39987. /** @hidden */
  39988. _badOS: boolean;
  39989. /** @hidden */
  39990. _badDesktopOS: boolean;
  39991. private _hardwareScalingLevel;
  39992. /** @hidden */
  39993. _caps: EngineCapabilities;
  39994. private _isStencilEnable;
  39995. private _glVersion;
  39996. private _glRenderer;
  39997. private _glVendor;
  39998. /** @hidden */
  39999. _videoTextureSupported: boolean;
  40000. protected _renderingQueueLaunched: boolean;
  40001. protected _activeRenderLoops: (() => void)[];
  40002. /**
  40003. * Observable signaled when a context lost event is raised
  40004. */
  40005. onContextLostObservable: Observable<ThinEngine>;
  40006. /**
  40007. * Observable signaled when a context restored event is raised
  40008. */
  40009. onContextRestoredObservable: Observable<ThinEngine>;
  40010. private _onContextLost;
  40011. private _onContextRestored;
  40012. protected _contextWasLost: boolean;
  40013. /** @hidden */
  40014. _doNotHandleContextLost: boolean;
  40015. /**
  40016. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40017. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40018. */
  40019. get doNotHandleContextLost(): boolean;
  40020. set doNotHandleContextLost(value: boolean);
  40021. /**
  40022. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40023. */
  40024. disableVertexArrayObjects: boolean;
  40025. /** @hidden */
  40026. protected _colorWrite: boolean;
  40027. /** @hidden */
  40028. protected _colorWriteChanged: boolean;
  40029. /** @hidden */
  40030. protected _depthCullingState: DepthCullingState;
  40031. /** @hidden */
  40032. protected _stencilState: StencilState;
  40033. /** @hidden */
  40034. _alphaState: AlphaState;
  40035. /** @hidden */
  40036. _alphaMode: number;
  40037. /** @hidden */
  40038. _alphaEquation: number;
  40039. /** @hidden */
  40040. _internalTexturesCache: InternalTexture[];
  40041. /** @hidden */
  40042. protected _activeChannel: number;
  40043. private _currentTextureChannel;
  40044. /** @hidden */
  40045. protected _boundTexturesCache: {
  40046. [key: string]: Nullable<InternalTexture>;
  40047. };
  40048. /** @hidden */
  40049. protected _currentEffect: Nullable<Effect>;
  40050. /** @hidden */
  40051. protected _currentProgram: Nullable<WebGLProgram>;
  40052. private _compiledEffects;
  40053. private _vertexAttribArraysEnabled;
  40054. /** @hidden */
  40055. protected _cachedViewport: Nullable<IViewportLike>;
  40056. private _cachedVertexArrayObject;
  40057. /** @hidden */
  40058. protected _cachedVertexBuffers: any;
  40059. /** @hidden */
  40060. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40061. /** @hidden */
  40062. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40063. /** @hidden */
  40064. _currentRenderTarget: Nullable<InternalTexture>;
  40065. private _uintIndicesCurrentlySet;
  40066. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40067. /** @hidden */
  40068. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40069. /** @hidden */
  40070. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40071. private _currentBufferPointers;
  40072. private _currentInstanceLocations;
  40073. private _currentInstanceBuffers;
  40074. private _textureUnits;
  40075. /** @hidden */
  40076. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40077. /** @hidden */
  40078. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40079. /** @hidden */
  40080. _boundRenderFunction: any;
  40081. private _vaoRecordInProgress;
  40082. private _mustWipeVertexAttributes;
  40083. private _emptyTexture;
  40084. private _emptyCubeTexture;
  40085. private _emptyTexture3D;
  40086. private _emptyTexture2DArray;
  40087. /** @hidden */
  40088. _frameHandler: number;
  40089. private _nextFreeTextureSlots;
  40090. private _maxSimultaneousTextures;
  40091. private _activeRequests;
  40092. /** @hidden */
  40093. _transformTextureUrl: Nullable<(url: string) => string>;
  40094. /**
  40095. * Gets information about the current host
  40096. */
  40097. hostInformation: HostInformation;
  40098. protected get _supportsHardwareTextureRescaling(): boolean;
  40099. private _framebufferDimensionsObject;
  40100. /**
  40101. * sets the object from which width and height will be taken from when getting render width and height
  40102. * Will fallback to the gl object
  40103. * @param dimensions the framebuffer width and height that will be used.
  40104. */
  40105. set framebufferDimensionsObject(dimensions: Nullable<{
  40106. framebufferWidth: number;
  40107. framebufferHeight: number;
  40108. }>);
  40109. /**
  40110. * Gets the current viewport
  40111. */
  40112. get currentViewport(): Nullable<IViewportLike>;
  40113. /**
  40114. * Gets the default empty texture
  40115. */
  40116. get emptyTexture(): InternalTexture;
  40117. /**
  40118. * Gets the default empty 3D texture
  40119. */
  40120. get emptyTexture3D(): InternalTexture;
  40121. /**
  40122. * Gets the default empty 2D array texture
  40123. */
  40124. get emptyTexture2DArray(): InternalTexture;
  40125. /**
  40126. * Gets the default empty cube texture
  40127. */
  40128. get emptyCubeTexture(): InternalTexture;
  40129. /**
  40130. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40131. */
  40132. readonly premultipliedAlpha: boolean;
  40133. /**
  40134. * Observable event triggered before each texture is initialized
  40135. */
  40136. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40137. /**
  40138. * Creates a new engine
  40139. * @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
  40140. * @param antialias defines enable antialiasing (default: false)
  40141. * @param options defines further options to be sent to the getContext() function
  40142. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40143. */
  40144. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40145. private _rebuildInternalTextures;
  40146. private _rebuildEffects;
  40147. /**
  40148. * Gets a boolean indicating if all created effects are ready
  40149. * @returns true if all effects are ready
  40150. */
  40151. areAllEffectsReady(): boolean;
  40152. protected _rebuildBuffers(): void;
  40153. protected _initGLContext(): void;
  40154. /**
  40155. * Gets version of the current webGL context
  40156. */
  40157. get webGLVersion(): number;
  40158. /**
  40159. * Gets a string identifying the name of the class
  40160. * @returns "Engine" string
  40161. */
  40162. getClassName(): string;
  40163. /**
  40164. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40165. */
  40166. get isStencilEnable(): boolean;
  40167. /** @hidden */
  40168. _prepareWorkingCanvas(): void;
  40169. /**
  40170. * Reset the texture cache to empty state
  40171. */
  40172. resetTextureCache(): void;
  40173. /**
  40174. * Gets an object containing information about the current webGL context
  40175. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40176. */
  40177. getGlInfo(): {
  40178. vendor: string;
  40179. renderer: string;
  40180. version: string;
  40181. };
  40182. /**
  40183. * Defines the hardware scaling level.
  40184. * By default the hardware scaling level is computed from the window device ratio.
  40185. * 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.
  40186. * @param level defines the level to use
  40187. */
  40188. setHardwareScalingLevel(level: number): void;
  40189. /**
  40190. * Gets the current hardware scaling level.
  40191. * By default the hardware scaling level is computed from the window device ratio.
  40192. * 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.
  40193. * @returns a number indicating the current hardware scaling level
  40194. */
  40195. getHardwareScalingLevel(): number;
  40196. /**
  40197. * Gets the list of loaded textures
  40198. * @returns an array containing all loaded textures
  40199. */
  40200. getLoadedTexturesCache(): InternalTexture[];
  40201. /**
  40202. * Gets the object containing all engine capabilities
  40203. * @returns the EngineCapabilities object
  40204. */
  40205. getCaps(): EngineCapabilities;
  40206. /**
  40207. * stop executing a render loop function and remove it from the execution array
  40208. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40209. */
  40210. stopRenderLoop(renderFunction?: () => void): void;
  40211. /** @hidden */
  40212. _renderLoop(): void;
  40213. /**
  40214. * Gets the HTML canvas attached with the current webGL context
  40215. * @returns a HTML canvas
  40216. */
  40217. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40218. /**
  40219. * Gets host window
  40220. * @returns the host window object
  40221. */
  40222. getHostWindow(): Nullable<Window>;
  40223. /**
  40224. * Gets the current render width
  40225. * @param useScreen defines if screen size must be used (or the current render target if any)
  40226. * @returns a number defining the current render width
  40227. */
  40228. getRenderWidth(useScreen?: boolean): number;
  40229. /**
  40230. * Gets the current render height
  40231. * @param useScreen defines if screen size must be used (or the current render target if any)
  40232. * @returns a number defining the current render height
  40233. */
  40234. getRenderHeight(useScreen?: boolean): number;
  40235. /**
  40236. * Can be used to override the current requestAnimationFrame requester.
  40237. * @hidden
  40238. */
  40239. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40240. /**
  40241. * Register and execute a render loop. The engine can have more than one render function
  40242. * @param renderFunction defines the function to continuously execute
  40243. */
  40244. runRenderLoop(renderFunction: () => void): void;
  40245. /**
  40246. * Clear the current render buffer or the current render target (if any is set up)
  40247. * @param color defines the color to use
  40248. * @param backBuffer defines if the back buffer must be cleared
  40249. * @param depth defines if the depth buffer must be cleared
  40250. * @param stencil defines if the stencil buffer must be cleared
  40251. */
  40252. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40253. private _viewportCached;
  40254. /** @hidden */
  40255. _viewport(x: number, y: number, width: number, height: number): void;
  40256. /**
  40257. * Set the WebGL's viewport
  40258. * @param viewport defines the viewport element to be used
  40259. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40260. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40261. */
  40262. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40263. /**
  40264. * Begin a new frame
  40265. */
  40266. beginFrame(): void;
  40267. /**
  40268. * Enf the current frame
  40269. */
  40270. endFrame(): void;
  40271. /**
  40272. * Resize the view according to the canvas' size
  40273. */
  40274. resize(): void;
  40275. /**
  40276. * Force a specific size of the canvas
  40277. * @param width defines the new canvas' width
  40278. * @param height defines the new canvas' height
  40279. * @returns true if the size was changed
  40280. */
  40281. setSize(width: number, height: number): boolean;
  40282. /**
  40283. * Binds the frame buffer to the specified texture.
  40284. * @param texture The texture to render to or null for the default canvas
  40285. * @param faceIndex The face of the texture to render to in case of cube texture
  40286. * @param requiredWidth The width of the target to render to
  40287. * @param requiredHeight The height of the target to render to
  40288. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40289. * @param lodLevel defines the lod level to bind to the frame buffer
  40290. * @param layer defines the 2d array index to bind to frame buffer to
  40291. */
  40292. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40293. /** @hidden */
  40294. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40295. /**
  40296. * Unbind the current render target texture from the webGL context
  40297. * @param texture defines the render target texture to unbind
  40298. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40299. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40300. */
  40301. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40302. /**
  40303. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40304. */
  40305. flushFramebuffer(): void;
  40306. /**
  40307. * Unbind the current render target and bind the default framebuffer
  40308. */
  40309. restoreDefaultFramebuffer(): void;
  40310. /** @hidden */
  40311. protected _resetVertexBufferBinding(): void;
  40312. /**
  40313. * Creates a vertex buffer
  40314. * @param data the data for the vertex buffer
  40315. * @returns the new WebGL static buffer
  40316. */
  40317. createVertexBuffer(data: DataArray): DataBuffer;
  40318. private _createVertexBuffer;
  40319. /**
  40320. * Creates a dynamic vertex buffer
  40321. * @param data the data for the dynamic vertex buffer
  40322. * @returns the new WebGL dynamic buffer
  40323. */
  40324. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40325. protected _resetIndexBufferBinding(): void;
  40326. /**
  40327. * Creates a new index buffer
  40328. * @param indices defines the content of the index buffer
  40329. * @param updatable defines if the index buffer must be updatable
  40330. * @returns a new webGL buffer
  40331. */
  40332. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40333. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40334. /**
  40335. * Bind a webGL buffer to the webGL context
  40336. * @param buffer defines the buffer to bind
  40337. */
  40338. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40339. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40340. private bindBuffer;
  40341. /**
  40342. * update the bound buffer with the given data
  40343. * @param data defines the data to update
  40344. */
  40345. updateArrayBuffer(data: Float32Array): void;
  40346. private _vertexAttribPointer;
  40347. /** @hidden */
  40348. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40349. private _bindVertexBuffersAttributes;
  40350. /**
  40351. * Records a vertex array object
  40352. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40353. * @param vertexBuffers defines the list of vertex buffers to store
  40354. * @param indexBuffer defines the index buffer to store
  40355. * @param effect defines the effect to store
  40356. * @returns the new vertex array object
  40357. */
  40358. recordVertexArrayObject(vertexBuffers: {
  40359. [key: string]: VertexBuffer;
  40360. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40361. /**
  40362. * Bind a specific vertex array object
  40363. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40364. * @param vertexArrayObject defines the vertex array object to bind
  40365. * @param indexBuffer defines the index buffer to bind
  40366. */
  40367. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40368. /**
  40369. * Bind webGl buffers directly to the webGL context
  40370. * @param vertexBuffer defines the vertex buffer to bind
  40371. * @param indexBuffer defines the index buffer to bind
  40372. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40373. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40374. * @param effect defines the effect associated with the vertex buffer
  40375. */
  40376. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40377. private _unbindVertexArrayObject;
  40378. /**
  40379. * Bind a list of vertex buffers to the webGL context
  40380. * @param vertexBuffers defines the list of vertex buffers to bind
  40381. * @param indexBuffer defines the index buffer to bind
  40382. * @param effect defines the effect associated with the vertex buffers
  40383. */
  40384. bindBuffers(vertexBuffers: {
  40385. [key: string]: Nullable<VertexBuffer>;
  40386. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40387. /**
  40388. * Unbind all instance attributes
  40389. */
  40390. unbindInstanceAttributes(): void;
  40391. /**
  40392. * Release and free the memory of a vertex array object
  40393. * @param vao defines the vertex array object to delete
  40394. */
  40395. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40396. /** @hidden */
  40397. _releaseBuffer(buffer: DataBuffer): boolean;
  40398. protected _deleteBuffer(buffer: DataBuffer): void;
  40399. /**
  40400. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40401. * @param instancesBuffer defines the webGL buffer to update and bind
  40402. * @param data defines the data to store in the buffer
  40403. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40404. */
  40405. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40406. /**
  40407. * Bind the content of a webGL buffer used with instantiation
  40408. * @param instancesBuffer defines the webGL buffer to bind
  40409. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40410. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40411. */
  40412. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40413. /**
  40414. * Disable the instance attribute corresponding to the name in parameter
  40415. * @param name defines the name of the attribute to disable
  40416. */
  40417. disableInstanceAttributeByName(name: string): void;
  40418. /**
  40419. * Disable the instance attribute corresponding to the location in parameter
  40420. * @param attributeLocation defines the attribute location of the attribute to disable
  40421. */
  40422. disableInstanceAttribute(attributeLocation: number): void;
  40423. /**
  40424. * Disable the attribute corresponding to the location in parameter
  40425. * @param attributeLocation defines the attribute location of the attribute to disable
  40426. */
  40427. disableAttributeByIndex(attributeLocation: number): void;
  40428. /**
  40429. * Send a draw order
  40430. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40431. * @param indexStart defines the starting index
  40432. * @param indexCount defines the number of index to draw
  40433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40434. */
  40435. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40436. /**
  40437. * Draw a list of points
  40438. * @param verticesStart defines the index of first vertex to draw
  40439. * @param verticesCount defines the count of vertices to draw
  40440. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40441. */
  40442. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40443. /**
  40444. * Draw a list of unindexed primitives
  40445. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40446. * @param verticesStart defines the index of first vertex to draw
  40447. * @param verticesCount defines the count of vertices to draw
  40448. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40449. */
  40450. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40451. /**
  40452. * Draw a list of indexed primitives
  40453. * @param fillMode defines the primitive to use
  40454. * @param indexStart defines the starting index
  40455. * @param indexCount defines the number of index to draw
  40456. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40457. */
  40458. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40459. /**
  40460. * Draw a list of unindexed primitives
  40461. * @param fillMode defines the primitive to use
  40462. * @param verticesStart defines the index of first vertex to draw
  40463. * @param verticesCount defines the count of vertices to draw
  40464. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40465. */
  40466. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40467. private _drawMode;
  40468. /** @hidden */
  40469. protected _reportDrawCall(): void;
  40470. /** @hidden */
  40471. _releaseEffect(effect: Effect): void;
  40472. /** @hidden */
  40473. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40474. /**
  40475. * Create a new effect (used to store vertex/fragment shaders)
  40476. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40477. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40478. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40479. * @param samplers defines an array of string used to represent textures
  40480. * @param defines defines the string containing the defines to use to compile the shaders
  40481. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40482. * @param onCompiled defines a function to call when the effect creation is successful
  40483. * @param onError defines a function to call when the effect creation has failed
  40484. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40485. * @returns the new Effect
  40486. */
  40487. 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;
  40488. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40489. private _compileShader;
  40490. private _compileRawShader;
  40491. /** @hidden */
  40492. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40493. /**
  40494. * Directly creates a webGL program
  40495. * @param pipelineContext defines the pipeline context to attach to
  40496. * @param vertexCode defines the vertex shader code to use
  40497. * @param fragmentCode defines the fragment shader code to use
  40498. * @param context defines the webGL context to use (if not set, the current one will be used)
  40499. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40500. * @returns the new webGL program
  40501. */
  40502. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40503. /**
  40504. * Creates a webGL program
  40505. * @param pipelineContext defines the pipeline context to attach to
  40506. * @param vertexCode defines the vertex shader code to use
  40507. * @param fragmentCode defines the fragment shader code to use
  40508. * @param defines defines the string containing the defines to use to compile the shaders
  40509. * @param context defines the webGL context to use (if not set, the current one will be used)
  40510. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40511. * @returns the new webGL program
  40512. */
  40513. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40514. /**
  40515. * Creates a new pipeline context
  40516. * @returns the new pipeline
  40517. */
  40518. createPipelineContext(): IPipelineContext;
  40519. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40520. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40521. /** @hidden */
  40522. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40523. /** @hidden */
  40524. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40525. /** @hidden */
  40526. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40527. /**
  40528. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40529. * @param pipelineContext defines the pipeline context to use
  40530. * @param uniformsNames defines the list of uniform names
  40531. * @returns an array of webGL uniform locations
  40532. */
  40533. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40534. /**
  40535. * Gets the lsit of active attributes for a given webGL program
  40536. * @param pipelineContext defines the pipeline context to use
  40537. * @param attributesNames defines the list of attribute names to get
  40538. * @returns an array of indices indicating the offset of each attribute
  40539. */
  40540. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40541. /**
  40542. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40543. * @param effect defines the effect to activate
  40544. */
  40545. enableEffect(effect: Nullable<Effect>): void;
  40546. /**
  40547. * Set the value of an uniform to a number (int)
  40548. * @param uniform defines the webGL uniform location where to store the value
  40549. * @param value defines the int number to store
  40550. * @returns true if the value was set
  40551. */
  40552. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40553. /**
  40554. * Set the value of an uniform to an array of int32
  40555. * @param uniform defines the webGL uniform location where to store the value
  40556. * @param array defines the array of int32 to store
  40557. * @returns true if the value was set
  40558. */
  40559. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40560. /**
  40561. * Set the value of an uniform to an array of int32 (stored as vec2)
  40562. * @param uniform defines the webGL uniform location where to store the value
  40563. * @param array defines the array of int32 to store
  40564. * @returns true if the value was set
  40565. */
  40566. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40567. /**
  40568. * Set the value of an uniform to an array of int32 (stored as vec3)
  40569. * @param uniform defines the webGL uniform location where to store the value
  40570. * @param array defines the array of int32 to store
  40571. * @returns true if the value was set
  40572. */
  40573. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40574. /**
  40575. * Set the value of an uniform to an array of int32 (stored as vec4)
  40576. * @param uniform defines the webGL uniform location where to store the value
  40577. * @param array defines the array of int32 to store
  40578. * @returns true if the value was set
  40579. */
  40580. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40581. /**
  40582. * Set the value of an uniform to an array of number
  40583. * @param uniform defines the webGL uniform location where to store the value
  40584. * @param array defines the array of number to store
  40585. * @returns true if the value was set
  40586. */
  40587. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40588. /**
  40589. * Set the value of an uniform to an array of number (stored as vec2)
  40590. * @param uniform defines the webGL uniform location where to store the value
  40591. * @param array defines the array of number to store
  40592. * @returns true if the value was set
  40593. */
  40594. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40595. /**
  40596. * Set the value of an uniform to an array of number (stored as vec3)
  40597. * @param uniform defines the webGL uniform location where to store the value
  40598. * @param array defines the array of number to store
  40599. * @returns true if the value was set
  40600. */
  40601. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40602. /**
  40603. * Set the value of an uniform to an array of number (stored as vec4)
  40604. * @param uniform defines the webGL uniform location where to store the value
  40605. * @param array defines the array of number to store
  40606. * @returns true if the value was set
  40607. */
  40608. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40609. /**
  40610. * Set the value of an uniform to an array of float32 (stored as matrices)
  40611. * @param uniform defines the webGL uniform location where to store the value
  40612. * @param matrices defines the array of float32 to store
  40613. * @returns true if the value was set
  40614. */
  40615. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40616. /**
  40617. * Set the value of an uniform to a matrix (3x3)
  40618. * @param uniform defines the webGL uniform location where to store the value
  40619. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40620. * @returns true if the value was set
  40621. */
  40622. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40623. /**
  40624. * Set the value of an uniform to a matrix (2x2)
  40625. * @param uniform defines the webGL uniform location where to store the value
  40626. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40627. * @returns true if the value was set
  40628. */
  40629. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40630. /**
  40631. * Set the value of an uniform to a number (float)
  40632. * @param uniform defines the webGL uniform location where to store the value
  40633. * @param value defines the float number to store
  40634. * @returns true if the value was transfered
  40635. */
  40636. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40637. /**
  40638. * Set the value of an uniform to a vec2
  40639. * @param uniform defines the webGL uniform location where to store the value
  40640. * @param x defines the 1st component of the value
  40641. * @param y defines the 2nd component of the value
  40642. * @returns true if the value was set
  40643. */
  40644. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40645. /**
  40646. * Set the value of an uniform to a vec3
  40647. * @param uniform defines the webGL uniform location where to store the value
  40648. * @param x defines the 1st component of the value
  40649. * @param y defines the 2nd component of the value
  40650. * @param z defines the 3rd component of the value
  40651. * @returns true if the value was set
  40652. */
  40653. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40654. /**
  40655. * Set the value of an uniform to a vec4
  40656. * @param uniform defines the webGL uniform location where to store the value
  40657. * @param x defines the 1st component of the value
  40658. * @param y defines the 2nd component of the value
  40659. * @param z defines the 3rd component of the value
  40660. * @param w defines the 4th component of the value
  40661. * @returns true if the value was set
  40662. */
  40663. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40664. /**
  40665. * Apply all cached states (depth, culling, stencil and alpha)
  40666. */
  40667. applyStates(): void;
  40668. /**
  40669. * Enable or disable color writing
  40670. * @param enable defines the state to set
  40671. */
  40672. setColorWrite(enable: boolean): void;
  40673. /**
  40674. * Gets a boolean indicating if color writing is enabled
  40675. * @returns the current color writing state
  40676. */
  40677. getColorWrite(): boolean;
  40678. /**
  40679. * Gets the depth culling state manager
  40680. */
  40681. get depthCullingState(): DepthCullingState;
  40682. /**
  40683. * Gets the alpha state manager
  40684. */
  40685. get alphaState(): AlphaState;
  40686. /**
  40687. * Gets the stencil state manager
  40688. */
  40689. get stencilState(): StencilState;
  40690. /**
  40691. * Clears the list of texture accessible through engine.
  40692. * This can help preventing texture load conflict due to name collision.
  40693. */
  40694. clearInternalTexturesCache(): void;
  40695. /**
  40696. * Force the entire cache to be cleared
  40697. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40698. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40699. */
  40700. wipeCaches(bruteForce?: boolean): void;
  40701. /** @hidden */
  40702. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40703. min: number;
  40704. mag: number;
  40705. };
  40706. /** @hidden */
  40707. _createTexture(): WebGLTexture;
  40708. /**
  40709. * Usually called from Texture.ts.
  40710. * Passed information to create a WebGLTexture
  40711. * @param url defines a value which contains one of the following:
  40712. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40713. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40714. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40715. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40716. * @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)
  40717. * @param scene needed for loading to the correct scene
  40718. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40719. * @param onLoad optional callback to be called upon successful completion
  40720. * @param onError optional callback to be called upon failure
  40721. * @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
  40722. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40723. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40724. * @param forcedExtension defines the extension to use to pick the right loader
  40725. * @param mimeType defines an optional mime type
  40726. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40727. */
  40728. 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;
  40729. /**
  40730. * Loads an image as an HTMLImageElement.
  40731. * @param input url string, ArrayBuffer, or Blob to load
  40732. * @param onLoad callback called when the image successfully loads
  40733. * @param onError callback called when the image fails to load
  40734. * @param offlineProvider offline provider for caching
  40735. * @param mimeType optional mime type
  40736. * @returns the HTMLImageElement of the loaded image
  40737. * @hidden
  40738. */
  40739. 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>;
  40740. /**
  40741. * @hidden
  40742. */
  40743. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40744. private _unpackFlipYCached;
  40745. /**
  40746. * In case you are sharing the context with other applications, it might
  40747. * be interested to not cache the unpack flip y state to ensure a consistent
  40748. * value would be set.
  40749. */
  40750. enableUnpackFlipYCached: boolean;
  40751. /** @hidden */
  40752. _unpackFlipY(value: boolean): void;
  40753. /** @hidden */
  40754. _getUnpackAlignement(): number;
  40755. private _getTextureTarget;
  40756. /**
  40757. * Update the sampling mode of a given texture
  40758. * @param samplingMode defines the required sampling mode
  40759. * @param texture defines the texture to update
  40760. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40761. */
  40762. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40763. /**
  40764. * Update the sampling mode of a given texture
  40765. * @param texture defines the texture to update
  40766. * @param wrapU defines the texture wrap mode of the u coordinates
  40767. * @param wrapV defines the texture wrap mode of the v coordinates
  40768. * @param wrapR defines the texture wrap mode of the r coordinates
  40769. */
  40770. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40771. /** @hidden */
  40772. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40773. width: number;
  40774. height: number;
  40775. layers?: number;
  40776. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  40777. /** @hidden */
  40778. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40779. /** @hidden */
  40780. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40781. /**
  40782. * Update a portion of an internal texture
  40783. * @param texture defines the texture to update
  40784. * @param imageData defines the data to store into the texture
  40785. * @param xOffset defines the x coordinates of the update rectangle
  40786. * @param yOffset defines the y coordinates of the update rectangle
  40787. * @param width defines the width of the update rectangle
  40788. * @param height defines the height of the update rectangle
  40789. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40790. * @param lod defines the lod level to update (0 by default)
  40791. */
  40792. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40793. /** @hidden */
  40794. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40795. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40796. private _prepareWebGLTexture;
  40797. /** @hidden */
  40798. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40799. private _getDepthStencilBuffer;
  40800. /** @hidden */
  40801. _releaseFramebufferObjects(texture: InternalTexture): void;
  40802. /** @hidden */
  40803. _releaseTexture(texture: InternalTexture): void;
  40804. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40805. protected _setProgram(program: WebGLProgram): void;
  40806. protected _boundUniforms: {
  40807. [key: number]: WebGLUniformLocation;
  40808. };
  40809. /**
  40810. * Binds an effect to the webGL context
  40811. * @param effect defines the effect to bind
  40812. */
  40813. bindSamplers(effect: Effect): void;
  40814. private _activateCurrentTexture;
  40815. /** @hidden */
  40816. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40817. /** @hidden */
  40818. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  40819. /**
  40820. * Unbind all textures from the webGL context
  40821. */
  40822. unbindAllTextures(): void;
  40823. /**
  40824. * Sets a texture to the according uniform.
  40825. * @param channel The texture channel
  40826. * @param uniform The uniform to set
  40827. * @param texture The texture to apply
  40828. */
  40829. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  40830. private _bindSamplerUniformToChannel;
  40831. private _getTextureWrapMode;
  40832. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40833. /**
  40834. * Sets an array of texture to the webGL context
  40835. * @param channel defines the channel where the texture array must be set
  40836. * @param uniform defines the associated uniform location
  40837. * @param textures defines the array of textures to bind
  40838. */
  40839. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  40840. /** @hidden */
  40841. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40842. private _setTextureParameterFloat;
  40843. private _setTextureParameterInteger;
  40844. /**
  40845. * Unbind all vertex attributes from the webGL context
  40846. */
  40847. unbindAllAttributes(): void;
  40848. /**
  40849. * 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
  40850. */
  40851. releaseEffects(): void;
  40852. /**
  40853. * Dispose and release all associated resources
  40854. */
  40855. dispose(): void;
  40856. /**
  40857. * Attach a new callback raised when context lost event is fired
  40858. * @param callback defines the callback to call
  40859. */
  40860. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40861. /**
  40862. * Attach a new callback raised when context restored event is fired
  40863. * @param callback defines the callback to call
  40864. */
  40865. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40866. /**
  40867. * Get the current error code of the webGL context
  40868. * @returns the error code
  40869. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40870. */
  40871. getError(): number;
  40872. private _canRenderToFloatFramebuffer;
  40873. private _canRenderToHalfFloatFramebuffer;
  40874. private _canRenderToFramebuffer;
  40875. /** @hidden */
  40876. _getWebGLTextureType(type: number): number;
  40877. /** @hidden */
  40878. _getInternalFormat(format: number): number;
  40879. /** @hidden */
  40880. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40881. /** @hidden */
  40882. _getRGBAMultiSampleBufferFormat(type: number): number;
  40883. /** @hidden */
  40884. _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;
  40885. /**
  40886. * Loads a file from a url
  40887. * @param url url to load
  40888. * @param onSuccess callback called when the file successfully loads
  40889. * @param onProgress callback called while file is loading (if the server supports this mode)
  40890. * @param offlineProvider defines the offline provider for caching
  40891. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40892. * @param onError callback called when the file fails to load
  40893. * @returns a file request object
  40894. * @hidden
  40895. */
  40896. 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;
  40897. /**
  40898. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40899. * @param x defines the x coordinate of the rectangle where pixels must be read
  40900. * @param y defines the y coordinate of the rectangle where pixels must be read
  40901. * @param width defines the width of the rectangle where pixels must be read
  40902. * @param height defines the height of the rectangle where pixels must be read
  40903. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40904. * @returns a Uint8Array containing RGBA colors
  40905. */
  40906. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40907. private static _IsSupported;
  40908. private static _HasMajorPerformanceCaveat;
  40909. /**
  40910. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40911. */
  40912. static get IsSupported(): boolean;
  40913. /**
  40914. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40915. * @returns true if the engine can be created
  40916. * @ignorenaming
  40917. */
  40918. static isSupported(): boolean;
  40919. /**
  40920. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  40921. */
  40922. static get HasMajorPerformanceCaveat(): boolean;
  40923. /**
  40924. * Find the next highest power of two.
  40925. * @param x Number to start search from.
  40926. * @return Next highest power of two.
  40927. */
  40928. static CeilingPOT(x: number): number;
  40929. /**
  40930. * Find the next lowest power of two.
  40931. * @param x Number to start search from.
  40932. * @return Next lowest power of two.
  40933. */
  40934. static FloorPOT(x: number): number;
  40935. /**
  40936. * Find the nearest power of two.
  40937. * @param x Number to start search from.
  40938. * @return Next nearest power of two.
  40939. */
  40940. static NearestPOT(x: number): number;
  40941. /**
  40942. * Get the closest exponent of two
  40943. * @param value defines the value to approximate
  40944. * @param max defines the maximum value to return
  40945. * @param mode defines how to define the closest value
  40946. * @returns closest exponent of two of the given value
  40947. */
  40948. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40949. /**
  40950. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40951. * @param func - the function to be called
  40952. * @param requester - the object that will request the next frame. Falls back to window.
  40953. * @returns frame number
  40954. */
  40955. static QueueNewFrame(func: () => void, requester?: any): number;
  40956. /**
  40957. * Gets host document
  40958. * @returns the host document object
  40959. */
  40960. getHostDocument(): Nullable<Document>;
  40961. }
  40962. }
  40963. declare module "babylonjs/Materials/Textures/internalTexture" {
  40964. import { Observable } from "babylonjs/Misc/observable";
  40965. import { Nullable, int } from "babylonjs/types";
  40966. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40968. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  40969. /**
  40970. * Defines the source of the internal texture
  40971. */
  40972. export enum InternalTextureSource {
  40973. /**
  40974. * The source of the texture data is unknown
  40975. */
  40976. Unknown = 0,
  40977. /**
  40978. * Texture data comes from an URL
  40979. */
  40980. Url = 1,
  40981. /**
  40982. * Texture data is only used for temporary storage
  40983. */
  40984. Temp = 2,
  40985. /**
  40986. * Texture data comes from raw data (ArrayBuffer)
  40987. */
  40988. Raw = 3,
  40989. /**
  40990. * Texture content is dynamic (video or dynamic texture)
  40991. */
  40992. Dynamic = 4,
  40993. /**
  40994. * Texture content is generated by rendering to it
  40995. */
  40996. RenderTarget = 5,
  40997. /**
  40998. * Texture content is part of a multi render target process
  40999. */
  41000. MultiRenderTarget = 6,
  41001. /**
  41002. * Texture data comes from a cube data file
  41003. */
  41004. Cube = 7,
  41005. /**
  41006. * Texture data comes from a raw cube data
  41007. */
  41008. CubeRaw = 8,
  41009. /**
  41010. * Texture data come from a prefiltered cube data file
  41011. */
  41012. CubePrefiltered = 9,
  41013. /**
  41014. * Texture content is raw 3D data
  41015. */
  41016. Raw3D = 10,
  41017. /**
  41018. * Texture content is raw 2D array data
  41019. */
  41020. Raw2DArray = 11,
  41021. /**
  41022. * Texture content is a depth texture
  41023. */
  41024. Depth = 12,
  41025. /**
  41026. * Texture data comes from a raw cube data encoded with RGBD
  41027. */
  41028. CubeRawRGBD = 13
  41029. }
  41030. /**
  41031. * Class used to store data associated with WebGL texture data for the engine
  41032. * This class should not be used directly
  41033. */
  41034. export class InternalTexture {
  41035. /** @hidden */
  41036. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41037. /**
  41038. * Defines if the texture is ready
  41039. */
  41040. isReady: boolean;
  41041. /**
  41042. * Defines if the texture is a cube texture
  41043. */
  41044. isCube: boolean;
  41045. /**
  41046. * Defines if the texture contains 3D data
  41047. */
  41048. is3D: boolean;
  41049. /**
  41050. * Defines if the texture contains 2D array data
  41051. */
  41052. is2DArray: boolean;
  41053. /**
  41054. * Defines if the texture contains multiview data
  41055. */
  41056. isMultiview: boolean;
  41057. /**
  41058. * Gets the URL used to load this texture
  41059. */
  41060. url: string;
  41061. /**
  41062. * Gets the sampling mode of the texture
  41063. */
  41064. samplingMode: number;
  41065. /**
  41066. * Gets a boolean indicating if the texture needs mipmaps generation
  41067. */
  41068. generateMipMaps: boolean;
  41069. /**
  41070. * Gets the number of samples used by the texture (WebGL2+ only)
  41071. */
  41072. samples: number;
  41073. /**
  41074. * Gets the type of the texture (int, float...)
  41075. */
  41076. type: number;
  41077. /**
  41078. * Gets the format of the texture (RGB, RGBA...)
  41079. */
  41080. format: number;
  41081. /**
  41082. * Observable called when the texture is loaded
  41083. */
  41084. onLoadedObservable: Observable<InternalTexture>;
  41085. /**
  41086. * Gets the width of the texture
  41087. */
  41088. width: number;
  41089. /**
  41090. * Gets the height of the texture
  41091. */
  41092. height: number;
  41093. /**
  41094. * Gets the depth of the texture
  41095. */
  41096. depth: number;
  41097. /**
  41098. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41099. */
  41100. baseWidth: number;
  41101. /**
  41102. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41103. */
  41104. baseHeight: number;
  41105. /**
  41106. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41107. */
  41108. baseDepth: number;
  41109. /**
  41110. * Gets a boolean indicating if the texture is inverted on Y axis
  41111. */
  41112. invertY: boolean;
  41113. /** @hidden */
  41114. _invertVScale: boolean;
  41115. /** @hidden */
  41116. _associatedChannel: number;
  41117. /** @hidden */
  41118. _source: InternalTextureSource;
  41119. /** @hidden */
  41120. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41121. /** @hidden */
  41122. _bufferView: Nullable<ArrayBufferView>;
  41123. /** @hidden */
  41124. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41125. /** @hidden */
  41126. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41127. /** @hidden */
  41128. _size: number;
  41129. /** @hidden */
  41130. _extension: string;
  41131. /** @hidden */
  41132. _files: Nullable<string[]>;
  41133. /** @hidden */
  41134. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41135. /** @hidden */
  41136. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41137. /** @hidden */
  41138. _framebuffer: Nullable<WebGLFramebuffer>;
  41139. /** @hidden */
  41140. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41141. /** @hidden */
  41142. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41143. /** @hidden */
  41144. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41145. /** @hidden */
  41146. _attachments: Nullable<number[]>;
  41147. /** @hidden */
  41148. _textureArray: Nullable<InternalTexture[]>;
  41149. /** @hidden */
  41150. _cachedCoordinatesMode: Nullable<number>;
  41151. /** @hidden */
  41152. _cachedWrapU: Nullable<number>;
  41153. /** @hidden */
  41154. _cachedWrapV: Nullable<number>;
  41155. /** @hidden */
  41156. _cachedWrapR: Nullable<number>;
  41157. /** @hidden */
  41158. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41159. /** @hidden */
  41160. _isDisabled: boolean;
  41161. /** @hidden */
  41162. _compression: Nullable<string>;
  41163. /** @hidden */
  41164. _generateStencilBuffer: boolean;
  41165. /** @hidden */
  41166. _generateDepthBuffer: boolean;
  41167. /** @hidden */
  41168. _comparisonFunction: number;
  41169. /** @hidden */
  41170. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41171. /** @hidden */
  41172. _lodGenerationScale: number;
  41173. /** @hidden */
  41174. _lodGenerationOffset: number;
  41175. /** @hidden */
  41176. _depthStencilTexture: Nullable<InternalTexture>;
  41177. /** @hidden */
  41178. _colorTextureArray: Nullable<WebGLTexture>;
  41179. /** @hidden */
  41180. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41181. /** @hidden */
  41182. _lodTextureHigh: Nullable<BaseTexture>;
  41183. /** @hidden */
  41184. _lodTextureMid: Nullable<BaseTexture>;
  41185. /** @hidden */
  41186. _lodTextureLow: Nullable<BaseTexture>;
  41187. /** @hidden */
  41188. _isRGBD: boolean;
  41189. /** @hidden */
  41190. _linearSpecularLOD: boolean;
  41191. /** @hidden */
  41192. _irradianceTexture: Nullable<BaseTexture>;
  41193. /** @hidden */
  41194. _webGLTexture: Nullable<WebGLTexture>;
  41195. /** @hidden */
  41196. _references: number;
  41197. /** @hidden */
  41198. _gammaSpace: Nullable<boolean>;
  41199. private _engine;
  41200. /**
  41201. * Gets the Engine the texture belongs to.
  41202. * @returns The babylon engine
  41203. */
  41204. getEngine(): ThinEngine;
  41205. /**
  41206. * Gets the data source type of the texture
  41207. */
  41208. get source(): InternalTextureSource;
  41209. /**
  41210. * Creates a new InternalTexture
  41211. * @param engine defines the engine to use
  41212. * @param source defines the type of data that will be used
  41213. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41214. */
  41215. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41216. /**
  41217. * Increments the number of references (ie. the number of Texture that point to it)
  41218. */
  41219. incrementReferences(): void;
  41220. /**
  41221. * Change the size of the texture (not the size of the content)
  41222. * @param width defines the new width
  41223. * @param height defines the new height
  41224. * @param depth defines the new depth (1 by default)
  41225. */
  41226. updateSize(width: int, height: int, depth?: int): void;
  41227. /** @hidden */
  41228. _rebuild(): void;
  41229. /** @hidden */
  41230. _swapAndDie(target: InternalTexture): void;
  41231. /**
  41232. * Dispose the current allocated resources
  41233. */
  41234. dispose(): void;
  41235. }
  41236. }
  41237. declare module "babylonjs/Audio/analyser" {
  41238. import { Scene } from "babylonjs/scene";
  41239. /**
  41240. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41241. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41242. */
  41243. export class Analyser {
  41244. /**
  41245. * Gets or sets the smoothing
  41246. * @ignorenaming
  41247. */
  41248. SMOOTHING: number;
  41249. /**
  41250. * Gets or sets the FFT table size
  41251. * @ignorenaming
  41252. */
  41253. FFT_SIZE: number;
  41254. /**
  41255. * Gets or sets the bar graph amplitude
  41256. * @ignorenaming
  41257. */
  41258. BARGRAPHAMPLITUDE: number;
  41259. /**
  41260. * Gets or sets the position of the debug canvas
  41261. * @ignorenaming
  41262. */
  41263. DEBUGCANVASPOS: {
  41264. x: number;
  41265. y: number;
  41266. };
  41267. /**
  41268. * Gets or sets the debug canvas size
  41269. * @ignorenaming
  41270. */
  41271. DEBUGCANVASSIZE: {
  41272. width: number;
  41273. height: number;
  41274. };
  41275. private _byteFreqs;
  41276. private _byteTime;
  41277. private _floatFreqs;
  41278. private _webAudioAnalyser;
  41279. private _debugCanvas;
  41280. private _debugCanvasContext;
  41281. private _scene;
  41282. private _registerFunc;
  41283. private _audioEngine;
  41284. /**
  41285. * Creates a new analyser
  41286. * @param scene defines hosting scene
  41287. */
  41288. constructor(scene: Scene);
  41289. /**
  41290. * Get the number of data values you will have to play with for the visualization
  41291. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41292. * @returns a number
  41293. */
  41294. getFrequencyBinCount(): number;
  41295. /**
  41296. * Gets the current frequency data as a byte array
  41297. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41298. * @returns a Uint8Array
  41299. */
  41300. getByteFrequencyData(): Uint8Array;
  41301. /**
  41302. * Gets the current waveform as a byte array
  41303. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41304. * @returns a Uint8Array
  41305. */
  41306. getByteTimeDomainData(): Uint8Array;
  41307. /**
  41308. * Gets the current frequency data as a float array
  41309. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41310. * @returns a Float32Array
  41311. */
  41312. getFloatFrequencyData(): Float32Array;
  41313. /**
  41314. * Renders the debug canvas
  41315. */
  41316. drawDebugCanvas(): void;
  41317. /**
  41318. * Stops rendering the debug canvas and removes it
  41319. */
  41320. stopDebugCanvas(): void;
  41321. /**
  41322. * Connects two audio nodes
  41323. * @param inputAudioNode defines first node to connect
  41324. * @param outputAudioNode defines second node to connect
  41325. */
  41326. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41327. /**
  41328. * Releases all associated resources
  41329. */
  41330. dispose(): void;
  41331. }
  41332. }
  41333. declare module "babylonjs/Audio/audioEngine" {
  41334. import { IDisposable } from "babylonjs/scene";
  41335. import { Analyser } from "babylonjs/Audio/analyser";
  41336. import { Nullable } from "babylonjs/types";
  41337. import { Observable } from "babylonjs/Misc/observable";
  41338. /**
  41339. * This represents an audio engine and it is responsible
  41340. * to play, synchronize and analyse sounds throughout the application.
  41341. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41342. */
  41343. export interface IAudioEngine extends IDisposable {
  41344. /**
  41345. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41346. */
  41347. readonly canUseWebAudio: boolean;
  41348. /**
  41349. * Gets the current AudioContext if available.
  41350. */
  41351. readonly audioContext: Nullable<AudioContext>;
  41352. /**
  41353. * The master gain node defines the global audio volume of your audio engine.
  41354. */
  41355. readonly masterGain: GainNode;
  41356. /**
  41357. * Gets whether or not mp3 are supported by your browser.
  41358. */
  41359. readonly isMP3supported: boolean;
  41360. /**
  41361. * Gets whether or not ogg are supported by your browser.
  41362. */
  41363. readonly isOGGsupported: boolean;
  41364. /**
  41365. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41366. * @ignoreNaming
  41367. */
  41368. WarnedWebAudioUnsupported: boolean;
  41369. /**
  41370. * Defines if the audio engine relies on a custom unlocked button.
  41371. * In this case, the embedded button will not be displayed.
  41372. */
  41373. useCustomUnlockedButton: boolean;
  41374. /**
  41375. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41376. */
  41377. readonly unlocked: boolean;
  41378. /**
  41379. * Event raised when audio has been unlocked on the browser.
  41380. */
  41381. onAudioUnlockedObservable: Observable<AudioEngine>;
  41382. /**
  41383. * Event raised when audio has been locked on the browser.
  41384. */
  41385. onAudioLockedObservable: Observable<AudioEngine>;
  41386. /**
  41387. * Flags the audio engine in Locked state.
  41388. * This happens due to new browser policies preventing audio to autoplay.
  41389. */
  41390. lock(): void;
  41391. /**
  41392. * Unlocks the audio engine once a user action has been done on the dom.
  41393. * This is helpful to resume play once browser policies have been satisfied.
  41394. */
  41395. unlock(): void;
  41396. /**
  41397. * Gets the global volume sets on the master gain.
  41398. * @returns the global volume if set or -1 otherwise
  41399. */
  41400. getGlobalVolume(): number;
  41401. /**
  41402. * Sets the global volume of your experience (sets on the master gain).
  41403. * @param newVolume Defines the new global volume of the application
  41404. */
  41405. setGlobalVolume(newVolume: number): void;
  41406. /**
  41407. * Connect the audio engine to an audio analyser allowing some amazing
  41408. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41409. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41410. * @param analyser The analyser to connect to the engine
  41411. */
  41412. connectToAnalyser(analyser: Analyser): void;
  41413. }
  41414. /**
  41415. * This represents the default audio engine used in babylon.
  41416. * It is responsible to play, synchronize and analyse sounds throughout the application.
  41417. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41418. */
  41419. export class AudioEngine implements IAudioEngine {
  41420. private _audioContext;
  41421. private _audioContextInitialized;
  41422. private _muteButton;
  41423. private _hostElement;
  41424. /**
  41425. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41426. */
  41427. canUseWebAudio: boolean;
  41428. /**
  41429. * The master gain node defines the global audio volume of your audio engine.
  41430. */
  41431. masterGain: GainNode;
  41432. /**
  41433. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41434. * @ignoreNaming
  41435. */
  41436. WarnedWebAudioUnsupported: boolean;
  41437. /**
  41438. * Gets whether or not mp3 are supported by your browser.
  41439. */
  41440. isMP3supported: boolean;
  41441. /**
  41442. * Gets whether or not ogg are supported by your browser.
  41443. */
  41444. isOGGsupported: boolean;
  41445. /**
  41446. * Gets whether audio has been unlocked on the device.
  41447. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  41448. * a user interaction has happened.
  41449. */
  41450. unlocked: boolean;
  41451. /**
  41452. * Defines if the audio engine relies on a custom unlocked button.
  41453. * In this case, the embedded button will not be displayed.
  41454. */
  41455. useCustomUnlockedButton: boolean;
  41456. /**
  41457. * Event raised when audio has been unlocked on the browser.
  41458. */
  41459. onAudioUnlockedObservable: Observable<AudioEngine>;
  41460. /**
  41461. * Event raised when audio has been locked on the browser.
  41462. */
  41463. onAudioLockedObservable: Observable<AudioEngine>;
  41464. /**
  41465. * Gets the current AudioContext if available.
  41466. */
  41467. get audioContext(): Nullable<AudioContext>;
  41468. private _connectedAnalyser;
  41469. /**
  41470. * Instantiates a new audio engine.
  41471. *
  41472. * There should be only one per page as some browsers restrict the number
  41473. * of audio contexts you can create.
  41474. * @param hostElement defines the host element where to display the mute icon if necessary
  41475. */
  41476. constructor(hostElement?: Nullable<HTMLElement>);
  41477. /**
  41478. * Flags the audio engine in Locked state.
  41479. * This happens due to new browser policies preventing audio to autoplay.
  41480. */
  41481. lock(): void;
  41482. /**
  41483. * Unlocks the audio engine once a user action has been done on the dom.
  41484. * This is helpful to resume play once browser policies have been satisfied.
  41485. */
  41486. unlock(): void;
  41487. private _resumeAudioContext;
  41488. private _initializeAudioContext;
  41489. private _tryToRun;
  41490. private _triggerRunningState;
  41491. private _triggerSuspendedState;
  41492. private _displayMuteButton;
  41493. private _moveButtonToTopLeft;
  41494. private _onResize;
  41495. private _hideMuteButton;
  41496. /**
  41497. * Destroy and release the resources associated with the audio ccontext.
  41498. */
  41499. dispose(): void;
  41500. /**
  41501. * Gets the global volume sets on the master gain.
  41502. * @returns the global volume if set or -1 otherwise
  41503. */
  41504. getGlobalVolume(): number;
  41505. /**
  41506. * Sets the global volume of your experience (sets on the master gain).
  41507. * @param newVolume Defines the new global volume of the application
  41508. */
  41509. setGlobalVolume(newVolume: number): void;
  41510. /**
  41511. * Connect the audio engine to an audio analyser allowing some amazing
  41512. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41513. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41514. * @param analyser The analyser to connect to the engine
  41515. */
  41516. connectToAnalyser(analyser: Analyser): void;
  41517. }
  41518. }
  41519. declare module "babylonjs/Loading/loadingScreen" {
  41520. /**
  41521. * Interface used to present a loading screen while loading a scene
  41522. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41523. */
  41524. export interface ILoadingScreen {
  41525. /**
  41526. * Function called to display the loading screen
  41527. */
  41528. displayLoadingUI: () => void;
  41529. /**
  41530. * Function called to hide the loading screen
  41531. */
  41532. hideLoadingUI: () => void;
  41533. /**
  41534. * Gets or sets the color to use for the background
  41535. */
  41536. loadingUIBackgroundColor: string;
  41537. /**
  41538. * Gets or sets the text to display while loading
  41539. */
  41540. loadingUIText: string;
  41541. }
  41542. /**
  41543. * Class used for the default loading screen
  41544. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41545. */
  41546. export class DefaultLoadingScreen implements ILoadingScreen {
  41547. private _renderingCanvas;
  41548. private _loadingText;
  41549. private _loadingDivBackgroundColor;
  41550. private _loadingDiv;
  41551. private _loadingTextDiv;
  41552. /** Gets or sets the logo url to use for the default loading screen */
  41553. static DefaultLogoUrl: string;
  41554. /** Gets or sets the spinner url to use for the default loading screen */
  41555. static DefaultSpinnerUrl: string;
  41556. /**
  41557. * Creates a new default loading screen
  41558. * @param _renderingCanvas defines the canvas used to render the scene
  41559. * @param _loadingText defines the default text to display
  41560. * @param _loadingDivBackgroundColor defines the default background color
  41561. */
  41562. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41563. /**
  41564. * Function called to display the loading screen
  41565. */
  41566. displayLoadingUI(): void;
  41567. /**
  41568. * Function called to hide the loading screen
  41569. */
  41570. hideLoadingUI(): void;
  41571. /**
  41572. * Gets or sets the text to display while loading
  41573. */
  41574. set loadingUIText(text: string);
  41575. get loadingUIText(): string;
  41576. /**
  41577. * Gets or sets the color to use for the background
  41578. */
  41579. get loadingUIBackgroundColor(): string;
  41580. set loadingUIBackgroundColor(color: string);
  41581. private _resizeLoadingUI;
  41582. }
  41583. }
  41584. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41585. /**
  41586. * Interface for any object that can request an animation frame
  41587. */
  41588. export interface ICustomAnimationFrameRequester {
  41589. /**
  41590. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41591. */
  41592. renderFunction?: Function;
  41593. /**
  41594. * Called to request the next frame to render to
  41595. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41596. */
  41597. requestAnimationFrame: Function;
  41598. /**
  41599. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41600. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41601. */
  41602. requestID?: number;
  41603. }
  41604. }
  41605. declare module "babylonjs/Misc/performanceMonitor" {
  41606. /**
  41607. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41608. */
  41609. export class PerformanceMonitor {
  41610. private _enabled;
  41611. private _rollingFrameTime;
  41612. private _lastFrameTimeMs;
  41613. /**
  41614. * constructor
  41615. * @param frameSampleSize The number of samples required to saturate the sliding window
  41616. */
  41617. constructor(frameSampleSize?: number);
  41618. /**
  41619. * Samples current frame
  41620. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41621. */
  41622. sampleFrame(timeMs?: number): void;
  41623. /**
  41624. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41625. */
  41626. get averageFrameTime(): number;
  41627. /**
  41628. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41629. */
  41630. get averageFrameTimeVariance(): number;
  41631. /**
  41632. * Returns the frame time of the most recent frame
  41633. */
  41634. get instantaneousFrameTime(): number;
  41635. /**
  41636. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41637. */
  41638. get averageFPS(): number;
  41639. /**
  41640. * Returns the average framerate in frames per second using the most recent frame time
  41641. */
  41642. get instantaneousFPS(): number;
  41643. /**
  41644. * Returns true if enough samples have been taken to completely fill the sliding window
  41645. */
  41646. get isSaturated(): boolean;
  41647. /**
  41648. * Enables contributions to the sliding window sample set
  41649. */
  41650. enable(): void;
  41651. /**
  41652. * Disables contributions to the sliding window sample set
  41653. * Samples will not be interpolated over the disabled period
  41654. */
  41655. disable(): void;
  41656. /**
  41657. * Returns true if sampling is enabled
  41658. */
  41659. get isEnabled(): boolean;
  41660. /**
  41661. * Resets performance monitor
  41662. */
  41663. reset(): void;
  41664. }
  41665. /**
  41666. * RollingAverage
  41667. *
  41668. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41669. */
  41670. export class RollingAverage {
  41671. /**
  41672. * Current average
  41673. */
  41674. average: number;
  41675. /**
  41676. * Current variance
  41677. */
  41678. variance: number;
  41679. protected _samples: Array<number>;
  41680. protected _sampleCount: number;
  41681. protected _pos: number;
  41682. protected _m2: number;
  41683. /**
  41684. * constructor
  41685. * @param length The number of samples required to saturate the sliding window
  41686. */
  41687. constructor(length: number);
  41688. /**
  41689. * Adds a sample to the sample set
  41690. * @param v The sample value
  41691. */
  41692. add(v: number): void;
  41693. /**
  41694. * Returns previously added values or null if outside of history or outside the sliding window domain
  41695. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41696. * @return Value previously recorded with add() or null if outside of range
  41697. */
  41698. history(i: number): number;
  41699. /**
  41700. * Returns true if enough samples have been taken to completely fill the sliding window
  41701. * @return true if sample-set saturated
  41702. */
  41703. isSaturated(): boolean;
  41704. /**
  41705. * Resets the rolling average (equivalent to 0 samples taken so far)
  41706. */
  41707. reset(): void;
  41708. /**
  41709. * Wraps a value around the sample range boundaries
  41710. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41711. * @return Wrapped position in sample range
  41712. */
  41713. protected _wrapPosition(i: number): number;
  41714. }
  41715. }
  41716. declare module "babylonjs/Misc/perfCounter" {
  41717. /**
  41718. * This class is used to track a performance counter which is number based.
  41719. * The user has access to many properties which give statistics of different nature.
  41720. *
  41721. * The implementer can track two kinds of Performance Counter: time and count.
  41722. * 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.
  41723. * 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.
  41724. */
  41725. export class PerfCounter {
  41726. /**
  41727. * Gets or sets a global boolean to turn on and off all the counters
  41728. */
  41729. static Enabled: boolean;
  41730. /**
  41731. * Returns the smallest value ever
  41732. */
  41733. get min(): number;
  41734. /**
  41735. * Returns the biggest value ever
  41736. */
  41737. get max(): number;
  41738. /**
  41739. * Returns the average value since the performance counter is running
  41740. */
  41741. get average(): number;
  41742. /**
  41743. * Returns the average value of the last second the counter was monitored
  41744. */
  41745. get lastSecAverage(): number;
  41746. /**
  41747. * Returns the current value
  41748. */
  41749. get current(): number;
  41750. /**
  41751. * Gets the accumulated total
  41752. */
  41753. get total(): number;
  41754. /**
  41755. * Gets the total value count
  41756. */
  41757. get count(): number;
  41758. /**
  41759. * Creates a new counter
  41760. */
  41761. constructor();
  41762. /**
  41763. * Call this method to start monitoring a new frame.
  41764. * 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.
  41765. */
  41766. fetchNewFrame(): void;
  41767. /**
  41768. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41769. * @param newCount the count value to add to the monitored count
  41770. * @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.
  41771. */
  41772. addCount(newCount: number, fetchResult: boolean): void;
  41773. /**
  41774. * Start monitoring this performance counter
  41775. */
  41776. beginMonitoring(): void;
  41777. /**
  41778. * Compute the time lapsed since the previous beginMonitoring() call.
  41779. * @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
  41780. */
  41781. endMonitoring(newFrame?: boolean): void;
  41782. private _fetchResult;
  41783. private _startMonitoringTime;
  41784. private _min;
  41785. private _max;
  41786. private _average;
  41787. private _current;
  41788. private _totalValueCount;
  41789. private _totalAccumulated;
  41790. private _lastSecAverage;
  41791. private _lastSecAccumulated;
  41792. private _lastSecTime;
  41793. private _lastSecValueCount;
  41794. }
  41795. }
  41796. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  41797. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41798. import { Nullable } from "babylonjs/types";
  41799. module "babylonjs/Engines/thinEngine" {
  41800. interface ThinEngine {
  41801. /** @hidden */
  41802. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  41803. }
  41804. }
  41805. }
  41806. declare module "babylonjs/Engines/engine" {
  41807. import { Observable } from "babylonjs/Misc/observable";
  41808. import { Nullable } from "babylonjs/types";
  41809. import { Scene } from "babylonjs/scene";
  41810. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41811. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  41812. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41813. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  41814. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41815. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41816. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  41817. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  41818. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41819. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41820. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  41821. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41822. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  41823. import "babylonjs/Engines/Extensions/engine.alpha";
  41824. import "babylonjs/Engines/Extensions/engine.readTexture";
  41825. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  41826. import { Material } from "babylonjs/Materials/material";
  41827. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41828. /**
  41829. * Defines the interface used by display changed events
  41830. */
  41831. export interface IDisplayChangedEventArgs {
  41832. /** Gets the vrDisplay object (if any) */
  41833. vrDisplay: Nullable<any>;
  41834. /** Gets a boolean indicating if webVR is supported */
  41835. vrSupported: boolean;
  41836. }
  41837. /**
  41838. * Defines the interface used by objects containing a viewport (like a camera)
  41839. */
  41840. interface IViewportOwnerLike {
  41841. /**
  41842. * Gets or sets the viewport
  41843. */
  41844. viewport: IViewportLike;
  41845. }
  41846. /**
  41847. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41848. */
  41849. export class Engine extends ThinEngine {
  41850. /** Defines that alpha blending is disabled */
  41851. static readonly ALPHA_DISABLE: number;
  41852. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41853. static readonly ALPHA_ADD: number;
  41854. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41855. static readonly ALPHA_COMBINE: number;
  41856. /** Defines that alpha blending to DEST - SRC * DEST */
  41857. static readonly ALPHA_SUBTRACT: number;
  41858. /** Defines that alpha blending to SRC * DEST */
  41859. static readonly ALPHA_MULTIPLY: number;
  41860. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41861. static readonly ALPHA_MAXIMIZED: number;
  41862. /** Defines that alpha blending to SRC + DEST */
  41863. static readonly ALPHA_ONEONE: number;
  41864. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41865. static readonly ALPHA_PREMULTIPLIED: number;
  41866. /**
  41867. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41868. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41869. */
  41870. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41871. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41872. static readonly ALPHA_INTERPOLATE: number;
  41873. /**
  41874. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41875. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41876. */
  41877. static readonly ALPHA_SCREENMODE: number;
  41878. /** Defines that the ressource is not delayed*/
  41879. static readonly DELAYLOADSTATE_NONE: number;
  41880. /** Defines that the ressource was successfully delay loaded */
  41881. static readonly DELAYLOADSTATE_LOADED: number;
  41882. /** Defines that the ressource is currently delay loading */
  41883. static readonly DELAYLOADSTATE_LOADING: number;
  41884. /** Defines that the ressource is delayed and has not started loading */
  41885. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41886. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41887. static readonly NEVER: number;
  41888. /** 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 */
  41889. static readonly ALWAYS: number;
  41890. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41891. static readonly LESS: number;
  41892. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41893. static readonly EQUAL: number;
  41894. /** 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 */
  41895. static readonly LEQUAL: number;
  41896. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41897. static readonly GREATER: number;
  41898. /** 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 */
  41899. static readonly GEQUAL: number;
  41900. /** 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 */
  41901. static readonly NOTEQUAL: number;
  41902. /** Passed to stencilOperation to specify that stencil value must be kept */
  41903. static readonly KEEP: number;
  41904. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41905. static readonly REPLACE: number;
  41906. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41907. static readonly INCR: number;
  41908. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41909. static readonly DECR: number;
  41910. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41911. static readonly INVERT: number;
  41912. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41913. static readonly INCR_WRAP: number;
  41914. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41915. static readonly DECR_WRAP: number;
  41916. /** Texture is not repeating outside of 0..1 UVs */
  41917. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41918. /** Texture is repeating outside of 0..1 UVs */
  41919. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41920. /** Texture is repeating and mirrored */
  41921. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41922. /** ALPHA */
  41923. static readonly TEXTUREFORMAT_ALPHA: number;
  41924. /** LUMINANCE */
  41925. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41926. /** LUMINANCE_ALPHA */
  41927. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41928. /** RGB */
  41929. static readonly TEXTUREFORMAT_RGB: number;
  41930. /** RGBA */
  41931. static readonly TEXTUREFORMAT_RGBA: number;
  41932. /** RED */
  41933. static readonly TEXTUREFORMAT_RED: number;
  41934. /** RED (2nd reference) */
  41935. static readonly TEXTUREFORMAT_R: number;
  41936. /** RG */
  41937. static readonly TEXTUREFORMAT_RG: number;
  41938. /** RED_INTEGER */
  41939. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41940. /** RED_INTEGER (2nd reference) */
  41941. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41942. /** RG_INTEGER */
  41943. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41944. /** RGB_INTEGER */
  41945. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41946. /** RGBA_INTEGER */
  41947. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41948. /** UNSIGNED_BYTE */
  41949. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41950. /** UNSIGNED_BYTE (2nd reference) */
  41951. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41952. /** FLOAT */
  41953. static readonly TEXTURETYPE_FLOAT: number;
  41954. /** HALF_FLOAT */
  41955. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41956. /** BYTE */
  41957. static readonly TEXTURETYPE_BYTE: number;
  41958. /** SHORT */
  41959. static readonly TEXTURETYPE_SHORT: number;
  41960. /** UNSIGNED_SHORT */
  41961. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41962. /** INT */
  41963. static readonly TEXTURETYPE_INT: number;
  41964. /** UNSIGNED_INT */
  41965. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41966. /** UNSIGNED_SHORT_4_4_4_4 */
  41967. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41968. /** UNSIGNED_SHORT_5_5_5_1 */
  41969. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41970. /** UNSIGNED_SHORT_5_6_5 */
  41971. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41972. /** UNSIGNED_INT_2_10_10_10_REV */
  41973. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41974. /** UNSIGNED_INT_24_8 */
  41975. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41976. /** UNSIGNED_INT_10F_11F_11F_REV */
  41977. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41978. /** UNSIGNED_INT_5_9_9_9_REV */
  41979. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41980. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41981. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41982. /** nearest is mag = nearest and min = nearest and mip = linear */
  41983. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41984. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41985. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41986. /** Trilinear is mag = linear and min = linear and mip = linear */
  41987. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41988. /** nearest is mag = nearest and min = nearest and mip = linear */
  41989. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41990. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41991. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41992. /** Trilinear is mag = linear and min = linear and mip = linear */
  41993. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41994. /** mag = nearest and min = nearest and mip = nearest */
  41995. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41996. /** mag = nearest and min = linear and mip = nearest */
  41997. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41998. /** mag = nearest and min = linear and mip = linear */
  41999. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42000. /** mag = nearest and min = linear and mip = none */
  42001. static readonly TEXTURE_NEAREST_LINEAR: number;
  42002. /** mag = nearest and min = nearest and mip = none */
  42003. static readonly TEXTURE_NEAREST_NEAREST: number;
  42004. /** mag = linear and min = nearest and mip = nearest */
  42005. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42006. /** mag = linear and min = nearest and mip = linear */
  42007. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42008. /** mag = linear and min = linear and mip = none */
  42009. static readonly TEXTURE_LINEAR_LINEAR: number;
  42010. /** mag = linear and min = nearest and mip = none */
  42011. static readonly TEXTURE_LINEAR_NEAREST: number;
  42012. /** Explicit coordinates mode */
  42013. static readonly TEXTURE_EXPLICIT_MODE: number;
  42014. /** Spherical coordinates mode */
  42015. static readonly TEXTURE_SPHERICAL_MODE: number;
  42016. /** Planar coordinates mode */
  42017. static readonly TEXTURE_PLANAR_MODE: number;
  42018. /** Cubic coordinates mode */
  42019. static readonly TEXTURE_CUBIC_MODE: number;
  42020. /** Projection coordinates mode */
  42021. static readonly TEXTURE_PROJECTION_MODE: number;
  42022. /** Skybox coordinates mode */
  42023. static readonly TEXTURE_SKYBOX_MODE: number;
  42024. /** Inverse Cubic coordinates mode */
  42025. static readonly TEXTURE_INVCUBIC_MODE: number;
  42026. /** Equirectangular coordinates mode */
  42027. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42028. /** Equirectangular Fixed coordinates mode */
  42029. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42030. /** Equirectangular Fixed Mirrored coordinates mode */
  42031. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42032. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42033. static readonly SCALEMODE_FLOOR: number;
  42034. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42035. static readonly SCALEMODE_NEAREST: number;
  42036. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42037. static readonly SCALEMODE_CEILING: number;
  42038. /**
  42039. * Returns the current npm package of the sdk
  42040. */
  42041. static get NpmPackage(): string;
  42042. /**
  42043. * Returns the current version of the framework
  42044. */
  42045. static get Version(): string;
  42046. /** Gets the list of created engines */
  42047. static get Instances(): Engine[];
  42048. /**
  42049. * Gets the latest created engine
  42050. */
  42051. static get LastCreatedEngine(): Nullable<Engine>;
  42052. /**
  42053. * Gets the latest created scene
  42054. */
  42055. static get LastCreatedScene(): Nullable<Scene>;
  42056. /**
  42057. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42058. * @param flag defines which part of the materials must be marked as dirty
  42059. * @param predicate defines a predicate used to filter which materials should be affected
  42060. */
  42061. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42062. /**
  42063. * Method called to create the default loading screen.
  42064. * This can be overriden in your own app.
  42065. * @param canvas The rendering canvas element
  42066. * @returns The loading screen
  42067. */
  42068. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42069. /**
  42070. * Method called to create the default rescale post process on each engine.
  42071. */
  42072. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42073. /**
  42074. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42075. **/
  42076. enableOfflineSupport: boolean;
  42077. /**
  42078. * 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)
  42079. **/
  42080. disableManifestCheck: boolean;
  42081. /**
  42082. * Gets the list of created scenes
  42083. */
  42084. scenes: Scene[];
  42085. /**
  42086. * Event raised when a new scene is created
  42087. */
  42088. onNewSceneAddedObservable: Observable<Scene>;
  42089. /**
  42090. * Gets the list of created postprocesses
  42091. */
  42092. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42093. /**
  42094. * Gets a boolean indicating if the pointer is currently locked
  42095. */
  42096. isPointerLock: boolean;
  42097. /**
  42098. * Observable event triggered each time the rendering canvas is resized
  42099. */
  42100. onResizeObservable: Observable<Engine>;
  42101. /**
  42102. * Observable event triggered each time the canvas loses focus
  42103. */
  42104. onCanvasBlurObservable: Observable<Engine>;
  42105. /**
  42106. * Observable event triggered each time the canvas gains focus
  42107. */
  42108. onCanvasFocusObservable: Observable<Engine>;
  42109. /**
  42110. * Observable event triggered each time the canvas receives pointerout event
  42111. */
  42112. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42113. /**
  42114. * Observable raised when the engine begins a new frame
  42115. */
  42116. onBeginFrameObservable: Observable<Engine>;
  42117. /**
  42118. * If set, will be used to request the next animation frame for the render loop
  42119. */
  42120. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42121. /**
  42122. * Observable raised when the engine ends the current frame
  42123. */
  42124. onEndFrameObservable: Observable<Engine>;
  42125. /**
  42126. * Observable raised when the engine is about to compile a shader
  42127. */
  42128. onBeforeShaderCompilationObservable: Observable<Engine>;
  42129. /**
  42130. * Observable raised when the engine has jsut compiled a shader
  42131. */
  42132. onAfterShaderCompilationObservable: Observable<Engine>;
  42133. /**
  42134. * Gets the audio engine
  42135. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42136. * @ignorenaming
  42137. */
  42138. static audioEngine: IAudioEngine;
  42139. /**
  42140. * Default AudioEngine factory responsible of creating the Audio Engine.
  42141. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42142. */
  42143. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42144. /**
  42145. * Default offline support factory responsible of creating a tool used to store data locally.
  42146. * By default, this will create a Database object if the workload has been embedded.
  42147. */
  42148. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42149. private _loadingScreen;
  42150. private _pointerLockRequested;
  42151. private _rescalePostProcess;
  42152. private _deterministicLockstep;
  42153. private _lockstepMaxSteps;
  42154. private _timeStep;
  42155. protected get _supportsHardwareTextureRescaling(): boolean;
  42156. private _fps;
  42157. private _deltaTime;
  42158. /** @hidden */
  42159. _drawCalls: PerfCounter;
  42160. /** 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 */
  42161. canvasTabIndex: number;
  42162. /**
  42163. * Turn this value on if you want to pause FPS computation when in background
  42164. */
  42165. disablePerformanceMonitorInBackground: boolean;
  42166. private _performanceMonitor;
  42167. /**
  42168. * Gets the performance monitor attached to this engine
  42169. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42170. */
  42171. get performanceMonitor(): PerformanceMonitor;
  42172. private _onFocus;
  42173. private _onBlur;
  42174. private _onCanvasPointerOut;
  42175. private _onCanvasBlur;
  42176. private _onCanvasFocus;
  42177. private _onFullscreenChange;
  42178. private _onPointerLockChange;
  42179. /**
  42180. * Gets the HTML element used to attach event listeners
  42181. * @returns a HTML element
  42182. */
  42183. getInputElement(): Nullable<HTMLElement>;
  42184. /**
  42185. * Creates a new engine
  42186. * @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
  42187. * @param antialias defines enable antialiasing (default: false)
  42188. * @param options defines further options to be sent to the getContext() function
  42189. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42190. */
  42191. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42192. /**
  42193. * Gets current aspect ratio
  42194. * @param viewportOwner defines the camera to use to get the aspect ratio
  42195. * @param useScreen defines if screen size must be used (or the current render target if any)
  42196. * @returns a number defining the aspect ratio
  42197. */
  42198. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42199. /**
  42200. * Gets current screen aspect ratio
  42201. * @returns a number defining the aspect ratio
  42202. */
  42203. getScreenAspectRatio(): number;
  42204. /**
  42205. * Gets the client rect of the HTML canvas attached with the current webGL context
  42206. * @returns a client rectanglee
  42207. */
  42208. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42209. /**
  42210. * Gets the client rect of the HTML element used for events
  42211. * @returns a client rectanglee
  42212. */
  42213. getInputElementClientRect(): Nullable<ClientRect>;
  42214. /**
  42215. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42216. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42217. * @returns true if engine is in deterministic lock step mode
  42218. */
  42219. isDeterministicLockStep(): boolean;
  42220. /**
  42221. * Gets the max steps when engine is running in deterministic lock step
  42222. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42223. * @returns the max steps
  42224. */
  42225. getLockstepMaxSteps(): number;
  42226. /**
  42227. * Returns the time in ms between steps when using deterministic lock step.
  42228. * @returns time step in (ms)
  42229. */
  42230. getTimeStep(): number;
  42231. /**
  42232. * Force the mipmap generation for the given render target texture
  42233. * @param texture defines the render target texture to use
  42234. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42235. */
  42236. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42237. /** States */
  42238. /**
  42239. * Set various states to the webGL context
  42240. * @param culling defines backface culling state
  42241. * @param zOffset defines the value to apply to zOffset (0 by default)
  42242. * @param force defines if states must be applied even if cache is up to date
  42243. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42244. */
  42245. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42246. /**
  42247. * Set the z offset to apply to current rendering
  42248. * @param value defines the offset to apply
  42249. */
  42250. setZOffset(value: number): void;
  42251. /**
  42252. * Gets the current value of the zOffset
  42253. * @returns the current zOffset state
  42254. */
  42255. getZOffset(): number;
  42256. /**
  42257. * Enable or disable depth buffering
  42258. * @param enable defines the state to set
  42259. */
  42260. setDepthBuffer(enable: boolean): void;
  42261. /**
  42262. * Gets a boolean indicating if depth writing is enabled
  42263. * @returns the current depth writing state
  42264. */
  42265. getDepthWrite(): boolean;
  42266. /**
  42267. * Enable or disable depth writing
  42268. * @param enable defines the state to set
  42269. */
  42270. setDepthWrite(enable: boolean): void;
  42271. /**
  42272. * Gets a boolean indicating if stencil buffer is enabled
  42273. * @returns the current stencil buffer state
  42274. */
  42275. getStencilBuffer(): boolean;
  42276. /**
  42277. * Enable or disable the stencil buffer
  42278. * @param enable defines if the stencil buffer must be enabled or disabled
  42279. */
  42280. setStencilBuffer(enable: boolean): void;
  42281. /**
  42282. * Gets the current stencil mask
  42283. * @returns a number defining the new stencil mask to use
  42284. */
  42285. getStencilMask(): number;
  42286. /**
  42287. * Sets the current stencil mask
  42288. * @param mask defines the new stencil mask to use
  42289. */
  42290. setStencilMask(mask: number): void;
  42291. /**
  42292. * Gets the current stencil function
  42293. * @returns a number defining the stencil function to use
  42294. */
  42295. getStencilFunction(): number;
  42296. /**
  42297. * Gets the current stencil reference value
  42298. * @returns a number defining the stencil reference value to use
  42299. */
  42300. getStencilFunctionReference(): number;
  42301. /**
  42302. * Gets the current stencil mask
  42303. * @returns a number defining the stencil mask to use
  42304. */
  42305. getStencilFunctionMask(): number;
  42306. /**
  42307. * Sets the current stencil function
  42308. * @param stencilFunc defines the new stencil function to use
  42309. */
  42310. setStencilFunction(stencilFunc: number): void;
  42311. /**
  42312. * Sets the current stencil reference
  42313. * @param reference defines the new stencil reference to use
  42314. */
  42315. setStencilFunctionReference(reference: number): void;
  42316. /**
  42317. * Sets the current stencil mask
  42318. * @param mask defines the new stencil mask to use
  42319. */
  42320. setStencilFunctionMask(mask: number): void;
  42321. /**
  42322. * Gets the current stencil operation when stencil fails
  42323. * @returns a number defining stencil operation to use when stencil fails
  42324. */
  42325. getStencilOperationFail(): number;
  42326. /**
  42327. * Gets the current stencil operation when depth fails
  42328. * @returns a number defining stencil operation to use when depth fails
  42329. */
  42330. getStencilOperationDepthFail(): number;
  42331. /**
  42332. * Gets the current stencil operation when stencil passes
  42333. * @returns a number defining stencil operation to use when stencil passes
  42334. */
  42335. getStencilOperationPass(): number;
  42336. /**
  42337. * Sets the stencil operation to use when stencil fails
  42338. * @param operation defines the stencil operation to use when stencil fails
  42339. */
  42340. setStencilOperationFail(operation: number): void;
  42341. /**
  42342. * Sets the stencil operation to use when depth fails
  42343. * @param operation defines the stencil operation to use when depth fails
  42344. */
  42345. setStencilOperationDepthFail(operation: number): void;
  42346. /**
  42347. * Sets the stencil operation to use when stencil passes
  42348. * @param operation defines the stencil operation to use when stencil passes
  42349. */
  42350. setStencilOperationPass(operation: number): void;
  42351. /**
  42352. * Sets a boolean indicating if the dithering state is enabled or disabled
  42353. * @param value defines the dithering state
  42354. */
  42355. setDitheringState(value: boolean): void;
  42356. /**
  42357. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42358. * @param value defines the rasterizer state
  42359. */
  42360. setRasterizerState(value: boolean): void;
  42361. /**
  42362. * Gets the current depth function
  42363. * @returns a number defining the depth function
  42364. */
  42365. getDepthFunction(): Nullable<number>;
  42366. /**
  42367. * Sets the current depth function
  42368. * @param depthFunc defines the function to use
  42369. */
  42370. setDepthFunction(depthFunc: number): void;
  42371. /**
  42372. * Sets the current depth function to GREATER
  42373. */
  42374. setDepthFunctionToGreater(): void;
  42375. /**
  42376. * Sets the current depth function to GEQUAL
  42377. */
  42378. setDepthFunctionToGreaterOrEqual(): void;
  42379. /**
  42380. * Sets the current depth function to LESS
  42381. */
  42382. setDepthFunctionToLess(): void;
  42383. /**
  42384. * Sets the current depth function to LEQUAL
  42385. */
  42386. setDepthFunctionToLessOrEqual(): void;
  42387. private _cachedStencilBuffer;
  42388. private _cachedStencilFunction;
  42389. private _cachedStencilMask;
  42390. private _cachedStencilOperationPass;
  42391. private _cachedStencilOperationFail;
  42392. private _cachedStencilOperationDepthFail;
  42393. private _cachedStencilReference;
  42394. /**
  42395. * Caches the the state of the stencil buffer
  42396. */
  42397. cacheStencilState(): void;
  42398. /**
  42399. * Restores the state of the stencil buffer
  42400. */
  42401. restoreStencilState(): void;
  42402. /**
  42403. * Directly set the WebGL Viewport
  42404. * @param x defines the x coordinate of the viewport (in screen space)
  42405. * @param y defines the y coordinate of the viewport (in screen space)
  42406. * @param width defines the width of the viewport (in screen space)
  42407. * @param height defines the height of the viewport (in screen space)
  42408. * @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
  42409. */
  42410. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42411. /**
  42412. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42413. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42414. * @param y defines the y-coordinate of the corner of the clear rectangle
  42415. * @param width defines the width of the clear rectangle
  42416. * @param height defines the height of the clear rectangle
  42417. * @param clearColor defines the clear color
  42418. */
  42419. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42420. /**
  42421. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42422. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42423. * @param y defines the y-coordinate of the corner of the clear rectangle
  42424. * @param width defines the width of the clear rectangle
  42425. * @param height defines the height of the clear rectangle
  42426. */
  42427. enableScissor(x: number, y: number, width: number, height: number): void;
  42428. /**
  42429. * Disable previously set scissor test rectangle
  42430. */
  42431. disableScissor(): void;
  42432. protected _reportDrawCall(): void;
  42433. /**
  42434. * Initializes a webVR display and starts listening to display change events
  42435. * The onVRDisplayChangedObservable will be notified upon these changes
  42436. * @returns The onVRDisplayChangedObservable
  42437. */
  42438. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42439. /** @hidden */
  42440. _prepareVRComponent(): void;
  42441. /** @hidden */
  42442. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42443. /** @hidden */
  42444. _submitVRFrame(): void;
  42445. /**
  42446. * Call this function to leave webVR mode
  42447. * Will do nothing if webVR is not supported or if there is no webVR device
  42448. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42449. */
  42450. disableVR(): void;
  42451. /**
  42452. * Gets a boolean indicating that the system is in VR mode and is presenting
  42453. * @returns true if VR mode is engaged
  42454. */
  42455. isVRPresenting(): boolean;
  42456. /** @hidden */
  42457. _requestVRFrame(): void;
  42458. /** @hidden */
  42459. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42460. /**
  42461. * Gets the source code of the vertex shader associated with a specific webGL program
  42462. * @param program defines the program to use
  42463. * @returns a string containing the source code of the vertex shader associated with the program
  42464. */
  42465. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42466. /**
  42467. * Gets the source code of the fragment shader associated with a specific webGL program
  42468. * @param program defines the program to use
  42469. * @returns a string containing the source code of the fragment shader associated with the program
  42470. */
  42471. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42472. /**
  42473. * Sets a depth stencil texture from a render target to the according uniform.
  42474. * @param channel The texture channel
  42475. * @param uniform The uniform to set
  42476. * @param texture The render target texture containing the depth stencil texture to apply
  42477. */
  42478. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42479. /**
  42480. * Sets a texture to the webGL context from a postprocess
  42481. * @param channel defines the channel to use
  42482. * @param postProcess defines the source postprocess
  42483. */
  42484. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42485. /**
  42486. * Binds the output of the passed in post process to the texture channel specified
  42487. * @param channel The channel the texture should be bound to
  42488. * @param postProcess The post process which's output should be bound
  42489. */
  42490. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42491. protected _rebuildBuffers(): void;
  42492. /** @hidden */
  42493. _renderFrame(): void;
  42494. _renderLoop(): void;
  42495. /** @hidden */
  42496. _renderViews(): boolean;
  42497. /**
  42498. * Toggle full screen mode
  42499. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42500. */
  42501. switchFullscreen(requestPointerLock: boolean): void;
  42502. /**
  42503. * Enters full screen mode
  42504. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42505. */
  42506. enterFullscreen(requestPointerLock: boolean): void;
  42507. /**
  42508. * Exits full screen mode
  42509. */
  42510. exitFullscreen(): void;
  42511. /**
  42512. * Enters Pointerlock mode
  42513. */
  42514. enterPointerlock(): void;
  42515. /**
  42516. * Exits Pointerlock mode
  42517. */
  42518. exitPointerlock(): void;
  42519. /**
  42520. * Begin a new frame
  42521. */
  42522. beginFrame(): void;
  42523. /**
  42524. * Enf the current frame
  42525. */
  42526. endFrame(): void;
  42527. resize(): void;
  42528. /**
  42529. * Force a specific size of the canvas
  42530. * @param width defines the new canvas' width
  42531. * @param height defines the new canvas' height
  42532. * @returns true if the size was changed
  42533. */
  42534. setSize(width: number, height: number): boolean;
  42535. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42536. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42537. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42538. _releaseTexture(texture: InternalTexture): void;
  42539. /**
  42540. * @hidden
  42541. * Rescales a texture
  42542. * @param source input texutre
  42543. * @param destination destination texture
  42544. * @param scene scene to use to render the resize
  42545. * @param internalFormat format to use when resizing
  42546. * @param onComplete callback to be called when resize has completed
  42547. */
  42548. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42549. /**
  42550. * Gets the current framerate
  42551. * @returns a number representing the framerate
  42552. */
  42553. getFps(): number;
  42554. /**
  42555. * Gets the time spent between current and previous frame
  42556. * @returns a number representing the delta time in ms
  42557. */
  42558. getDeltaTime(): number;
  42559. private _measureFps;
  42560. /** @hidden */
  42561. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42562. /**
  42563. * Updates the sample count of a render target texture
  42564. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42565. * @param texture defines the texture to update
  42566. * @param samples defines the sample count to set
  42567. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42568. */
  42569. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42570. /**
  42571. * Updates a depth texture Comparison Mode and Function.
  42572. * If the comparison Function is equal to 0, the mode will be set to none.
  42573. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42574. * @param texture The texture to set the comparison function for
  42575. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42576. */
  42577. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42578. /**
  42579. * Creates a webGL buffer to use with instanciation
  42580. * @param capacity defines the size of the buffer
  42581. * @returns the webGL buffer
  42582. */
  42583. createInstancesBuffer(capacity: number): DataBuffer;
  42584. /**
  42585. * Delete a webGL buffer used with instanciation
  42586. * @param buffer defines the webGL buffer to delete
  42587. */
  42588. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42589. private _clientWaitAsync;
  42590. /** @hidden */
  42591. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42592. dispose(): void;
  42593. private _disableTouchAction;
  42594. /**
  42595. * Display the loading screen
  42596. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42597. */
  42598. displayLoadingUI(): void;
  42599. /**
  42600. * Hide the loading screen
  42601. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42602. */
  42603. hideLoadingUI(): void;
  42604. /**
  42605. * Gets the current loading screen object
  42606. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42607. */
  42608. get loadingScreen(): ILoadingScreen;
  42609. /**
  42610. * Sets the current loading screen object
  42611. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42612. */
  42613. set loadingScreen(loadingScreen: ILoadingScreen);
  42614. /**
  42615. * Sets the current loading screen text
  42616. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42617. */
  42618. set loadingUIText(text: string);
  42619. /**
  42620. * Sets the current loading screen background color
  42621. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42622. */
  42623. set loadingUIBackgroundColor(color: string);
  42624. /** Pointerlock and fullscreen */
  42625. /**
  42626. * Ask the browser to promote the current element to pointerlock mode
  42627. * @param element defines the DOM element to promote
  42628. */
  42629. static _RequestPointerlock(element: HTMLElement): void;
  42630. /**
  42631. * Asks the browser to exit pointerlock mode
  42632. */
  42633. static _ExitPointerlock(): void;
  42634. /**
  42635. * Ask the browser to promote the current element to fullscreen rendering mode
  42636. * @param element defines the DOM element to promote
  42637. */
  42638. static _RequestFullscreen(element: HTMLElement): void;
  42639. /**
  42640. * Asks the browser to exit fullscreen mode
  42641. */
  42642. static _ExitFullscreen(): void;
  42643. }
  42644. }
  42645. declare module "babylonjs/Engines/engineStore" {
  42646. import { Nullable } from "babylonjs/types";
  42647. import { Engine } from "babylonjs/Engines/engine";
  42648. import { Scene } from "babylonjs/scene";
  42649. /**
  42650. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42651. * during the life time of the application.
  42652. */
  42653. export class EngineStore {
  42654. /** Gets the list of created engines */
  42655. static Instances: import("babylonjs/Engines/engine").Engine[];
  42656. /** @hidden */
  42657. static _LastCreatedScene: Nullable<Scene>;
  42658. /**
  42659. * Gets the latest created engine
  42660. */
  42661. static get LastCreatedEngine(): Nullable<Engine>;
  42662. /**
  42663. * Gets the latest created scene
  42664. */
  42665. static get LastCreatedScene(): Nullable<Scene>;
  42666. /**
  42667. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42668. * @ignorenaming
  42669. */
  42670. static UseFallbackTexture: boolean;
  42671. /**
  42672. * Texture content used if a texture cannot loaded
  42673. * @ignorenaming
  42674. */
  42675. static FallbackTexture: string;
  42676. }
  42677. }
  42678. declare module "babylonjs/Misc/promise" {
  42679. /**
  42680. * Helper class that provides a small promise polyfill
  42681. */
  42682. export class PromisePolyfill {
  42683. /**
  42684. * Static function used to check if the polyfill is required
  42685. * If this is the case then the function will inject the polyfill to window.Promise
  42686. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42687. */
  42688. static Apply(force?: boolean): void;
  42689. }
  42690. }
  42691. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  42692. /**
  42693. * Interface for screenshot methods with describe argument called `size` as object with options
  42694. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42695. */
  42696. export interface IScreenshotSize {
  42697. /**
  42698. * number in pixels for canvas height
  42699. */
  42700. height?: number;
  42701. /**
  42702. * multiplier allowing render at a higher or lower resolution
  42703. * If value is defined then height and width will be ignored and taken from camera
  42704. */
  42705. precision?: number;
  42706. /**
  42707. * number in pixels for canvas width
  42708. */
  42709. width?: number;
  42710. }
  42711. }
  42712. declare module "babylonjs/Misc/tools" {
  42713. import { Nullable, float } from "babylonjs/types";
  42714. import { DomManagement } from "babylonjs/Misc/domManagement";
  42715. import { WebRequest } from "babylonjs/Misc/webRequest";
  42716. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  42717. import { ReadFileError } from "babylonjs/Misc/fileTools";
  42718. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42719. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  42720. import { Camera } from "babylonjs/Cameras/camera";
  42721. import { Engine } from "babylonjs/Engines/engine";
  42722. interface IColor4Like {
  42723. r: float;
  42724. g: float;
  42725. b: float;
  42726. a: float;
  42727. }
  42728. /**
  42729. * Class containing a set of static utilities functions
  42730. */
  42731. export class Tools {
  42732. /**
  42733. * Gets or sets the base URL to use to load assets
  42734. */
  42735. static get BaseUrl(): string;
  42736. static set BaseUrl(value: string);
  42737. /**
  42738. * Enable/Disable Custom HTTP Request Headers globally.
  42739. * default = false
  42740. * @see CustomRequestHeaders
  42741. */
  42742. static UseCustomRequestHeaders: boolean;
  42743. /**
  42744. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42745. * i.e. when loading files, where the server/service expects an Authorization header
  42746. */
  42747. static CustomRequestHeaders: {
  42748. [key: string]: string;
  42749. };
  42750. /**
  42751. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42752. */
  42753. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42754. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42755. /**
  42756. * Default behaviour for cors in the application.
  42757. * It can be a string if the expected behavior is identical in the entire app.
  42758. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42759. */
  42760. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42761. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42762. /**
  42763. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42764. * @ignorenaming
  42765. */
  42766. static get UseFallbackTexture(): boolean;
  42767. static set UseFallbackTexture(value: boolean);
  42768. /**
  42769. * Use this object to register external classes like custom textures or material
  42770. * to allow the laoders to instantiate them
  42771. */
  42772. static get RegisteredExternalClasses(): {
  42773. [key: string]: Object;
  42774. };
  42775. static set RegisteredExternalClasses(classes: {
  42776. [key: string]: Object;
  42777. });
  42778. /**
  42779. * Texture content used if a texture cannot loaded
  42780. * @ignorenaming
  42781. */
  42782. static get fallbackTexture(): string;
  42783. static set fallbackTexture(value: string);
  42784. /**
  42785. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42786. * @param u defines the coordinate on X axis
  42787. * @param v defines the coordinate on Y axis
  42788. * @param width defines the width of the source data
  42789. * @param height defines the height of the source data
  42790. * @param pixels defines the source byte array
  42791. * @param color defines the output color
  42792. */
  42793. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42794. /**
  42795. * Interpolates between a and b via alpha
  42796. * @param a The lower value (returned when alpha = 0)
  42797. * @param b The upper value (returned when alpha = 1)
  42798. * @param alpha The interpolation-factor
  42799. * @return The mixed value
  42800. */
  42801. static Mix(a: number, b: number, alpha: number): number;
  42802. /**
  42803. * Tries to instantiate a new object from a given class name
  42804. * @param className defines the class name to instantiate
  42805. * @returns the new object or null if the system was not able to do the instantiation
  42806. */
  42807. static Instantiate(className: string): any;
  42808. /**
  42809. * Provides a slice function that will work even on IE
  42810. * @param data defines the array to slice
  42811. * @param start defines the start of the data (optional)
  42812. * @param end defines the end of the data (optional)
  42813. * @returns the new sliced array
  42814. */
  42815. static Slice<T>(data: T, start?: number, end?: number): T;
  42816. /**
  42817. * Polyfill for setImmediate
  42818. * @param action defines the action to execute after the current execution block
  42819. */
  42820. static SetImmediate(action: () => void): void;
  42821. /**
  42822. * Function indicating if a number is an exponent of 2
  42823. * @param value defines the value to test
  42824. * @returns true if the value is an exponent of 2
  42825. */
  42826. static IsExponentOfTwo(value: number): boolean;
  42827. private static _tmpFloatArray;
  42828. /**
  42829. * Returns the nearest 32-bit single precision float representation of a Number
  42830. * @param value A Number. If the parameter is of a different type, it will get converted
  42831. * to a number or to NaN if it cannot be converted
  42832. * @returns number
  42833. */
  42834. static FloatRound(value: number): number;
  42835. /**
  42836. * Extracts the filename from a path
  42837. * @param path defines the path to use
  42838. * @returns the filename
  42839. */
  42840. static GetFilename(path: string): string;
  42841. /**
  42842. * Extracts the "folder" part of a path (everything before the filename).
  42843. * @param uri The URI to extract the info from
  42844. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42845. * @returns The "folder" part of the path
  42846. */
  42847. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42848. /**
  42849. * Extracts text content from a DOM element hierarchy
  42850. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42851. */
  42852. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42853. /**
  42854. * Convert an angle in radians to degrees
  42855. * @param angle defines the angle to convert
  42856. * @returns the angle in degrees
  42857. */
  42858. static ToDegrees(angle: number): number;
  42859. /**
  42860. * Convert an angle in degrees to radians
  42861. * @param angle defines the angle to convert
  42862. * @returns the angle in radians
  42863. */
  42864. static ToRadians(angle: number): number;
  42865. /**
  42866. * Returns an array if obj is not an array
  42867. * @param obj defines the object to evaluate as an array
  42868. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42869. * @returns either obj directly if obj is an array or a new array containing obj
  42870. */
  42871. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42872. /**
  42873. * Gets the pointer prefix to use
  42874. * @param engine defines the engine we are finding the prefix for
  42875. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42876. */
  42877. static GetPointerPrefix(engine: Engine): string;
  42878. /**
  42879. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42880. * @param url define the url we are trying
  42881. * @param element define the dom element where to configure the cors policy
  42882. */
  42883. static SetCorsBehavior(url: string | string[], element: {
  42884. crossOrigin: string | null;
  42885. }): void;
  42886. /**
  42887. * Removes unwanted characters from an url
  42888. * @param url defines the url to clean
  42889. * @returns the cleaned url
  42890. */
  42891. static CleanUrl(url: string): string;
  42892. /**
  42893. * Gets or sets a function used to pre-process url before using them to load assets
  42894. */
  42895. static get PreprocessUrl(): (url: string) => string;
  42896. static set PreprocessUrl(processor: (url: string) => string);
  42897. /**
  42898. * Loads an image as an HTMLImageElement.
  42899. * @param input url string, ArrayBuffer, or Blob to load
  42900. * @param onLoad callback called when the image successfully loads
  42901. * @param onError callback called when the image fails to load
  42902. * @param offlineProvider offline provider for caching
  42903. * @param mimeType optional mime type
  42904. * @returns the HTMLImageElement of the loaded image
  42905. */
  42906. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42907. /**
  42908. * Loads a file from a url
  42909. * @param url url string, ArrayBuffer, or Blob to load
  42910. * @param onSuccess callback called when the file successfully loads
  42911. * @param onProgress callback called while file is loading (if the server supports this mode)
  42912. * @param offlineProvider defines the offline provider for caching
  42913. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42914. * @param onError callback called when the file fails to load
  42915. * @returns a file request object
  42916. */
  42917. 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;
  42918. /**
  42919. * Loads a file from a url
  42920. * @param url the file url to load
  42921. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42922. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42923. */
  42924. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42925. /**
  42926. * Load a script (identified by an url). When the url returns, the
  42927. * content of this file is added into a new script element, attached to the DOM (body element)
  42928. * @param scriptUrl defines the url of the script to laod
  42929. * @param onSuccess defines the callback called when the script is loaded
  42930. * @param onError defines the callback to call if an error occurs
  42931. * @param scriptId defines the id of the script element
  42932. */
  42933. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42934. /**
  42935. * Load an asynchronous script (identified by an url). When the url returns, the
  42936. * content of this file is added into a new script element, attached to the DOM (body element)
  42937. * @param scriptUrl defines the url of the script to laod
  42938. * @param scriptId defines the id of the script element
  42939. * @returns a promise request object
  42940. */
  42941. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42942. /**
  42943. * Loads a file from a blob
  42944. * @param fileToLoad defines the blob to use
  42945. * @param callback defines the callback to call when data is loaded
  42946. * @param progressCallback defines the callback to call during loading process
  42947. * @returns a file request object
  42948. */
  42949. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42950. /**
  42951. * Reads a file from a File object
  42952. * @param file defines the file to load
  42953. * @param onSuccess defines the callback to call when data is loaded
  42954. * @param onProgress defines the callback to call during loading process
  42955. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42956. * @param onError defines the callback to call when an error occurs
  42957. * @returns a file request object
  42958. */
  42959. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42960. /**
  42961. * Creates a data url from a given string content
  42962. * @param content defines the content to convert
  42963. * @returns the new data url link
  42964. */
  42965. static FileAsURL(content: string): string;
  42966. /**
  42967. * Format the given number to a specific decimal format
  42968. * @param value defines the number to format
  42969. * @param decimals defines the number of decimals to use
  42970. * @returns the formatted string
  42971. */
  42972. static Format(value: number, decimals?: number): string;
  42973. /**
  42974. * Tries to copy an object by duplicating every property
  42975. * @param source defines the source object
  42976. * @param destination defines the target object
  42977. * @param doNotCopyList defines a list of properties to avoid
  42978. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42979. */
  42980. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42981. /**
  42982. * Gets a boolean indicating if the given object has no own property
  42983. * @param obj defines the object to test
  42984. * @returns true if object has no own property
  42985. */
  42986. static IsEmpty(obj: any): boolean;
  42987. /**
  42988. * Function used to register events at window level
  42989. * @param windowElement defines the Window object to use
  42990. * @param events defines the events to register
  42991. */
  42992. static RegisterTopRootEvents(windowElement: Window, events: {
  42993. name: string;
  42994. handler: Nullable<(e: FocusEvent) => any>;
  42995. }[]): void;
  42996. /**
  42997. * Function used to unregister events from window level
  42998. * @param windowElement defines the Window object to use
  42999. * @param events defines the events to unregister
  43000. */
  43001. static UnregisterTopRootEvents(windowElement: Window, events: {
  43002. name: string;
  43003. handler: Nullable<(e: FocusEvent) => any>;
  43004. }[]): void;
  43005. /**
  43006. * @ignore
  43007. */
  43008. static _ScreenshotCanvas: HTMLCanvasElement;
  43009. /**
  43010. * Dumps the current bound framebuffer
  43011. * @param width defines the rendering width
  43012. * @param height defines the rendering height
  43013. * @param engine defines the hosting engine
  43014. * @param successCallback defines the callback triggered once the data are available
  43015. * @param mimeType defines the mime type of the result
  43016. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43017. */
  43018. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43019. /**
  43020. * Converts the canvas data to blob.
  43021. * This acts as a polyfill for browsers not supporting the to blob function.
  43022. * @param canvas Defines the canvas to extract the data from
  43023. * @param successCallback Defines the callback triggered once the data are available
  43024. * @param mimeType Defines the mime type of the result
  43025. */
  43026. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43027. /**
  43028. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43029. * @param successCallback defines the callback triggered once the data are available
  43030. * @param mimeType defines the mime type of the result
  43031. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43032. */
  43033. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43034. /**
  43035. * Downloads a blob in the browser
  43036. * @param blob defines the blob to download
  43037. * @param fileName defines the name of the downloaded file
  43038. */
  43039. static Download(blob: Blob, fileName: string): void;
  43040. /**
  43041. * Captures a screenshot of the current rendering
  43042. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43043. * @param engine defines the rendering engine
  43044. * @param camera defines the source camera
  43045. * @param size This parameter can be set to a single number or to an object with the
  43046. * following (optional) properties: precision, width, height. If a single number is passed,
  43047. * it will be used for both width and height. If an object is passed, the screenshot size
  43048. * will be derived from the parameters. The precision property is a multiplier allowing
  43049. * rendering at a higher or lower resolution
  43050. * @param successCallback defines the callback receives a single parameter which contains the
  43051. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43052. * src parameter of an <img> to display it
  43053. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43054. * Check your browser for supported MIME types
  43055. */
  43056. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43057. /**
  43058. * Captures a screenshot of the current rendering
  43059. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43060. * @param engine defines the rendering engine
  43061. * @param camera defines the source camera
  43062. * @param size This parameter can be set to a single number or to an object with the
  43063. * following (optional) properties: precision, width, height. If a single number is passed,
  43064. * it will be used for both width and height. If an object is passed, the screenshot size
  43065. * will be derived from the parameters. The precision property is a multiplier allowing
  43066. * rendering at a higher or lower resolution
  43067. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43068. * Check your browser for supported MIME types
  43069. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43070. * to the src parameter of an <img> to display it
  43071. */
  43072. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43073. /**
  43074. * Generates an image screenshot from the specified camera.
  43075. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43076. * @param engine The engine to use for rendering
  43077. * @param camera The camera to use for rendering
  43078. * @param size This parameter can be set to a single number or to an object with the
  43079. * following (optional) properties: precision, width, height. If a single number is passed,
  43080. * it will be used for both width and height. If an object is passed, the screenshot size
  43081. * will be derived from the parameters. The precision property is a multiplier allowing
  43082. * rendering at a higher or lower resolution
  43083. * @param successCallback The callback receives a single parameter which contains the
  43084. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43085. * src parameter of an <img> to display it
  43086. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43087. * Check your browser for supported MIME types
  43088. * @param samples Texture samples (default: 1)
  43089. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43090. * @param fileName A name for for the downloaded file.
  43091. */
  43092. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43093. /**
  43094. * Generates an image screenshot from the specified camera.
  43095. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43096. * @param engine The engine to use for rendering
  43097. * @param camera The camera to use for rendering
  43098. * @param size This parameter can be set to a single number or to an object with the
  43099. * following (optional) properties: precision, width, height. If a single number is passed,
  43100. * it will be used for both width and height. If an object is passed, the screenshot size
  43101. * will be derived from the parameters. The precision property is a multiplier allowing
  43102. * rendering at a higher or lower resolution
  43103. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43104. * Check your browser for supported MIME types
  43105. * @param samples Texture samples (default: 1)
  43106. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43107. * @param fileName A name for for the downloaded file.
  43108. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43109. * to the src parameter of an <img> to display it
  43110. */
  43111. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43112. /**
  43113. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43114. * Be aware Math.random() could cause collisions, but:
  43115. * "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"
  43116. * @returns a pseudo random id
  43117. */
  43118. static RandomId(): string;
  43119. /**
  43120. * Test if the given uri is a base64 string
  43121. * @param uri The uri to test
  43122. * @return True if the uri is a base64 string or false otherwise
  43123. */
  43124. static IsBase64(uri: string): boolean;
  43125. /**
  43126. * Decode the given base64 uri.
  43127. * @param uri The uri to decode
  43128. * @return The decoded base64 data.
  43129. */
  43130. static DecodeBase64(uri: string): ArrayBuffer;
  43131. /**
  43132. * Gets the absolute url.
  43133. * @param url the input url
  43134. * @return the absolute url
  43135. */
  43136. static GetAbsoluteUrl(url: string): string;
  43137. /**
  43138. * No log
  43139. */
  43140. static readonly NoneLogLevel: number;
  43141. /**
  43142. * Only message logs
  43143. */
  43144. static readonly MessageLogLevel: number;
  43145. /**
  43146. * Only warning logs
  43147. */
  43148. static readonly WarningLogLevel: number;
  43149. /**
  43150. * Only error logs
  43151. */
  43152. static readonly ErrorLogLevel: number;
  43153. /**
  43154. * All logs
  43155. */
  43156. static readonly AllLogLevel: number;
  43157. /**
  43158. * Gets a value indicating the number of loading errors
  43159. * @ignorenaming
  43160. */
  43161. static get errorsCount(): number;
  43162. /**
  43163. * Callback called when a new log is added
  43164. */
  43165. static OnNewCacheEntry: (entry: string) => void;
  43166. /**
  43167. * Log a message to the console
  43168. * @param message defines the message to log
  43169. */
  43170. static Log(message: string): void;
  43171. /**
  43172. * Write a warning message to the console
  43173. * @param message defines the message to log
  43174. */
  43175. static Warn(message: string): void;
  43176. /**
  43177. * Write an error message to the console
  43178. * @param message defines the message to log
  43179. */
  43180. static Error(message: string): void;
  43181. /**
  43182. * Gets current log cache (list of logs)
  43183. */
  43184. static get LogCache(): string;
  43185. /**
  43186. * Clears the log cache
  43187. */
  43188. static ClearLogCache(): void;
  43189. /**
  43190. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43191. */
  43192. static set LogLevels(level: number);
  43193. /**
  43194. * Checks if the window object exists
  43195. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43196. */
  43197. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43198. /**
  43199. * No performance log
  43200. */
  43201. static readonly PerformanceNoneLogLevel: number;
  43202. /**
  43203. * Use user marks to log performance
  43204. */
  43205. static readonly PerformanceUserMarkLogLevel: number;
  43206. /**
  43207. * Log performance to the console
  43208. */
  43209. static readonly PerformanceConsoleLogLevel: number;
  43210. private static _performance;
  43211. /**
  43212. * Sets the current performance log level
  43213. */
  43214. static set PerformanceLogLevel(level: number);
  43215. private static _StartPerformanceCounterDisabled;
  43216. private static _EndPerformanceCounterDisabled;
  43217. private static _StartUserMark;
  43218. private static _EndUserMark;
  43219. private static _StartPerformanceConsole;
  43220. private static _EndPerformanceConsole;
  43221. /**
  43222. * Starts a performance counter
  43223. */
  43224. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43225. /**
  43226. * Ends a specific performance coutner
  43227. */
  43228. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43229. /**
  43230. * Gets either window.performance.now() if supported or Date.now() else
  43231. */
  43232. static get Now(): number;
  43233. /**
  43234. * This method will return the name of the class used to create the instance of the given object.
  43235. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43236. * @param object the object to get the class name from
  43237. * @param isType defines if the object is actually a type
  43238. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43239. */
  43240. static GetClassName(object: any, isType?: boolean): string;
  43241. /**
  43242. * Gets the first element of an array satisfying a given predicate
  43243. * @param array defines the array to browse
  43244. * @param predicate defines the predicate to use
  43245. * @returns null if not found or the element
  43246. */
  43247. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43248. /**
  43249. * This method will return the name of the full name of the class, including its owning module (if any).
  43250. * 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).
  43251. * @param object the object to get the class name from
  43252. * @param isType defines if the object is actually a type
  43253. * @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.
  43254. * @ignorenaming
  43255. */
  43256. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43257. /**
  43258. * Returns a promise that resolves after the given amount of time.
  43259. * @param delay Number of milliseconds to delay
  43260. * @returns Promise that resolves after the given amount of time
  43261. */
  43262. static DelayAsync(delay: number): Promise<void>;
  43263. /**
  43264. * Utility function to detect if the current user agent is Safari
  43265. * @returns whether or not the current user agent is safari
  43266. */
  43267. static IsSafari(): boolean;
  43268. }
  43269. /**
  43270. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43271. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43272. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43273. * @param name The name of the class, case should be preserved
  43274. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43275. */
  43276. export function className(name: string, module?: string): (target: Object) => void;
  43277. /**
  43278. * An implementation of a loop for asynchronous functions.
  43279. */
  43280. export class AsyncLoop {
  43281. /**
  43282. * Defines the number of iterations for the loop
  43283. */
  43284. iterations: number;
  43285. /**
  43286. * Defines the current index of the loop.
  43287. */
  43288. index: number;
  43289. private _done;
  43290. private _fn;
  43291. private _successCallback;
  43292. /**
  43293. * Constructor.
  43294. * @param iterations the number of iterations.
  43295. * @param func the function to run each iteration
  43296. * @param successCallback the callback that will be called upon succesful execution
  43297. * @param offset starting offset.
  43298. */
  43299. constructor(
  43300. /**
  43301. * Defines the number of iterations for the loop
  43302. */
  43303. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43304. /**
  43305. * Execute the next iteration. Must be called after the last iteration was finished.
  43306. */
  43307. executeNext(): void;
  43308. /**
  43309. * Break the loop and run the success callback.
  43310. */
  43311. breakLoop(): void;
  43312. /**
  43313. * Create and run an async loop.
  43314. * @param iterations the number of iterations.
  43315. * @param fn the function to run each iteration
  43316. * @param successCallback the callback that will be called upon succesful execution
  43317. * @param offset starting offset.
  43318. * @returns the created async loop object
  43319. */
  43320. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43321. /**
  43322. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43323. * @param iterations total number of iterations
  43324. * @param syncedIterations number of synchronous iterations in each async iteration.
  43325. * @param fn the function to call each iteration.
  43326. * @param callback a success call back that will be called when iterating stops.
  43327. * @param breakFunction a break condition (optional)
  43328. * @param timeout timeout settings for the setTimeout function. default - 0.
  43329. * @returns the created async loop object
  43330. */
  43331. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43332. }
  43333. }
  43334. declare module "babylonjs/Misc/stringDictionary" {
  43335. import { Nullable } from "babylonjs/types";
  43336. /**
  43337. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43338. * The underlying implementation relies on an associative array to ensure the best performances.
  43339. * The value can be anything including 'null' but except 'undefined'
  43340. */
  43341. export class StringDictionary<T> {
  43342. /**
  43343. * This will clear this dictionary and copy the content from the 'source' one.
  43344. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43345. * @param source the dictionary to take the content from and copy to this dictionary
  43346. */
  43347. copyFrom(source: StringDictionary<T>): void;
  43348. /**
  43349. * Get a value based from its key
  43350. * @param key the given key to get the matching value from
  43351. * @return the value if found, otherwise undefined is returned
  43352. */
  43353. get(key: string): T | undefined;
  43354. /**
  43355. * Get a value from its key or add it if it doesn't exist.
  43356. * This method will ensure you that a given key/data will be present in the dictionary.
  43357. * @param key the given key to get the matching value from
  43358. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43359. * The factory will only be invoked if there's no data for the given key.
  43360. * @return the value corresponding to the key.
  43361. */
  43362. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43363. /**
  43364. * Get a value from its key if present in the dictionary otherwise add it
  43365. * @param key the key to get the value from
  43366. * @param val if there's no such key/value pair in the dictionary add it with this value
  43367. * @return the value corresponding to the key
  43368. */
  43369. getOrAdd(key: string, val: T): T;
  43370. /**
  43371. * Check if there's a given key in the dictionary
  43372. * @param key the key to check for
  43373. * @return true if the key is present, false otherwise
  43374. */
  43375. contains(key: string): boolean;
  43376. /**
  43377. * Add a new key and its corresponding value
  43378. * @param key the key to add
  43379. * @param value the value corresponding to the key
  43380. * @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
  43381. */
  43382. add(key: string, value: T): boolean;
  43383. /**
  43384. * Update a specific value associated to a key
  43385. * @param key defines the key to use
  43386. * @param value defines the value to store
  43387. * @returns true if the value was updated (or false if the key was not found)
  43388. */
  43389. set(key: string, value: T): boolean;
  43390. /**
  43391. * Get the element of the given key and remove it from the dictionary
  43392. * @param key defines the key to search
  43393. * @returns the value associated with the key or null if not found
  43394. */
  43395. getAndRemove(key: string): Nullable<T>;
  43396. /**
  43397. * Remove a key/value from the dictionary.
  43398. * @param key the key to remove
  43399. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43400. */
  43401. remove(key: string): boolean;
  43402. /**
  43403. * Clear the whole content of the dictionary
  43404. */
  43405. clear(): void;
  43406. /**
  43407. * Gets the current count
  43408. */
  43409. get count(): number;
  43410. /**
  43411. * Execute a callback on each key/val of the dictionary.
  43412. * Note that you can remove any element in this dictionary in the callback implementation
  43413. * @param callback the callback to execute on a given key/value pair
  43414. */
  43415. forEach(callback: (key: string, val: T) => void): void;
  43416. /**
  43417. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43418. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43419. * Note that you can remove any element in this dictionary in the callback implementation
  43420. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43421. * @returns the first item
  43422. */
  43423. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43424. private _count;
  43425. private _data;
  43426. }
  43427. }
  43428. declare module "babylonjs/Collisions/collisionCoordinator" {
  43429. import { Nullable } from "babylonjs/types";
  43430. import { Scene } from "babylonjs/scene";
  43431. import { Vector3 } from "babylonjs/Maths/math.vector";
  43432. import { Collider } from "babylonjs/Collisions/collider";
  43433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43434. /** @hidden */
  43435. export interface ICollisionCoordinator {
  43436. createCollider(): Collider;
  43437. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43438. init(scene: Scene): void;
  43439. }
  43440. /** @hidden */
  43441. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43442. private _scene;
  43443. private _scaledPosition;
  43444. private _scaledVelocity;
  43445. private _finalPosition;
  43446. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43447. createCollider(): Collider;
  43448. init(scene: Scene): void;
  43449. private _collideWithWorld;
  43450. }
  43451. }
  43452. declare module "babylonjs/Inputs/scene.inputManager" {
  43453. import { Nullable } from "babylonjs/types";
  43454. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43455. import { Vector2 } from "babylonjs/Maths/math.vector";
  43456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43457. import { Scene } from "babylonjs/scene";
  43458. /**
  43459. * Class used to manage all inputs for the scene.
  43460. */
  43461. export class InputManager {
  43462. /** The distance in pixel that you have to move to prevent some events */
  43463. static DragMovementThreshold: number;
  43464. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43465. static LongPressDelay: number;
  43466. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43467. static DoubleClickDelay: number;
  43468. /** If you need to check double click without raising a single click at first click, enable this flag */
  43469. static ExclusiveDoubleClickMode: boolean;
  43470. /** 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. */
  43471. private _alreadyAttached;
  43472. private _wheelEventName;
  43473. private _onPointerMove;
  43474. private _onPointerDown;
  43475. private _onPointerUp;
  43476. private _initClickEvent;
  43477. private _initActionManager;
  43478. private _delayedSimpleClick;
  43479. private _delayedSimpleClickTimeout;
  43480. private _previousDelayedSimpleClickTimeout;
  43481. private _meshPickProceed;
  43482. private _previousButtonPressed;
  43483. private _currentPickResult;
  43484. private _previousPickResult;
  43485. private _totalPointersPressed;
  43486. private _doubleClickOccured;
  43487. private _pointerOverMesh;
  43488. private _pickedDownMesh;
  43489. private _pickedUpMesh;
  43490. private _pointerX;
  43491. private _pointerY;
  43492. private _unTranslatedPointerX;
  43493. private _unTranslatedPointerY;
  43494. private _startingPointerPosition;
  43495. private _previousStartingPointerPosition;
  43496. private _startingPointerTime;
  43497. private _previousStartingPointerTime;
  43498. private _pointerCaptures;
  43499. private _meshUnderPointerId;
  43500. private _onKeyDown;
  43501. private _onKeyUp;
  43502. private _onCanvasFocusObserver;
  43503. private _onCanvasBlurObserver;
  43504. private _scene;
  43505. /**
  43506. * Creates a new InputManager
  43507. * @param scene defines the hosting scene
  43508. */
  43509. constructor(scene: Scene);
  43510. /**
  43511. * Gets the mesh that is currently under the pointer
  43512. */
  43513. get meshUnderPointer(): Nullable<AbstractMesh>;
  43514. /**
  43515. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43516. * @param pointerId the pointer id to use
  43517. * @returns The mesh under this pointer id or null if not found
  43518. */
  43519. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43520. /**
  43521. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43522. */
  43523. get unTranslatedPointer(): Vector2;
  43524. /**
  43525. * Gets or sets the current on-screen X position of the pointer
  43526. */
  43527. get pointerX(): number;
  43528. set pointerX(value: number);
  43529. /**
  43530. * Gets or sets the current on-screen Y position of the pointer
  43531. */
  43532. get pointerY(): number;
  43533. set pointerY(value: number);
  43534. private _updatePointerPosition;
  43535. private _processPointerMove;
  43536. private _setRayOnPointerInfo;
  43537. private _checkPrePointerObservable;
  43538. /**
  43539. * Use this method to simulate a pointer move on a mesh
  43540. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43541. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43542. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43543. */
  43544. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43545. /**
  43546. * Use this method to simulate a pointer down on a mesh
  43547. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43548. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43549. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43550. */
  43551. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43552. private _processPointerDown;
  43553. /** @hidden */
  43554. _isPointerSwiping(): boolean;
  43555. /**
  43556. * Use this method to simulate a pointer up on a mesh
  43557. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43558. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43559. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43560. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43561. */
  43562. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43563. private _processPointerUp;
  43564. /**
  43565. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43566. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43567. * @returns true if the pointer was captured
  43568. */
  43569. isPointerCaptured(pointerId?: number): boolean;
  43570. /**
  43571. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43572. * @param attachUp defines if you want to attach events to pointerup
  43573. * @param attachDown defines if you want to attach events to pointerdown
  43574. * @param attachMove defines if you want to attach events to pointermove
  43575. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43576. */
  43577. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43578. /**
  43579. * Detaches all event handlers
  43580. */
  43581. detachControl(): void;
  43582. /**
  43583. * Force the value of meshUnderPointer
  43584. * @param mesh defines the mesh to use
  43585. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43586. */
  43587. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43588. /**
  43589. * Gets the mesh under the pointer
  43590. * @returns a Mesh or null if no mesh is under the pointer
  43591. */
  43592. getPointerOverMesh(): Nullable<AbstractMesh>;
  43593. }
  43594. }
  43595. declare module "babylonjs/Animations/animationGroup" {
  43596. import { Animatable } from "babylonjs/Animations/animatable";
  43597. import { Animation } from "babylonjs/Animations/animation";
  43598. import { Scene, IDisposable } from "babylonjs/scene";
  43599. import { Observable } from "babylonjs/Misc/observable";
  43600. import { Nullable } from "babylonjs/types";
  43601. import "babylonjs/Animations/animatable";
  43602. /**
  43603. * This class defines the direct association between an animation and a target
  43604. */
  43605. export class TargetedAnimation {
  43606. /**
  43607. * Animation to perform
  43608. */
  43609. animation: Animation;
  43610. /**
  43611. * Target to animate
  43612. */
  43613. target: any;
  43614. /**
  43615. * Returns the string "TargetedAnimation"
  43616. * @returns "TargetedAnimation"
  43617. */
  43618. getClassName(): string;
  43619. /**
  43620. * Serialize the object
  43621. * @returns the JSON object representing the current entity
  43622. */
  43623. serialize(): any;
  43624. }
  43625. /**
  43626. * Use this class to create coordinated animations on multiple targets
  43627. */
  43628. export class AnimationGroup implements IDisposable {
  43629. /** The name of the animation group */
  43630. name: string;
  43631. private _scene;
  43632. private _targetedAnimations;
  43633. private _animatables;
  43634. private _from;
  43635. private _to;
  43636. private _isStarted;
  43637. private _isPaused;
  43638. private _speedRatio;
  43639. private _loopAnimation;
  43640. private _isAdditive;
  43641. /**
  43642. * Gets or sets the unique id of the node
  43643. */
  43644. uniqueId: number;
  43645. /**
  43646. * This observable will notify when one animation have ended
  43647. */
  43648. onAnimationEndObservable: Observable<TargetedAnimation>;
  43649. /**
  43650. * Observer raised when one animation loops
  43651. */
  43652. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43653. /**
  43654. * Observer raised when all animations have looped
  43655. */
  43656. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43657. /**
  43658. * This observable will notify when all animations have ended.
  43659. */
  43660. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43661. /**
  43662. * This observable will notify when all animations have paused.
  43663. */
  43664. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43665. /**
  43666. * This observable will notify when all animations are playing.
  43667. */
  43668. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43669. /**
  43670. * Gets the first frame
  43671. */
  43672. get from(): number;
  43673. /**
  43674. * Gets the last frame
  43675. */
  43676. get to(): number;
  43677. /**
  43678. * Define if the animations are started
  43679. */
  43680. get isStarted(): boolean;
  43681. /**
  43682. * Gets a value indicating that the current group is playing
  43683. */
  43684. get isPlaying(): boolean;
  43685. /**
  43686. * Gets or sets the speed ratio to use for all animations
  43687. */
  43688. get speedRatio(): number;
  43689. /**
  43690. * Gets or sets the speed ratio to use for all animations
  43691. */
  43692. set speedRatio(value: number);
  43693. /**
  43694. * Gets or sets if all animations should loop or not
  43695. */
  43696. get loopAnimation(): boolean;
  43697. set loopAnimation(value: boolean);
  43698. /**
  43699. * Gets or sets if all animations should be evaluated additively
  43700. */
  43701. get isAdditive(): boolean;
  43702. set isAdditive(value: boolean);
  43703. /**
  43704. * Gets the targeted animations for this animation group
  43705. */
  43706. get targetedAnimations(): Array<TargetedAnimation>;
  43707. /**
  43708. * returning the list of animatables controlled by this animation group.
  43709. */
  43710. get animatables(): Array<Animatable>;
  43711. /**
  43712. * Gets the list of target animations
  43713. */
  43714. get children(): TargetedAnimation[];
  43715. /**
  43716. * Instantiates a new Animation Group.
  43717. * This helps managing several animations at once.
  43718. * @see https://doc.babylonjs.com/how_to/group
  43719. * @param name Defines the name of the group
  43720. * @param scene Defines the scene the group belongs to
  43721. */
  43722. constructor(
  43723. /** The name of the animation group */
  43724. name: string, scene?: Nullable<Scene>);
  43725. /**
  43726. * Add an animation (with its target) in the group
  43727. * @param animation defines the animation we want to add
  43728. * @param target defines the target of the animation
  43729. * @returns the TargetedAnimation object
  43730. */
  43731. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43732. /**
  43733. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43734. * It can add constant keys at begin or end
  43735. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43736. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43737. * @returns the animation group
  43738. */
  43739. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43740. private _animationLoopCount;
  43741. private _animationLoopFlags;
  43742. private _processLoop;
  43743. /**
  43744. * Start all animations on given targets
  43745. * @param loop defines if animations must loop
  43746. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43747. * @param from defines the from key (optional)
  43748. * @param to defines the to key (optional)
  43749. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43750. * @returns the current animation group
  43751. */
  43752. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43753. /**
  43754. * Pause all animations
  43755. * @returns the animation group
  43756. */
  43757. pause(): AnimationGroup;
  43758. /**
  43759. * Play all animations to initial state
  43760. * This function will start() the animations if they were not started or will restart() them if they were paused
  43761. * @param loop defines if animations must loop
  43762. * @returns the animation group
  43763. */
  43764. play(loop?: boolean): AnimationGroup;
  43765. /**
  43766. * Reset all animations to initial state
  43767. * @returns the animation group
  43768. */
  43769. reset(): AnimationGroup;
  43770. /**
  43771. * Restart animations from key 0
  43772. * @returns the animation group
  43773. */
  43774. restart(): AnimationGroup;
  43775. /**
  43776. * Stop all animations
  43777. * @returns the animation group
  43778. */
  43779. stop(): AnimationGroup;
  43780. /**
  43781. * Set animation weight for all animatables
  43782. * @param weight defines the weight to use
  43783. * @return the animationGroup
  43784. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43785. */
  43786. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43787. /**
  43788. * Synchronize and normalize all animatables with a source animatable
  43789. * @param root defines the root animatable to synchronize with
  43790. * @return the animationGroup
  43791. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43792. */
  43793. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43794. /**
  43795. * Goes to a specific frame in this animation group
  43796. * @param frame the frame number to go to
  43797. * @return the animationGroup
  43798. */
  43799. goToFrame(frame: number): AnimationGroup;
  43800. /**
  43801. * Dispose all associated resources
  43802. */
  43803. dispose(): void;
  43804. private _checkAnimationGroupEnded;
  43805. /**
  43806. * Clone the current animation group and returns a copy
  43807. * @param newName defines the name of the new group
  43808. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43809. * @returns the new aniamtion group
  43810. */
  43811. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43812. /**
  43813. * Serializes the animationGroup to an object
  43814. * @returns Serialized object
  43815. */
  43816. serialize(): any;
  43817. /**
  43818. * Returns a new AnimationGroup object parsed from the source provided.
  43819. * @param parsedAnimationGroup defines the source
  43820. * @param scene defines the scene that will receive the animationGroup
  43821. * @returns a new AnimationGroup
  43822. */
  43823. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43824. /**
  43825. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43826. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43827. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43828. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43829. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43830. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43831. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43832. */
  43833. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43834. /**
  43835. * Returns the string "AnimationGroup"
  43836. * @returns "AnimationGroup"
  43837. */
  43838. getClassName(): string;
  43839. /**
  43840. * Creates a detailled string about the object
  43841. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43842. * @returns a string representing the object
  43843. */
  43844. toString(fullDetails?: boolean): string;
  43845. }
  43846. }
  43847. declare module "babylonjs/scene" {
  43848. import { Nullable } from "babylonjs/types";
  43849. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  43850. import { Observable } from "babylonjs/Misc/observable";
  43851. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43852. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  43853. import { Geometry } from "babylonjs/Meshes/geometry";
  43854. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43857. import { Mesh } from "babylonjs/Meshes/mesh";
  43858. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43859. import { Bone } from "babylonjs/Bones/bone";
  43860. import { Skeleton } from "babylonjs/Bones/skeleton";
  43861. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  43862. import { Camera } from "babylonjs/Cameras/camera";
  43863. import { AbstractScene } from "babylonjs/abstractScene";
  43864. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43865. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43866. import { Material } from "babylonjs/Materials/material";
  43867. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43868. import { Effect } from "babylonjs/Materials/effect";
  43869. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  43870. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  43871. import { Light } from "babylonjs/Lights/light";
  43872. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43873. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  43874. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  43875. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  43876. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  43877. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43878. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  43879. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  43880. import { Engine } from "babylonjs/Engines/engine";
  43881. import { Node } from "babylonjs/node";
  43882. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  43883. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  43884. import { WebRequest } from "babylonjs/Misc/webRequest";
  43885. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  43886. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43887. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43888. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  43889. import { Plane } from "babylonjs/Maths/math.plane";
  43890. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  43891. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  43892. import { Ray } from "babylonjs/Culling/ray";
  43893. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  43894. import { Animation } from "babylonjs/Animations/animation";
  43895. import { Animatable } from "babylonjs/Animations/animatable";
  43896. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43897. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  43898. import { Collider } from "babylonjs/Collisions/collider";
  43899. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43900. /**
  43901. * Define an interface for all classes that will hold resources
  43902. */
  43903. export interface IDisposable {
  43904. /**
  43905. * Releases all held resources
  43906. */
  43907. dispose(): void;
  43908. }
  43909. /** Interface defining initialization parameters for Scene class */
  43910. export interface SceneOptions {
  43911. /**
  43912. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  43913. * It will improve performance when the number of geometries becomes important.
  43914. */
  43915. useGeometryUniqueIdsMap?: boolean;
  43916. /**
  43917. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  43918. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43919. */
  43920. useMaterialMeshMap?: boolean;
  43921. /**
  43922. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  43923. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  43924. */
  43925. useClonedMeshMap?: boolean;
  43926. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  43927. virtual?: boolean;
  43928. }
  43929. /**
  43930. * Represents a scene to be rendered by the engine.
  43931. * @see https://doc.babylonjs.com/features/scene
  43932. */
  43933. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  43934. /** The fog is deactivated */
  43935. static readonly FOGMODE_NONE: number;
  43936. /** The fog density is following an exponential function */
  43937. static readonly FOGMODE_EXP: number;
  43938. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  43939. static readonly FOGMODE_EXP2: number;
  43940. /** The fog density is following a linear function. */
  43941. static readonly FOGMODE_LINEAR: number;
  43942. /**
  43943. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  43944. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43945. */
  43946. static MinDeltaTime: number;
  43947. /**
  43948. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  43949. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43950. */
  43951. static MaxDeltaTime: number;
  43952. /**
  43953. * Factory used to create the default material.
  43954. * @param name The name of the material to create
  43955. * @param scene The scene to create the material for
  43956. * @returns The default material
  43957. */
  43958. static DefaultMaterialFactory(scene: Scene): Material;
  43959. /**
  43960. * Factory used to create the a collision coordinator.
  43961. * @returns The collision coordinator
  43962. */
  43963. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  43964. /** @hidden */
  43965. _inputManager: InputManager;
  43966. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  43967. cameraToUseForPointers: Nullable<Camera>;
  43968. /** @hidden */
  43969. readonly _isScene: boolean;
  43970. /** @hidden */
  43971. _blockEntityCollection: boolean;
  43972. /**
  43973. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  43974. */
  43975. autoClear: boolean;
  43976. /**
  43977. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  43978. */
  43979. autoClearDepthAndStencil: boolean;
  43980. /**
  43981. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  43982. */
  43983. clearColor: Color4;
  43984. /**
  43985. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  43986. */
  43987. ambientColor: Color3;
  43988. /**
  43989. * This is use to store the default BRDF lookup for PBR materials in your scene.
  43990. * It should only be one of the following (if not the default embedded one):
  43991. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  43992. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  43993. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  43994. * The material properties need to be setup according to the type of texture in use.
  43995. */
  43996. environmentBRDFTexture: BaseTexture;
  43997. /**
  43998. * Texture used in all pbr material as the reflection texture.
  43999. * As in the majority of the scene they are the same (exception for multi room and so on),
  44000. * this is easier to reference from here than from all the materials.
  44001. */
  44002. get environmentTexture(): Nullable<BaseTexture>;
  44003. /**
  44004. * Texture used in all pbr material as the reflection texture.
  44005. * As in the majority of the scene they are the same (exception for multi room and so on),
  44006. * this is easier to set here than in all the materials.
  44007. */
  44008. set environmentTexture(value: Nullable<BaseTexture>);
  44009. /** @hidden */
  44010. protected _environmentIntensity: number;
  44011. /**
  44012. * Intensity of the environment in all pbr material.
  44013. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44014. * As in the majority of the scene they are the same (exception for multi room and so on),
  44015. * this is easier to reference from here than from all the materials.
  44016. */
  44017. get environmentIntensity(): number;
  44018. /**
  44019. * Intensity of the environment in all pbr material.
  44020. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44021. * As in the majority of the scene they are the same (exception for multi room and so on),
  44022. * this is easier to set here than in all the materials.
  44023. */
  44024. set environmentIntensity(value: number);
  44025. /** @hidden */
  44026. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44027. /**
  44028. * Default image processing configuration used either in the rendering
  44029. * Forward main pass or through the imageProcessingPostProcess if present.
  44030. * As in the majority of the scene they are the same (exception for multi camera),
  44031. * this is easier to reference from here than from all the materials and post process.
  44032. *
  44033. * No setter as we it is a shared configuration, you can set the values instead.
  44034. */
  44035. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44036. private _forceWireframe;
  44037. /**
  44038. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44039. */
  44040. set forceWireframe(value: boolean);
  44041. get forceWireframe(): boolean;
  44042. private _skipFrustumClipping;
  44043. /**
  44044. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44045. */
  44046. set skipFrustumClipping(value: boolean);
  44047. get skipFrustumClipping(): boolean;
  44048. private _forcePointsCloud;
  44049. /**
  44050. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44051. */
  44052. set forcePointsCloud(value: boolean);
  44053. get forcePointsCloud(): boolean;
  44054. /**
  44055. * Gets or sets the active clipplane 1
  44056. */
  44057. clipPlane: Nullable<Plane>;
  44058. /**
  44059. * Gets or sets the active clipplane 2
  44060. */
  44061. clipPlane2: Nullable<Plane>;
  44062. /**
  44063. * Gets or sets the active clipplane 3
  44064. */
  44065. clipPlane3: Nullable<Plane>;
  44066. /**
  44067. * Gets or sets the active clipplane 4
  44068. */
  44069. clipPlane4: Nullable<Plane>;
  44070. /**
  44071. * Gets or sets the active clipplane 5
  44072. */
  44073. clipPlane5: Nullable<Plane>;
  44074. /**
  44075. * Gets or sets the active clipplane 6
  44076. */
  44077. clipPlane6: Nullable<Plane>;
  44078. /**
  44079. * Gets or sets a boolean indicating if animations are enabled
  44080. */
  44081. animationsEnabled: boolean;
  44082. private _animationPropertiesOverride;
  44083. /**
  44084. * Gets or sets the animation properties override
  44085. */
  44086. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44087. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44088. /**
  44089. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44090. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44091. */
  44092. useConstantAnimationDeltaTime: boolean;
  44093. /**
  44094. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44095. * Please note that it requires to run a ray cast through the scene on every frame
  44096. */
  44097. constantlyUpdateMeshUnderPointer: boolean;
  44098. /**
  44099. * Defines the HTML cursor to use when hovering over interactive elements
  44100. */
  44101. hoverCursor: string;
  44102. /**
  44103. * Defines the HTML default cursor to use (empty by default)
  44104. */
  44105. defaultCursor: string;
  44106. /**
  44107. * Defines whether cursors are handled by the scene.
  44108. */
  44109. doNotHandleCursors: boolean;
  44110. /**
  44111. * This is used to call preventDefault() on pointer down
  44112. * in order to block unwanted artifacts like system double clicks
  44113. */
  44114. preventDefaultOnPointerDown: boolean;
  44115. /**
  44116. * This is used to call preventDefault() on pointer up
  44117. * in order to block unwanted artifacts like system double clicks
  44118. */
  44119. preventDefaultOnPointerUp: boolean;
  44120. /**
  44121. * Gets or sets user defined metadata
  44122. */
  44123. metadata: any;
  44124. /**
  44125. * For internal use only. Please do not use.
  44126. */
  44127. reservedDataStore: any;
  44128. /**
  44129. * Gets the name of the plugin used to load this scene (null by default)
  44130. */
  44131. loadingPluginName: string;
  44132. /**
  44133. * Use this array to add regular expressions used to disable offline support for specific urls
  44134. */
  44135. disableOfflineSupportExceptionRules: RegExp[];
  44136. /**
  44137. * An event triggered when the scene is disposed.
  44138. */
  44139. onDisposeObservable: Observable<Scene>;
  44140. private _onDisposeObserver;
  44141. /** Sets a function to be executed when this scene is disposed. */
  44142. set onDispose(callback: () => void);
  44143. /**
  44144. * An event triggered before rendering the scene (right after animations and physics)
  44145. */
  44146. onBeforeRenderObservable: Observable<Scene>;
  44147. private _onBeforeRenderObserver;
  44148. /** Sets a function to be executed before rendering this scene */
  44149. set beforeRender(callback: Nullable<() => void>);
  44150. /**
  44151. * An event triggered after rendering the scene
  44152. */
  44153. onAfterRenderObservable: Observable<Scene>;
  44154. /**
  44155. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44156. */
  44157. onAfterRenderCameraObservable: Observable<Camera>;
  44158. private _onAfterRenderObserver;
  44159. /** Sets a function to be executed after rendering this scene */
  44160. set afterRender(callback: Nullable<() => void>);
  44161. /**
  44162. * An event triggered before animating the scene
  44163. */
  44164. onBeforeAnimationsObservable: Observable<Scene>;
  44165. /**
  44166. * An event triggered after animations processing
  44167. */
  44168. onAfterAnimationsObservable: Observable<Scene>;
  44169. /**
  44170. * An event triggered before draw calls are ready to be sent
  44171. */
  44172. onBeforeDrawPhaseObservable: Observable<Scene>;
  44173. /**
  44174. * An event triggered after draw calls have been sent
  44175. */
  44176. onAfterDrawPhaseObservable: Observable<Scene>;
  44177. /**
  44178. * An event triggered when the scene is ready
  44179. */
  44180. onReadyObservable: Observable<Scene>;
  44181. /**
  44182. * An event triggered before rendering a camera
  44183. */
  44184. onBeforeCameraRenderObservable: Observable<Camera>;
  44185. private _onBeforeCameraRenderObserver;
  44186. /** Sets a function to be executed before rendering a camera*/
  44187. set beforeCameraRender(callback: () => void);
  44188. /**
  44189. * An event triggered after rendering a camera
  44190. */
  44191. onAfterCameraRenderObservable: Observable<Camera>;
  44192. private _onAfterCameraRenderObserver;
  44193. /** Sets a function to be executed after rendering a camera*/
  44194. set afterCameraRender(callback: () => void);
  44195. /**
  44196. * An event triggered when active meshes evaluation is about to start
  44197. */
  44198. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44199. /**
  44200. * An event triggered when active meshes evaluation is done
  44201. */
  44202. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44203. /**
  44204. * An event triggered when particles rendering is about to start
  44205. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44206. */
  44207. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44208. /**
  44209. * An event triggered when particles rendering is done
  44210. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44211. */
  44212. onAfterParticlesRenderingObservable: Observable<Scene>;
  44213. /**
  44214. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44215. */
  44216. onDataLoadedObservable: Observable<Scene>;
  44217. /**
  44218. * An event triggered when a camera is created
  44219. */
  44220. onNewCameraAddedObservable: Observable<Camera>;
  44221. /**
  44222. * An event triggered when a camera is removed
  44223. */
  44224. onCameraRemovedObservable: Observable<Camera>;
  44225. /**
  44226. * An event triggered when a light is created
  44227. */
  44228. onNewLightAddedObservable: Observable<Light>;
  44229. /**
  44230. * An event triggered when a light is removed
  44231. */
  44232. onLightRemovedObservable: Observable<Light>;
  44233. /**
  44234. * An event triggered when a geometry is created
  44235. */
  44236. onNewGeometryAddedObservable: Observable<Geometry>;
  44237. /**
  44238. * An event triggered when a geometry is removed
  44239. */
  44240. onGeometryRemovedObservable: Observable<Geometry>;
  44241. /**
  44242. * An event triggered when a transform node is created
  44243. */
  44244. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44245. /**
  44246. * An event triggered when a transform node is removed
  44247. */
  44248. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44249. /**
  44250. * An event triggered when a mesh is created
  44251. */
  44252. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44253. /**
  44254. * An event triggered when a mesh is removed
  44255. */
  44256. onMeshRemovedObservable: Observable<AbstractMesh>;
  44257. /**
  44258. * An event triggered when a skeleton is created
  44259. */
  44260. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44261. /**
  44262. * An event triggered when a skeleton is removed
  44263. */
  44264. onSkeletonRemovedObservable: Observable<Skeleton>;
  44265. /**
  44266. * An event triggered when a material is created
  44267. */
  44268. onNewMaterialAddedObservable: Observable<Material>;
  44269. /**
  44270. * An event triggered when a material is removed
  44271. */
  44272. onMaterialRemovedObservable: Observable<Material>;
  44273. /**
  44274. * An event triggered when a texture is created
  44275. */
  44276. onNewTextureAddedObservable: Observable<BaseTexture>;
  44277. /**
  44278. * An event triggered when a texture is removed
  44279. */
  44280. onTextureRemovedObservable: Observable<BaseTexture>;
  44281. /**
  44282. * An event triggered when render targets are about to be rendered
  44283. * Can happen multiple times per frame.
  44284. */
  44285. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44286. /**
  44287. * An event triggered when render targets were rendered.
  44288. * Can happen multiple times per frame.
  44289. */
  44290. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44291. /**
  44292. * An event triggered before calculating deterministic simulation step
  44293. */
  44294. onBeforeStepObservable: Observable<Scene>;
  44295. /**
  44296. * An event triggered after calculating deterministic simulation step
  44297. */
  44298. onAfterStepObservable: Observable<Scene>;
  44299. /**
  44300. * An event triggered when the activeCamera property is updated
  44301. */
  44302. onActiveCameraChanged: Observable<Scene>;
  44303. /**
  44304. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44305. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44306. * 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)
  44307. */
  44308. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44309. /**
  44310. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44311. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44312. * 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)
  44313. */
  44314. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44315. /**
  44316. * This Observable will when a mesh has been imported into the scene.
  44317. */
  44318. onMeshImportedObservable: Observable<AbstractMesh>;
  44319. /**
  44320. * This Observable will when an animation file has been imported into the scene.
  44321. */
  44322. onAnimationFileImportedObservable: Observable<Scene>;
  44323. /**
  44324. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44325. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44326. */
  44327. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44328. /** @hidden */
  44329. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44330. /**
  44331. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44332. */
  44333. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44334. /**
  44335. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44336. */
  44337. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44338. /**
  44339. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44340. */
  44341. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44342. /** Callback called when a pointer move is detected */
  44343. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44344. /** Callback called when a pointer down is detected */
  44345. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44346. /** Callback called when a pointer up is detected */
  44347. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44348. /** Callback called when a pointer pick is detected */
  44349. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44350. /**
  44351. * 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).
  44352. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44353. */
  44354. onPrePointerObservable: Observable<PointerInfoPre>;
  44355. /**
  44356. * Observable event triggered each time an input event is received from the rendering canvas
  44357. */
  44358. onPointerObservable: Observable<PointerInfo>;
  44359. /**
  44360. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44361. */
  44362. get unTranslatedPointer(): Vector2;
  44363. /**
  44364. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44365. */
  44366. static get DragMovementThreshold(): number;
  44367. static set DragMovementThreshold(value: number);
  44368. /**
  44369. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44370. */
  44371. static get LongPressDelay(): number;
  44372. static set LongPressDelay(value: number);
  44373. /**
  44374. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44375. */
  44376. static get DoubleClickDelay(): number;
  44377. static set DoubleClickDelay(value: number);
  44378. /** If you need to check double click without raising a single click at first click, enable this flag */
  44379. static get ExclusiveDoubleClickMode(): boolean;
  44380. static set ExclusiveDoubleClickMode(value: boolean);
  44381. /** @hidden */
  44382. _mirroredCameraPosition: Nullable<Vector3>;
  44383. /**
  44384. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44385. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44386. */
  44387. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44388. /**
  44389. * Observable event triggered each time an keyboard event is received from the hosting window
  44390. */
  44391. onKeyboardObservable: Observable<KeyboardInfo>;
  44392. private _useRightHandedSystem;
  44393. /**
  44394. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44395. */
  44396. set useRightHandedSystem(value: boolean);
  44397. get useRightHandedSystem(): boolean;
  44398. private _timeAccumulator;
  44399. private _currentStepId;
  44400. private _currentInternalStep;
  44401. /**
  44402. * Sets the step Id used by deterministic lock step
  44403. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44404. * @param newStepId defines the step Id
  44405. */
  44406. setStepId(newStepId: number): void;
  44407. /**
  44408. * Gets the step Id used by deterministic lock step
  44409. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44410. * @returns the step Id
  44411. */
  44412. getStepId(): number;
  44413. /**
  44414. * Gets the internal step used by deterministic lock step
  44415. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44416. * @returns the internal step
  44417. */
  44418. getInternalStep(): number;
  44419. private _fogEnabled;
  44420. /**
  44421. * Gets or sets a boolean indicating if fog is enabled on this scene
  44422. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44423. * (Default is true)
  44424. */
  44425. set fogEnabled(value: boolean);
  44426. get fogEnabled(): boolean;
  44427. private _fogMode;
  44428. /**
  44429. * Gets or sets the fog mode to use
  44430. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44431. * | mode | value |
  44432. * | --- | --- |
  44433. * | FOGMODE_NONE | 0 |
  44434. * | FOGMODE_EXP | 1 |
  44435. * | FOGMODE_EXP2 | 2 |
  44436. * | FOGMODE_LINEAR | 3 |
  44437. */
  44438. set fogMode(value: number);
  44439. get fogMode(): number;
  44440. /**
  44441. * Gets or sets the fog color to use
  44442. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44443. * (Default is Color3(0.2, 0.2, 0.3))
  44444. */
  44445. fogColor: Color3;
  44446. /**
  44447. * Gets or sets the fog density to use
  44448. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44449. * (Default is 0.1)
  44450. */
  44451. fogDensity: number;
  44452. /**
  44453. * Gets or sets the fog start distance to use
  44454. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44455. * (Default is 0)
  44456. */
  44457. fogStart: number;
  44458. /**
  44459. * Gets or sets the fog end distance to use
  44460. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44461. * (Default is 1000)
  44462. */
  44463. fogEnd: number;
  44464. /**
  44465. * Flag indicating that the frame buffer binding is handled by another component
  44466. */
  44467. prePass: boolean;
  44468. private _shadowsEnabled;
  44469. /**
  44470. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44471. */
  44472. set shadowsEnabled(value: boolean);
  44473. get shadowsEnabled(): boolean;
  44474. private _lightsEnabled;
  44475. /**
  44476. * Gets or sets a boolean indicating if lights are enabled on this scene
  44477. */
  44478. set lightsEnabled(value: boolean);
  44479. get lightsEnabled(): boolean;
  44480. /** All of the active cameras added to this scene. */
  44481. activeCameras: Camera[];
  44482. /** @hidden */
  44483. _activeCamera: Nullable<Camera>;
  44484. /** Gets or sets the current active camera */
  44485. get activeCamera(): Nullable<Camera>;
  44486. set activeCamera(value: Nullable<Camera>);
  44487. private _defaultMaterial;
  44488. /** The default material used on meshes when no material is affected */
  44489. get defaultMaterial(): Material;
  44490. /** The default material used on meshes when no material is affected */
  44491. set defaultMaterial(value: Material);
  44492. private _texturesEnabled;
  44493. /**
  44494. * Gets or sets a boolean indicating if textures are enabled on this scene
  44495. */
  44496. set texturesEnabled(value: boolean);
  44497. get texturesEnabled(): boolean;
  44498. /**
  44499. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44500. */
  44501. physicsEnabled: boolean;
  44502. /**
  44503. * Gets or sets a boolean indicating if particles are enabled on this scene
  44504. */
  44505. particlesEnabled: boolean;
  44506. /**
  44507. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44508. */
  44509. spritesEnabled: boolean;
  44510. private _skeletonsEnabled;
  44511. /**
  44512. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44513. */
  44514. set skeletonsEnabled(value: boolean);
  44515. get skeletonsEnabled(): boolean;
  44516. /**
  44517. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44518. */
  44519. lensFlaresEnabled: boolean;
  44520. /**
  44521. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44522. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44523. */
  44524. collisionsEnabled: boolean;
  44525. private _collisionCoordinator;
  44526. /** @hidden */
  44527. get collisionCoordinator(): ICollisionCoordinator;
  44528. /**
  44529. * Defines the gravity applied to this scene (used only for collisions)
  44530. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44531. */
  44532. gravity: Vector3;
  44533. /**
  44534. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44535. */
  44536. postProcessesEnabled: boolean;
  44537. /**
  44538. * Gets the current postprocess manager
  44539. */
  44540. postProcessManager: PostProcessManager;
  44541. /**
  44542. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44543. */
  44544. renderTargetsEnabled: boolean;
  44545. /**
  44546. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44547. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44548. */
  44549. dumpNextRenderTargets: boolean;
  44550. /**
  44551. * The list of user defined render targets added to the scene
  44552. */
  44553. customRenderTargets: RenderTargetTexture[];
  44554. /**
  44555. * Defines if texture loading must be delayed
  44556. * If true, textures will only be loaded when they need to be rendered
  44557. */
  44558. useDelayedTextureLoading: boolean;
  44559. /**
  44560. * Gets the list of meshes imported to the scene through SceneLoader
  44561. */
  44562. importedMeshesFiles: String[];
  44563. /**
  44564. * Gets or sets a boolean indicating if probes are enabled on this scene
  44565. */
  44566. probesEnabled: boolean;
  44567. /**
  44568. * Gets or sets the current offline provider to use to store scene data
  44569. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44570. */
  44571. offlineProvider: IOfflineProvider;
  44572. /**
  44573. * Gets or sets the action manager associated with the scene
  44574. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44575. */
  44576. actionManager: AbstractActionManager;
  44577. private _meshesForIntersections;
  44578. /**
  44579. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44580. */
  44581. proceduralTexturesEnabled: boolean;
  44582. private _engine;
  44583. private _totalVertices;
  44584. /** @hidden */
  44585. _activeIndices: PerfCounter;
  44586. /** @hidden */
  44587. _activeParticles: PerfCounter;
  44588. /** @hidden */
  44589. _activeBones: PerfCounter;
  44590. private _animationRatio;
  44591. /** @hidden */
  44592. _animationTimeLast: number;
  44593. /** @hidden */
  44594. _animationTime: number;
  44595. /**
  44596. * Gets or sets a general scale for animation speed
  44597. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44598. */
  44599. animationTimeScale: number;
  44600. /** @hidden */
  44601. _cachedMaterial: Nullable<Material>;
  44602. /** @hidden */
  44603. _cachedEffect: Nullable<Effect>;
  44604. /** @hidden */
  44605. _cachedVisibility: Nullable<number>;
  44606. private _renderId;
  44607. private _frameId;
  44608. private _executeWhenReadyTimeoutId;
  44609. private _intermediateRendering;
  44610. private _viewUpdateFlag;
  44611. private _projectionUpdateFlag;
  44612. /** @hidden */
  44613. _toBeDisposed: Nullable<IDisposable>[];
  44614. private _activeRequests;
  44615. /** @hidden */
  44616. _pendingData: any[];
  44617. private _isDisposed;
  44618. /**
  44619. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44620. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44621. */
  44622. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44623. private _activeMeshes;
  44624. private _processedMaterials;
  44625. private _renderTargets;
  44626. /** @hidden */
  44627. _activeParticleSystems: SmartArray<IParticleSystem>;
  44628. private _activeSkeletons;
  44629. private _softwareSkinnedMeshes;
  44630. private _renderingManager;
  44631. /** @hidden */
  44632. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44633. private _transformMatrix;
  44634. private _sceneUbo;
  44635. /** @hidden */
  44636. _viewMatrix: Matrix;
  44637. private _projectionMatrix;
  44638. /** @hidden */
  44639. _forcedViewPosition: Nullable<Vector3>;
  44640. /** @hidden */
  44641. _frustumPlanes: Plane[];
  44642. /**
  44643. * Gets the list of frustum planes (built from the active camera)
  44644. */
  44645. get frustumPlanes(): Plane[];
  44646. /**
  44647. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44648. * This is useful if there are more lights that the maximum simulteanous authorized
  44649. */
  44650. requireLightSorting: boolean;
  44651. /** @hidden */
  44652. readonly useMaterialMeshMap: boolean;
  44653. /** @hidden */
  44654. readonly useClonedMeshMap: boolean;
  44655. private _externalData;
  44656. private _uid;
  44657. /**
  44658. * @hidden
  44659. * Backing store of defined scene components.
  44660. */
  44661. _components: ISceneComponent[];
  44662. /**
  44663. * @hidden
  44664. * Backing store of defined scene components.
  44665. */
  44666. _serializableComponents: ISceneSerializableComponent[];
  44667. /**
  44668. * List of components to register on the next registration step.
  44669. */
  44670. private _transientComponents;
  44671. /**
  44672. * Registers the transient components if needed.
  44673. */
  44674. private _registerTransientComponents;
  44675. /**
  44676. * @hidden
  44677. * Add a component to the scene.
  44678. * Note that the ccomponent could be registered on th next frame if this is called after
  44679. * the register component stage.
  44680. * @param component Defines the component to add to the scene
  44681. */
  44682. _addComponent(component: ISceneComponent): void;
  44683. /**
  44684. * @hidden
  44685. * Gets a component from the scene.
  44686. * @param name defines the name of the component to retrieve
  44687. * @returns the component or null if not present
  44688. */
  44689. _getComponent(name: string): Nullable<ISceneComponent>;
  44690. /**
  44691. * @hidden
  44692. * Defines the actions happening before camera updates.
  44693. */
  44694. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  44695. /**
  44696. * @hidden
  44697. * Defines the actions happening before clear the canvas.
  44698. */
  44699. _beforeClearStage: Stage<SimpleStageAction>;
  44700. /**
  44701. * @hidden
  44702. * Defines the actions when collecting render targets for the frame.
  44703. */
  44704. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44705. /**
  44706. * @hidden
  44707. * Defines the actions happening for one camera in the frame.
  44708. */
  44709. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  44710. /**
  44711. * @hidden
  44712. * Defines the actions happening during the per mesh ready checks.
  44713. */
  44714. _isReadyForMeshStage: Stage<MeshStageAction>;
  44715. /**
  44716. * @hidden
  44717. * Defines the actions happening before evaluate active mesh checks.
  44718. */
  44719. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  44720. /**
  44721. * @hidden
  44722. * Defines the actions happening during the evaluate sub mesh checks.
  44723. */
  44724. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  44725. /**
  44726. * @hidden
  44727. * Defines the actions happening during the active mesh stage.
  44728. */
  44729. _activeMeshStage: Stage<ActiveMeshStageAction>;
  44730. /**
  44731. * @hidden
  44732. * Defines the actions happening during the per camera render target step.
  44733. */
  44734. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  44735. /**
  44736. * @hidden
  44737. * Defines the actions happening just before the active camera is drawing.
  44738. */
  44739. _beforeCameraDrawStage: Stage<CameraStageAction>;
  44740. /**
  44741. * @hidden
  44742. * Defines the actions happening just before a render target is drawing.
  44743. */
  44744. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44745. /**
  44746. * @hidden
  44747. * Defines the actions happening just before a rendering group is drawing.
  44748. */
  44749. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44750. /**
  44751. * @hidden
  44752. * Defines the actions happening just before a mesh is drawing.
  44753. */
  44754. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44755. /**
  44756. * @hidden
  44757. * Defines the actions happening just after a mesh has been drawn.
  44758. */
  44759. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  44760. /**
  44761. * @hidden
  44762. * Defines the actions happening just after a rendering group has been drawn.
  44763. */
  44764. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  44765. /**
  44766. * @hidden
  44767. * Defines the actions happening just after the active camera has been drawn.
  44768. */
  44769. _afterCameraDrawStage: Stage<CameraStageAction>;
  44770. /**
  44771. * @hidden
  44772. * Defines the actions happening just after a render target has been drawn.
  44773. */
  44774. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  44775. /**
  44776. * @hidden
  44777. * Defines the actions happening just after rendering all cameras and computing intersections.
  44778. */
  44779. _afterRenderStage: Stage<SimpleStageAction>;
  44780. /**
  44781. * @hidden
  44782. * Defines the actions happening when a pointer move event happens.
  44783. */
  44784. _pointerMoveStage: Stage<PointerMoveStageAction>;
  44785. /**
  44786. * @hidden
  44787. * Defines the actions happening when a pointer down event happens.
  44788. */
  44789. _pointerDownStage: Stage<PointerUpDownStageAction>;
  44790. /**
  44791. * @hidden
  44792. * Defines the actions happening when a pointer up event happens.
  44793. */
  44794. _pointerUpStage: Stage<PointerUpDownStageAction>;
  44795. /**
  44796. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  44797. */
  44798. private geometriesByUniqueId;
  44799. /**
  44800. * Creates a new Scene
  44801. * @param engine defines the engine to use to render this scene
  44802. * @param options defines the scene options
  44803. */
  44804. constructor(engine: Engine, options?: SceneOptions);
  44805. /**
  44806. * Gets a string identifying the name of the class
  44807. * @returns "Scene" string
  44808. */
  44809. getClassName(): string;
  44810. private _defaultMeshCandidates;
  44811. /**
  44812. * @hidden
  44813. */
  44814. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44815. private _defaultSubMeshCandidates;
  44816. /**
  44817. * @hidden
  44818. */
  44819. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44820. /**
  44821. * Sets the default candidate providers for the scene.
  44822. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  44823. * and getCollidingSubMeshCandidates to their default function
  44824. */
  44825. setDefaultCandidateProviders(): void;
  44826. /**
  44827. * Gets the mesh that is currently under the pointer
  44828. */
  44829. get meshUnderPointer(): Nullable<AbstractMesh>;
  44830. /**
  44831. * Gets or sets the current on-screen X position of the pointer
  44832. */
  44833. get pointerX(): number;
  44834. set pointerX(value: number);
  44835. /**
  44836. * Gets or sets the current on-screen Y position of the pointer
  44837. */
  44838. get pointerY(): number;
  44839. set pointerY(value: number);
  44840. /**
  44841. * Gets the cached material (ie. the latest rendered one)
  44842. * @returns the cached material
  44843. */
  44844. getCachedMaterial(): Nullable<Material>;
  44845. /**
  44846. * Gets the cached effect (ie. the latest rendered one)
  44847. * @returns the cached effect
  44848. */
  44849. getCachedEffect(): Nullable<Effect>;
  44850. /**
  44851. * Gets the cached visibility state (ie. the latest rendered one)
  44852. * @returns the cached visibility state
  44853. */
  44854. getCachedVisibility(): Nullable<number>;
  44855. /**
  44856. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  44857. * @param material defines the current material
  44858. * @param effect defines the current effect
  44859. * @param visibility defines the current visibility state
  44860. * @returns true if one parameter is not cached
  44861. */
  44862. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  44863. /**
  44864. * Gets the engine associated with the scene
  44865. * @returns an Engine
  44866. */
  44867. getEngine(): Engine;
  44868. /**
  44869. * Gets the total number of vertices rendered per frame
  44870. * @returns the total number of vertices rendered per frame
  44871. */
  44872. getTotalVertices(): number;
  44873. /**
  44874. * Gets the performance counter for total vertices
  44875. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44876. */
  44877. get totalVerticesPerfCounter(): PerfCounter;
  44878. /**
  44879. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  44880. * @returns the total number of active indices rendered per frame
  44881. */
  44882. getActiveIndices(): number;
  44883. /**
  44884. * Gets the performance counter for active indices
  44885. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44886. */
  44887. get totalActiveIndicesPerfCounter(): PerfCounter;
  44888. /**
  44889. * Gets the total number of active particles rendered per frame
  44890. * @returns the total number of active particles rendered per frame
  44891. */
  44892. getActiveParticles(): number;
  44893. /**
  44894. * Gets the performance counter for active particles
  44895. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44896. */
  44897. get activeParticlesPerfCounter(): PerfCounter;
  44898. /**
  44899. * Gets the total number of active bones rendered per frame
  44900. * @returns the total number of active bones rendered per frame
  44901. */
  44902. getActiveBones(): number;
  44903. /**
  44904. * Gets the performance counter for active bones
  44905. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  44906. */
  44907. get activeBonesPerfCounter(): PerfCounter;
  44908. /**
  44909. * Gets the array of active meshes
  44910. * @returns an array of AbstractMesh
  44911. */
  44912. getActiveMeshes(): SmartArray<AbstractMesh>;
  44913. /**
  44914. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  44915. * @returns a number
  44916. */
  44917. getAnimationRatio(): number;
  44918. /**
  44919. * Gets an unique Id for the current render phase
  44920. * @returns a number
  44921. */
  44922. getRenderId(): number;
  44923. /**
  44924. * Gets an unique Id for the current frame
  44925. * @returns a number
  44926. */
  44927. getFrameId(): number;
  44928. /** Call this function if you want to manually increment the render Id*/
  44929. incrementRenderId(): void;
  44930. private _createUbo;
  44931. /**
  44932. * Use this method to simulate a pointer move on a mesh
  44933. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44934. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44935. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44936. * @returns the current scene
  44937. */
  44938. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44939. /**
  44940. * Use this method to simulate a pointer down on a mesh
  44941. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44942. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44943. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44944. * @returns the current scene
  44945. */
  44946. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  44947. /**
  44948. * Use this method to simulate a pointer up on a mesh
  44949. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44950. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44951. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44952. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44953. * @returns the current scene
  44954. */
  44955. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  44956. /**
  44957. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44958. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44959. * @returns true if the pointer was captured
  44960. */
  44961. isPointerCaptured(pointerId?: number): boolean;
  44962. /**
  44963. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44964. * @param attachUp defines if you want to attach events to pointerup
  44965. * @param attachDown defines if you want to attach events to pointerdown
  44966. * @param attachMove defines if you want to attach events to pointermove
  44967. */
  44968. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  44969. /** Detaches all event handlers*/
  44970. detachControl(): void;
  44971. /**
  44972. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  44973. * Delay loaded resources are not taking in account
  44974. * @return true if all required resources are ready
  44975. */
  44976. isReady(): boolean;
  44977. /** Resets all cached information relative to material (including effect and visibility) */
  44978. resetCachedMaterial(): void;
  44979. /**
  44980. * Registers a function to be called before every frame render
  44981. * @param func defines the function to register
  44982. */
  44983. registerBeforeRender(func: () => void): void;
  44984. /**
  44985. * Unregisters a function called before every frame render
  44986. * @param func defines the function to unregister
  44987. */
  44988. unregisterBeforeRender(func: () => void): void;
  44989. /**
  44990. * Registers a function to be called after every frame render
  44991. * @param func defines the function to register
  44992. */
  44993. registerAfterRender(func: () => void): void;
  44994. /**
  44995. * Unregisters a function called after every frame render
  44996. * @param func defines the function to unregister
  44997. */
  44998. unregisterAfterRender(func: () => void): void;
  44999. private _executeOnceBeforeRender;
  45000. /**
  45001. * The provided function will run before render once and will be disposed afterwards.
  45002. * A timeout delay can be provided so that the function will be executed in N ms.
  45003. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45004. * @param func The function to be executed.
  45005. * @param timeout optional delay in ms
  45006. */
  45007. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45008. /** @hidden */
  45009. _addPendingData(data: any): void;
  45010. /** @hidden */
  45011. _removePendingData(data: any): void;
  45012. /**
  45013. * Returns the number of items waiting to be loaded
  45014. * @returns the number of items waiting to be loaded
  45015. */
  45016. getWaitingItemsCount(): number;
  45017. /**
  45018. * Returns a boolean indicating if the scene is still loading data
  45019. */
  45020. get isLoading(): boolean;
  45021. /**
  45022. * Registers a function to be executed when the scene is ready
  45023. * @param {Function} func - the function to be executed
  45024. */
  45025. executeWhenReady(func: () => void): void;
  45026. /**
  45027. * Returns a promise that resolves when the scene is ready
  45028. * @returns A promise that resolves when the scene is ready
  45029. */
  45030. whenReadyAsync(): Promise<void>;
  45031. /** @hidden */
  45032. _checkIsReady(): void;
  45033. /**
  45034. * Gets all animatable attached to the scene
  45035. */
  45036. get animatables(): Animatable[];
  45037. /**
  45038. * Resets the last animation time frame.
  45039. * Useful to override when animations start running when loading a scene for the first time.
  45040. */
  45041. resetLastAnimationTimeFrame(): void;
  45042. /**
  45043. * Gets the current view matrix
  45044. * @returns a Matrix
  45045. */
  45046. getViewMatrix(): Matrix;
  45047. /**
  45048. * Gets the current projection matrix
  45049. * @returns a Matrix
  45050. */
  45051. getProjectionMatrix(): Matrix;
  45052. /**
  45053. * Gets the current transform matrix
  45054. * @returns a Matrix made of View * Projection
  45055. */
  45056. getTransformMatrix(): Matrix;
  45057. /**
  45058. * Sets the current transform matrix
  45059. * @param viewL defines the View matrix to use
  45060. * @param projectionL defines the Projection matrix to use
  45061. * @param viewR defines the right View matrix to use (if provided)
  45062. * @param projectionR defines the right Projection matrix to use (if provided)
  45063. */
  45064. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45065. /**
  45066. * Gets the uniform buffer used to store scene data
  45067. * @returns a UniformBuffer
  45068. */
  45069. getSceneUniformBuffer(): UniformBuffer;
  45070. /**
  45071. * Gets an unique (relatively to the current scene) Id
  45072. * @returns an unique number for the scene
  45073. */
  45074. getUniqueId(): number;
  45075. /**
  45076. * Add a mesh to the list of scene's meshes
  45077. * @param newMesh defines the mesh to add
  45078. * @param recursive if all child meshes should also be added to the scene
  45079. */
  45080. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45081. /**
  45082. * Remove a mesh for the list of scene's meshes
  45083. * @param toRemove defines the mesh to remove
  45084. * @param recursive if all child meshes should also be removed from the scene
  45085. * @returns the index where the mesh was in the mesh list
  45086. */
  45087. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45088. /**
  45089. * Add a transform node to the list of scene's transform nodes
  45090. * @param newTransformNode defines the transform node to add
  45091. */
  45092. addTransformNode(newTransformNode: TransformNode): void;
  45093. /**
  45094. * Remove a transform node for the list of scene's transform nodes
  45095. * @param toRemove defines the transform node to remove
  45096. * @returns the index where the transform node was in the transform node list
  45097. */
  45098. removeTransformNode(toRemove: TransformNode): number;
  45099. /**
  45100. * Remove a skeleton for the list of scene's skeletons
  45101. * @param toRemove defines the skeleton to remove
  45102. * @returns the index where the skeleton was in the skeleton list
  45103. */
  45104. removeSkeleton(toRemove: Skeleton): number;
  45105. /**
  45106. * Remove a morph target for the list of scene's morph targets
  45107. * @param toRemove defines the morph target to remove
  45108. * @returns the index where the morph target was in the morph target list
  45109. */
  45110. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45111. /**
  45112. * Remove a light for the list of scene's lights
  45113. * @param toRemove defines the light to remove
  45114. * @returns the index where the light was in the light list
  45115. */
  45116. removeLight(toRemove: Light): number;
  45117. /**
  45118. * Remove a camera for the list of scene's cameras
  45119. * @param toRemove defines the camera to remove
  45120. * @returns the index where the camera was in the camera list
  45121. */
  45122. removeCamera(toRemove: Camera): number;
  45123. /**
  45124. * Remove a particle system for the list of scene's particle systems
  45125. * @param toRemove defines the particle system to remove
  45126. * @returns the index where the particle system was in the particle system list
  45127. */
  45128. removeParticleSystem(toRemove: IParticleSystem): number;
  45129. /**
  45130. * Remove a animation for the list of scene's animations
  45131. * @param toRemove defines the animation to remove
  45132. * @returns the index where the animation was in the animation list
  45133. */
  45134. removeAnimation(toRemove: Animation): number;
  45135. /**
  45136. * Will stop the animation of the given target
  45137. * @param target - the target
  45138. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45139. * @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)
  45140. */
  45141. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45142. /**
  45143. * Removes the given animation group from this scene.
  45144. * @param toRemove The animation group to remove
  45145. * @returns The index of the removed animation group
  45146. */
  45147. removeAnimationGroup(toRemove: AnimationGroup): number;
  45148. /**
  45149. * Removes the given multi-material from this scene.
  45150. * @param toRemove The multi-material to remove
  45151. * @returns The index of the removed multi-material
  45152. */
  45153. removeMultiMaterial(toRemove: MultiMaterial): number;
  45154. /**
  45155. * Removes the given material from this scene.
  45156. * @param toRemove The material to remove
  45157. * @returns The index of the removed material
  45158. */
  45159. removeMaterial(toRemove: Material): number;
  45160. /**
  45161. * Removes the given action manager from this scene.
  45162. * @param toRemove The action manager to remove
  45163. * @returns The index of the removed action manager
  45164. */
  45165. removeActionManager(toRemove: AbstractActionManager): number;
  45166. /**
  45167. * Removes the given texture from this scene.
  45168. * @param toRemove The texture to remove
  45169. * @returns The index of the removed texture
  45170. */
  45171. removeTexture(toRemove: BaseTexture): number;
  45172. /**
  45173. * Adds the given light to this scene
  45174. * @param newLight The light to add
  45175. */
  45176. addLight(newLight: Light): void;
  45177. /**
  45178. * Sorts the list list based on light priorities
  45179. */
  45180. sortLightsByPriority(): void;
  45181. /**
  45182. * Adds the given camera to this scene
  45183. * @param newCamera The camera to add
  45184. */
  45185. addCamera(newCamera: Camera): void;
  45186. /**
  45187. * Adds the given skeleton to this scene
  45188. * @param newSkeleton The skeleton to add
  45189. */
  45190. addSkeleton(newSkeleton: Skeleton): void;
  45191. /**
  45192. * Adds the given particle system to this scene
  45193. * @param newParticleSystem The particle system to add
  45194. */
  45195. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45196. /**
  45197. * Adds the given animation to this scene
  45198. * @param newAnimation The animation to add
  45199. */
  45200. addAnimation(newAnimation: Animation): void;
  45201. /**
  45202. * Adds the given animation group to this scene.
  45203. * @param newAnimationGroup The animation group to add
  45204. */
  45205. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45206. /**
  45207. * Adds the given multi-material to this scene
  45208. * @param newMultiMaterial The multi-material to add
  45209. */
  45210. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45211. /**
  45212. * Adds the given material to this scene
  45213. * @param newMaterial The material to add
  45214. */
  45215. addMaterial(newMaterial: Material): void;
  45216. /**
  45217. * Adds the given morph target to this scene
  45218. * @param newMorphTargetManager The morph target to add
  45219. */
  45220. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45221. /**
  45222. * Adds the given geometry to this scene
  45223. * @param newGeometry The geometry to add
  45224. */
  45225. addGeometry(newGeometry: Geometry): void;
  45226. /**
  45227. * Adds the given action manager to this scene
  45228. * @param newActionManager The action manager to add
  45229. */
  45230. addActionManager(newActionManager: AbstractActionManager): void;
  45231. /**
  45232. * Adds the given texture to this scene.
  45233. * @param newTexture The texture to add
  45234. */
  45235. addTexture(newTexture: BaseTexture): void;
  45236. /**
  45237. * Switch active camera
  45238. * @param newCamera defines the new active camera
  45239. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45240. */
  45241. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45242. /**
  45243. * sets the active camera of the scene using its ID
  45244. * @param id defines the camera's ID
  45245. * @return the new active camera or null if none found.
  45246. */
  45247. setActiveCameraByID(id: string): Nullable<Camera>;
  45248. /**
  45249. * sets the active camera of the scene using its name
  45250. * @param name defines the camera's name
  45251. * @returns the new active camera or null if none found.
  45252. */
  45253. setActiveCameraByName(name: string): Nullable<Camera>;
  45254. /**
  45255. * get an animation group using its name
  45256. * @param name defines the material's name
  45257. * @return the animation group or null if none found.
  45258. */
  45259. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45260. /**
  45261. * Get a material using its unique id
  45262. * @param uniqueId defines the material's unique id
  45263. * @return the material or null if none found.
  45264. */
  45265. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45266. /**
  45267. * get a material using its id
  45268. * @param id defines the material's ID
  45269. * @return the material or null if none found.
  45270. */
  45271. getMaterialByID(id: string): Nullable<Material>;
  45272. /**
  45273. * Gets a the last added material using a given id
  45274. * @param id defines the material's ID
  45275. * @return the last material with the given id or null if none found.
  45276. */
  45277. getLastMaterialByID(id: string): Nullable<Material>;
  45278. /**
  45279. * Gets a material using its name
  45280. * @param name defines the material's name
  45281. * @return the material or null if none found.
  45282. */
  45283. getMaterialByName(name: string): Nullable<Material>;
  45284. /**
  45285. * Get a texture using its unique id
  45286. * @param uniqueId defines the texture's unique id
  45287. * @return the texture or null if none found.
  45288. */
  45289. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45290. /**
  45291. * Gets a camera using its id
  45292. * @param id defines the id to look for
  45293. * @returns the camera or null if not found
  45294. */
  45295. getCameraByID(id: string): Nullable<Camera>;
  45296. /**
  45297. * Gets a camera using its unique id
  45298. * @param uniqueId defines the unique id to look for
  45299. * @returns the camera or null if not found
  45300. */
  45301. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45302. /**
  45303. * Gets a camera using its name
  45304. * @param name defines the camera's name
  45305. * @return the camera or null if none found.
  45306. */
  45307. getCameraByName(name: string): Nullable<Camera>;
  45308. /**
  45309. * Gets a bone using its id
  45310. * @param id defines the bone's id
  45311. * @return the bone or null if not found
  45312. */
  45313. getBoneByID(id: string): Nullable<Bone>;
  45314. /**
  45315. * Gets a bone using its id
  45316. * @param name defines the bone's name
  45317. * @return the bone or null if not found
  45318. */
  45319. getBoneByName(name: string): Nullable<Bone>;
  45320. /**
  45321. * Gets a light node using its name
  45322. * @param name defines the the light's name
  45323. * @return the light or null if none found.
  45324. */
  45325. getLightByName(name: string): Nullable<Light>;
  45326. /**
  45327. * Gets a light node using its id
  45328. * @param id defines the light's id
  45329. * @return the light or null if none found.
  45330. */
  45331. getLightByID(id: string): Nullable<Light>;
  45332. /**
  45333. * Gets a light node using its scene-generated unique ID
  45334. * @param uniqueId defines the light's unique id
  45335. * @return the light or null if none found.
  45336. */
  45337. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45338. /**
  45339. * Gets a particle system by id
  45340. * @param id defines the particle system id
  45341. * @return the corresponding system or null if none found
  45342. */
  45343. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45344. /**
  45345. * Gets a geometry using its ID
  45346. * @param id defines the geometry's id
  45347. * @return the geometry or null if none found.
  45348. */
  45349. getGeometryByID(id: string): Nullable<Geometry>;
  45350. private _getGeometryByUniqueID;
  45351. /**
  45352. * Add a new geometry to this scene
  45353. * @param geometry defines the geometry to be added to the scene.
  45354. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45355. * @return a boolean defining if the geometry was added or not
  45356. */
  45357. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45358. /**
  45359. * Removes an existing geometry
  45360. * @param geometry defines the geometry to be removed from the scene
  45361. * @return a boolean defining if the geometry was removed or not
  45362. */
  45363. removeGeometry(geometry: Geometry): boolean;
  45364. /**
  45365. * Gets the list of geometries attached to the scene
  45366. * @returns an array of Geometry
  45367. */
  45368. getGeometries(): Geometry[];
  45369. /**
  45370. * Gets the first added mesh found of a given ID
  45371. * @param id defines the id to search for
  45372. * @return the mesh found or null if not found at all
  45373. */
  45374. getMeshByID(id: string): Nullable<AbstractMesh>;
  45375. /**
  45376. * Gets a list of meshes using their id
  45377. * @param id defines the id to search for
  45378. * @returns a list of meshes
  45379. */
  45380. getMeshesByID(id: string): Array<AbstractMesh>;
  45381. /**
  45382. * Gets the first added transform node found of a given ID
  45383. * @param id defines the id to search for
  45384. * @return the found transform node or null if not found at all.
  45385. */
  45386. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45387. /**
  45388. * Gets a transform node with its auto-generated unique id
  45389. * @param uniqueId efines the unique id to search for
  45390. * @return the found transform node or null if not found at all.
  45391. */
  45392. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45393. /**
  45394. * Gets a list of transform nodes using their id
  45395. * @param id defines the id to search for
  45396. * @returns a list of transform nodes
  45397. */
  45398. getTransformNodesByID(id: string): Array<TransformNode>;
  45399. /**
  45400. * Gets a mesh with its auto-generated unique id
  45401. * @param uniqueId defines the unique id to search for
  45402. * @return the found mesh or null if not found at all.
  45403. */
  45404. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45405. /**
  45406. * Gets a the last added mesh using a given id
  45407. * @param id defines the id to search for
  45408. * @return the found mesh or null if not found at all.
  45409. */
  45410. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45411. /**
  45412. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45413. * @param id defines the id to search for
  45414. * @return the found node or null if not found at all
  45415. */
  45416. getLastEntryByID(id: string): Nullable<Node>;
  45417. /**
  45418. * Gets a node (Mesh, Camera, Light) using a given id
  45419. * @param id defines the id to search for
  45420. * @return the found node or null if not found at all
  45421. */
  45422. getNodeByID(id: string): Nullable<Node>;
  45423. /**
  45424. * Gets a node (Mesh, Camera, Light) using a given name
  45425. * @param name defines the name to search for
  45426. * @return the found node or null if not found at all.
  45427. */
  45428. getNodeByName(name: string): Nullable<Node>;
  45429. /**
  45430. * Gets a mesh using a given name
  45431. * @param name defines the name to search for
  45432. * @return the found mesh or null if not found at all.
  45433. */
  45434. getMeshByName(name: string): Nullable<AbstractMesh>;
  45435. /**
  45436. * Gets a transform node using a given name
  45437. * @param name defines the name to search for
  45438. * @return the found transform node or null if not found at all.
  45439. */
  45440. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45441. /**
  45442. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45443. * @param id defines the id to search for
  45444. * @return the found skeleton or null if not found at all.
  45445. */
  45446. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45447. /**
  45448. * Gets a skeleton using a given auto generated unique id
  45449. * @param uniqueId defines the unique id to search for
  45450. * @return the found skeleton or null if not found at all.
  45451. */
  45452. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45453. /**
  45454. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45455. * @param id defines the id to search for
  45456. * @return the found skeleton or null if not found at all.
  45457. */
  45458. getSkeletonById(id: string): Nullable<Skeleton>;
  45459. /**
  45460. * Gets a skeleton using a given name
  45461. * @param name defines the name to search for
  45462. * @return the found skeleton or null if not found at all.
  45463. */
  45464. getSkeletonByName(name: string): Nullable<Skeleton>;
  45465. /**
  45466. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45467. * @param id defines the id to search for
  45468. * @return the found morph target manager or null if not found at all.
  45469. */
  45470. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45471. /**
  45472. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45473. * @param id defines the id to search for
  45474. * @return the found morph target or null if not found at all.
  45475. */
  45476. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45477. /**
  45478. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45479. * @param name defines the name to search for
  45480. * @return the found morph target or null if not found at all.
  45481. */
  45482. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45483. /**
  45484. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45485. * @param name defines the name to search for
  45486. * @return the found post process or null if not found at all.
  45487. */
  45488. getPostProcessByName(name: string): Nullable<PostProcess>;
  45489. /**
  45490. * Gets a boolean indicating if the given mesh is active
  45491. * @param mesh defines the mesh to look for
  45492. * @returns true if the mesh is in the active list
  45493. */
  45494. isActiveMesh(mesh: AbstractMesh): boolean;
  45495. /**
  45496. * Return a unique id as a string which can serve as an identifier for the scene
  45497. */
  45498. get uid(): string;
  45499. /**
  45500. * Add an externaly attached data from its key.
  45501. * This method call will fail and return false, if such key already exists.
  45502. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45503. * @param key the unique key that identifies the data
  45504. * @param data the data object to associate to the key for this Engine instance
  45505. * @return true if no such key were already present and the data was added successfully, false otherwise
  45506. */
  45507. addExternalData<T>(key: string, data: T): boolean;
  45508. /**
  45509. * Get an externaly attached data from its key
  45510. * @param key the unique key that identifies the data
  45511. * @return the associated data, if present (can be null), or undefined if not present
  45512. */
  45513. getExternalData<T>(key: string): Nullable<T>;
  45514. /**
  45515. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45516. * @param key the unique key that identifies the data
  45517. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45518. * @return the associated data, can be null if the factory returned null.
  45519. */
  45520. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45521. /**
  45522. * Remove an externaly attached data from the Engine instance
  45523. * @param key the unique key that identifies the data
  45524. * @return true if the data was successfully removed, false if it doesn't exist
  45525. */
  45526. removeExternalData(key: string): boolean;
  45527. private _evaluateSubMesh;
  45528. /**
  45529. * Clear the processed materials smart array preventing retention point in material dispose.
  45530. */
  45531. freeProcessedMaterials(): void;
  45532. private _preventFreeActiveMeshesAndRenderingGroups;
  45533. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45534. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45535. * when disposing several meshes in a row or a hierarchy of meshes.
  45536. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45537. */
  45538. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45539. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45540. /**
  45541. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45542. */
  45543. freeActiveMeshes(): void;
  45544. /**
  45545. * Clear the info related to rendering groups preventing retention points during dispose.
  45546. */
  45547. freeRenderingGroups(): void;
  45548. /** @hidden */
  45549. _isInIntermediateRendering(): boolean;
  45550. /**
  45551. * Lambda returning the list of potentially active meshes.
  45552. */
  45553. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45554. /**
  45555. * Lambda returning the list of potentially active sub meshes.
  45556. */
  45557. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45558. /**
  45559. * Lambda returning the list of potentially intersecting sub meshes.
  45560. */
  45561. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45562. /**
  45563. * Lambda returning the list of potentially colliding sub meshes.
  45564. */
  45565. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45566. private _activeMeshesFrozen;
  45567. private _skipEvaluateActiveMeshesCompletely;
  45568. /**
  45569. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45570. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45571. * @param onSuccess optional success callback
  45572. * @param onError optional error callback
  45573. * @returns the current scene
  45574. */
  45575. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45576. /**
  45577. * Use this function to restart evaluating active meshes on every frame
  45578. * @returns the current scene
  45579. */
  45580. unfreezeActiveMeshes(): Scene;
  45581. private _evaluateActiveMeshes;
  45582. private _activeMesh;
  45583. /**
  45584. * Update the transform matrix to update from the current active camera
  45585. * @param force defines a boolean used to force the update even if cache is up to date
  45586. */
  45587. updateTransformMatrix(force?: boolean): void;
  45588. private _bindFrameBuffer;
  45589. /** @hidden */
  45590. _allowPostProcessClearColor: boolean;
  45591. /** @hidden */
  45592. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45593. private _processSubCameras;
  45594. private _checkIntersections;
  45595. /** @hidden */
  45596. _advancePhysicsEngineStep(step: number): void;
  45597. /**
  45598. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45599. */
  45600. getDeterministicFrameTime: () => number;
  45601. /** @hidden */
  45602. _animate(): void;
  45603. /** Execute all animations (for a frame) */
  45604. animate(): void;
  45605. /**
  45606. * Render the scene
  45607. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45608. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45609. */
  45610. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45611. /**
  45612. * Freeze all materials
  45613. * A frozen material will not be updatable but should be faster to render
  45614. */
  45615. freezeMaterials(): void;
  45616. /**
  45617. * Unfreeze all materials
  45618. * A frozen material will not be updatable but should be faster to render
  45619. */
  45620. unfreezeMaterials(): void;
  45621. /**
  45622. * Releases all held ressources
  45623. */
  45624. dispose(): void;
  45625. /**
  45626. * Gets if the scene is already disposed
  45627. */
  45628. get isDisposed(): boolean;
  45629. /**
  45630. * Call this function to reduce memory footprint of the scene.
  45631. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45632. */
  45633. clearCachedVertexData(): void;
  45634. /**
  45635. * This function will remove the local cached buffer data from texture.
  45636. * It will save memory but will prevent the texture from being rebuilt
  45637. */
  45638. cleanCachedTextureBuffer(): void;
  45639. /**
  45640. * Get the world extend vectors with an optional filter
  45641. *
  45642. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45643. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45644. */
  45645. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45646. min: Vector3;
  45647. max: Vector3;
  45648. };
  45649. /**
  45650. * Creates a ray that can be used to pick in the scene
  45651. * @param x defines the x coordinate of the origin (on-screen)
  45652. * @param y defines the y coordinate of the origin (on-screen)
  45653. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45654. * @param camera defines the camera to use for the picking
  45655. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45656. * @returns a Ray
  45657. */
  45658. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45659. /**
  45660. * Creates a ray that can be used to pick in the scene
  45661. * @param x defines the x coordinate of the origin (on-screen)
  45662. * @param y defines the y coordinate of the origin (on-screen)
  45663. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45664. * @param result defines the ray where to store the picking ray
  45665. * @param camera defines the camera to use for the picking
  45666. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45667. * @returns the current scene
  45668. */
  45669. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  45670. /**
  45671. * Creates a ray that can be used to pick in the scene
  45672. * @param x defines the x coordinate of the origin (on-screen)
  45673. * @param y defines the y coordinate of the origin (on-screen)
  45674. * @param camera defines the camera to use for the picking
  45675. * @returns a Ray
  45676. */
  45677. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  45678. /**
  45679. * Creates a ray that can be used to pick in the scene
  45680. * @param x defines the x coordinate of the origin (on-screen)
  45681. * @param y defines the y coordinate of the origin (on-screen)
  45682. * @param result defines the ray where to store the picking ray
  45683. * @param camera defines the camera to use for the picking
  45684. * @returns the current scene
  45685. */
  45686. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  45687. /** Launch a ray to try to pick a mesh in the scene
  45688. * @param x position on screen
  45689. * @param y position on screen
  45690. * @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
  45691. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45692. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45693. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45694. * @returns a PickingInfo
  45695. */
  45696. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45697. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  45698. * @param x position on screen
  45699. * @param y position on screen
  45700. * @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
  45701. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45702. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45703. * @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)
  45704. */
  45705. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  45706. /** Use the given ray to pick a mesh in the scene
  45707. * @param ray The ray to use to pick meshes
  45708. * @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
  45709. * @param fastCheck defines if the first intersection will be used (and not the closest)
  45710. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45711. * @returns a PickingInfo
  45712. */
  45713. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  45714. /**
  45715. * Launch a ray to try to pick a mesh in the scene
  45716. * @param x X position on screen
  45717. * @param y Y position on screen
  45718. * @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
  45719. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  45720. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45721. * @returns an array of PickingInfo
  45722. */
  45723. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45724. /**
  45725. * Launch a ray to try to pick a mesh in the scene
  45726. * @param ray Ray to use
  45727. * @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
  45728. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  45729. * @returns an array of PickingInfo
  45730. */
  45731. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  45732. /**
  45733. * Force the value of meshUnderPointer
  45734. * @param mesh defines the mesh to use
  45735. * @param pointerId optional pointer id when using more than one pointer
  45736. */
  45737. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45738. /**
  45739. * Gets the mesh under the pointer
  45740. * @returns a Mesh or null if no mesh is under the pointer
  45741. */
  45742. getPointerOverMesh(): Nullable<AbstractMesh>;
  45743. /** @hidden */
  45744. _rebuildGeometries(): void;
  45745. /** @hidden */
  45746. _rebuildTextures(): void;
  45747. private _getByTags;
  45748. /**
  45749. * Get a list of meshes by tags
  45750. * @param tagsQuery defines the tags query to use
  45751. * @param forEach defines a predicate used to filter results
  45752. * @returns an array of Mesh
  45753. */
  45754. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  45755. /**
  45756. * Get a list of cameras by tags
  45757. * @param tagsQuery defines the tags query to use
  45758. * @param forEach defines a predicate used to filter results
  45759. * @returns an array of Camera
  45760. */
  45761. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  45762. /**
  45763. * Get a list of lights by tags
  45764. * @param tagsQuery defines the tags query to use
  45765. * @param forEach defines a predicate used to filter results
  45766. * @returns an array of Light
  45767. */
  45768. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  45769. /**
  45770. * Get a list of materials by tags
  45771. * @param tagsQuery defines the tags query to use
  45772. * @param forEach defines a predicate used to filter results
  45773. * @returns an array of Material
  45774. */
  45775. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  45776. /**
  45777. * Get a list of transform nodes by tags
  45778. * @param tagsQuery defines the tags query to use
  45779. * @param forEach defines a predicate used to filter results
  45780. * @returns an array of TransformNode
  45781. */
  45782. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  45783. /**
  45784. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  45785. * This allowed control for front to back rendering or reversly depending of the special needs.
  45786. *
  45787. * @param renderingGroupId The rendering group id corresponding to its index
  45788. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  45789. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  45790. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  45791. */
  45792. 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;
  45793. /**
  45794. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  45795. *
  45796. * @param renderingGroupId The rendering group id corresponding to its index
  45797. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45798. * @param depth Automatically clears depth between groups if true and autoClear is true.
  45799. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  45800. */
  45801. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  45802. /**
  45803. * Gets the current auto clear configuration for one rendering group of the rendering
  45804. * manager.
  45805. * @param index the rendering group index to get the information for
  45806. * @returns The auto clear setup for the requested rendering group
  45807. */
  45808. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  45809. private _blockMaterialDirtyMechanism;
  45810. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  45811. get blockMaterialDirtyMechanism(): boolean;
  45812. set blockMaterialDirtyMechanism(value: boolean);
  45813. /**
  45814. * Will flag all materials as dirty to trigger new shader compilation
  45815. * @param flag defines the flag used to specify which material part must be marked as dirty
  45816. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  45817. */
  45818. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  45819. /** @hidden */
  45820. _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;
  45821. /** @hidden */
  45822. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45823. /** @hidden */
  45824. _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;
  45825. /** @hidden */
  45826. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  45827. /** @hidden */
  45828. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  45829. /** @hidden */
  45830. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  45831. }
  45832. }
  45833. declare module "babylonjs/assetContainer" {
  45834. import { AbstractScene } from "babylonjs/abstractScene";
  45835. import { Scene } from "babylonjs/scene";
  45836. import { Mesh } from "babylonjs/Meshes/mesh";
  45837. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45838. import { Skeleton } from "babylonjs/Bones/skeleton";
  45839. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45840. import { Animatable } from "babylonjs/Animations/animatable";
  45841. import { Nullable } from "babylonjs/types";
  45842. import { Node } from "babylonjs/node";
  45843. /**
  45844. * Set of assets to keep when moving a scene into an asset container.
  45845. */
  45846. export class KeepAssets extends AbstractScene {
  45847. }
  45848. /**
  45849. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  45850. */
  45851. export class InstantiatedEntries {
  45852. /**
  45853. * List of new root nodes (eg. nodes with no parent)
  45854. */
  45855. rootNodes: TransformNode[];
  45856. /**
  45857. * List of new skeletons
  45858. */
  45859. skeletons: Skeleton[];
  45860. /**
  45861. * List of new animation groups
  45862. */
  45863. animationGroups: AnimationGroup[];
  45864. }
  45865. /**
  45866. * Container with a set of assets that can be added or removed from a scene.
  45867. */
  45868. export class AssetContainer extends AbstractScene {
  45869. private _wasAddedToScene;
  45870. /**
  45871. * The scene the AssetContainer belongs to.
  45872. */
  45873. scene: Scene;
  45874. /**
  45875. * Instantiates an AssetContainer.
  45876. * @param scene The scene the AssetContainer belongs to.
  45877. */
  45878. constructor(scene: Scene);
  45879. /**
  45880. * Instantiate or clone all meshes and add the new ones to the scene.
  45881. * Skeletons and animation groups will all be cloned
  45882. * @param nameFunction defines an optional function used to get new names for clones
  45883. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  45884. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  45885. */
  45886. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  45887. /**
  45888. * Adds all the assets from the container to the scene.
  45889. */
  45890. addAllToScene(): void;
  45891. /**
  45892. * Removes all the assets in the container from the scene
  45893. */
  45894. removeAllFromScene(): void;
  45895. /**
  45896. * Disposes all the assets in the container
  45897. */
  45898. dispose(): void;
  45899. private _moveAssets;
  45900. /**
  45901. * Removes all the assets contained in the scene and adds them to the container.
  45902. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  45903. */
  45904. moveAllFromScene(keepAssets?: KeepAssets): void;
  45905. /**
  45906. * 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.
  45907. * @returns the root mesh
  45908. */
  45909. createRootMesh(): Mesh;
  45910. /**
  45911. * Merge animations (direct and animation groups) from this asset container into a scene
  45912. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45913. * @param animatables set of animatables to retarget to a node from the scene
  45914. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  45915. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  45916. */
  45917. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  45918. }
  45919. }
  45920. declare module "babylonjs/abstractScene" {
  45921. import { Scene } from "babylonjs/scene";
  45922. import { Nullable } from "babylonjs/types";
  45923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45924. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45925. import { Geometry } from "babylonjs/Meshes/geometry";
  45926. import { Skeleton } from "babylonjs/Bones/skeleton";
  45927. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  45928. import { AssetContainer } from "babylonjs/assetContainer";
  45929. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45930. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45932. import { Material } from "babylonjs/Materials/material";
  45933. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  45934. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  45935. import { Camera } from "babylonjs/Cameras/camera";
  45936. import { Light } from "babylonjs/Lights/light";
  45937. import { Node } from "babylonjs/node";
  45938. import { Animation } from "babylonjs/Animations/animation";
  45939. /**
  45940. * Defines how the parser contract is defined.
  45941. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  45942. */
  45943. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  45944. /**
  45945. * Defines how the individual parser contract is defined.
  45946. * These parser can parse an individual asset
  45947. */
  45948. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  45949. /**
  45950. * Base class of the scene acting as a container for the different elements composing a scene.
  45951. * This class is dynamically extended by the different components of the scene increasing
  45952. * flexibility and reducing coupling
  45953. */
  45954. export abstract class AbstractScene {
  45955. /**
  45956. * Stores the list of available parsers in the application.
  45957. */
  45958. private static _BabylonFileParsers;
  45959. /**
  45960. * Stores the list of available individual parsers in the application.
  45961. */
  45962. private static _IndividualBabylonFileParsers;
  45963. /**
  45964. * Adds a parser in the list of available ones
  45965. * @param name Defines the name of the parser
  45966. * @param parser Defines the parser to add
  45967. */
  45968. static AddParser(name: string, parser: BabylonFileParser): void;
  45969. /**
  45970. * Gets a general parser from the list of avaialble ones
  45971. * @param name Defines the name of the parser
  45972. * @returns the requested parser or null
  45973. */
  45974. static GetParser(name: string): Nullable<BabylonFileParser>;
  45975. /**
  45976. * Adds n individual parser in the list of available ones
  45977. * @param name Defines the name of the parser
  45978. * @param parser Defines the parser to add
  45979. */
  45980. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  45981. /**
  45982. * Gets an individual parser from the list of avaialble ones
  45983. * @param name Defines the name of the parser
  45984. * @returns the requested parser or null
  45985. */
  45986. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  45987. /**
  45988. * Parser json data and populate both a scene and its associated container object
  45989. * @param jsonData Defines the data to parse
  45990. * @param scene Defines the scene to parse the data for
  45991. * @param container Defines the container attached to the parsing sequence
  45992. * @param rootUrl Defines the root url of the data
  45993. */
  45994. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  45995. /**
  45996. * Gets the list of root nodes (ie. nodes with no parent)
  45997. */
  45998. rootNodes: Node[];
  45999. /** All of the cameras added to this scene
  46000. * @see https://doc.babylonjs.com/babylon101/cameras
  46001. */
  46002. cameras: Camera[];
  46003. /**
  46004. * All of the lights added to this scene
  46005. * @see https://doc.babylonjs.com/babylon101/lights
  46006. */
  46007. lights: Light[];
  46008. /**
  46009. * All of the (abstract) meshes added to this scene
  46010. */
  46011. meshes: AbstractMesh[];
  46012. /**
  46013. * The list of skeletons added to the scene
  46014. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46015. */
  46016. skeletons: Skeleton[];
  46017. /**
  46018. * All of the particle systems added to this scene
  46019. * @see https://doc.babylonjs.com/babylon101/particles
  46020. */
  46021. particleSystems: IParticleSystem[];
  46022. /**
  46023. * Gets a list of Animations associated with the scene
  46024. */
  46025. animations: Animation[];
  46026. /**
  46027. * All of the animation groups added to this scene
  46028. * @see https://doc.babylonjs.com/how_to/group
  46029. */
  46030. animationGroups: AnimationGroup[];
  46031. /**
  46032. * All of the multi-materials added to this scene
  46033. * @see https://doc.babylonjs.com/how_to/multi_materials
  46034. */
  46035. multiMaterials: MultiMaterial[];
  46036. /**
  46037. * All of the materials added to this scene
  46038. * In the context of a Scene, it is not supposed to be modified manually.
  46039. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46040. * Note also that the order of the Material within the array is not significant and might change.
  46041. * @see https://doc.babylonjs.com/babylon101/materials
  46042. */
  46043. materials: Material[];
  46044. /**
  46045. * The list of morph target managers added to the scene
  46046. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46047. */
  46048. morphTargetManagers: MorphTargetManager[];
  46049. /**
  46050. * The list of geometries used in the scene.
  46051. */
  46052. geometries: Geometry[];
  46053. /**
  46054. * All of the tranform nodes added to this scene
  46055. * In the context of a Scene, it is not supposed to be modified manually.
  46056. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46057. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46058. * @see https://doc.babylonjs.com/how_to/transformnode
  46059. */
  46060. transformNodes: TransformNode[];
  46061. /**
  46062. * ActionManagers available on the scene.
  46063. */
  46064. actionManagers: AbstractActionManager[];
  46065. /**
  46066. * Textures to keep.
  46067. */
  46068. textures: BaseTexture[];
  46069. /** @hidden */
  46070. protected _environmentTexture: Nullable<BaseTexture>;
  46071. /**
  46072. * Texture used in all pbr material as the reflection texture.
  46073. * As in the majority of the scene they are the same (exception for multi room and so on),
  46074. * this is easier to reference from here than from all the materials.
  46075. */
  46076. get environmentTexture(): Nullable<BaseTexture>;
  46077. set environmentTexture(value: Nullable<BaseTexture>);
  46078. /**
  46079. * The list of postprocesses added to the scene
  46080. */
  46081. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46082. /**
  46083. * @returns all meshes, lights, cameras, transformNodes and bones
  46084. */
  46085. getNodes(): Array<Node>;
  46086. }
  46087. }
  46088. declare module "babylonjs/Audio/sound" {
  46089. import { Observable } from "babylonjs/Misc/observable";
  46090. import { Vector3 } from "babylonjs/Maths/math.vector";
  46091. import { Nullable } from "babylonjs/types";
  46092. import { Scene } from "babylonjs/scene";
  46093. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46094. /**
  46095. * Interface used to define options for Sound class
  46096. */
  46097. export interface ISoundOptions {
  46098. /**
  46099. * Does the sound autoplay once loaded.
  46100. */
  46101. autoplay?: boolean;
  46102. /**
  46103. * Does the sound loop after it finishes playing once.
  46104. */
  46105. loop?: boolean;
  46106. /**
  46107. * Sound's volume
  46108. */
  46109. volume?: number;
  46110. /**
  46111. * Is it a spatial sound?
  46112. */
  46113. spatialSound?: boolean;
  46114. /**
  46115. * Maximum distance to hear that sound
  46116. */
  46117. maxDistance?: number;
  46118. /**
  46119. * Uses user defined attenuation function
  46120. */
  46121. useCustomAttenuation?: boolean;
  46122. /**
  46123. * Define the roll off factor of spatial sounds.
  46124. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46125. */
  46126. rolloffFactor?: number;
  46127. /**
  46128. * Define the reference distance the sound should be heard perfectly.
  46129. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46130. */
  46131. refDistance?: number;
  46132. /**
  46133. * Define the distance attenuation model the sound will follow.
  46134. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46135. */
  46136. distanceModel?: string;
  46137. /**
  46138. * Defines the playback speed (1 by default)
  46139. */
  46140. playbackRate?: number;
  46141. /**
  46142. * Defines if the sound is from a streaming source
  46143. */
  46144. streaming?: boolean;
  46145. /**
  46146. * Defines an optional length (in seconds) inside the sound file
  46147. */
  46148. length?: number;
  46149. /**
  46150. * Defines an optional offset (in seconds) inside the sound file
  46151. */
  46152. offset?: number;
  46153. /**
  46154. * If true, URLs will not be required to state the audio file codec to use.
  46155. */
  46156. skipCodecCheck?: boolean;
  46157. }
  46158. /**
  46159. * Defines a sound that can be played in the application.
  46160. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46161. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46162. */
  46163. export class Sound {
  46164. /**
  46165. * The name of the sound in the scene.
  46166. */
  46167. name: string;
  46168. /**
  46169. * Does the sound autoplay once loaded.
  46170. */
  46171. autoplay: boolean;
  46172. /**
  46173. * Does the sound loop after it finishes playing once.
  46174. */
  46175. loop: boolean;
  46176. /**
  46177. * Does the sound use a custom attenuation curve to simulate the falloff
  46178. * happening when the source gets further away from the camera.
  46179. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46180. */
  46181. useCustomAttenuation: boolean;
  46182. /**
  46183. * The sound track id this sound belongs to.
  46184. */
  46185. soundTrackId: number;
  46186. /**
  46187. * Is this sound currently played.
  46188. */
  46189. isPlaying: boolean;
  46190. /**
  46191. * Is this sound currently paused.
  46192. */
  46193. isPaused: boolean;
  46194. /**
  46195. * Does this sound enables spatial sound.
  46196. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46197. */
  46198. spatialSound: boolean;
  46199. /**
  46200. * Define the reference distance the sound should be heard perfectly.
  46201. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46202. */
  46203. refDistance: number;
  46204. /**
  46205. * Define the roll off factor of spatial sounds.
  46206. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46207. */
  46208. rolloffFactor: number;
  46209. /**
  46210. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46211. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46212. */
  46213. maxDistance: number;
  46214. /**
  46215. * Define the distance attenuation model the sound will follow.
  46216. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46217. */
  46218. distanceModel: string;
  46219. /**
  46220. * @hidden
  46221. * Back Compat
  46222. **/
  46223. onended: () => any;
  46224. /**
  46225. * Gets or sets an object used to store user defined information for the sound.
  46226. */
  46227. metadata: any;
  46228. /**
  46229. * Observable event when the current playing sound finishes.
  46230. */
  46231. onEndedObservable: Observable<Sound>;
  46232. private _panningModel;
  46233. private _playbackRate;
  46234. private _streaming;
  46235. private _startTime;
  46236. private _startOffset;
  46237. private _position;
  46238. /** @hidden */
  46239. _positionInEmitterSpace: boolean;
  46240. private _localDirection;
  46241. private _volume;
  46242. private _isReadyToPlay;
  46243. private _isDirectional;
  46244. private _readyToPlayCallback;
  46245. private _audioBuffer;
  46246. private _soundSource;
  46247. private _streamingSource;
  46248. private _soundPanner;
  46249. private _soundGain;
  46250. private _inputAudioNode;
  46251. private _outputAudioNode;
  46252. private _coneInnerAngle;
  46253. private _coneOuterAngle;
  46254. private _coneOuterGain;
  46255. private _scene;
  46256. private _connectedTransformNode;
  46257. private _customAttenuationFunction;
  46258. private _registerFunc;
  46259. private _isOutputConnected;
  46260. private _htmlAudioElement;
  46261. private _urlType;
  46262. private _length?;
  46263. private _offset?;
  46264. /** @hidden */
  46265. static _SceneComponentInitialization: (scene: Scene) => void;
  46266. /**
  46267. * Create a sound and attach it to a scene
  46268. * @param name Name of your sound
  46269. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46270. * @param scene defines the scene the sound belongs to
  46271. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46272. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46273. */
  46274. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46275. /**
  46276. * Release the sound and its associated resources
  46277. */
  46278. dispose(): void;
  46279. /**
  46280. * Gets if the sounds is ready to be played or not.
  46281. * @returns true if ready, otherwise false
  46282. */
  46283. isReady(): boolean;
  46284. private _soundLoaded;
  46285. /**
  46286. * Sets the data of the sound from an audiobuffer
  46287. * @param audioBuffer The audioBuffer containing the data
  46288. */
  46289. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46290. /**
  46291. * Updates the current sounds options such as maxdistance, loop...
  46292. * @param options A JSON object containing values named as the object properties
  46293. */
  46294. updateOptions(options: ISoundOptions): void;
  46295. private _createSpatialParameters;
  46296. private _updateSpatialParameters;
  46297. /**
  46298. * Switch the panning model to HRTF:
  46299. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46300. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46301. */
  46302. switchPanningModelToHRTF(): void;
  46303. /**
  46304. * Switch the panning model to Equal Power:
  46305. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46306. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46307. */
  46308. switchPanningModelToEqualPower(): void;
  46309. private _switchPanningModel;
  46310. /**
  46311. * Connect this sound to a sound track audio node like gain...
  46312. * @param soundTrackAudioNode the sound track audio node to connect to
  46313. */
  46314. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46315. /**
  46316. * Transform this sound into a directional source
  46317. * @param coneInnerAngle Size of the inner cone in degree
  46318. * @param coneOuterAngle Size of the outer cone in degree
  46319. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46320. */
  46321. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46322. /**
  46323. * Gets or sets the inner angle for the directional cone.
  46324. */
  46325. get directionalConeInnerAngle(): number;
  46326. /**
  46327. * Gets or sets the inner angle for the directional cone.
  46328. */
  46329. set directionalConeInnerAngle(value: number);
  46330. /**
  46331. * Gets or sets the outer angle for the directional cone.
  46332. */
  46333. get directionalConeOuterAngle(): number;
  46334. /**
  46335. * Gets or sets the outer angle for the directional cone.
  46336. */
  46337. set directionalConeOuterAngle(value: number);
  46338. /**
  46339. * Sets the position of the emitter if spatial sound is enabled
  46340. * @param newPosition Defines the new posisiton
  46341. */
  46342. setPosition(newPosition: Vector3): void;
  46343. /**
  46344. * Sets the local direction of the emitter if spatial sound is enabled
  46345. * @param newLocalDirection Defines the new local direction
  46346. */
  46347. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46348. private _updateDirection;
  46349. /** @hidden */
  46350. updateDistanceFromListener(): void;
  46351. /**
  46352. * Sets a new custom attenuation function for the sound.
  46353. * @param callback Defines the function used for the attenuation
  46354. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46355. */
  46356. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46357. /**
  46358. * Play the sound
  46359. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46360. * @param offset (optional) Start the sound at a specific time in seconds
  46361. * @param length (optional) Sound duration (in seconds)
  46362. */
  46363. play(time?: number, offset?: number, length?: number): void;
  46364. private _onended;
  46365. /**
  46366. * Stop the sound
  46367. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46368. */
  46369. stop(time?: number): void;
  46370. /**
  46371. * Put the sound in pause
  46372. */
  46373. pause(): void;
  46374. /**
  46375. * Sets a dedicated volume for this sounds
  46376. * @param newVolume Define the new volume of the sound
  46377. * @param time Define time for gradual change to new volume
  46378. */
  46379. setVolume(newVolume: number, time?: number): void;
  46380. /**
  46381. * Set the sound play back rate
  46382. * @param newPlaybackRate Define the playback rate the sound should be played at
  46383. */
  46384. setPlaybackRate(newPlaybackRate: number): void;
  46385. /**
  46386. * Gets the volume of the sound.
  46387. * @returns the volume of the sound
  46388. */
  46389. getVolume(): number;
  46390. /**
  46391. * Attach the sound to a dedicated mesh
  46392. * @param transformNode The transform node to connect the sound with
  46393. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46394. */
  46395. attachToMesh(transformNode: TransformNode): void;
  46396. /**
  46397. * Detach the sound from the previously attached mesh
  46398. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46399. */
  46400. detachFromMesh(): void;
  46401. private _onRegisterAfterWorldMatrixUpdate;
  46402. /**
  46403. * Clone the current sound in the scene.
  46404. * @returns the new sound clone
  46405. */
  46406. clone(): Nullable<Sound>;
  46407. /**
  46408. * Gets the current underlying audio buffer containing the data
  46409. * @returns the audio buffer
  46410. */
  46411. getAudioBuffer(): Nullable<AudioBuffer>;
  46412. /**
  46413. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46414. * @returns the source node
  46415. */
  46416. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46417. /**
  46418. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46419. * @returns the gain node
  46420. */
  46421. getSoundGain(): Nullable<GainNode>;
  46422. /**
  46423. * Serializes the Sound in a JSON representation
  46424. * @returns the JSON representation of the sound
  46425. */
  46426. serialize(): any;
  46427. /**
  46428. * Parse a JSON representation of a sound to innstantiate in a given scene
  46429. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46430. * @param scene Define the scene the new parsed sound should be created in
  46431. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46432. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46433. * @returns the newly parsed sound
  46434. */
  46435. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46436. }
  46437. }
  46438. declare module "babylonjs/Actions/directAudioActions" {
  46439. import { Action } from "babylonjs/Actions/action";
  46440. import { Condition } from "babylonjs/Actions/condition";
  46441. import { Sound } from "babylonjs/Audio/sound";
  46442. /**
  46443. * This defines an action helpful to play a defined sound on a triggered action.
  46444. */
  46445. export class PlaySoundAction extends Action {
  46446. private _sound;
  46447. /**
  46448. * Instantiate the action
  46449. * @param triggerOptions defines the trigger options
  46450. * @param sound defines the sound to play
  46451. * @param condition defines the trigger related conditions
  46452. */
  46453. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46454. /** @hidden */
  46455. _prepare(): void;
  46456. /**
  46457. * Execute the action and play the sound.
  46458. */
  46459. execute(): void;
  46460. /**
  46461. * Serializes the actions and its related information.
  46462. * @param parent defines the object to serialize in
  46463. * @returns the serialized object
  46464. */
  46465. serialize(parent: any): any;
  46466. }
  46467. /**
  46468. * This defines an action helpful to stop a defined sound on a triggered action.
  46469. */
  46470. export class StopSoundAction extends Action {
  46471. private _sound;
  46472. /**
  46473. * Instantiate the action
  46474. * @param triggerOptions defines the trigger options
  46475. * @param sound defines the sound to stop
  46476. * @param condition defines the trigger related conditions
  46477. */
  46478. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46479. /** @hidden */
  46480. _prepare(): void;
  46481. /**
  46482. * Execute the action and stop the sound.
  46483. */
  46484. execute(): void;
  46485. /**
  46486. * Serializes the actions and its related information.
  46487. * @param parent defines the object to serialize in
  46488. * @returns the serialized object
  46489. */
  46490. serialize(parent: any): any;
  46491. }
  46492. }
  46493. declare module "babylonjs/Actions/interpolateValueAction" {
  46494. import { Action } from "babylonjs/Actions/action";
  46495. import { Condition } from "babylonjs/Actions/condition";
  46496. import { Observable } from "babylonjs/Misc/observable";
  46497. /**
  46498. * This defines an action responsible to change the value of a property
  46499. * by interpolating between its current value and the newly set one once triggered.
  46500. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46501. */
  46502. export class InterpolateValueAction extends Action {
  46503. /**
  46504. * Defines the path of the property where the value should be interpolated
  46505. */
  46506. propertyPath: string;
  46507. /**
  46508. * Defines the target value at the end of the interpolation.
  46509. */
  46510. value: any;
  46511. /**
  46512. * Defines the time it will take for the property to interpolate to the value.
  46513. */
  46514. duration: number;
  46515. /**
  46516. * Defines if the other scene animations should be stopped when the action has been triggered
  46517. */
  46518. stopOtherAnimations?: boolean;
  46519. /**
  46520. * Defines a callback raised once the interpolation animation has been done.
  46521. */
  46522. onInterpolationDone?: () => void;
  46523. /**
  46524. * Observable triggered once the interpolation animation has been done.
  46525. */
  46526. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46527. private _target;
  46528. private _effectiveTarget;
  46529. private _property;
  46530. /**
  46531. * Instantiate the action
  46532. * @param triggerOptions defines the trigger options
  46533. * @param target defines the object containing the value to interpolate
  46534. * @param propertyPath defines the path to the property in the target object
  46535. * @param value defines the target value at the end of the interpolation
  46536. * @param duration deines the time it will take for the property to interpolate to the value.
  46537. * @param condition defines the trigger related conditions
  46538. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46539. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46540. */
  46541. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46542. /** @hidden */
  46543. _prepare(): void;
  46544. /**
  46545. * Execute the action starts the value interpolation.
  46546. */
  46547. execute(): void;
  46548. /**
  46549. * Serializes the actions and its related information.
  46550. * @param parent defines the object to serialize in
  46551. * @returns the serialized object
  46552. */
  46553. serialize(parent: any): any;
  46554. }
  46555. }
  46556. declare module "babylonjs/Actions/index" {
  46557. export * from "babylonjs/Actions/abstractActionManager";
  46558. export * from "babylonjs/Actions/action";
  46559. export * from "babylonjs/Actions/actionEvent";
  46560. export * from "babylonjs/Actions/actionManager";
  46561. export * from "babylonjs/Actions/condition";
  46562. export * from "babylonjs/Actions/directActions";
  46563. export * from "babylonjs/Actions/directAudioActions";
  46564. export * from "babylonjs/Actions/interpolateValueAction";
  46565. }
  46566. declare module "babylonjs/Animations/index" {
  46567. export * from "babylonjs/Animations/animatable";
  46568. export * from "babylonjs/Animations/animation";
  46569. export * from "babylonjs/Animations/animationGroup";
  46570. export * from "babylonjs/Animations/animationPropertiesOverride";
  46571. export * from "babylonjs/Animations/easing";
  46572. export * from "babylonjs/Animations/runtimeAnimation";
  46573. export * from "babylonjs/Animations/animationEvent";
  46574. export * from "babylonjs/Animations/animationGroup";
  46575. export * from "babylonjs/Animations/animationKey";
  46576. export * from "babylonjs/Animations/animationRange";
  46577. export * from "babylonjs/Animations/animatable.interface";
  46578. }
  46579. declare module "babylonjs/Audio/soundTrack" {
  46580. import { Sound } from "babylonjs/Audio/sound";
  46581. import { Analyser } from "babylonjs/Audio/analyser";
  46582. import { Scene } from "babylonjs/scene";
  46583. /**
  46584. * Options allowed during the creation of a sound track.
  46585. */
  46586. export interface ISoundTrackOptions {
  46587. /**
  46588. * The volume the sound track should take during creation
  46589. */
  46590. volume?: number;
  46591. /**
  46592. * Define if the sound track is the main sound track of the scene
  46593. */
  46594. mainTrack?: boolean;
  46595. }
  46596. /**
  46597. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46598. * It will be also used in a future release to apply effects on a specific track.
  46599. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46600. */
  46601. export class SoundTrack {
  46602. /**
  46603. * The unique identifier of the sound track in the scene.
  46604. */
  46605. id: number;
  46606. /**
  46607. * The list of sounds included in the sound track.
  46608. */
  46609. soundCollection: Array<Sound>;
  46610. private _outputAudioNode;
  46611. private _scene;
  46612. private _connectedAnalyser;
  46613. private _options;
  46614. private _isInitialized;
  46615. /**
  46616. * Creates a new sound track.
  46617. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46618. * @param scene Define the scene the sound track belongs to
  46619. * @param options
  46620. */
  46621. constructor(scene: Scene, options?: ISoundTrackOptions);
  46622. private _initializeSoundTrackAudioGraph;
  46623. /**
  46624. * Release the sound track and its associated resources
  46625. */
  46626. dispose(): void;
  46627. /**
  46628. * Adds a sound to this sound track
  46629. * @param sound define the cound to add
  46630. * @ignoreNaming
  46631. */
  46632. AddSound(sound: Sound): void;
  46633. /**
  46634. * Removes a sound to this sound track
  46635. * @param sound define the cound to remove
  46636. * @ignoreNaming
  46637. */
  46638. RemoveSound(sound: Sound): void;
  46639. /**
  46640. * Set a global volume for the full sound track.
  46641. * @param newVolume Define the new volume of the sound track
  46642. */
  46643. setVolume(newVolume: number): void;
  46644. /**
  46645. * Switch the panning model to HRTF:
  46646. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46648. */
  46649. switchPanningModelToHRTF(): void;
  46650. /**
  46651. * Switch the panning model to Equal Power:
  46652. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46654. */
  46655. switchPanningModelToEqualPower(): void;
  46656. /**
  46657. * Connect the sound track to an audio analyser allowing some amazing
  46658. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46659. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46660. * @param analyser The analyser to connect to the engine
  46661. */
  46662. connectToAnalyser(analyser: Analyser): void;
  46663. }
  46664. }
  46665. declare module "babylonjs/Audio/audioSceneComponent" {
  46666. import { Sound } from "babylonjs/Audio/sound";
  46667. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  46668. import { Nullable } from "babylonjs/types";
  46669. import { Vector3 } from "babylonjs/Maths/math.vector";
  46670. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46671. import { Scene } from "babylonjs/scene";
  46672. import { AbstractScene } from "babylonjs/abstractScene";
  46673. import "babylonjs/Audio/audioEngine";
  46674. module "babylonjs/abstractScene" {
  46675. interface AbstractScene {
  46676. /**
  46677. * The list of sounds used in the scene.
  46678. */
  46679. sounds: Nullable<Array<Sound>>;
  46680. }
  46681. }
  46682. module "babylonjs/scene" {
  46683. interface Scene {
  46684. /**
  46685. * @hidden
  46686. * Backing field
  46687. */
  46688. _mainSoundTrack: SoundTrack;
  46689. /**
  46690. * The main sound track played by the scene.
  46691. * It cotains your primary collection of sounds.
  46692. */
  46693. mainSoundTrack: SoundTrack;
  46694. /**
  46695. * The list of sound tracks added to the scene
  46696. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46697. */
  46698. soundTracks: Nullable<Array<SoundTrack>>;
  46699. /**
  46700. * Gets a sound using a given name
  46701. * @param name defines the name to search for
  46702. * @return the found sound or null if not found at all.
  46703. */
  46704. getSoundByName(name: string): Nullable<Sound>;
  46705. /**
  46706. * Gets or sets if audio support is enabled
  46707. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46708. */
  46709. audioEnabled: boolean;
  46710. /**
  46711. * Gets or sets if audio will be output to headphones
  46712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46713. */
  46714. headphone: boolean;
  46715. /**
  46716. * Gets or sets custom audio listener position provider
  46717. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46718. */
  46719. audioListenerPositionProvider: Nullable<() => Vector3>;
  46720. /**
  46721. * Gets or sets a refresh rate when using 3D audio positioning
  46722. */
  46723. audioPositioningRefreshRate: number;
  46724. }
  46725. }
  46726. /**
  46727. * Defines the sound scene component responsible to manage any sounds
  46728. * in a given scene.
  46729. */
  46730. export class AudioSceneComponent implements ISceneSerializableComponent {
  46731. private static _CameraDirectionLH;
  46732. private static _CameraDirectionRH;
  46733. /**
  46734. * The component name helpfull to identify the component in the list of scene components.
  46735. */
  46736. readonly name: string;
  46737. /**
  46738. * The scene the component belongs to.
  46739. */
  46740. scene: Scene;
  46741. private _audioEnabled;
  46742. /**
  46743. * Gets whether audio is enabled or not.
  46744. * Please use related enable/disable method to switch state.
  46745. */
  46746. get audioEnabled(): boolean;
  46747. private _headphone;
  46748. /**
  46749. * Gets whether audio is outputing to headphone or not.
  46750. * Please use the according Switch methods to change output.
  46751. */
  46752. get headphone(): boolean;
  46753. /**
  46754. * Gets or sets a refresh rate when using 3D audio positioning
  46755. */
  46756. audioPositioningRefreshRate: number;
  46757. private _audioListenerPositionProvider;
  46758. /**
  46759. * Gets the current audio listener position provider
  46760. */
  46761. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  46762. /**
  46763. * Sets a custom listener position for all sounds in the scene
  46764. * By default, this is the position of the first active camera
  46765. */
  46766. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  46767. /**
  46768. * Creates a new instance of the component for the given scene
  46769. * @param scene Defines the scene to register the component in
  46770. */
  46771. constructor(scene: Scene);
  46772. /**
  46773. * Registers the component in a given scene
  46774. */
  46775. register(): void;
  46776. /**
  46777. * Rebuilds the elements related to this component in case of
  46778. * context lost for instance.
  46779. */
  46780. rebuild(): void;
  46781. /**
  46782. * Serializes the component data to the specified json object
  46783. * @param serializationObject The object to serialize to
  46784. */
  46785. serialize(serializationObject: any): void;
  46786. /**
  46787. * Adds all the elements from the container to the scene
  46788. * @param container the container holding the elements
  46789. */
  46790. addFromContainer(container: AbstractScene): void;
  46791. /**
  46792. * Removes all the elements in the container from the scene
  46793. * @param container contains the elements to remove
  46794. * @param dispose if the removed element should be disposed (default: false)
  46795. */
  46796. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46797. /**
  46798. * Disposes the component and the associated ressources.
  46799. */
  46800. dispose(): void;
  46801. /**
  46802. * Disables audio in the associated scene.
  46803. */
  46804. disableAudio(): void;
  46805. /**
  46806. * Enables audio in the associated scene.
  46807. */
  46808. enableAudio(): void;
  46809. /**
  46810. * Switch audio to headphone output.
  46811. */
  46812. switchAudioModeForHeadphones(): void;
  46813. /**
  46814. * Switch audio to normal speakers.
  46815. */
  46816. switchAudioModeForNormalSpeakers(): void;
  46817. private _cachedCameraDirection;
  46818. private _cachedCameraPosition;
  46819. private _lastCheck;
  46820. private _afterRender;
  46821. }
  46822. }
  46823. declare module "babylonjs/Audio/weightedsound" {
  46824. import { Sound } from "babylonjs/Audio/sound";
  46825. /**
  46826. * Wraps one or more Sound objects and selects one with random weight for playback.
  46827. */
  46828. export class WeightedSound {
  46829. /** When true a Sound will be selected and played when the current playing Sound completes. */
  46830. loop: boolean;
  46831. private _coneInnerAngle;
  46832. private _coneOuterAngle;
  46833. private _volume;
  46834. /** A Sound is currently playing. */
  46835. isPlaying: boolean;
  46836. /** A Sound is currently paused. */
  46837. isPaused: boolean;
  46838. private _sounds;
  46839. private _weights;
  46840. private _currentIndex?;
  46841. /**
  46842. * Creates a new WeightedSound from the list of sounds given.
  46843. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  46844. * @param sounds Array of Sounds that will be selected from.
  46845. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  46846. */
  46847. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  46848. /**
  46849. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  46850. */
  46851. get directionalConeInnerAngle(): number;
  46852. /**
  46853. * The size of cone in degress for a directional sound in which there will be no attenuation.
  46854. */
  46855. set directionalConeInnerAngle(value: number);
  46856. /**
  46857. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46858. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46859. */
  46860. get directionalConeOuterAngle(): number;
  46861. /**
  46862. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  46863. * Listener angles between innerAngle and outerAngle will falloff linearly.
  46864. */
  46865. set directionalConeOuterAngle(value: number);
  46866. /**
  46867. * Playback volume.
  46868. */
  46869. get volume(): number;
  46870. /**
  46871. * Playback volume.
  46872. */
  46873. set volume(value: number);
  46874. private _onended;
  46875. /**
  46876. * Suspend playback
  46877. */
  46878. pause(): void;
  46879. /**
  46880. * Stop playback
  46881. */
  46882. stop(): void;
  46883. /**
  46884. * Start playback.
  46885. * @param startOffset Position the clip head at a specific time in seconds.
  46886. */
  46887. play(startOffset?: number): void;
  46888. }
  46889. }
  46890. declare module "babylonjs/Audio/index" {
  46891. export * from "babylonjs/Audio/analyser";
  46892. export * from "babylonjs/Audio/audioEngine";
  46893. export * from "babylonjs/Audio/audioSceneComponent";
  46894. export * from "babylonjs/Audio/sound";
  46895. export * from "babylonjs/Audio/soundTrack";
  46896. export * from "babylonjs/Audio/weightedsound";
  46897. }
  46898. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  46899. import { Behavior } from "babylonjs/Behaviors/behavior";
  46900. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46901. import { BackEase } from "babylonjs/Animations/easing";
  46902. /**
  46903. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  46904. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46905. */
  46906. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  46907. /**
  46908. * Gets the name of the behavior.
  46909. */
  46910. get name(): string;
  46911. /**
  46912. * The easing function used by animations
  46913. */
  46914. static EasingFunction: BackEase;
  46915. /**
  46916. * The easing mode used by animations
  46917. */
  46918. static EasingMode: number;
  46919. /**
  46920. * The duration of the animation, in milliseconds
  46921. */
  46922. transitionDuration: number;
  46923. /**
  46924. * Length of the distance animated by the transition when lower radius is reached
  46925. */
  46926. lowerRadiusTransitionRange: number;
  46927. /**
  46928. * Length of the distance animated by the transition when upper radius is reached
  46929. */
  46930. upperRadiusTransitionRange: number;
  46931. private _autoTransitionRange;
  46932. /**
  46933. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46934. */
  46935. get autoTransitionRange(): boolean;
  46936. /**
  46937. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  46938. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  46939. */
  46940. set autoTransitionRange(value: boolean);
  46941. private _attachedCamera;
  46942. private _onAfterCheckInputsObserver;
  46943. private _onMeshTargetChangedObserver;
  46944. /**
  46945. * Initializes the behavior.
  46946. */
  46947. init(): void;
  46948. /**
  46949. * Attaches the behavior to its arc rotate camera.
  46950. * @param camera Defines the camera to attach the behavior to
  46951. */
  46952. attach(camera: ArcRotateCamera): void;
  46953. /**
  46954. * Detaches the behavior from its current arc rotate camera.
  46955. */
  46956. detach(): void;
  46957. private _radiusIsAnimating;
  46958. private _radiusBounceTransition;
  46959. private _animatables;
  46960. private _cachedWheelPrecision;
  46961. /**
  46962. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  46963. * @param radiusLimit The limit to check against.
  46964. * @return Bool to indicate if at limit.
  46965. */
  46966. private _isRadiusAtLimit;
  46967. /**
  46968. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  46969. * @param radiusDelta The delta by which to animate to. Can be negative.
  46970. */
  46971. private _applyBoundRadiusAnimation;
  46972. /**
  46973. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  46974. */
  46975. protected _clearAnimationLocks(): void;
  46976. /**
  46977. * Stops and removes all animations that have been applied to the camera
  46978. */
  46979. stopAllAnimations(): void;
  46980. }
  46981. }
  46982. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  46983. import { Behavior } from "babylonjs/Behaviors/behavior";
  46984. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46985. import { ExponentialEase } from "babylonjs/Animations/easing";
  46986. import { Nullable } from "babylonjs/types";
  46987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46988. import { Vector3 } from "babylonjs/Maths/math.vector";
  46989. /**
  46990. * 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.
  46991. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46992. */
  46993. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  46994. /**
  46995. * Gets the name of the behavior.
  46996. */
  46997. get name(): string;
  46998. private _mode;
  46999. private _radiusScale;
  47000. private _positionScale;
  47001. private _defaultElevation;
  47002. private _elevationReturnTime;
  47003. private _elevationReturnWaitTime;
  47004. private _zoomStopsAnimation;
  47005. private _framingTime;
  47006. /**
  47007. * The easing function used by animations
  47008. */
  47009. static EasingFunction: ExponentialEase;
  47010. /**
  47011. * The easing mode used by animations
  47012. */
  47013. static EasingMode: number;
  47014. /**
  47015. * Sets the current mode used by the behavior
  47016. */
  47017. set mode(mode: number);
  47018. /**
  47019. * Gets current mode used by the behavior.
  47020. */
  47021. get mode(): number;
  47022. /**
  47023. * Sets the scale applied to the radius (1 by default)
  47024. */
  47025. set radiusScale(radius: number);
  47026. /**
  47027. * Gets the scale applied to the radius
  47028. */
  47029. get radiusScale(): number;
  47030. /**
  47031. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47032. */
  47033. set positionScale(scale: number);
  47034. /**
  47035. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47036. */
  47037. get positionScale(): number;
  47038. /**
  47039. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47040. * behaviour is triggered, in radians.
  47041. */
  47042. set defaultElevation(elevation: number);
  47043. /**
  47044. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47045. * behaviour is triggered, in radians.
  47046. */
  47047. get defaultElevation(): number;
  47048. /**
  47049. * Sets the time (in milliseconds) taken to return to the default beta position.
  47050. * Negative value indicates camera should not return to default.
  47051. */
  47052. set elevationReturnTime(speed: number);
  47053. /**
  47054. * Gets the time (in milliseconds) taken to return to the default beta position.
  47055. * Negative value indicates camera should not return to default.
  47056. */
  47057. get elevationReturnTime(): number;
  47058. /**
  47059. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47060. */
  47061. set elevationReturnWaitTime(time: number);
  47062. /**
  47063. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47064. */
  47065. get elevationReturnWaitTime(): number;
  47066. /**
  47067. * Sets the flag that indicates if user zooming should stop animation.
  47068. */
  47069. set zoomStopsAnimation(flag: boolean);
  47070. /**
  47071. * Gets the flag that indicates if user zooming should stop animation.
  47072. */
  47073. get zoomStopsAnimation(): boolean;
  47074. /**
  47075. * Sets the transition time when framing the mesh, in milliseconds
  47076. */
  47077. set framingTime(time: number);
  47078. /**
  47079. * Gets the transition time when framing the mesh, in milliseconds
  47080. */
  47081. get framingTime(): number;
  47082. /**
  47083. * Define if the behavior should automatically change the configured
  47084. * camera limits and sensibilities.
  47085. */
  47086. autoCorrectCameraLimitsAndSensibility: boolean;
  47087. private _onPrePointerObservableObserver;
  47088. private _onAfterCheckInputsObserver;
  47089. private _onMeshTargetChangedObserver;
  47090. private _attachedCamera;
  47091. private _isPointerDown;
  47092. private _lastInteractionTime;
  47093. /**
  47094. * Initializes the behavior.
  47095. */
  47096. init(): void;
  47097. /**
  47098. * Attaches the behavior to its arc rotate camera.
  47099. * @param camera Defines the camera to attach the behavior to
  47100. */
  47101. attach(camera: ArcRotateCamera): void;
  47102. /**
  47103. * Detaches the behavior from its current arc rotate camera.
  47104. */
  47105. detach(): void;
  47106. private _animatables;
  47107. private _betaIsAnimating;
  47108. private _betaTransition;
  47109. private _radiusTransition;
  47110. private _vectorTransition;
  47111. /**
  47112. * Targets the given mesh and updates zoom level accordingly.
  47113. * @param mesh The mesh to target.
  47114. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47115. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47116. */
  47117. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47118. /**
  47119. * Targets the given mesh with its children and updates zoom level accordingly.
  47120. * @param mesh The mesh to target.
  47121. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47122. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47123. */
  47124. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47125. /**
  47126. * Targets the given meshes with their children and updates zoom level accordingly.
  47127. * @param meshes The mesh to target.
  47128. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47129. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47130. */
  47131. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47132. /**
  47133. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47134. * @param minimumWorld Determines the smaller position of the bounding box extend
  47135. * @param maximumWorld Determines the bigger position of the bounding box extend
  47136. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47137. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47138. */
  47139. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47140. /**
  47141. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47142. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47143. * frustum width.
  47144. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47145. * to fully enclose the mesh in the viewing frustum.
  47146. */
  47147. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47148. /**
  47149. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47150. * is automatically returned to its default position (expected to be above ground plane).
  47151. */
  47152. private _maintainCameraAboveGround;
  47153. /**
  47154. * Returns the frustum slope based on the canvas ratio and camera FOV
  47155. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47156. */
  47157. private _getFrustumSlope;
  47158. /**
  47159. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47160. */
  47161. private _clearAnimationLocks;
  47162. /**
  47163. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47164. */
  47165. private _applyUserInteraction;
  47166. /**
  47167. * Stops and removes all animations that have been applied to the camera
  47168. */
  47169. stopAllAnimations(): void;
  47170. /**
  47171. * Gets a value indicating if the user is moving the camera
  47172. */
  47173. get isUserIsMoving(): boolean;
  47174. /**
  47175. * The camera can move all the way towards the mesh.
  47176. */
  47177. static IgnoreBoundsSizeMode: number;
  47178. /**
  47179. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47180. */
  47181. static FitFrustumSidesMode: number;
  47182. }
  47183. }
  47184. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47185. import { Nullable } from "babylonjs/types";
  47186. import { Camera } from "babylonjs/Cameras/camera";
  47187. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47188. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47189. /**
  47190. * Base class for Camera Pointer Inputs.
  47191. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47192. * for example usage.
  47193. */
  47194. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47195. /**
  47196. * Defines the camera the input is attached to.
  47197. */
  47198. abstract camera: Camera;
  47199. /**
  47200. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47201. */
  47202. protected _altKey: boolean;
  47203. protected _ctrlKey: boolean;
  47204. protected _metaKey: boolean;
  47205. protected _shiftKey: boolean;
  47206. /**
  47207. * Which mouse buttons were pressed at time of last mouse event.
  47208. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47209. */
  47210. protected _buttonsPressed: number;
  47211. /**
  47212. * Defines the buttons associated with the input to handle camera move.
  47213. */
  47214. buttons: number[];
  47215. /**
  47216. * Attach the input controls to a specific dom element to get the input from.
  47217. * @param element Defines the element the controls should be listened from
  47218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47219. */
  47220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47221. /**
  47222. * Detach the current controls from the specified dom element.
  47223. * @param element Defines the element to stop listening the inputs from
  47224. */
  47225. detachControl(element: Nullable<HTMLElement>): void;
  47226. /**
  47227. * Gets the class name of the current input.
  47228. * @returns the class name
  47229. */
  47230. getClassName(): string;
  47231. /**
  47232. * Get the friendly name associated with the input class.
  47233. * @returns the input friendly name
  47234. */
  47235. getSimpleName(): string;
  47236. /**
  47237. * Called on pointer POINTERDOUBLETAP event.
  47238. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47239. */
  47240. protected onDoubleTap(type: string): void;
  47241. /**
  47242. * Called on pointer POINTERMOVE event if only a single touch is active.
  47243. * Override this method to provide functionality.
  47244. */
  47245. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47246. /**
  47247. * Called on pointer POINTERMOVE event if multiple touches are active.
  47248. * Override this method to provide functionality.
  47249. */
  47250. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47251. /**
  47252. * Called on JS contextmenu event.
  47253. * Override this method to provide functionality.
  47254. */
  47255. protected onContextMenu(evt: PointerEvent): void;
  47256. /**
  47257. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47258. * press.
  47259. * Override this method to provide functionality.
  47260. */
  47261. protected onButtonDown(evt: PointerEvent): void;
  47262. /**
  47263. * Called each time a new POINTERUP event occurs. Ie, for each button
  47264. * release.
  47265. * Override this method to provide functionality.
  47266. */
  47267. protected onButtonUp(evt: PointerEvent): void;
  47268. /**
  47269. * Called when window becomes inactive.
  47270. * Override this method to provide functionality.
  47271. */
  47272. protected onLostFocus(): void;
  47273. private _pointerInput;
  47274. private _observer;
  47275. private _onLostFocus;
  47276. private pointA;
  47277. private pointB;
  47278. }
  47279. }
  47280. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47281. import { Nullable } from "babylonjs/types";
  47282. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47283. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47284. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47285. /**
  47286. * Manage the pointers inputs to control an arc rotate camera.
  47287. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47288. */
  47289. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47290. /**
  47291. * Defines the camera the input is attached to.
  47292. */
  47293. camera: ArcRotateCamera;
  47294. /**
  47295. * Gets the class name of the current input.
  47296. * @returns the class name
  47297. */
  47298. getClassName(): string;
  47299. /**
  47300. * Defines the buttons associated with the input to handle camera move.
  47301. */
  47302. buttons: number[];
  47303. /**
  47304. * Defines the pointer angular sensibility along the X axis or how fast is
  47305. * the camera rotating.
  47306. */
  47307. angularSensibilityX: number;
  47308. /**
  47309. * Defines the pointer angular sensibility along the Y axis or how fast is
  47310. * the camera rotating.
  47311. */
  47312. angularSensibilityY: number;
  47313. /**
  47314. * Defines the pointer pinch precision or how fast is the camera zooming.
  47315. */
  47316. pinchPrecision: number;
  47317. /**
  47318. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47319. * from 0.
  47320. * It defines the percentage of current camera.radius to use as delta when
  47321. * pinch zoom is used.
  47322. */
  47323. pinchDeltaPercentage: number;
  47324. /**
  47325. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47326. * that any object in the plane at the camera's target point will scale
  47327. * perfectly with finger motion.
  47328. * Overrides pinchDeltaPercentage and pinchPrecision.
  47329. */
  47330. useNaturalPinchZoom: boolean;
  47331. /**
  47332. * Defines the pointer panning sensibility or how fast is the camera moving.
  47333. */
  47334. panningSensibility: number;
  47335. /**
  47336. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47337. */
  47338. multiTouchPanning: boolean;
  47339. /**
  47340. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47341. * zoom (pinch) through multitouch.
  47342. */
  47343. multiTouchPanAndZoom: boolean;
  47344. /**
  47345. * Revers pinch action direction.
  47346. */
  47347. pinchInwards: boolean;
  47348. private _isPanClick;
  47349. private _twoFingerActivityCount;
  47350. private _isPinching;
  47351. /**
  47352. * Called on pointer POINTERMOVE event if only a single touch is active.
  47353. */
  47354. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47355. /**
  47356. * Called on pointer POINTERDOUBLETAP event.
  47357. */
  47358. protected onDoubleTap(type: string): void;
  47359. /**
  47360. * Called on pointer POINTERMOVE event if multiple touches are active.
  47361. */
  47362. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47363. /**
  47364. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47365. * press.
  47366. */
  47367. protected onButtonDown(evt: PointerEvent): void;
  47368. /**
  47369. * Called each time a new POINTERUP event occurs. Ie, for each button
  47370. * release.
  47371. */
  47372. protected onButtonUp(evt: PointerEvent): void;
  47373. /**
  47374. * Called when window becomes inactive.
  47375. */
  47376. protected onLostFocus(): void;
  47377. }
  47378. }
  47379. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47380. import { Nullable } from "babylonjs/types";
  47381. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47382. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47383. /**
  47384. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47385. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47386. */
  47387. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47388. /**
  47389. * Defines the camera the input is attached to.
  47390. */
  47391. camera: ArcRotateCamera;
  47392. /**
  47393. * Defines the list of key codes associated with the up action (increase alpha)
  47394. */
  47395. keysUp: number[];
  47396. /**
  47397. * Defines the list of key codes associated with the down action (decrease alpha)
  47398. */
  47399. keysDown: number[];
  47400. /**
  47401. * Defines the list of key codes associated with the left action (increase beta)
  47402. */
  47403. keysLeft: number[];
  47404. /**
  47405. * Defines the list of key codes associated with the right action (decrease beta)
  47406. */
  47407. keysRight: number[];
  47408. /**
  47409. * Defines the list of key codes associated with the reset action.
  47410. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47411. */
  47412. keysReset: number[];
  47413. /**
  47414. * Defines the panning sensibility of the inputs.
  47415. * (How fast is the camera panning)
  47416. */
  47417. panningSensibility: number;
  47418. /**
  47419. * Defines the zooming sensibility of the inputs.
  47420. * (How fast is the camera zooming)
  47421. */
  47422. zoomingSensibility: number;
  47423. /**
  47424. * Defines whether maintaining the alt key down switch the movement mode from
  47425. * orientation to zoom.
  47426. */
  47427. useAltToZoom: boolean;
  47428. /**
  47429. * Rotation speed of the camera
  47430. */
  47431. angularSpeed: number;
  47432. private _keys;
  47433. private _ctrlPressed;
  47434. private _altPressed;
  47435. private _onCanvasBlurObserver;
  47436. private _onKeyboardObserver;
  47437. private _engine;
  47438. private _scene;
  47439. /**
  47440. * Attach the input controls to a specific dom element to get the input from.
  47441. * @param element Defines the element the controls should be listened from
  47442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47443. */
  47444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47445. /**
  47446. * Detach the current controls from the specified dom element.
  47447. * @param element Defines the element to stop listening the inputs from
  47448. */
  47449. detachControl(element: Nullable<HTMLElement>): void;
  47450. /**
  47451. * Update the current camera state depending on the inputs that have been used this frame.
  47452. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47453. */
  47454. checkInputs(): void;
  47455. /**
  47456. * Gets the class name of the current intput.
  47457. * @returns the class name
  47458. */
  47459. getClassName(): string;
  47460. /**
  47461. * Get the friendly name associated with the input class.
  47462. * @returns the input friendly name
  47463. */
  47464. getSimpleName(): string;
  47465. }
  47466. }
  47467. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47468. import { Nullable } from "babylonjs/types";
  47469. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47470. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47471. /**
  47472. * Manage the mouse wheel inputs to control an arc rotate camera.
  47473. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47474. */
  47475. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47476. /**
  47477. * Defines the camera the input is attached to.
  47478. */
  47479. camera: ArcRotateCamera;
  47480. /**
  47481. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47482. */
  47483. wheelPrecision: number;
  47484. /**
  47485. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47486. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47487. */
  47488. wheelDeltaPercentage: number;
  47489. private _wheel;
  47490. private _observer;
  47491. private computeDeltaFromMouseWheelLegacyEvent;
  47492. /**
  47493. * Attach the input controls to a specific dom element to get the input from.
  47494. * @param element Defines the element the controls should be listened from
  47495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47496. */
  47497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47498. /**
  47499. * Detach the current controls from the specified dom element.
  47500. * @param element Defines the element to stop listening the inputs from
  47501. */
  47502. detachControl(element: Nullable<HTMLElement>): void;
  47503. /**
  47504. * Gets the class name of the current intput.
  47505. * @returns the class name
  47506. */
  47507. getClassName(): string;
  47508. /**
  47509. * Get the friendly name associated with the input class.
  47510. * @returns the input friendly name
  47511. */
  47512. getSimpleName(): string;
  47513. }
  47514. }
  47515. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47516. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47517. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47518. /**
  47519. * Default Inputs manager for the ArcRotateCamera.
  47520. * It groups all the default supported inputs for ease of use.
  47521. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47522. */
  47523. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47524. /**
  47525. * Instantiates a new ArcRotateCameraInputsManager.
  47526. * @param camera Defines the camera the inputs belong to
  47527. */
  47528. constructor(camera: ArcRotateCamera);
  47529. /**
  47530. * Add mouse wheel input support to the input manager.
  47531. * @returns the current input manager
  47532. */
  47533. addMouseWheel(): ArcRotateCameraInputsManager;
  47534. /**
  47535. * Add pointers input support to the input manager.
  47536. * @returns the current input manager
  47537. */
  47538. addPointers(): ArcRotateCameraInputsManager;
  47539. /**
  47540. * Add keyboard input support to the input manager.
  47541. * @returns the current input manager
  47542. */
  47543. addKeyboard(): ArcRotateCameraInputsManager;
  47544. }
  47545. }
  47546. declare module "babylonjs/Cameras/arcRotateCamera" {
  47547. import { Observable } from "babylonjs/Misc/observable";
  47548. import { Nullable } from "babylonjs/types";
  47549. import { Scene } from "babylonjs/scene";
  47550. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47552. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47553. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47554. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47555. import { Camera } from "babylonjs/Cameras/camera";
  47556. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47557. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47558. import { Collider } from "babylonjs/Collisions/collider";
  47559. /**
  47560. * This represents an orbital type of camera.
  47561. *
  47562. * 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.
  47563. * 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.
  47564. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47565. */
  47566. export class ArcRotateCamera extends TargetCamera {
  47567. /**
  47568. * Defines the rotation angle of the camera along the longitudinal axis.
  47569. */
  47570. alpha: number;
  47571. /**
  47572. * Defines the rotation angle of the camera along the latitudinal axis.
  47573. */
  47574. beta: number;
  47575. /**
  47576. * Defines the radius of the camera from it s target point.
  47577. */
  47578. radius: number;
  47579. protected _target: Vector3;
  47580. protected _targetHost: Nullable<AbstractMesh>;
  47581. /**
  47582. * Defines the target point of the camera.
  47583. * The camera looks towards it form the radius distance.
  47584. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47585. */
  47586. get target(): Vector3;
  47587. set target(value: Vector3);
  47588. /**
  47589. * Define the current local position of the camera in the scene
  47590. */
  47591. get position(): Vector3;
  47592. set position(newPosition: Vector3);
  47593. protected _upToYMatrix: Matrix;
  47594. protected _YToUpMatrix: Matrix;
  47595. /**
  47596. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47597. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47598. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47599. */
  47600. set upVector(vec: Vector3);
  47601. get upVector(): Vector3;
  47602. /**
  47603. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47604. */
  47605. setMatUp(): void;
  47606. /**
  47607. * Current inertia value on the longitudinal axis.
  47608. * The bigger this number the longer it will take for the camera to stop.
  47609. */
  47610. inertialAlphaOffset: number;
  47611. /**
  47612. * Current inertia value on the latitudinal axis.
  47613. * The bigger this number the longer it will take for the camera to stop.
  47614. */
  47615. inertialBetaOffset: number;
  47616. /**
  47617. * Current inertia value on the radius axis.
  47618. * The bigger this number the longer it will take for the camera to stop.
  47619. */
  47620. inertialRadiusOffset: number;
  47621. /**
  47622. * Minimum allowed angle on the longitudinal axis.
  47623. * This can help limiting how the Camera is able to move in the scene.
  47624. */
  47625. lowerAlphaLimit: Nullable<number>;
  47626. /**
  47627. * Maximum allowed angle on the longitudinal axis.
  47628. * This can help limiting how the Camera is able to move in the scene.
  47629. */
  47630. upperAlphaLimit: Nullable<number>;
  47631. /**
  47632. * Minimum allowed angle on the latitudinal axis.
  47633. * This can help limiting how the Camera is able to move in the scene.
  47634. */
  47635. lowerBetaLimit: number;
  47636. /**
  47637. * Maximum allowed angle on the latitudinal axis.
  47638. * This can help limiting how the Camera is able to move in the scene.
  47639. */
  47640. upperBetaLimit: number;
  47641. /**
  47642. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  47643. * This can help limiting how the Camera is able to move in the scene.
  47644. */
  47645. lowerRadiusLimit: Nullable<number>;
  47646. /**
  47647. * Maximum allowed distance of the camera to the target (The camera can not get further).
  47648. * This can help limiting how the Camera is able to move in the scene.
  47649. */
  47650. upperRadiusLimit: Nullable<number>;
  47651. /**
  47652. * Defines the current inertia value used during panning of the camera along the X axis.
  47653. */
  47654. inertialPanningX: number;
  47655. /**
  47656. * Defines the current inertia value used during panning of the camera along the Y axis.
  47657. */
  47658. inertialPanningY: number;
  47659. /**
  47660. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  47661. * Basically if your fingers moves away from more than this distance you will be considered
  47662. * in pinch mode.
  47663. */
  47664. pinchToPanMaxDistance: number;
  47665. /**
  47666. * Defines the maximum distance the camera can pan.
  47667. * This could help keeping the cammera always in your scene.
  47668. */
  47669. panningDistanceLimit: Nullable<number>;
  47670. /**
  47671. * Defines the target of the camera before paning.
  47672. */
  47673. panningOriginTarget: Vector3;
  47674. /**
  47675. * Defines the value of the inertia used during panning.
  47676. * 0 would mean stop inertia and one would mean no decelleration at all.
  47677. */
  47678. panningInertia: number;
  47679. /**
  47680. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  47681. */
  47682. get angularSensibilityX(): number;
  47683. set angularSensibilityX(value: number);
  47684. /**
  47685. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  47686. */
  47687. get angularSensibilityY(): number;
  47688. set angularSensibilityY(value: number);
  47689. /**
  47690. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  47691. */
  47692. get pinchPrecision(): number;
  47693. set pinchPrecision(value: number);
  47694. /**
  47695. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  47696. * It will be used instead of pinchDeltaPrecision if different from 0.
  47697. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47698. */
  47699. get pinchDeltaPercentage(): number;
  47700. set pinchDeltaPercentage(value: number);
  47701. /**
  47702. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  47703. * and pinch delta percentage.
  47704. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47705. * that any object in the plane at the camera's target point will scale
  47706. * perfectly with finger motion.
  47707. */
  47708. get useNaturalPinchZoom(): boolean;
  47709. set useNaturalPinchZoom(value: boolean);
  47710. /**
  47711. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  47712. */
  47713. get panningSensibility(): number;
  47714. set panningSensibility(value: number);
  47715. /**
  47716. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  47717. */
  47718. get keysUp(): number[];
  47719. set keysUp(value: number[]);
  47720. /**
  47721. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  47722. */
  47723. get keysDown(): number[];
  47724. set keysDown(value: number[]);
  47725. /**
  47726. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  47727. */
  47728. get keysLeft(): number[];
  47729. set keysLeft(value: number[]);
  47730. /**
  47731. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  47732. */
  47733. get keysRight(): number[];
  47734. set keysRight(value: number[]);
  47735. /**
  47736. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47737. */
  47738. get wheelPrecision(): number;
  47739. set wheelPrecision(value: number);
  47740. /**
  47741. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  47742. * It will be used instead of pinchDeltaPrecision if different from 0.
  47743. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  47744. */
  47745. get wheelDeltaPercentage(): number;
  47746. set wheelDeltaPercentage(value: number);
  47747. /**
  47748. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  47749. */
  47750. zoomOnFactor: number;
  47751. /**
  47752. * Defines a screen offset for the camera position.
  47753. */
  47754. targetScreenOffset: Vector2;
  47755. /**
  47756. * Allows the camera to be completely reversed.
  47757. * If false the camera can not arrive upside down.
  47758. */
  47759. allowUpsideDown: boolean;
  47760. /**
  47761. * Define if double tap/click is used to restore the previously saved state of the camera.
  47762. */
  47763. useInputToRestoreState: boolean;
  47764. /** @hidden */
  47765. _viewMatrix: Matrix;
  47766. /** @hidden */
  47767. _useCtrlForPanning: boolean;
  47768. /** @hidden */
  47769. _panningMouseButton: number;
  47770. /**
  47771. * Defines the input associated to the camera.
  47772. */
  47773. inputs: ArcRotateCameraInputsManager;
  47774. /** @hidden */
  47775. _reset: () => void;
  47776. /**
  47777. * Defines the allowed panning axis.
  47778. */
  47779. panningAxis: Vector3;
  47780. protected _localDirection: Vector3;
  47781. protected _transformedDirection: Vector3;
  47782. private _bouncingBehavior;
  47783. /**
  47784. * Gets the bouncing behavior of the camera if it has been enabled.
  47785. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47786. */
  47787. get bouncingBehavior(): Nullable<BouncingBehavior>;
  47788. /**
  47789. * Defines if the bouncing behavior of the camera is enabled on the camera.
  47790. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47791. */
  47792. get useBouncingBehavior(): boolean;
  47793. set useBouncingBehavior(value: boolean);
  47794. private _framingBehavior;
  47795. /**
  47796. * Gets the framing behavior of the camera if it has been enabled.
  47797. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47798. */
  47799. get framingBehavior(): Nullable<FramingBehavior>;
  47800. /**
  47801. * Defines if the framing behavior of the camera is enabled on the camera.
  47802. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47803. */
  47804. get useFramingBehavior(): boolean;
  47805. set useFramingBehavior(value: boolean);
  47806. private _autoRotationBehavior;
  47807. /**
  47808. * Gets the auto rotation behavior of the camera if it has been enabled.
  47809. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47810. */
  47811. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  47812. /**
  47813. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  47814. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47815. */
  47816. get useAutoRotationBehavior(): boolean;
  47817. set useAutoRotationBehavior(value: boolean);
  47818. /**
  47819. * Observable triggered when the mesh target has been changed on the camera.
  47820. */
  47821. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  47822. /**
  47823. * Event raised when the camera is colliding with a mesh.
  47824. */
  47825. onCollide: (collidedMesh: AbstractMesh) => void;
  47826. /**
  47827. * Defines whether the camera should check collision with the objects oh the scene.
  47828. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  47829. */
  47830. checkCollisions: boolean;
  47831. /**
  47832. * Defines the collision radius of the camera.
  47833. * This simulates a sphere around the camera.
  47834. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47835. */
  47836. collisionRadius: Vector3;
  47837. protected _collider: Collider;
  47838. protected _previousPosition: Vector3;
  47839. protected _collisionVelocity: Vector3;
  47840. protected _newPosition: Vector3;
  47841. protected _previousAlpha: number;
  47842. protected _previousBeta: number;
  47843. protected _previousRadius: number;
  47844. protected _collisionTriggered: boolean;
  47845. protected _targetBoundingCenter: Nullable<Vector3>;
  47846. private _computationVector;
  47847. /**
  47848. * Instantiates a new ArcRotateCamera in a given scene
  47849. * @param name Defines the name of the camera
  47850. * @param alpha Defines the camera rotation along the logitudinal axis
  47851. * @param beta Defines the camera rotation along the latitudinal axis
  47852. * @param radius Defines the camera distance from its target
  47853. * @param target Defines the camera target
  47854. * @param scene Defines the scene the camera belongs to
  47855. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  47856. */
  47857. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47858. /** @hidden */
  47859. _initCache(): void;
  47860. /** @hidden */
  47861. _updateCache(ignoreParentClass?: boolean): void;
  47862. protected _getTargetPosition(): Vector3;
  47863. private _storedAlpha;
  47864. private _storedBeta;
  47865. private _storedRadius;
  47866. private _storedTarget;
  47867. private _storedTargetScreenOffset;
  47868. /**
  47869. * Stores the current state of the camera (alpha, beta, radius and target)
  47870. * @returns the camera itself
  47871. */
  47872. storeState(): Camera;
  47873. /**
  47874. * @hidden
  47875. * Restored camera state. You must call storeState() first
  47876. */
  47877. _restoreStateValues(): boolean;
  47878. /** @hidden */
  47879. _isSynchronizedViewMatrix(): boolean;
  47880. /**
  47881. * Attached controls to the current camera.
  47882. * @param element Defines the element the controls should be listened from
  47883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47884. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  47885. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  47886. */
  47887. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  47888. /**
  47889. * Detach the current controls from the camera.
  47890. * The camera will stop reacting to inputs.
  47891. * @param element Defines the element to stop listening the inputs from
  47892. */
  47893. detachControl(element: HTMLElement): void;
  47894. /** @hidden */
  47895. _checkInputs(): void;
  47896. protected _checkLimits(): void;
  47897. /**
  47898. * Rebuilds angles (alpha, beta) and radius from the give position and target
  47899. */
  47900. rebuildAnglesAndRadius(): void;
  47901. /**
  47902. * Use a position to define the current camera related information like alpha, beta and radius
  47903. * @param position Defines the position to set the camera at
  47904. */
  47905. setPosition(position: Vector3): void;
  47906. /**
  47907. * Defines the target the camera should look at.
  47908. * This will automatically adapt alpha beta and radius to fit within the new target.
  47909. * @param target Defines the new target as a Vector or a mesh
  47910. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  47911. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  47912. */
  47913. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  47914. /** @hidden */
  47915. _getViewMatrix(): Matrix;
  47916. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  47917. /**
  47918. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  47919. * @param meshes Defines the mesh to zoom on
  47920. * @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)
  47921. */
  47922. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  47923. /**
  47924. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  47925. * The target will be changed but the radius
  47926. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  47927. * @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)
  47928. */
  47929. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  47930. min: Vector3;
  47931. max: Vector3;
  47932. distance: number;
  47933. }, doNotUpdateMaxZ?: boolean): void;
  47934. /**
  47935. * @override
  47936. * Override Camera.createRigCamera
  47937. */
  47938. createRigCamera(name: string, cameraIndex: number): Camera;
  47939. /**
  47940. * @hidden
  47941. * @override
  47942. * Override Camera._updateRigCameras
  47943. */
  47944. _updateRigCameras(): void;
  47945. /**
  47946. * Destroy the camera and release the current resources hold by it.
  47947. */
  47948. dispose(): void;
  47949. /**
  47950. * Gets the current object class name.
  47951. * @return the class name
  47952. */
  47953. getClassName(): string;
  47954. }
  47955. }
  47956. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  47957. import { Behavior } from "babylonjs/Behaviors/behavior";
  47958. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47959. /**
  47960. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  47961. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  47962. */
  47963. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  47964. /**
  47965. * Gets the name of the behavior.
  47966. */
  47967. get name(): string;
  47968. private _zoomStopsAnimation;
  47969. private _idleRotationSpeed;
  47970. private _idleRotationWaitTime;
  47971. private _idleRotationSpinupTime;
  47972. /**
  47973. * Sets the flag that indicates if user zooming should stop animation.
  47974. */
  47975. set zoomStopsAnimation(flag: boolean);
  47976. /**
  47977. * Gets the flag that indicates if user zooming should stop animation.
  47978. */
  47979. get zoomStopsAnimation(): boolean;
  47980. /**
  47981. * Sets the default speed at which the camera rotates around the model.
  47982. */
  47983. set idleRotationSpeed(speed: number);
  47984. /**
  47985. * Gets the default speed at which the camera rotates around the model.
  47986. */
  47987. get idleRotationSpeed(): number;
  47988. /**
  47989. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  47990. */
  47991. set idleRotationWaitTime(time: number);
  47992. /**
  47993. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  47994. */
  47995. get idleRotationWaitTime(): number;
  47996. /**
  47997. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  47998. */
  47999. set idleRotationSpinupTime(time: number);
  48000. /**
  48001. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48002. */
  48003. get idleRotationSpinupTime(): number;
  48004. /**
  48005. * Gets a value indicating if the camera is currently rotating because of this behavior
  48006. */
  48007. get rotationInProgress(): boolean;
  48008. private _onPrePointerObservableObserver;
  48009. private _onAfterCheckInputsObserver;
  48010. private _attachedCamera;
  48011. private _isPointerDown;
  48012. private _lastFrameTime;
  48013. private _lastInteractionTime;
  48014. private _cameraRotationSpeed;
  48015. /**
  48016. * Initializes the behavior.
  48017. */
  48018. init(): void;
  48019. /**
  48020. * Attaches the behavior to its arc rotate camera.
  48021. * @param camera Defines the camera to attach the behavior to
  48022. */
  48023. attach(camera: ArcRotateCamera): void;
  48024. /**
  48025. * Detaches the behavior from its current arc rotate camera.
  48026. */
  48027. detach(): void;
  48028. /**
  48029. * Returns true if user is scrolling.
  48030. * @return true if user is scrolling.
  48031. */
  48032. private _userIsZooming;
  48033. private _lastFrameRadius;
  48034. private _shouldAnimationStopForInteraction;
  48035. /**
  48036. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48037. */
  48038. private _applyUserInteraction;
  48039. private _userIsMoving;
  48040. }
  48041. }
  48042. declare module "babylonjs/Behaviors/Cameras/index" {
  48043. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48044. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48045. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48046. }
  48047. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48048. import { Mesh } from "babylonjs/Meshes/mesh";
  48049. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48050. import { Behavior } from "babylonjs/Behaviors/behavior";
  48051. /**
  48052. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48053. */
  48054. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48055. private ui;
  48056. /**
  48057. * The name of the behavior
  48058. */
  48059. name: string;
  48060. /**
  48061. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48062. */
  48063. distanceAwayFromFace: number;
  48064. /**
  48065. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48066. */
  48067. distanceAwayFromBottomOfFace: number;
  48068. private _faceVectors;
  48069. private _target;
  48070. private _scene;
  48071. private _onRenderObserver;
  48072. private _tmpMatrix;
  48073. private _tmpVector;
  48074. /**
  48075. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48076. * @param ui The transform node that should be attched to the mesh
  48077. */
  48078. constructor(ui: TransformNode);
  48079. /**
  48080. * Initializes the behavior
  48081. */
  48082. init(): void;
  48083. private _closestFace;
  48084. private _zeroVector;
  48085. private _lookAtTmpMatrix;
  48086. private _lookAtToRef;
  48087. /**
  48088. * Attaches the AttachToBoxBehavior to the passed in mesh
  48089. * @param target The mesh that the specified node will be attached to
  48090. */
  48091. attach(target: Mesh): void;
  48092. /**
  48093. * Detaches the behavior from the mesh
  48094. */
  48095. detach(): void;
  48096. }
  48097. }
  48098. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48099. import { Behavior } from "babylonjs/Behaviors/behavior";
  48100. import { Mesh } from "babylonjs/Meshes/mesh";
  48101. /**
  48102. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48103. */
  48104. export class FadeInOutBehavior implements Behavior<Mesh> {
  48105. /**
  48106. * Time in milliseconds to delay before fading in (Default: 0)
  48107. */
  48108. delay: number;
  48109. /**
  48110. * Time in milliseconds for the mesh to fade in (Default: 300)
  48111. */
  48112. fadeInTime: number;
  48113. private _millisecondsPerFrame;
  48114. private _hovered;
  48115. private _hoverValue;
  48116. private _ownerNode;
  48117. /**
  48118. * Instatiates the FadeInOutBehavior
  48119. */
  48120. constructor();
  48121. /**
  48122. * The name of the behavior
  48123. */
  48124. get name(): string;
  48125. /**
  48126. * Initializes the behavior
  48127. */
  48128. init(): void;
  48129. /**
  48130. * Attaches the fade behavior on the passed in mesh
  48131. * @param ownerNode The mesh that will be faded in/out once attached
  48132. */
  48133. attach(ownerNode: Mesh): void;
  48134. /**
  48135. * Detaches the behavior from the mesh
  48136. */
  48137. detach(): void;
  48138. /**
  48139. * Triggers the mesh to begin fading in or out
  48140. * @param value if the object should fade in or out (true to fade in)
  48141. */
  48142. fadeIn(value: boolean): void;
  48143. private _update;
  48144. private _setAllVisibility;
  48145. }
  48146. }
  48147. declare module "babylonjs/Misc/pivotTools" {
  48148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48149. /**
  48150. * Class containing a set of static utilities functions for managing Pivots
  48151. * @hidden
  48152. */
  48153. export class PivotTools {
  48154. private static _PivotCached;
  48155. private static _OldPivotPoint;
  48156. private static _PivotTranslation;
  48157. private static _PivotTmpVector;
  48158. private static _PivotPostMultiplyPivotMatrix;
  48159. /** @hidden */
  48160. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48161. /** @hidden */
  48162. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48163. }
  48164. }
  48165. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48166. import { Scene } from "babylonjs/scene";
  48167. import { Vector4 } from "babylonjs/Maths/math.vector";
  48168. import { Mesh } from "babylonjs/Meshes/mesh";
  48169. import { Nullable } from "babylonjs/types";
  48170. import { Plane } from "babylonjs/Maths/math.plane";
  48171. /**
  48172. * Class containing static functions to help procedurally build meshes
  48173. */
  48174. export class PlaneBuilder {
  48175. /**
  48176. * Creates a plane mesh
  48177. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48178. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48179. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48183. * @param name defines the name of the mesh
  48184. * @param options defines the options used to create the mesh
  48185. * @param scene defines the hosting scene
  48186. * @returns the plane mesh
  48187. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48188. */
  48189. static CreatePlane(name: string, options: {
  48190. size?: number;
  48191. width?: number;
  48192. height?: number;
  48193. sideOrientation?: number;
  48194. frontUVs?: Vector4;
  48195. backUVs?: Vector4;
  48196. updatable?: boolean;
  48197. sourcePlane?: Plane;
  48198. }, scene?: Nullable<Scene>): Mesh;
  48199. }
  48200. }
  48201. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48202. import { Behavior } from "babylonjs/Behaviors/behavior";
  48203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48204. import { Observable } from "babylonjs/Misc/observable";
  48205. import { Vector3 } from "babylonjs/Maths/math.vector";
  48206. import { Ray } from "babylonjs/Culling/ray";
  48207. import "babylonjs/Meshes/Builders/planeBuilder";
  48208. /**
  48209. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48210. */
  48211. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48212. private static _AnyMouseID;
  48213. /**
  48214. * Abstract mesh the behavior is set on
  48215. */
  48216. attachedNode: AbstractMesh;
  48217. private _dragPlane;
  48218. private _scene;
  48219. private _pointerObserver;
  48220. private _beforeRenderObserver;
  48221. private static _planeScene;
  48222. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48223. /**
  48224. * 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)
  48225. */
  48226. maxDragAngle: number;
  48227. /**
  48228. * @hidden
  48229. */
  48230. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48231. /**
  48232. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48233. */
  48234. currentDraggingPointerID: number;
  48235. /**
  48236. * The last position where the pointer hit the drag plane in world space
  48237. */
  48238. lastDragPosition: Vector3;
  48239. /**
  48240. * If the behavior is currently in a dragging state
  48241. */
  48242. dragging: boolean;
  48243. /**
  48244. * 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)
  48245. */
  48246. dragDeltaRatio: number;
  48247. /**
  48248. * If the drag plane orientation should be updated during the dragging (Default: true)
  48249. */
  48250. updateDragPlane: boolean;
  48251. private _debugMode;
  48252. private _moving;
  48253. /**
  48254. * Fires each time the attached mesh is dragged with the pointer
  48255. * * delta between last drag position and current drag position in world space
  48256. * * dragDistance along the drag axis
  48257. * * dragPlaneNormal normal of the current drag plane used during the drag
  48258. * * dragPlanePoint in world space where the drag intersects the drag plane
  48259. */
  48260. onDragObservable: Observable<{
  48261. delta: Vector3;
  48262. dragPlanePoint: Vector3;
  48263. dragPlaneNormal: Vector3;
  48264. dragDistance: number;
  48265. pointerId: number;
  48266. }>;
  48267. /**
  48268. * Fires each time a drag begins (eg. mouse down on mesh)
  48269. */
  48270. onDragStartObservable: Observable<{
  48271. dragPlanePoint: Vector3;
  48272. pointerId: number;
  48273. }>;
  48274. /**
  48275. * Fires each time a drag ends (eg. mouse release after drag)
  48276. */
  48277. onDragEndObservable: Observable<{
  48278. dragPlanePoint: Vector3;
  48279. pointerId: number;
  48280. }>;
  48281. /**
  48282. * If the attached mesh should be moved when dragged
  48283. */
  48284. moveAttached: boolean;
  48285. /**
  48286. * If the drag behavior will react to drag events (Default: true)
  48287. */
  48288. enabled: boolean;
  48289. /**
  48290. * If pointer events should start and release the drag (Default: true)
  48291. */
  48292. startAndReleaseDragOnPointerEvents: boolean;
  48293. /**
  48294. * If camera controls should be detached during the drag
  48295. */
  48296. detachCameraControls: boolean;
  48297. /**
  48298. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48299. */
  48300. useObjectOrientationForDragging: boolean;
  48301. private _options;
  48302. /**
  48303. * Gets the options used by the behavior
  48304. */
  48305. get options(): {
  48306. dragAxis?: Vector3;
  48307. dragPlaneNormal?: Vector3;
  48308. };
  48309. /**
  48310. * Sets the options used by the behavior
  48311. */
  48312. set options(options: {
  48313. dragAxis?: Vector3;
  48314. dragPlaneNormal?: Vector3;
  48315. });
  48316. /**
  48317. * Creates a pointer drag behavior that can be attached to a mesh
  48318. * @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)
  48319. */
  48320. constructor(options?: {
  48321. dragAxis?: Vector3;
  48322. dragPlaneNormal?: Vector3;
  48323. });
  48324. /**
  48325. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48326. */
  48327. validateDrag: (targetPosition: Vector3) => boolean;
  48328. /**
  48329. * The name of the behavior
  48330. */
  48331. get name(): string;
  48332. /**
  48333. * Initializes the behavior
  48334. */
  48335. init(): void;
  48336. private _tmpVector;
  48337. private _alternatePickedPoint;
  48338. private _worldDragAxis;
  48339. private _targetPosition;
  48340. private _attachedElement;
  48341. /**
  48342. * Attaches the drag behavior the passed in mesh
  48343. * @param ownerNode The mesh that will be dragged around once attached
  48344. * @param predicate Predicate to use for pick filtering
  48345. */
  48346. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48347. /**
  48348. * Force relase the drag action by code.
  48349. */
  48350. releaseDrag(): void;
  48351. private _startDragRay;
  48352. private _lastPointerRay;
  48353. /**
  48354. * Simulates the start of a pointer drag event on the behavior
  48355. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48356. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48357. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48358. */
  48359. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48360. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48361. private _dragDelta;
  48362. protected _moveDrag(ray: Ray): void;
  48363. private _pickWithRayOnDragPlane;
  48364. private _pointA;
  48365. private _pointC;
  48366. private _localAxis;
  48367. private _lookAt;
  48368. private _updateDragPlanePosition;
  48369. /**
  48370. * Detaches the behavior from the mesh
  48371. */
  48372. detach(): void;
  48373. }
  48374. }
  48375. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48376. import { Mesh } from "babylonjs/Meshes/mesh";
  48377. import { Behavior } from "babylonjs/Behaviors/behavior";
  48378. /**
  48379. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48380. */
  48381. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48382. private _dragBehaviorA;
  48383. private _dragBehaviorB;
  48384. private _startDistance;
  48385. private _initialScale;
  48386. private _targetScale;
  48387. private _ownerNode;
  48388. private _sceneRenderObserver;
  48389. /**
  48390. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48391. */
  48392. constructor();
  48393. /**
  48394. * The name of the behavior
  48395. */
  48396. get name(): string;
  48397. /**
  48398. * Initializes the behavior
  48399. */
  48400. init(): void;
  48401. private _getCurrentDistance;
  48402. /**
  48403. * Attaches the scale behavior the passed in mesh
  48404. * @param ownerNode The mesh that will be scaled around once attached
  48405. */
  48406. attach(ownerNode: Mesh): void;
  48407. /**
  48408. * Detaches the behavior from the mesh
  48409. */
  48410. detach(): void;
  48411. }
  48412. }
  48413. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48414. import { Behavior } from "babylonjs/Behaviors/behavior";
  48415. import { Mesh } from "babylonjs/Meshes/mesh";
  48416. import { Observable } from "babylonjs/Misc/observable";
  48417. /**
  48418. * 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
  48419. */
  48420. export class SixDofDragBehavior implements Behavior<Mesh> {
  48421. private static _virtualScene;
  48422. private _ownerNode;
  48423. private _sceneRenderObserver;
  48424. private _scene;
  48425. private _targetPosition;
  48426. private _virtualOriginMesh;
  48427. private _virtualDragMesh;
  48428. private _pointerObserver;
  48429. private _moving;
  48430. private _startingOrientation;
  48431. private _attachedElement;
  48432. /**
  48433. * 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)
  48434. */
  48435. private zDragFactor;
  48436. /**
  48437. * If the object should rotate to face the drag origin
  48438. */
  48439. rotateDraggedObject: boolean;
  48440. /**
  48441. * If the behavior is currently in a dragging state
  48442. */
  48443. dragging: boolean;
  48444. /**
  48445. * 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)
  48446. */
  48447. dragDeltaRatio: number;
  48448. /**
  48449. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48450. */
  48451. currentDraggingPointerID: number;
  48452. /**
  48453. * If camera controls should be detached during the drag
  48454. */
  48455. detachCameraControls: boolean;
  48456. /**
  48457. * Fires each time a drag starts
  48458. */
  48459. onDragStartObservable: Observable<{}>;
  48460. /**
  48461. * Fires each time a drag ends (eg. mouse release after drag)
  48462. */
  48463. onDragEndObservable: Observable<{}>;
  48464. /**
  48465. * 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
  48466. */
  48467. constructor();
  48468. /**
  48469. * The name of the behavior
  48470. */
  48471. get name(): string;
  48472. /**
  48473. * Initializes the behavior
  48474. */
  48475. init(): void;
  48476. /**
  48477. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48478. */
  48479. private get _pointerCamera();
  48480. /**
  48481. * Attaches the scale behavior the passed in mesh
  48482. * @param ownerNode The mesh that will be scaled around once attached
  48483. */
  48484. attach(ownerNode: Mesh): void;
  48485. /**
  48486. * Detaches the behavior from the mesh
  48487. */
  48488. detach(): void;
  48489. }
  48490. }
  48491. declare module "babylonjs/Behaviors/Meshes/index" {
  48492. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48493. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48494. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48495. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48496. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48497. }
  48498. declare module "babylonjs/Behaviors/index" {
  48499. export * from "babylonjs/Behaviors/behavior";
  48500. export * from "babylonjs/Behaviors/Cameras/index";
  48501. export * from "babylonjs/Behaviors/Meshes/index";
  48502. }
  48503. declare module "babylonjs/Bones/boneIKController" {
  48504. import { Bone } from "babylonjs/Bones/bone";
  48505. import { Vector3 } from "babylonjs/Maths/math.vector";
  48506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48507. import { Nullable } from "babylonjs/types";
  48508. /**
  48509. * Class used to apply inverse kinematics to bones
  48510. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48511. */
  48512. export class BoneIKController {
  48513. private static _tmpVecs;
  48514. private static _tmpQuat;
  48515. private static _tmpMats;
  48516. /**
  48517. * Gets or sets the target mesh
  48518. */
  48519. targetMesh: AbstractMesh;
  48520. /** Gets or sets the mesh used as pole */
  48521. poleTargetMesh: AbstractMesh;
  48522. /**
  48523. * Gets or sets the bone used as pole
  48524. */
  48525. poleTargetBone: Nullable<Bone>;
  48526. /**
  48527. * Gets or sets the target position
  48528. */
  48529. targetPosition: Vector3;
  48530. /**
  48531. * Gets or sets the pole target position
  48532. */
  48533. poleTargetPosition: Vector3;
  48534. /**
  48535. * Gets or sets the pole target local offset
  48536. */
  48537. poleTargetLocalOffset: Vector3;
  48538. /**
  48539. * Gets or sets the pole angle
  48540. */
  48541. poleAngle: number;
  48542. /**
  48543. * Gets or sets the mesh associated with the controller
  48544. */
  48545. mesh: AbstractMesh;
  48546. /**
  48547. * 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)
  48548. */
  48549. slerpAmount: number;
  48550. private _bone1Quat;
  48551. private _bone1Mat;
  48552. private _bone2Ang;
  48553. private _bone1;
  48554. private _bone2;
  48555. private _bone1Length;
  48556. private _bone2Length;
  48557. private _maxAngle;
  48558. private _maxReach;
  48559. private _rightHandedSystem;
  48560. private _bendAxis;
  48561. private _slerping;
  48562. private _adjustRoll;
  48563. /**
  48564. * Gets or sets maximum allowed angle
  48565. */
  48566. get maxAngle(): number;
  48567. set maxAngle(value: number);
  48568. /**
  48569. * Creates a new BoneIKController
  48570. * @param mesh defines the mesh to control
  48571. * @param bone defines the bone to control
  48572. * @param options defines options to set up the controller
  48573. */
  48574. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48575. targetMesh?: AbstractMesh;
  48576. poleTargetMesh?: AbstractMesh;
  48577. poleTargetBone?: Bone;
  48578. poleTargetLocalOffset?: Vector3;
  48579. poleAngle?: number;
  48580. bendAxis?: Vector3;
  48581. maxAngle?: number;
  48582. slerpAmount?: number;
  48583. });
  48584. private _setMaxAngle;
  48585. /**
  48586. * Force the controller to update the bones
  48587. */
  48588. update(): void;
  48589. }
  48590. }
  48591. declare module "babylonjs/Bones/boneLookController" {
  48592. import { Vector3 } from "babylonjs/Maths/math.vector";
  48593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48594. import { Bone } from "babylonjs/Bones/bone";
  48595. import { Space } from "babylonjs/Maths/math.axis";
  48596. /**
  48597. * Class used to make a bone look toward a point in space
  48598. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48599. */
  48600. export class BoneLookController {
  48601. private static _tmpVecs;
  48602. private static _tmpQuat;
  48603. private static _tmpMats;
  48604. /**
  48605. * The target Vector3 that the bone will look at
  48606. */
  48607. target: Vector3;
  48608. /**
  48609. * The mesh that the bone is attached to
  48610. */
  48611. mesh: AbstractMesh;
  48612. /**
  48613. * The bone that will be looking to the target
  48614. */
  48615. bone: Bone;
  48616. /**
  48617. * The up axis of the coordinate system that is used when the bone is rotated
  48618. */
  48619. upAxis: Vector3;
  48620. /**
  48621. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  48622. */
  48623. upAxisSpace: Space;
  48624. /**
  48625. * Used to make an adjustment to the yaw of the bone
  48626. */
  48627. adjustYaw: number;
  48628. /**
  48629. * Used to make an adjustment to the pitch of the bone
  48630. */
  48631. adjustPitch: number;
  48632. /**
  48633. * Used to make an adjustment to the roll of the bone
  48634. */
  48635. adjustRoll: number;
  48636. /**
  48637. * 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)
  48638. */
  48639. slerpAmount: number;
  48640. private _minYaw;
  48641. private _maxYaw;
  48642. private _minPitch;
  48643. private _maxPitch;
  48644. private _minYawSin;
  48645. private _minYawCos;
  48646. private _maxYawSin;
  48647. private _maxYawCos;
  48648. private _midYawConstraint;
  48649. private _minPitchTan;
  48650. private _maxPitchTan;
  48651. private _boneQuat;
  48652. private _slerping;
  48653. private _transformYawPitch;
  48654. private _transformYawPitchInv;
  48655. private _firstFrameSkipped;
  48656. private _yawRange;
  48657. private _fowardAxis;
  48658. /**
  48659. * Gets or sets the minimum yaw angle that the bone can look to
  48660. */
  48661. get minYaw(): number;
  48662. set minYaw(value: number);
  48663. /**
  48664. * Gets or sets the maximum yaw angle that the bone can look to
  48665. */
  48666. get maxYaw(): number;
  48667. set maxYaw(value: number);
  48668. /**
  48669. * Gets or sets the minimum pitch angle that the bone can look to
  48670. */
  48671. get minPitch(): number;
  48672. set minPitch(value: number);
  48673. /**
  48674. * Gets or sets the maximum pitch angle that the bone can look to
  48675. */
  48676. get maxPitch(): number;
  48677. set maxPitch(value: number);
  48678. /**
  48679. * Create a BoneLookController
  48680. * @param mesh the mesh that the bone belongs to
  48681. * @param bone the bone that will be looking to the target
  48682. * @param target the target Vector3 to look at
  48683. * @param options optional settings:
  48684. * * maxYaw: the maximum angle the bone will yaw to
  48685. * * minYaw: the minimum angle the bone will yaw to
  48686. * * maxPitch: the maximum angle the bone will pitch to
  48687. * * minPitch: the minimum angle the bone will yaw to
  48688. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  48689. * * upAxis: the up axis of the coordinate system
  48690. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  48691. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  48692. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  48693. * * adjustYaw: used to make an adjustment to the yaw of the bone
  48694. * * adjustPitch: used to make an adjustment to the pitch of the bone
  48695. * * adjustRoll: used to make an adjustment to the roll of the bone
  48696. **/
  48697. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  48698. maxYaw?: number;
  48699. minYaw?: number;
  48700. maxPitch?: number;
  48701. minPitch?: number;
  48702. slerpAmount?: number;
  48703. upAxis?: Vector3;
  48704. upAxisSpace?: Space;
  48705. yawAxis?: Vector3;
  48706. pitchAxis?: Vector3;
  48707. adjustYaw?: number;
  48708. adjustPitch?: number;
  48709. adjustRoll?: number;
  48710. });
  48711. /**
  48712. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  48713. */
  48714. update(): void;
  48715. private _getAngleDiff;
  48716. private _getAngleBetween;
  48717. private _isAngleBetween;
  48718. }
  48719. }
  48720. declare module "babylonjs/Bones/index" {
  48721. export * from "babylonjs/Bones/bone";
  48722. export * from "babylonjs/Bones/boneIKController";
  48723. export * from "babylonjs/Bones/boneLookController";
  48724. export * from "babylonjs/Bones/skeleton";
  48725. }
  48726. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  48727. import { Nullable } from "babylonjs/types";
  48728. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48729. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48730. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  48731. /**
  48732. * Manage the gamepad inputs to control an arc rotate camera.
  48733. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48734. */
  48735. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  48736. /**
  48737. * Defines the camera the input is attached to.
  48738. */
  48739. camera: ArcRotateCamera;
  48740. /**
  48741. * Defines the gamepad the input is gathering event from.
  48742. */
  48743. gamepad: Nullable<Gamepad>;
  48744. /**
  48745. * Defines the gamepad rotation sensiblity.
  48746. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48747. */
  48748. gamepadRotationSensibility: number;
  48749. /**
  48750. * Defines the gamepad move sensiblity.
  48751. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48752. */
  48753. gamepadMoveSensibility: number;
  48754. private _yAxisScale;
  48755. /**
  48756. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48757. */
  48758. get invertYAxis(): boolean;
  48759. set invertYAxis(value: boolean);
  48760. private _onGamepadConnectedObserver;
  48761. private _onGamepadDisconnectedObserver;
  48762. /**
  48763. * Attach the input controls to a specific dom element to get the input from.
  48764. * @param element Defines the element the controls should be listened from
  48765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48766. */
  48767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48768. /**
  48769. * Detach the current controls from the specified dom element.
  48770. * @param element Defines the element to stop listening the inputs from
  48771. */
  48772. detachControl(element: Nullable<HTMLElement>): void;
  48773. /**
  48774. * Update the current camera state depending on the inputs that have been used this frame.
  48775. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48776. */
  48777. checkInputs(): void;
  48778. /**
  48779. * Gets the class name of the current intput.
  48780. * @returns the class name
  48781. */
  48782. getClassName(): string;
  48783. /**
  48784. * Get the friendly name associated with the input class.
  48785. * @returns the input friendly name
  48786. */
  48787. getSimpleName(): string;
  48788. }
  48789. }
  48790. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  48791. import { Nullable } from "babylonjs/types";
  48792. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48794. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48795. interface ArcRotateCameraInputsManager {
  48796. /**
  48797. * Add orientation input support to the input manager.
  48798. * @returns the current input manager
  48799. */
  48800. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  48801. }
  48802. }
  48803. /**
  48804. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  48805. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48806. */
  48807. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  48808. /**
  48809. * Defines the camera the input is attached to.
  48810. */
  48811. camera: ArcRotateCamera;
  48812. /**
  48813. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  48814. */
  48815. alphaCorrection: number;
  48816. /**
  48817. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  48818. */
  48819. gammaCorrection: number;
  48820. private _alpha;
  48821. private _gamma;
  48822. private _dirty;
  48823. private _deviceOrientationHandler;
  48824. /**
  48825. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  48826. */
  48827. constructor();
  48828. /**
  48829. * Attach the input controls to a specific dom element to get the input from.
  48830. * @param element Defines the element the controls should be listened from
  48831. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48832. */
  48833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48834. /** @hidden */
  48835. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  48836. /**
  48837. * Update the current camera state depending on the inputs that have been used this frame.
  48838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48839. */
  48840. checkInputs(): void;
  48841. /**
  48842. * Detach the current controls from the specified dom element.
  48843. * @param element Defines the element to stop listening the inputs from
  48844. */
  48845. detachControl(element: Nullable<HTMLElement>): void;
  48846. /**
  48847. * Gets the class name of the current intput.
  48848. * @returns the class name
  48849. */
  48850. getClassName(): string;
  48851. /**
  48852. * Get the friendly name associated with the input class.
  48853. * @returns the input friendly name
  48854. */
  48855. getSimpleName(): string;
  48856. }
  48857. }
  48858. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  48859. import { Nullable } from "babylonjs/types";
  48860. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48861. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48862. /**
  48863. * Listen to mouse events to control the camera.
  48864. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48865. */
  48866. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  48867. /**
  48868. * Defines the camera the input is attached to.
  48869. */
  48870. camera: FlyCamera;
  48871. /**
  48872. * Defines if touch is enabled. (Default is true.)
  48873. */
  48874. touchEnabled: boolean;
  48875. /**
  48876. * Defines the buttons associated with the input to handle camera rotation.
  48877. */
  48878. buttons: number[];
  48879. /**
  48880. * Assign buttons for Yaw control.
  48881. */
  48882. buttonsYaw: number[];
  48883. /**
  48884. * Assign buttons for Pitch control.
  48885. */
  48886. buttonsPitch: number[];
  48887. /**
  48888. * Assign buttons for Roll control.
  48889. */
  48890. buttonsRoll: number[];
  48891. /**
  48892. * Detect if any button is being pressed while mouse is moved.
  48893. * -1 = Mouse locked.
  48894. * 0 = Left button.
  48895. * 1 = Middle Button.
  48896. * 2 = Right Button.
  48897. */
  48898. activeButton: number;
  48899. /**
  48900. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  48901. * Higher values reduce its sensitivity.
  48902. */
  48903. angularSensibility: number;
  48904. private _observer;
  48905. private _rollObserver;
  48906. private previousPosition;
  48907. private noPreventDefault;
  48908. private element;
  48909. /**
  48910. * Listen to mouse events to control the camera.
  48911. * @param touchEnabled Define if touch is enabled. (Default is true.)
  48912. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48913. */
  48914. constructor(touchEnabled?: boolean);
  48915. /**
  48916. * Attach the mouse control to the HTML DOM element.
  48917. * @param element Defines the element that listens to the input events.
  48918. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  48919. */
  48920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48921. /**
  48922. * Detach the current controls from the specified dom element.
  48923. * @param element Defines the element to stop listening the inputs from
  48924. */
  48925. detachControl(element: Nullable<HTMLElement>): void;
  48926. /**
  48927. * Gets the class name of the current input.
  48928. * @returns the class name.
  48929. */
  48930. getClassName(): string;
  48931. /**
  48932. * Get the friendly name associated with the input class.
  48933. * @returns the input's friendly name.
  48934. */
  48935. getSimpleName(): string;
  48936. private _pointerInput;
  48937. private _onMouseMove;
  48938. /**
  48939. * Rotate camera by mouse offset.
  48940. */
  48941. private rotateCamera;
  48942. }
  48943. }
  48944. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  48945. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  48946. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48947. /**
  48948. * Default Inputs manager for the FlyCamera.
  48949. * It groups all the default supported inputs for ease of use.
  48950. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48951. */
  48952. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  48953. /**
  48954. * Instantiates a new FlyCameraInputsManager.
  48955. * @param camera Defines the camera the inputs belong to.
  48956. */
  48957. constructor(camera: FlyCamera);
  48958. /**
  48959. * Add keyboard input support to the input manager.
  48960. * @returns the new FlyCameraKeyboardMoveInput().
  48961. */
  48962. addKeyboard(): FlyCameraInputsManager;
  48963. /**
  48964. * Add mouse input support to the input manager.
  48965. * @param touchEnabled Enable touch screen support.
  48966. * @returns the new FlyCameraMouseInput().
  48967. */
  48968. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  48969. }
  48970. }
  48971. declare module "babylonjs/Cameras/flyCamera" {
  48972. import { Scene } from "babylonjs/scene";
  48973. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  48974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48975. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  48976. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  48977. /**
  48978. * This is a flying camera, designed for 3D movement and rotation in all directions,
  48979. * such as in a 3D Space Shooter or a Flight Simulator.
  48980. */
  48981. export class FlyCamera extends TargetCamera {
  48982. /**
  48983. * Define the collision ellipsoid of the camera.
  48984. * This is helpful for simulating a camera body, like a player's body.
  48985. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48986. */
  48987. ellipsoid: Vector3;
  48988. /**
  48989. * Define an offset for the position of the ellipsoid around the camera.
  48990. * This can be helpful if the camera is attached away from the player's body center,
  48991. * such as at its head.
  48992. */
  48993. ellipsoidOffset: Vector3;
  48994. /**
  48995. * Enable or disable collisions of the camera with the rest of the scene objects.
  48996. */
  48997. checkCollisions: boolean;
  48998. /**
  48999. * Enable or disable gravity on the camera.
  49000. */
  49001. applyGravity: boolean;
  49002. /**
  49003. * Define the current direction the camera is moving to.
  49004. */
  49005. cameraDirection: Vector3;
  49006. /**
  49007. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49008. * This overrides and empties cameraRotation.
  49009. */
  49010. rotationQuaternion: Quaternion;
  49011. /**
  49012. * Track Roll to maintain the wanted Rolling when looking around.
  49013. */
  49014. _trackRoll: number;
  49015. /**
  49016. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49017. */
  49018. rollCorrect: number;
  49019. /**
  49020. * Mimic a banked turn, Rolling the camera when Yawing.
  49021. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49022. */
  49023. bankedTurn: boolean;
  49024. /**
  49025. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49026. */
  49027. bankedTurnLimit: number;
  49028. /**
  49029. * Value of 0 disables the banked Roll.
  49030. * Value of 1 is equal to the Yaw angle in radians.
  49031. */
  49032. bankedTurnMultiplier: number;
  49033. /**
  49034. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49035. */
  49036. inputs: FlyCameraInputsManager;
  49037. /**
  49038. * Gets the input sensibility for mouse input.
  49039. * Higher values reduce sensitivity.
  49040. */
  49041. get angularSensibility(): number;
  49042. /**
  49043. * Sets the input sensibility for a mouse input.
  49044. * Higher values reduce sensitivity.
  49045. */
  49046. set angularSensibility(value: number);
  49047. /**
  49048. * Get the keys for camera movement forward.
  49049. */
  49050. get keysForward(): number[];
  49051. /**
  49052. * Set the keys for camera movement forward.
  49053. */
  49054. set keysForward(value: number[]);
  49055. /**
  49056. * Get the keys for camera movement backward.
  49057. */
  49058. get keysBackward(): number[];
  49059. set keysBackward(value: number[]);
  49060. /**
  49061. * Get the keys for camera movement up.
  49062. */
  49063. get keysUp(): number[];
  49064. /**
  49065. * Set the keys for camera movement up.
  49066. */
  49067. set keysUp(value: number[]);
  49068. /**
  49069. * Get the keys for camera movement down.
  49070. */
  49071. get keysDown(): number[];
  49072. /**
  49073. * Set the keys for camera movement down.
  49074. */
  49075. set keysDown(value: number[]);
  49076. /**
  49077. * Get the keys for camera movement left.
  49078. */
  49079. get keysLeft(): number[];
  49080. /**
  49081. * Set the keys for camera movement left.
  49082. */
  49083. set keysLeft(value: number[]);
  49084. /**
  49085. * Set the keys for camera movement right.
  49086. */
  49087. get keysRight(): number[];
  49088. /**
  49089. * Set the keys for camera movement right.
  49090. */
  49091. set keysRight(value: number[]);
  49092. /**
  49093. * Event raised when the camera collides with a mesh in the scene.
  49094. */
  49095. onCollide: (collidedMesh: AbstractMesh) => void;
  49096. private _collider;
  49097. private _needMoveForGravity;
  49098. private _oldPosition;
  49099. private _diffPosition;
  49100. private _newPosition;
  49101. /** @hidden */
  49102. _localDirection: Vector3;
  49103. /** @hidden */
  49104. _transformedDirection: Vector3;
  49105. /**
  49106. * Instantiates a FlyCamera.
  49107. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49108. * such as in a 3D Space Shooter or a Flight Simulator.
  49109. * @param name Define the name of the camera in the scene.
  49110. * @param position Define the starting position of the camera in the scene.
  49111. * @param scene Define the scene the camera belongs to.
  49112. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49113. */
  49114. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49115. /**
  49116. * Attach a control to the HTML DOM element.
  49117. * @param element Defines the element that listens to the input events.
  49118. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  49119. */
  49120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49121. /**
  49122. * Detach a control from the HTML DOM element.
  49123. * The camera will stop reacting to that input.
  49124. * @param element Defines the element that listens to the input events.
  49125. */
  49126. detachControl(element: HTMLElement): void;
  49127. private _collisionMask;
  49128. /**
  49129. * Get the mask that the camera ignores in collision events.
  49130. */
  49131. get collisionMask(): number;
  49132. /**
  49133. * Set the mask that the camera ignores in collision events.
  49134. */
  49135. set collisionMask(mask: number);
  49136. /** @hidden */
  49137. _collideWithWorld(displacement: Vector3): void;
  49138. /** @hidden */
  49139. private _onCollisionPositionChange;
  49140. /** @hidden */
  49141. _checkInputs(): void;
  49142. /** @hidden */
  49143. _decideIfNeedsToMove(): boolean;
  49144. /** @hidden */
  49145. _updatePosition(): void;
  49146. /**
  49147. * Restore the Roll to its target value at the rate specified.
  49148. * @param rate - Higher means slower restoring.
  49149. * @hidden
  49150. */
  49151. restoreRoll(rate: number): void;
  49152. /**
  49153. * Destroy the camera and release the current resources held by it.
  49154. */
  49155. dispose(): void;
  49156. /**
  49157. * Get the current object class name.
  49158. * @returns the class name.
  49159. */
  49160. getClassName(): string;
  49161. }
  49162. }
  49163. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49164. import { Nullable } from "babylonjs/types";
  49165. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49166. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49167. /**
  49168. * Listen to keyboard events to control the camera.
  49169. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49170. */
  49171. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49172. /**
  49173. * Defines the camera the input is attached to.
  49174. */
  49175. camera: FlyCamera;
  49176. /**
  49177. * The list of keyboard keys used to control the forward move of the camera.
  49178. */
  49179. keysForward: number[];
  49180. /**
  49181. * The list of keyboard keys used to control the backward move of the camera.
  49182. */
  49183. keysBackward: number[];
  49184. /**
  49185. * The list of keyboard keys used to control the forward move of the camera.
  49186. */
  49187. keysUp: number[];
  49188. /**
  49189. * The list of keyboard keys used to control the backward move of the camera.
  49190. */
  49191. keysDown: number[];
  49192. /**
  49193. * The list of keyboard keys used to control the right strafe move of the camera.
  49194. */
  49195. keysRight: number[];
  49196. /**
  49197. * The list of keyboard keys used to control the left strafe move of the camera.
  49198. */
  49199. keysLeft: number[];
  49200. private _keys;
  49201. private _onCanvasBlurObserver;
  49202. private _onKeyboardObserver;
  49203. private _engine;
  49204. private _scene;
  49205. /**
  49206. * Attach the input controls to a specific dom element to get the input from.
  49207. * @param element Defines the element the controls should be listened from
  49208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49209. */
  49210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49211. /**
  49212. * Detach the current controls from the specified dom element.
  49213. * @param element Defines the element to stop listening the inputs from
  49214. */
  49215. detachControl(element: Nullable<HTMLElement>): void;
  49216. /**
  49217. * Gets the class name of the current intput.
  49218. * @returns the class name
  49219. */
  49220. getClassName(): string;
  49221. /** @hidden */
  49222. _onLostFocus(e: FocusEvent): void;
  49223. /**
  49224. * Get the friendly name associated with the input class.
  49225. * @returns the input friendly name
  49226. */
  49227. getSimpleName(): string;
  49228. /**
  49229. * Update the current camera state depending on the inputs that have been used this frame.
  49230. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49231. */
  49232. checkInputs(): void;
  49233. }
  49234. }
  49235. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49236. import { Nullable } from "babylonjs/types";
  49237. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49238. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49239. /**
  49240. * Manage the mouse wheel inputs to control a follow camera.
  49241. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49242. */
  49243. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49244. /**
  49245. * Defines the camera the input is attached to.
  49246. */
  49247. camera: FollowCamera;
  49248. /**
  49249. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49250. */
  49251. axisControlRadius: boolean;
  49252. /**
  49253. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49254. */
  49255. axisControlHeight: boolean;
  49256. /**
  49257. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49258. */
  49259. axisControlRotation: boolean;
  49260. /**
  49261. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49262. * relation to mouseWheel events.
  49263. */
  49264. wheelPrecision: number;
  49265. /**
  49266. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49267. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49268. */
  49269. wheelDeltaPercentage: number;
  49270. private _wheel;
  49271. private _observer;
  49272. /**
  49273. * Attach the input controls to a specific dom element to get the input from.
  49274. * @param element Defines the element the controls should be listened from
  49275. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49276. */
  49277. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49278. /**
  49279. * Detach the current controls from the specified dom element.
  49280. * @param element Defines the element to stop listening the inputs from
  49281. */
  49282. detachControl(element: Nullable<HTMLElement>): void;
  49283. /**
  49284. * Gets the class name of the current intput.
  49285. * @returns the class name
  49286. */
  49287. getClassName(): string;
  49288. /**
  49289. * Get the friendly name associated with the input class.
  49290. * @returns the input friendly name
  49291. */
  49292. getSimpleName(): string;
  49293. }
  49294. }
  49295. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49296. import { Nullable } from "babylonjs/types";
  49297. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49298. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49299. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49300. /**
  49301. * Manage the pointers inputs to control an follow camera.
  49302. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49303. */
  49304. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49305. /**
  49306. * Defines the camera the input is attached to.
  49307. */
  49308. camera: FollowCamera;
  49309. /**
  49310. * Gets the class name of the current input.
  49311. * @returns the class name
  49312. */
  49313. getClassName(): string;
  49314. /**
  49315. * Defines the pointer angular sensibility along the X axis or how fast is
  49316. * the camera rotating.
  49317. * A negative number will reverse the axis direction.
  49318. */
  49319. angularSensibilityX: number;
  49320. /**
  49321. * Defines the pointer angular sensibility along the Y axis or how fast is
  49322. * the camera rotating.
  49323. * A negative number will reverse the axis direction.
  49324. */
  49325. angularSensibilityY: number;
  49326. /**
  49327. * Defines the pointer pinch precision or how fast is the camera zooming.
  49328. * A negative number will reverse the axis direction.
  49329. */
  49330. pinchPrecision: number;
  49331. /**
  49332. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49333. * from 0.
  49334. * It defines the percentage of current camera.radius to use as delta when
  49335. * pinch zoom is used.
  49336. */
  49337. pinchDeltaPercentage: number;
  49338. /**
  49339. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49340. */
  49341. axisXControlRadius: boolean;
  49342. /**
  49343. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49344. */
  49345. axisXControlHeight: boolean;
  49346. /**
  49347. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49348. */
  49349. axisXControlRotation: boolean;
  49350. /**
  49351. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49352. */
  49353. axisYControlRadius: boolean;
  49354. /**
  49355. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49356. */
  49357. axisYControlHeight: boolean;
  49358. /**
  49359. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49360. */
  49361. axisYControlRotation: boolean;
  49362. /**
  49363. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49364. */
  49365. axisPinchControlRadius: boolean;
  49366. /**
  49367. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49368. */
  49369. axisPinchControlHeight: boolean;
  49370. /**
  49371. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49372. */
  49373. axisPinchControlRotation: boolean;
  49374. /**
  49375. * Log error messages if basic misconfiguration has occurred.
  49376. */
  49377. warningEnable: boolean;
  49378. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49379. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49380. private _warningCounter;
  49381. private _warning;
  49382. }
  49383. }
  49384. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49385. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49386. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49387. /**
  49388. * Default Inputs manager for the FollowCamera.
  49389. * It groups all the default supported inputs for ease of use.
  49390. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49391. */
  49392. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49393. /**
  49394. * Instantiates a new FollowCameraInputsManager.
  49395. * @param camera Defines the camera the inputs belong to
  49396. */
  49397. constructor(camera: FollowCamera);
  49398. /**
  49399. * Add keyboard input support to the input manager.
  49400. * @returns the current input manager
  49401. */
  49402. addKeyboard(): FollowCameraInputsManager;
  49403. /**
  49404. * Add mouse wheel input support to the input manager.
  49405. * @returns the current input manager
  49406. */
  49407. addMouseWheel(): FollowCameraInputsManager;
  49408. /**
  49409. * Add pointers input support to the input manager.
  49410. * @returns the current input manager
  49411. */
  49412. addPointers(): FollowCameraInputsManager;
  49413. /**
  49414. * Add orientation input support to the input manager.
  49415. * @returns the current input manager
  49416. */
  49417. addVRDeviceOrientation(): FollowCameraInputsManager;
  49418. }
  49419. }
  49420. declare module "babylonjs/Cameras/followCamera" {
  49421. import { Nullable } from "babylonjs/types";
  49422. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49423. import { Scene } from "babylonjs/scene";
  49424. import { Vector3 } from "babylonjs/Maths/math.vector";
  49425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49426. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49427. /**
  49428. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49429. * an arc rotate version arcFollowCamera are available.
  49430. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49431. */
  49432. export class FollowCamera extends TargetCamera {
  49433. /**
  49434. * Distance the follow camera should follow an object at
  49435. */
  49436. radius: number;
  49437. /**
  49438. * Minimum allowed distance of the camera to the axis of rotation
  49439. * (The camera can not get closer).
  49440. * This can help limiting how the Camera is able to move in the scene.
  49441. */
  49442. lowerRadiusLimit: Nullable<number>;
  49443. /**
  49444. * Maximum allowed distance of the camera to the axis of rotation
  49445. * (The camera can not get further).
  49446. * This can help limiting how the Camera is able to move in the scene.
  49447. */
  49448. upperRadiusLimit: Nullable<number>;
  49449. /**
  49450. * Define a rotation offset between the camera and the object it follows
  49451. */
  49452. rotationOffset: number;
  49453. /**
  49454. * Minimum allowed angle to camera position relative to target object.
  49455. * This can help limiting how the Camera is able to move in the scene.
  49456. */
  49457. lowerRotationOffsetLimit: Nullable<number>;
  49458. /**
  49459. * Maximum allowed angle to camera position relative to target object.
  49460. * This can help limiting how the Camera is able to move in the scene.
  49461. */
  49462. upperRotationOffsetLimit: Nullable<number>;
  49463. /**
  49464. * Define a height offset between the camera and the object it follows.
  49465. * It can help following an object from the top (like a car chaing a plane)
  49466. */
  49467. heightOffset: number;
  49468. /**
  49469. * Minimum allowed height of camera position relative to target object.
  49470. * This can help limiting how the Camera is able to move in the scene.
  49471. */
  49472. lowerHeightOffsetLimit: Nullable<number>;
  49473. /**
  49474. * Maximum allowed height of camera position relative to target object.
  49475. * This can help limiting how the Camera is able to move in the scene.
  49476. */
  49477. upperHeightOffsetLimit: Nullable<number>;
  49478. /**
  49479. * Define how fast the camera can accelerate to follow it s target.
  49480. */
  49481. cameraAcceleration: number;
  49482. /**
  49483. * Define the speed limit of the camera following an object.
  49484. */
  49485. maxCameraSpeed: number;
  49486. /**
  49487. * Define the target of the camera.
  49488. */
  49489. lockedTarget: Nullable<AbstractMesh>;
  49490. /**
  49491. * Defines the input associated with the camera.
  49492. */
  49493. inputs: FollowCameraInputsManager;
  49494. /**
  49495. * Instantiates the follow camera.
  49496. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49497. * @param name Define the name of the camera in the scene
  49498. * @param position Define the position of the camera
  49499. * @param scene Define the scene the camera belong to
  49500. * @param lockedTarget Define the target of the camera
  49501. */
  49502. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49503. private _follow;
  49504. /**
  49505. * Attached controls to the current camera.
  49506. * @param element Defines the element the controls should be listened from
  49507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49508. */
  49509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49510. /**
  49511. * Detach the current controls from the camera.
  49512. * The camera will stop reacting to inputs.
  49513. * @param element Defines the element to stop listening the inputs from
  49514. */
  49515. detachControl(element: HTMLElement): void;
  49516. /** @hidden */
  49517. _checkInputs(): void;
  49518. private _checkLimits;
  49519. /**
  49520. * Gets the camera class name.
  49521. * @returns the class name
  49522. */
  49523. getClassName(): string;
  49524. }
  49525. /**
  49526. * Arc Rotate version of the follow camera.
  49527. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49528. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49529. */
  49530. export class ArcFollowCamera extends TargetCamera {
  49531. /** The longitudinal angle of the camera */
  49532. alpha: number;
  49533. /** The latitudinal angle of the camera */
  49534. beta: number;
  49535. /** The radius of the camera from its target */
  49536. radius: number;
  49537. private _cartesianCoordinates;
  49538. /** Define the camera target (the mesh it should follow) */
  49539. private _meshTarget;
  49540. /**
  49541. * Instantiates a new ArcFollowCamera
  49542. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49543. * @param name Define the name of the camera
  49544. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49545. * @param beta Define the rotation angle of the camera around the elevation axis
  49546. * @param radius Define the radius of the camera from its target point
  49547. * @param target Define the target of the camera
  49548. * @param scene Define the scene the camera belongs to
  49549. */
  49550. constructor(name: string,
  49551. /** The longitudinal angle of the camera */
  49552. alpha: number,
  49553. /** The latitudinal angle of the camera */
  49554. beta: number,
  49555. /** The radius of the camera from its target */
  49556. radius: number,
  49557. /** Define the camera target (the mesh it should follow) */
  49558. target: Nullable<AbstractMesh>, scene: Scene);
  49559. private _follow;
  49560. /** @hidden */
  49561. _checkInputs(): void;
  49562. /**
  49563. * Returns the class name of the object.
  49564. * It is mostly used internally for serialization purposes.
  49565. */
  49566. getClassName(): string;
  49567. }
  49568. }
  49569. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49570. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49571. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49572. import { Nullable } from "babylonjs/types";
  49573. /**
  49574. * Manage the keyboard inputs to control the movement of a follow camera.
  49575. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49576. */
  49577. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49578. /**
  49579. * Defines the camera the input is attached to.
  49580. */
  49581. camera: FollowCamera;
  49582. /**
  49583. * Defines the list of key codes associated with the up action (increase heightOffset)
  49584. */
  49585. keysHeightOffsetIncr: number[];
  49586. /**
  49587. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49588. */
  49589. keysHeightOffsetDecr: number[];
  49590. /**
  49591. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49592. */
  49593. keysHeightOffsetModifierAlt: boolean;
  49594. /**
  49595. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49596. */
  49597. keysHeightOffsetModifierCtrl: boolean;
  49598. /**
  49599. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49600. */
  49601. keysHeightOffsetModifierShift: boolean;
  49602. /**
  49603. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49604. */
  49605. keysRotationOffsetIncr: number[];
  49606. /**
  49607. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49608. */
  49609. keysRotationOffsetDecr: number[];
  49610. /**
  49611. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49612. */
  49613. keysRotationOffsetModifierAlt: boolean;
  49614. /**
  49615. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49616. */
  49617. keysRotationOffsetModifierCtrl: boolean;
  49618. /**
  49619. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49620. */
  49621. keysRotationOffsetModifierShift: boolean;
  49622. /**
  49623. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49624. */
  49625. keysRadiusIncr: number[];
  49626. /**
  49627. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49628. */
  49629. keysRadiusDecr: number[];
  49630. /**
  49631. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49632. */
  49633. keysRadiusModifierAlt: boolean;
  49634. /**
  49635. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  49636. */
  49637. keysRadiusModifierCtrl: boolean;
  49638. /**
  49639. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  49640. */
  49641. keysRadiusModifierShift: boolean;
  49642. /**
  49643. * Defines the rate of change of heightOffset.
  49644. */
  49645. heightSensibility: number;
  49646. /**
  49647. * Defines the rate of change of rotationOffset.
  49648. */
  49649. rotationSensibility: number;
  49650. /**
  49651. * Defines the rate of change of radius.
  49652. */
  49653. radiusSensibility: number;
  49654. private _keys;
  49655. private _ctrlPressed;
  49656. private _altPressed;
  49657. private _shiftPressed;
  49658. private _onCanvasBlurObserver;
  49659. private _onKeyboardObserver;
  49660. private _engine;
  49661. private _scene;
  49662. /**
  49663. * Attach the input controls to a specific dom element to get the input from.
  49664. * @param element Defines the element the controls should be listened from
  49665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49666. */
  49667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49668. /**
  49669. * Detach the current controls from the specified dom element.
  49670. * @param element Defines the element to stop listening the inputs from
  49671. */
  49672. detachControl(element: Nullable<HTMLElement>): void;
  49673. /**
  49674. * Update the current camera state depending on the inputs that have been used this frame.
  49675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49676. */
  49677. checkInputs(): void;
  49678. /**
  49679. * Gets the class name of the current input.
  49680. * @returns the class name
  49681. */
  49682. getClassName(): string;
  49683. /**
  49684. * Get the friendly name associated with the input class.
  49685. * @returns the input friendly name
  49686. */
  49687. getSimpleName(): string;
  49688. /**
  49689. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49690. * allow modification of the heightOffset value.
  49691. */
  49692. private _modifierHeightOffset;
  49693. /**
  49694. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49695. * allow modification of the rotationOffset value.
  49696. */
  49697. private _modifierRotationOffset;
  49698. /**
  49699. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  49700. * allow modification of the radius value.
  49701. */
  49702. private _modifierRadius;
  49703. }
  49704. }
  49705. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  49706. import { Nullable } from "babylonjs/types";
  49707. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49708. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49709. import { Observable } from "babylonjs/Misc/observable";
  49710. module "babylonjs/Cameras/freeCameraInputsManager" {
  49711. interface FreeCameraInputsManager {
  49712. /**
  49713. * @hidden
  49714. */
  49715. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  49716. /**
  49717. * Add orientation input support to the input manager.
  49718. * @returns the current input manager
  49719. */
  49720. addDeviceOrientation(): FreeCameraInputsManager;
  49721. }
  49722. }
  49723. /**
  49724. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  49725. * Screen rotation is taken into account.
  49726. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49727. */
  49728. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  49729. private _camera;
  49730. private _screenOrientationAngle;
  49731. private _constantTranform;
  49732. private _screenQuaternion;
  49733. private _alpha;
  49734. private _beta;
  49735. private _gamma;
  49736. /**
  49737. * Can be used to detect if a device orientation sensor is available on a device
  49738. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  49739. * @returns a promise that will resolve on orientation change
  49740. */
  49741. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  49742. /**
  49743. * @hidden
  49744. */
  49745. _onDeviceOrientationChangedObservable: Observable<void>;
  49746. /**
  49747. * Instantiates a new input
  49748. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49749. */
  49750. constructor();
  49751. /**
  49752. * Define the camera controlled by the input.
  49753. */
  49754. get camera(): FreeCamera;
  49755. set camera(camera: FreeCamera);
  49756. /**
  49757. * Attach the input controls to a specific dom element to get the input from.
  49758. * @param element Defines the element the controls should be listened from
  49759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49760. */
  49761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49762. private _orientationChanged;
  49763. private _deviceOrientation;
  49764. /**
  49765. * Detach the current controls from the specified dom element.
  49766. * @param element Defines the element to stop listening the inputs from
  49767. */
  49768. detachControl(element: Nullable<HTMLElement>): void;
  49769. /**
  49770. * Update the current camera state depending on the inputs that have been used this frame.
  49771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49772. */
  49773. checkInputs(): void;
  49774. /**
  49775. * Gets the class name of the current intput.
  49776. * @returns the class name
  49777. */
  49778. getClassName(): string;
  49779. /**
  49780. * Get the friendly name associated with the input class.
  49781. * @returns the input friendly name
  49782. */
  49783. getSimpleName(): string;
  49784. }
  49785. }
  49786. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  49787. import { Nullable } from "babylonjs/types";
  49788. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49789. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49790. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49791. /**
  49792. * Manage the gamepad inputs to control a free camera.
  49793. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49794. */
  49795. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  49796. /**
  49797. * Define the camera the input is attached to.
  49798. */
  49799. camera: FreeCamera;
  49800. /**
  49801. * Define the Gamepad controlling the input
  49802. */
  49803. gamepad: Nullable<Gamepad>;
  49804. /**
  49805. * Defines the gamepad rotation sensiblity.
  49806. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49807. */
  49808. gamepadAngularSensibility: number;
  49809. /**
  49810. * Defines the gamepad move sensiblity.
  49811. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49812. */
  49813. gamepadMoveSensibility: number;
  49814. private _yAxisScale;
  49815. /**
  49816. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49817. */
  49818. get invertYAxis(): boolean;
  49819. set invertYAxis(value: boolean);
  49820. private _onGamepadConnectedObserver;
  49821. private _onGamepadDisconnectedObserver;
  49822. private _cameraTransform;
  49823. private _deltaTransform;
  49824. private _vector3;
  49825. private _vector2;
  49826. /**
  49827. * Attach the input controls to a specific dom element to get the input from.
  49828. * @param element Defines the element the controls should be listened from
  49829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49830. */
  49831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49832. /**
  49833. * Detach the current controls from the specified dom element.
  49834. * @param element Defines the element to stop listening the inputs from
  49835. */
  49836. detachControl(element: Nullable<HTMLElement>): void;
  49837. /**
  49838. * Update the current camera state depending on the inputs that have been used this frame.
  49839. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49840. */
  49841. checkInputs(): void;
  49842. /**
  49843. * Gets the class name of the current intput.
  49844. * @returns the class name
  49845. */
  49846. getClassName(): string;
  49847. /**
  49848. * Get the friendly name associated with the input class.
  49849. * @returns the input friendly name
  49850. */
  49851. getSimpleName(): string;
  49852. }
  49853. }
  49854. declare module "babylonjs/Misc/virtualJoystick" {
  49855. import { Nullable } from "babylonjs/types";
  49856. import { Vector3 } from "babylonjs/Maths/math.vector";
  49857. /**
  49858. * Defines the potential axis of a Joystick
  49859. */
  49860. export enum JoystickAxis {
  49861. /** X axis */
  49862. X = 0,
  49863. /** Y axis */
  49864. Y = 1,
  49865. /** Z axis */
  49866. Z = 2
  49867. }
  49868. /**
  49869. * Represents the different customization options available
  49870. * for VirtualJoystick
  49871. */
  49872. interface VirtualJoystickCustomizations {
  49873. /**
  49874. * Size of the joystick's puck
  49875. */
  49876. puckSize: number;
  49877. /**
  49878. * Size of the joystick's container
  49879. */
  49880. containerSize: number;
  49881. /**
  49882. * Color of the joystick && puck
  49883. */
  49884. color: string;
  49885. /**
  49886. * Image URL for the joystick's puck
  49887. */
  49888. puckImage?: string;
  49889. /**
  49890. * Image URL for the joystick's container
  49891. */
  49892. containerImage?: string;
  49893. /**
  49894. * Defines the unmoving position of the joystick container
  49895. */
  49896. position?: {
  49897. x: number;
  49898. y: number;
  49899. };
  49900. /**
  49901. * Defines whether or not the joystick container is always visible
  49902. */
  49903. alwaysVisible: boolean;
  49904. /**
  49905. * Defines whether or not to limit the movement of the puck to the joystick's container
  49906. */
  49907. limitToContainer: boolean;
  49908. }
  49909. /**
  49910. * Class used to define virtual joystick (used in touch mode)
  49911. */
  49912. export class VirtualJoystick {
  49913. /**
  49914. * Gets or sets a boolean indicating that left and right values must be inverted
  49915. */
  49916. reverseLeftRight: boolean;
  49917. /**
  49918. * Gets or sets a boolean indicating that up and down values must be inverted
  49919. */
  49920. reverseUpDown: boolean;
  49921. /**
  49922. * Gets the offset value for the position (ie. the change of the position value)
  49923. */
  49924. deltaPosition: Vector3;
  49925. /**
  49926. * Gets a boolean indicating if the virtual joystick was pressed
  49927. */
  49928. pressed: boolean;
  49929. /**
  49930. * Canvas the virtual joystick will render onto, default z-index of this is 5
  49931. */
  49932. static Canvas: Nullable<HTMLCanvasElement>;
  49933. /**
  49934. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  49935. */
  49936. limitToContainer: boolean;
  49937. private static _globalJoystickIndex;
  49938. private static _alwaysVisibleSticks;
  49939. private static vjCanvasContext;
  49940. private static vjCanvasWidth;
  49941. private static vjCanvasHeight;
  49942. private static halfWidth;
  49943. private static _GetDefaultOptions;
  49944. private _action;
  49945. private _axisTargetedByLeftAndRight;
  49946. private _axisTargetedByUpAndDown;
  49947. private _joystickSensibility;
  49948. private _inversedSensibility;
  49949. private _joystickPointerID;
  49950. private _joystickColor;
  49951. private _joystickPointerPos;
  49952. private _joystickPreviousPointerPos;
  49953. private _joystickPointerStartPos;
  49954. private _deltaJoystickVector;
  49955. private _leftJoystick;
  49956. private _touches;
  49957. private _joystickPosition;
  49958. private _alwaysVisible;
  49959. private _puckImage;
  49960. private _containerImage;
  49961. private _joystickPuckSize;
  49962. private _joystickContainerSize;
  49963. private _clearPuckSize;
  49964. private _clearContainerSize;
  49965. private _clearPuckSizeOffset;
  49966. private _clearContainerSizeOffset;
  49967. private _onPointerDownHandlerRef;
  49968. private _onPointerMoveHandlerRef;
  49969. private _onPointerUpHandlerRef;
  49970. private _onResize;
  49971. /**
  49972. * Creates a new virtual joystick
  49973. * @param leftJoystick defines that the joystick is for left hand (false by default)
  49974. * @param customizations Defines the options we want to customize the VirtualJoystick
  49975. */
  49976. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  49977. /**
  49978. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  49979. * @param newJoystickSensibility defines the new sensibility
  49980. */
  49981. setJoystickSensibility(newJoystickSensibility: number): void;
  49982. private _onPointerDown;
  49983. private _onPointerMove;
  49984. private _onPointerUp;
  49985. /**
  49986. * Change the color of the virtual joystick
  49987. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  49988. */
  49989. setJoystickColor(newColor: string): void;
  49990. /**
  49991. * Size of the joystick's container
  49992. */
  49993. set containerSize(newSize: number);
  49994. get containerSize(): number;
  49995. /**
  49996. * Size of the joystick's puck
  49997. */
  49998. set puckSize(newSize: number);
  49999. get puckSize(): number;
  50000. /**
  50001. * Clears the set position of the joystick
  50002. */
  50003. clearPosition(): void;
  50004. /**
  50005. * Defines whether or not the joystick container is always visible
  50006. */
  50007. set alwaysVisible(value: boolean);
  50008. get alwaysVisible(): boolean;
  50009. /**
  50010. * Sets the constant position of the Joystick container
  50011. * @param x X axis coordinate
  50012. * @param y Y axis coordinate
  50013. */
  50014. setPosition(x: number, y: number): void;
  50015. /**
  50016. * Defines a callback to call when the joystick is touched
  50017. * @param action defines the callback
  50018. */
  50019. setActionOnTouch(action: () => any): void;
  50020. /**
  50021. * Defines which axis you'd like to control for left & right
  50022. * @param axis defines the axis to use
  50023. */
  50024. setAxisForLeftRight(axis: JoystickAxis): void;
  50025. /**
  50026. * Defines which axis you'd like to control for up & down
  50027. * @param axis defines the axis to use
  50028. */
  50029. setAxisForUpDown(axis: JoystickAxis): void;
  50030. /**
  50031. * Clears the canvas from the previous puck / container draw
  50032. */
  50033. private _clearPreviousDraw;
  50034. /**
  50035. * Loads `urlPath` to be used for the container's image
  50036. * @param urlPath defines the urlPath of an image to use
  50037. */
  50038. setContainerImage(urlPath: string): void;
  50039. /**
  50040. * Loads `urlPath` to be used for the puck's image
  50041. * @param urlPath defines the urlPath of an image to use
  50042. */
  50043. setPuckImage(urlPath: string): void;
  50044. /**
  50045. * Draws the Virtual Joystick's container
  50046. */
  50047. private _drawContainer;
  50048. /**
  50049. * Draws the Virtual Joystick's puck
  50050. */
  50051. private _drawPuck;
  50052. private _drawVirtualJoystick;
  50053. /**
  50054. * Release internal HTML canvas
  50055. */
  50056. releaseCanvas(): void;
  50057. }
  50058. }
  50059. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50060. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50061. import { Nullable } from "babylonjs/types";
  50062. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50063. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50064. module "babylonjs/Cameras/freeCameraInputsManager" {
  50065. interface FreeCameraInputsManager {
  50066. /**
  50067. * Add virtual joystick input support to the input manager.
  50068. * @returns the current input manager
  50069. */
  50070. addVirtualJoystick(): FreeCameraInputsManager;
  50071. }
  50072. }
  50073. /**
  50074. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50075. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50076. */
  50077. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50078. /**
  50079. * Defines the camera the input is attached to.
  50080. */
  50081. camera: FreeCamera;
  50082. private _leftjoystick;
  50083. private _rightjoystick;
  50084. /**
  50085. * Gets the left stick of the virtual joystick.
  50086. * @returns The virtual Joystick
  50087. */
  50088. getLeftJoystick(): VirtualJoystick;
  50089. /**
  50090. * Gets the right stick of the virtual joystick.
  50091. * @returns The virtual Joystick
  50092. */
  50093. getRightJoystick(): VirtualJoystick;
  50094. /**
  50095. * Update the current camera state depending on the inputs that have been used this frame.
  50096. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50097. */
  50098. checkInputs(): void;
  50099. /**
  50100. * Attach the input controls to a specific dom element to get the input from.
  50101. * @param element Defines the element the controls should be listened from
  50102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50103. */
  50104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50105. /**
  50106. * Detach the current controls from the specified dom element.
  50107. * @param element Defines the element to stop listening the inputs from
  50108. */
  50109. detachControl(element: Nullable<HTMLElement>): void;
  50110. /**
  50111. * Gets the class name of the current intput.
  50112. * @returns the class name
  50113. */
  50114. getClassName(): string;
  50115. /**
  50116. * Get the friendly name associated with the input class.
  50117. * @returns the input friendly name
  50118. */
  50119. getSimpleName(): string;
  50120. }
  50121. }
  50122. declare module "babylonjs/Cameras/Inputs/index" {
  50123. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50124. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50125. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50126. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50127. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50128. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50129. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50130. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50131. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50132. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50133. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50134. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50135. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50136. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50137. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50138. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50139. }
  50140. declare module "babylonjs/Cameras/touchCamera" {
  50141. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50142. import { Scene } from "babylonjs/scene";
  50143. import { Vector3 } from "babylonjs/Maths/math.vector";
  50144. /**
  50145. * This represents a FPS type of camera controlled by touch.
  50146. * This is like a universal camera minus the Gamepad controls.
  50147. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50148. */
  50149. export class TouchCamera extends FreeCamera {
  50150. /**
  50151. * Defines the touch sensibility for rotation.
  50152. * The higher the faster.
  50153. */
  50154. get touchAngularSensibility(): number;
  50155. set touchAngularSensibility(value: number);
  50156. /**
  50157. * Defines the touch sensibility for move.
  50158. * The higher the faster.
  50159. */
  50160. get touchMoveSensibility(): number;
  50161. set touchMoveSensibility(value: number);
  50162. /**
  50163. * Instantiates a new touch camera.
  50164. * This represents a FPS type of camera controlled by touch.
  50165. * This is like a universal camera minus the Gamepad controls.
  50166. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50167. * @param name Define the name of the camera in the scene
  50168. * @param position Define the start position of the camera in the scene
  50169. * @param scene Define the scene the camera belongs to
  50170. */
  50171. constructor(name: string, position: Vector3, scene: Scene);
  50172. /**
  50173. * Gets the current object class name.
  50174. * @return the class name
  50175. */
  50176. getClassName(): string;
  50177. /** @hidden */
  50178. _setupInputs(): void;
  50179. }
  50180. }
  50181. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50182. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50183. import { Scene } from "babylonjs/scene";
  50184. import { Vector3 } from "babylonjs/Maths/math.vector";
  50185. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50186. import { Axis } from "babylonjs/Maths/math.axis";
  50187. /**
  50188. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50189. * being tilted forward or back and left or right.
  50190. */
  50191. export class DeviceOrientationCamera extends FreeCamera {
  50192. private _initialQuaternion;
  50193. private _quaternionCache;
  50194. private _tmpDragQuaternion;
  50195. private _disablePointerInputWhenUsingDeviceOrientation;
  50196. /**
  50197. * Creates a new device orientation camera
  50198. * @param name The name of the camera
  50199. * @param position The start position camera
  50200. * @param scene The scene the camera belongs to
  50201. */
  50202. constructor(name: string, position: Vector3, scene: Scene);
  50203. /**
  50204. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50205. */
  50206. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50207. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50208. private _dragFactor;
  50209. /**
  50210. * Enabled turning on the y axis when the orientation sensor is active
  50211. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50212. */
  50213. enableHorizontalDragging(dragFactor?: number): void;
  50214. /**
  50215. * Gets the current instance class name ("DeviceOrientationCamera").
  50216. * This helps avoiding instanceof at run time.
  50217. * @returns the class name
  50218. */
  50219. getClassName(): string;
  50220. /**
  50221. * @hidden
  50222. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50223. */
  50224. _checkInputs(): void;
  50225. /**
  50226. * Reset the camera to its default orientation on the specified axis only.
  50227. * @param axis The axis to reset
  50228. */
  50229. resetToCurrentRotation(axis?: Axis): void;
  50230. }
  50231. }
  50232. declare module "babylonjs/Gamepads/xboxGamepad" {
  50233. import { Observable } from "babylonjs/Misc/observable";
  50234. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50235. /**
  50236. * Defines supported buttons for XBox360 compatible gamepads
  50237. */
  50238. export enum Xbox360Button {
  50239. /** A */
  50240. A = 0,
  50241. /** B */
  50242. B = 1,
  50243. /** X */
  50244. X = 2,
  50245. /** Y */
  50246. Y = 3,
  50247. /** Left button */
  50248. LB = 4,
  50249. /** Right button */
  50250. RB = 5,
  50251. /** Back */
  50252. Back = 8,
  50253. /** Start */
  50254. Start = 9,
  50255. /** Left stick */
  50256. LeftStick = 10,
  50257. /** Right stick */
  50258. RightStick = 11
  50259. }
  50260. /** Defines values for XBox360 DPad */
  50261. export enum Xbox360Dpad {
  50262. /** Up */
  50263. Up = 12,
  50264. /** Down */
  50265. Down = 13,
  50266. /** Left */
  50267. Left = 14,
  50268. /** Right */
  50269. Right = 15
  50270. }
  50271. /**
  50272. * Defines a XBox360 gamepad
  50273. */
  50274. export class Xbox360Pad extends Gamepad {
  50275. private _leftTrigger;
  50276. private _rightTrigger;
  50277. private _onlefttriggerchanged;
  50278. private _onrighttriggerchanged;
  50279. private _onbuttondown;
  50280. private _onbuttonup;
  50281. private _ondpaddown;
  50282. private _ondpadup;
  50283. /** Observable raised when a button is pressed */
  50284. onButtonDownObservable: Observable<Xbox360Button>;
  50285. /** Observable raised when a button is released */
  50286. onButtonUpObservable: Observable<Xbox360Button>;
  50287. /** Observable raised when a pad is pressed */
  50288. onPadDownObservable: Observable<Xbox360Dpad>;
  50289. /** Observable raised when a pad is released */
  50290. onPadUpObservable: Observable<Xbox360Dpad>;
  50291. private _buttonA;
  50292. private _buttonB;
  50293. private _buttonX;
  50294. private _buttonY;
  50295. private _buttonBack;
  50296. private _buttonStart;
  50297. private _buttonLB;
  50298. private _buttonRB;
  50299. private _buttonLeftStick;
  50300. private _buttonRightStick;
  50301. private _dPadUp;
  50302. private _dPadDown;
  50303. private _dPadLeft;
  50304. private _dPadRight;
  50305. private _isXboxOnePad;
  50306. /**
  50307. * Creates a new XBox360 gamepad object
  50308. * @param id defines the id of this gamepad
  50309. * @param index defines its index
  50310. * @param gamepad defines the internal HTML gamepad object
  50311. * @param xboxOne defines if it is a XBox One gamepad
  50312. */
  50313. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50314. /**
  50315. * Defines the callback to call when left trigger is pressed
  50316. * @param callback defines the callback to use
  50317. */
  50318. onlefttriggerchanged(callback: (value: number) => void): void;
  50319. /**
  50320. * Defines the callback to call when right trigger is pressed
  50321. * @param callback defines the callback to use
  50322. */
  50323. onrighttriggerchanged(callback: (value: number) => void): void;
  50324. /**
  50325. * Gets the left trigger value
  50326. */
  50327. get leftTrigger(): number;
  50328. /**
  50329. * Sets the left trigger value
  50330. */
  50331. set leftTrigger(newValue: number);
  50332. /**
  50333. * Gets the right trigger value
  50334. */
  50335. get rightTrigger(): number;
  50336. /**
  50337. * Sets the right trigger value
  50338. */
  50339. set rightTrigger(newValue: number);
  50340. /**
  50341. * Defines the callback to call when a button is pressed
  50342. * @param callback defines the callback to use
  50343. */
  50344. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50345. /**
  50346. * Defines the callback to call when a button is released
  50347. * @param callback defines the callback to use
  50348. */
  50349. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50350. /**
  50351. * Defines the callback to call when a pad is pressed
  50352. * @param callback defines the callback to use
  50353. */
  50354. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50355. /**
  50356. * Defines the callback to call when a pad is released
  50357. * @param callback defines the callback to use
  50358. */
  50359. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50360. private _setButtonValue;
  50361. private _setDPadValue;
  50362. /**
  50363. * Gets the value of the `A` button
  50364. */
  50365. get buttonA(): number;
  50366. /**
  50367. * Sets the value of the `A` button
  50368. */
  50369. set buttonA(value: number);
  50370. /**
  50371. * Gets the value of the `B` button
  50372. */
  50373. get buttonB(): number;
  50374. /**
  50375. * Sets the value of the `B` button
  50376. */
  50377. set buttonB(value: number);
  50378. /**
  50379. * Gets the value of the `X` button
  50380. */
  50381. get buttonX(): number;
  50382. /**
  50383. * Sets the value of the `X` button
  50384. */
  50385. set buttonX(value: number);
  50386. /**
  50387. * Gets the value of the `Y` button
  50388. */
  50389. get buttonY(): number;
  50390. /**
  50391. * Sets the value of the `Y` button
  50392. */
  50393. set buttonY(value: number);
  50394. /**
  50395. * Gets the value of the `Start` button
  50396. */
  50397. get buttonStart(): number;
  50398. /**
  50399. * Sets the value of the `Start` button
  50400. */
  50401. set buttonStart(value: number);
  50402. /**
  50403. * Gets the value of the `Back` button
  50404. */
  50405. get buttonBack(): number;
  50406. /**
  50407. * Sets the value of the `Back` button
  50408. */
  50409. set buttonBack(value: number);
  50410. /**
  50411. * Gets the value of the `Left` button
  50412. */
  50413. get buttonLB(): number;
  50414. /**
  50415. * Sets the value of the `Left` button
  50416. */
  50417. set buttonLB(value: number);
  50418. /**
  50419. * Gets the value of the `Right` button
  50420. */
  50421. get buttonRB(): number;
  50422. /**
  50423. * Sets the value of the `Right` button
  50424. */
  50425. set buttonRB(value: number);
  50426. /**
  50427. * Gets the value of the Left joystick
  50428. */
  50429. get buttonLeftStick(): number;
  50430. /**
  50431. * Sets the value of the Left joystick
  50432. */
  50433. set buttonLeftStick(value: number);
  50434. /**
  50435. * Gets the value of the Right joystick
  50436. */
  50437. get buttonRightStick(): number;
  50438. /**
  50439. * Sets the value of the Right joystick
  50440. */
  50441. set buttonRightStick(value: number);
  50442. /**
  50443. * Gets the value of D-pad up
  50444. */
  50445. get dPadUp(): number;
  50446. /**
  50447. * Sets the value of D-pad up
  50448. */
  50449. set dPadUp(value: number);
  50450. /**
  50451. * Gets the value of D-pad down
  50452. */
  50453. get dPadDown(): number;
  50454. /**
  50455. * Sets the value of D-pad down
  50456. */
  50457. set dPadDown(value: number);
  50458. /**
  50459. * Gets the value of D-pad left
  50460. */
  50461. get dPadLeft(): number;
  50462. /**
  50463. * Sets the value of D-pad left
  50464. */
  50465. set dPadLeft(value: number);
  50466. /**
  50467. * Gets the value of D-pad right
  50468. */
  50469. get dPadRight(): number;
  50470. /**
  50471. * Sets the value of D-pad right
  50472. */
  50473. set dPadRight(value: number);
  50474. /**
  50475. * Force the gamepad to synchronize with device values
  50476. */
  50477. update(): void;
  50478. /**
  50479. * Disposes the gamepad
  50480. */
  50481. dispose(): void;
  50482. }
  50483. }
  50484. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50485. import { Observable } from "babylonjs/Misc/observable";
  50486. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50487. /**
  50488. * Defines supported buttons for DualShock compatible gamepads
  50489. */
  50490. export enum DualShockButton {
  50491. /** Cross */
  50492. Cross = 0,
  50493. /** Circle */
  50494. Circle = 1,
  50495. /** Square */
  50496. Square = 2,
  50497. /** Triangle */
  50498. Triangle = 3,
  50499. /** L1 */
  50500. L1 = 4,
  50501. /** R1 */
  50502. R1 = 5,
  50503. /** Share */
  50504. Share = 8,
  50505. /** Options */
  50506. Options = 9,
  50507. /** Left stick */
  50508. LeftStick = 10,
  50509. /** Right stick */
  50510. RightStick = 11
  50511. }
  50512. /** Defines values for DualShock DPad */
  50513. export enum DualShockDpad {
  50514. /** Up */
  50515. Up = 12,
  50516. /** Down */
  50517. Down = 13,
  50518. /** Left */
  50519. Left = 14,
  50520. /** Right */
  50521. Right = 15
  50522. }
  50523. /**
  50524. * Defines a DualShock gamepad
  50525. */
  50526. export class DualShockPad extends Gamepad {
  50527. private _leftTrigger;
  50528. private _rightTrigger;
  50529. private _onlefttriggerchanged;
  50530. private _onrighttriggerchanged;
  50531. private _onbuttondown;
  50532. private _onbuttonup;
  50533. private _ondpaddown;
  50534. private _ondpadup;
  50535. /** Observable raised when a button is pressed */
  50536. onButtonDownObservable: Observable<DualShockButton>;
  50537. /** Observable raised when a button is released */
  50538. onButtonUpObservable: Observable<DualShockButton>;
  50539. /** Observable raised when a pad is pressed */
  50540. onPadDownObservable: Observable<DualShockDpad>;
  50541. /** Observable raised when a pad is released */
  50542. onPadUpObservable: Observable<DualShockDpad>;
  50543. private _buttonCross;
  50544. private _buttonCircle;
  50545. private _buttonSquare;
  50546. private _buttonTriangle;
  50547. private _buttonShare;
  50548. private _buttonOptions;
  50549. private _buttonL1;
  50550. private _buttonR1;
  50551. private _buttonLeftStick;
  50552. private _buttonRightStick;
  50553. private _dPadUp;
  50554. private _dPadDown;
  50555. private _dPadLeft;
  50556. private _dPadRight;
  50557. /**
  50558. * Creates a new DualShock gamepad object
  50559. * @param id defines the id of this gamepad
  50560. * @param index defines its index
  50561. * @param gamepad defines the internal HTML gamepad object
  50562. */
  50563. constructor(id: string, index: number, gamepad: any);
  50564. /**
  50565. * Defines the callback to call when left trigger is pressed
  50566. * @param callback defines the callback to use
  50567. */
  50568. onlefttriggerchanged(callback: (value: number) => void): void;
  50569. /**
  50570. * Defines the callback to call when right trigger is pressed
  50571. * @param callback defines the callback to use
  50572. */
  50573. onrighttriggerchanged(callback: (value: number) => void): void;
  50574. /**
  50575. * Gets the left trigger value
  50576. */
  50577. get leftTrigger(): number;
  50578. /**
  50579. * Sets the left trigger value
  50580. */
  50581. set leftTrigger(newValue: number);
  50582. /**
  50583. * Gets the right trigger value
  50584. */
  50585. get rightTrigger(): number;
  50586. /**
  50587. * Sets the right trigger value
  50588. */
  50589. set rightTrigger(newValue: number);
  50590. /**
  50591. * Defines the callback to call when a button is pressed
  50592. * @param callback defines the callback to use
  50593. */
  50594. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50595. /**
  50596. * Defines the callback to call when a button is released
  50597. * @param callback defines the callback to use
  50598. */
  50599. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50600. /**
  50601. * Defines the callback to call when a pad is pressed
  50602. * @param callback defines the callback to use
  50603. */
  50604. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50605. /**
  50606. * Defines the callback to call when a pad is released
  50607. * @param callback defines the callback to use
  50608. */
  50609. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50610. private _setButtonValue;
  50611. private _setDPadValue;
  50612. /**
  50613. * Gets the value of the `Cross` button
  50614. */
  50615. get buttonCross(): number;
  50616. /**
  50617. * Sets the value of the `Cross` button
  50618. */
  50619. set buttonCross(value: number);
  50620. /**
  50621. * Gets the value of the `Circle` button
  50622. */
  50623. get buttonCircle(): number;
  50624. /**
  50625. * Sets the value of the `Circle` button
  50626. */
  50627. set buttonCircle(value: number);
  50628. /**
  50629. * Gets the value of the `Square` button
  50630. */
  50631. get buttonSquare(): number;
  50632. /**
  50633. * Sets the value of the `Square` button
  50634. */
  50635. set buttonSquare(value: number);
  50636. /**
  50637. * Gets the value of the `Triangle` button
  50638. */
  50639. get buttonTriangle(): number;
  50640. /**
  50641. * Sets the value of the `Triangle` button
  50642. */
  50643. set buttonTriangle(value: number);
  50644. /**
  50645. * Gets the value of the `Options` button
  50646. */
  50647. get buttonOptions(): number;
  50648. /**
  50649. * Sets the value of the `Options` button
  50650. */
  50651. set buttonOptions(value: number);
  50652. /**
  50653. * Gets the value of the `Share` button
  50654. */
  50655. get buttonShare(): number;
  50656. /**
  50657. * Sets the value of the `Share` button
  50658. */
  50659. set buttonShare(value: number);
  50660. /**
  50661. * Gets the value of the `L1` button
  50662. */
  50663. get buttonL1(): number;
  50664. /**
  50665. * Sets the value of the `L1` button
  50666. */
  50667. set buttonL1(value: number);
  50668. /**
  50669. * Gets the value of the `R1` button
  50670. */
  50671. get buttonR1(): number;
  50672. /**
  50673. * Sets the value of the `R1` button
  50674. */
  50675. set buttonR1(value: number);
  50676. /**
  50677. * Gets the value of the Left joystick
  50678. */
  50679. get buttonLeftStick(): number;
  50680. /**
  50681. * Sets the value of the Left joystick
  50682. */
  50683. set buttonLeftStick(value: number);
  50684. /**
  50685. * Gets the value of the Right joystick
  50686. */
  50687. get buttonRightStick(): number;
  50688. /**
  50689. * Sets the value of the Right joystick
  50690. */
  50691. set buttonRightStick(value: number);
  50692. /**
  50693. * Gets the value of D-pad up
  50694. */
  50695. get dPadUp(): number;
  50696. /**
  50697. * Sets the value of D-pad up
  50698. */
  50699. set dPadUp(value: number);
  50700. /**
  50701. * Gets the value of D-pad down
  50702. */
  50703. get dPadDown(): number;
  50704. /**
  50705. * Sets the value of D-pad down
  50706. */
  50707. set dPadDown(value: number);
  50708. /**
  50709. * Gets the value of D-pad left
  50710. */
  50711. get dPadLeft(): number;
  50712. /**
  50713. * Sets the value of D-pad left
  50714. */
  50715. set dPadLeft(value: number);
  50716. /**
  50717. * Gets the value of D-pad right
  50718. */
  50719. get dPadRight(): number;
  50720. /**
  50721. * Sets the value of D-pad right
  50722. */
  50723. set dPadRight(value: number);
  50724. /**
  50725. * Force the gamepad to synchronize with device values
  50726. */
  50727. update(): void;
  50728. /**
  50729. * Disposes the gamepad
  50730. */
  50731. dispose(): void;
  50732. }
  50733. }
  50734. declare module "babylonjs/Gamepads/gamepadManager" {
  50735. import { Observable } from "babylonjs/Misc/observable";
  50736. import { Nullable } from "babylonjs/types";
  50737. import { Scene } from "babylonjs/scene";
  50738. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50739. /**
  50740. * Manager for handling gamepads
  50741. */
  50742. export class GamepadManager {
  50743. private _scene?;
  50744. private _babylonGamepads;
  50745. private _oneGamepadConnected;
  50746. /** @hidden */
  50747. _isMonitoring: boolean;
  50748. private _gamepadEventSupported;
  50749. private _gamepadSupport?;
  50750. /**
  50751. * observable to be triggered when the gamepad controller has been connected
  50752. */
  50753. onGamepadConnectedObservable: Observable<Gamepad>;
  50754. /**
  50755. * observable to be triggered when the gamepad controller has been disconnected
  50756. */
  50757. onGamepadDisconnectedObservable: Observable<Gamepad>;
  50758. private _onGamepadConnectedEvent;
  50759. private _onGamepadDisconnectedEvent;
  50760. /**
  50761. * Initializes the gamepad manager
  50762. * @param _scene BabylonJS scene
  50763. */
  50764. constructor(_scene?: Scene | undefined);
  50765. /**
  50766. * The gamepads in the game pad manager
  50767. */
  50768. get gamepads(): Gamepad[];
  50769. /**
  50770. * Get the gamepad controllers based on type
  50771. * @param type The type of gamepad controller
  50772. * @returns Nullable gamepad
  50773. */
  50774. getGamepadByType(type?: number): Nullable<Gamepad>;
  50775. /**
  50776. * Disposes the gamepad manager
  50777. */
  50778. dispose(): void;
  50779. private _addNewGamepad;
  50780. private _startMonitoringGamepads;
  50781. private _stopMonitoringGamepads;
  50782. /** @hidden */
  50783. _checkGamepadsStatus(): void;
  50784. private _updateGamepadObjects;
  50785. }
  50786. }
  50787. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  50788. import { Nullable } from "babylonjs/types";
  50789. import { Scene } from "babylonjs/scene";
  50790. import { ISceneComponent } from "babylonjs/sceneComponent";
  50791. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  50792. module "babylonjs/scene" {
  50793. interface Scene {
  50794. /** @hidden */
  50795. _gamepadManager: Nullable<GamepadManager>;
  50796. /**
  50797. * Gets the gamepad manager associated with the scene
  50798. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  50799. */
  50800. gamepadManager: GamepadManager;
  50801. }
  50802. }
  50803. module "babylonjs/Cameras/freeCameraInputsManager" {
  50804. /**
  50805. * Interface representing a free camera inputs manager
  50806. */
  50807. interface FreeCameraInputsManager {
  50808. /**
  50809. * Adds gamepad input support to the FreeCameraInputsManager.
  50810. * @returns the FreeCameraInputsManager
  50811. */
  50812. addGamepad(): FreeCameraInputsManager;
  50813. }
  50814. }
  50815. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  50816. /**
  50817. * Interface representing an arc rotate camera inputs manager
  50818. */
  50819. interface ArcRotateCameraInputsManager {
  50820. /**
  50821. * Adds gamepad input support to the ArcRotateCamera InputManager.
  50822. * @returns the camera inputs manager
  50823. */
  50824. addGamepad(): ArcRotateCameraInputsManager;
  50825. }
  50826. }
  50827. /**
  50828. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  50829. */
  50830. export class GamepadSystemSceneComponent implements ISceneComponent {
  50831. /**
  50832. * The component name helpfull to identify the component in the list of scene components.
  50833. */
  50834. readonly name: string;
  50835. /**
  50836. * The scene the component belongs to.
  50837. */
  50838. scene: Scene;
  50839. /**
  50840. * Creates a new instance of the component for the given scene
  50841. * @param scene Defines the scene to register the component in
  50842. */
  50843. constructor(scene: Scene);
  50844. /**
  50845. * Registers the component in a given scene
  50846. */
  50847. register(): void;
  50848. /**
  50849. * Rebuilds the elements related to this component in case of
  50850. * context lost for instance.
  50851. */
  50852. rebuild(): void;
  50853. /**
  50854. * Disposes the component and the associated ressources
  50855. */
  50856. dispose(): void;
  50857. private _beforeCameraUpdate;
  50858. }
  50859. }
  50860. declare module "babylonjs/Cameras/universalCamera" {
  50861. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  50862. import { Scene } from "babylonjs/scene";
  50863. import { Vector3 } from "babylonjs/Maths/math.vector";
  50864. import "babylonjs/Gamepads/gamepadSceneComponent";
  50865. /**
  50866. * 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,
  50867. * which still works and will still be found in many Playgrounds.
  50868. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50869. */
  50870. export class UniversalCamera extends TouchCamera {
  50871. /**
  50872. * Defines the gamepad rotation sensiblity.
  50873. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50874. */
  50875. get gamepadAngularSensibility(): number;
  50876. set gamepadAngularSensibility(value: number);
  50877. /**
  50878. * Defines the gamepad move sensiblity.
  50879. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50880. */
  50881. get gamepadMoveSensibility(): number;
  50882. set gamepadMoveSensibility(value: number);
  50883. /**
  50884. * 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,
  50885. * which still works and will still be found in many Playgrounds.
  50886. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50887. * @param name Define the name of the camera in the scene
  50888. * @param position Define the start position of the camera in the scene
  50889. * @param scene Define the scene the camera belongs to
  50890. */
  50891. constructor(name: string, position: Vector3, scene: Scene);
  50892. /**
  50893. * Gets the current object class name.
  50894. * @return the class name
  50895. */
  50896. getClassName(): string;
  50897. }
  50898. }
  50899. declare module "babylonjs/Cameras/gamepadCamera" {
  50900. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  50901. import { Scene } from "babylonjs/scene";
  50902. import { Vector3 } from "babylonjs/Maths/math.vector";
  50903. /**
  50904. * This represents a FPS type of camera. This is only here for back compat purpose.
  50905. * Please use the UniversalCamera instead as both are identical.
  50906. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50907. */
  50908. export class GamepadCamera extends UniversalCamera {
  50909. /**
  50910. * Instantiates a new Gamepad Camera
  50911. * This represents a FPS type of camera. This is only here for back compat purpose.
  50912. * Please use the UniversalCamera instead as both are identical.
  50913. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50914. * @param name Define the name of the camera in the scene
  50915. * @param position Define the start position of the camera in the scene
  50916. * @param scene Define the scene the camera belongs to
  50917. */
  50918. constructor(name: string, position: Vector3, scene: Scene);
  50919. /**
  50920. * Gets the current object class name.
  50921. * @return the class name
  50922. */
  50923. getClassName(): string;
  50924. }
  50925. }
  50926. declare module "babylonjs/Shaders/pass.fragment" {
  50927. /** @hidden */
  50928. export var passPixelShader: {
  50929. name: string;
  50930. shader: string;
  50931. };
  50932. }
  50933. declare module "babylonjs/Shaders/passCube.fragment" {
  50934. /** @hidden */
  50935. export var passCubePixelShader: {
  50936. name: string;
  50937. shader: string;
  50938. };
  50939. }
  50940. declare module "babylonjs/PostProcesses/passPostProcess" {
  50941. import { Nullable } from "babylonjs/types";
  50942. import { Camera } from "babylonjs/Cameras/camera";
  50943. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  50944. import { Engine } from "babylonjs/Engines/engine";
  50945. import "babylonjs/Shaders/pass.fragment";
  50946. import "babylonjs/Shaders/passCube.fragment";
  50947. import { Scene } from "babylonjs/scene";
  50948. /**
  50949. * PassPostProcess which produces an output the same as it's input
  50950. */
  50951. export class PassPostProcess extends PostProcess {
  50952. /**
  50953. * Gets a string identifying the name of the class
  50954. * @returns "PassPostProcess" string
  50955. */
  50956. getClassName(): string;
  50957. /**
  50958. * Creates the PassPostProcess
  50959. * @param name The name of the effect.
  50960. * @param options The required width/height ratio to downsize to before computing the render pass.
  50961. * @param camera The camera to apply the render pass to.
  50962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50963. * @param engine The engine which the post process will be applied. (default: current engine)
  50964. * @param reusable If the post process can be reused on the same frame. (default: false)
  50965. * @param textureType The type of texture to be used when performing the post processing.
  50966. * @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)
  50967. */
  50968. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50969. /** @hidden */
  50970. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  50971. }
  50972. /**
  50973. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  50974. */
  50975. export class PassCubePostProcess extends PostProcess {
  50976. private _face;
  50977. /**
  50978. * Gets or sets the cube face to display.
  50979. * * 0 is +X
  50980. * * 1 is -X
  50981. * * 2 is +Y
  50982. * * 3 is -Y
  50983. * * 4 is +Z
  50984. * * 5 is -Z
  50985. */
  50986. get face(): number;
  50987. set face(value: number);
  50988. /**
  50989. * Gets a string identifying the name of the class
  50990. * @returns "PassCubePostProcess" string
  50991. */
  50992. getClassName(): string;
  50993. /**
  50994. * Creates the PassCubePostProcess
  50995. * @param name The name of the effect.
  50996. * @param options The required width/height ratio to downsize to before computing the render pass.
  50997. * @param camera The camera to apply the render pass to.
  50998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50999. * @param engine The engine which the post process will be applied. (default: current engine)
  51000. * @param reusable If the post process can be reused on the same frame. (default: false)
  51001. * @param textureType The type of texture to be used when performing the post processing.
  51002. * @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)
  51003. */
  51004. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51005. /** @hidden */
  51006. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51007. }
  51008. }
  51009. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51010. /** @hidden */
  51011. export var anaglyphPixelShader: {
  51012. name: string;
  51013. shader: string;
  51014. };
  51015. }
  51016. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51017. import { Engine } from "babylonjs/Engines/engine";
  51018. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51019. import { Camera } from "babylonjs/Cameras/camera";
  51020. import "babylonjs/Shaders/anaglyph.fragment";
  51021. /**
  51022. * Postprocess used to generate anaglyphic rendering
  51023. */
  51024. export class AnaglyphPostProcess extends PostProcess {
  51025. private _passedProcess;
  51026. /**
  51027. * Gets a string identifying the name of the class
  51028. * @returns "AnaglyphPostProcess" string
  51029. */
  51030. getClassName(): string;
  51031. /**
  51032. * Creates a new AnaglyphPostProcess
  51033. * @param name defines postprocess name
  51034. * @param options defines creation options or target ratio scale
  51035. * @param rigCameras defines cameras using this postprocess
  51036. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51037. * @param engine defines hosting engine
  51038. * @param reusable defines if the postprocess will be reused multiple times per frame
  51039. */
  51040. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51041. }
  51042. }
  51043. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51044. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51045. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51046. import { Scene } from "babylonjs/scene";
  51047. import { Vector3 } from "babylonjs/Maths/math.vector";
  51048. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51049. /**
  51050. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51051. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51052. */
  51053. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51054. /**
  51055. * Creates a new AnaglyphArcRotateCamera
  51056. * @param name defines camera name
  51057. * @param alpha defines alpha angle (in radians)
  51058. * @param beta defines beta angle (in radians)
  51059. * @param radius defines radius
  51060. * @param target defines camera target
  51061. * @param interaxialDistance defines distance between each color axis
  51062. * @param scene defines the hosting scene
  51063. */
  51064. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51065. /**
  51066. * Gets camera class name
  51067. * @returns AnaglyphArcRotateCamera
  51068. */
  51069. getClassName(): string;
  51070. }
  51071. }
  51072. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51073. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51074. import { Scene } from "babylonjs/scene";
  51075. import { Vector3 } from "babylonjs/Maths/math.vector";
  51076. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51077. /**
  51078. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51079. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51080. */
  51081. export class AnaglyphFreeCamera extends FreeCamera {
  51082. /**
  51083. * Creates a new AnaglyphFreeCamera
  51084. * @param name defines camera name
  51085. * @param position defines initial position
  51086. * @param interaxialDistance defines distance between each color axis
  51087. * @param scene defines the hosting scene
  51088. */
  51089. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51090. /**
  51091. * Gets camera class name
  51092. * @returns AnaglyphFreeCamera
  51093. */
  51094. getClassName(): string;
  51095. }
  51096. }
  51097. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51098. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51099. import { Scene } from "babylonjs/scene";
  51100. import { Vector3 } from "babylonjs/Maths/math.vector";
  51101. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51102. /**
  51103. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51104. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51105. */
  51106. export class AnaglyphGamepadCamera extends GamepadCamera {
  51107. /**
  51108. * Creates a new AnaglyphGamepadCamera
  51109. * @param name defines camera name
  51110. * @param position defines initial position
  51111. * @param interaxialDistance defines distance between each color axis
  51112. * @param scene defines the hosting scene
  51113. */
  51114. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51115. /**
  51116. * Gets camera class name
  51117. * @returns AnaglyphGamepadCamera
  51118. */
  51119. getClassName(): string;
  51120. }
  51121. }
  51122. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51123. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51124. import { Scene } from "babylonjs/scene";
  51125. import { Vector3 } from "babylonjs/Maths/math.vector";
  51126. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51127. /**
  51128. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51129. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51130. */
  51131. export class AnaglyphUniversalCamera extends UniversalCamera {
  51132. /**
  51133. * Creates a new AnaglyphUniversalCamera
  51134. * @param name defines camera name
  51135. * @param position defines initial position
  51136. * @param interaxialDistance defines distance between each color axis
  51137. * @param scene defines the hosting scene
  51138. */
  51139. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51140. /**
  51141. * Gets camera class name
  51142. * @returns AnaglyphUniversalCamera
  51143. */
  51144. getClassName(): string;
  51145. }
  51146. }
  51147. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51148. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51149. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51150. import { Scene } from "babylonjs/scene";
  51151. import { Vector3 } from "babylonjs/Maths/math.vector";
  51152. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51153. /**
  51154. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51155. * @see https://doc.babylonjs.com/features/cameras
  51156. */
  51157. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51158. /**
  51159. * Creates a new StereoscopicArcRotateCamera
  51160. * @param name defines camera name
  51161. * @param alpha defines alpha angle (in radians)
  51162. * @param beta defines beta angle (in radians)
  51163. * @param radius defines radius
  51164. * @param target defines camera target
  51165. * @param interaxialDistance defines distance between each color axis
  51166. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51167. * @param scene defines the hosting scene
  51168. */
  51169. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51170. /**
  51171. * Gets camera class name
  51172. * @returns StereoscopicArcRotateCamera
  51173. */
  51174. getClassName(): string;
  51175. }
  51176. }
  51177. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51178. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51179. import { Scene } from "babylonjs/scene";
  51180. import { Vector3 } from "babylonjs/Maths/math.vector";
  51181. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51182. /**
  51183. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51184. * @see https://doc.babylonjs.com/features/cameras
  51185. */
  51186. export class StereoscopicFreeCamera extends FreeCamera {
  51187. /**
  51188. * Creates a new StereoscopicFreeCamera
  51189. * @param name defines camera name
  51190. * @param position defines initial position
  51191. * @param interaxialDistance defines distance between each color axis
  51192. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51193. * @param scene defines the hosting scene
  51194. */
  51195. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51196. /**
  51197. * Gets camera class name
  51198. * @returns StereoscopicFreeCamera
  51199. */
  51200. getClassName(): string;
  51201. }
  51202. }
  51203. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51204. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51205. import { Scene } from "babylonjs/scene";
  51206. import { Vector3 } from "babylonjs/Maths/math.vector";
  51207. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51208. /**
  51209. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51210. * @see https://doc.babylonjs.com/features/cameras
  51211. */
  51212. export class StereoscopicGamepadCamera extends GamepadCamera {
  51213. /**
  51214. * Creates a new StereoscopicGamepadCamera
  51215. * @param name defines camera name
  51216. * @param position defines initial position
  51217. * @param interaxialDistance defines distance between each color axis
  51218. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51219. * @param scene defines the hosting scene
  51220. */
  51221. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51222. /**
  51223. * Gets camera class name
  51224. * @returns StereoscopicGamepadCamera
  51225. */
  51226. getClassName(): string;
  51227. }
  51228. }
  51229. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51230. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51231. import { Scene } from "babylonjs/scene";
  51232. import { Vector3 } from "babylonjs/Maths/math.vector";
  51233. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51234. /**
  51235. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51236. * @see https://doc.babylonjs.com/features/cameras
  51237. */
  51238. export class StereoscopicUniversalCamera extends UniversalCamera {
  51239. /**
  51240. * Creates a new StereoscopicUniversalCamera
  51241. * @param name defines camera name
  51242. * @param position defines initial position
  51243. * @param interaxialDistance defines distance between each color axis
  51244. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51245. * @param scene defines the hosting scene
  51246. */
  51247. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51248. /**
  51249. * Gets camera class name
  51250. * @returns StereoscopicUniversalCamera
  51251. */
  51252. getClassName(): string;
  51253. }
  51254. }
  51255. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51256. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51257. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51258. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51259. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51260. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51261. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51262. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51263. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51264. }
  51265. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51266. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51267. import { Scene } from "babylonjs/scene";
  51268. import { Vector3 } from "babylonjs/Maths/math.vector";
  51269. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51270. /**
  51271. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51272. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51273. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51274. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51275. */
  51276. export class VirtualJoysticksCamera extends FreeCamera {
  51277. /**
  51278. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51279. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51280. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51281. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51282. * @param name Define the name of the camera in the scene
  51283. * @param position Define the start position of the camera in the scene
  51284. * @param scene Define the scene the camera belongs to
  51285. */
  51286. constructor(name: string, position: Vector3, scene: Scene);
  51287. /**
  51288. * Gets the current object class name.
  51289. * @return the class name
  51290. */
  51291. getClassName(): string;
  51292. }
  51293. }
  51294. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51295. import { Matrix } from "babylonjs/Maths/math.vector";
  51296. /**
  51297. * This represents all the required metrics to create a VR camera.
  51298. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51299. */
  51300. export class VRCameraMetrics {
  51301. /**
  51302. * Define the horizontal resolution off the screen.
  51303. */
  51304. hResolution: number;
  51305. /**
  51306. * Define the vertical resolution off the screen.
  51307. */
  51308. vResolution: number;
  51309. /**
  51310. * Define the horizontal screen size.
  51311. */
  51312. hScreenSize: number;
  51313. /**
  51314. * Define the vertical screen size.
  51315. */
  51316. vScreenSize: number;
  51317. /**
  51318. * Define the vertical screen center position.
  51319. */
  51320. vScreenCenter: number;
  51321. /**
  51322. * Define the distance of the eyes to the screen.
  51323. */
  51324. eyeToScreenDistance: number;
  51325. /**
  51326. * Define the distance between both lenses
  51327. */
  51328. lensSeparationDistance: number;
  51329. /**
  51330. * Define the distance between both viewer's eyes.
  51331. */
  51332. interpupillaryDistance: number;
  51333. /**
  51334. * Define the distortion factor of the VR postprocess.
  51335. * Please, touch with care.
  51336. */
  51337. distortionK: number[];
  51338. /**
  51339. * Define the chromatic aberration correction factors for the VR post process.
  51340. */
  51341. chromaAbCorrection: number[];
  51342. /**
  51343. * Define the scale factor of the post process.
  51344. * The smaller the better but the slower.
  51345. */
  51346. postProcessScaleFactor: number;
  51347. /**
  51348. * Define an offset for the lens center.
  51349. */
  51350. lensCenterOffset: number;
  51351. /**
  51352. * Define if the current vr camera should compensate the distortion of the lense or not.
  51353. */
  51354. compensateDistortion: boolean;
  51355. /**
  51356. * Defines if multiview should be enabled when rendering (Default: false)
  51357. */
  51358. multiviewEnabled: boolean;
  51359. /**
  51360. * Gets the rendering aspect ratio based on the provided resolutions.
  51361. */
  51362. get aspectRatio(): number;
  51363. /**
  51364. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51365. */
  51366. get aspectRatioFov(): number;
  51367. /**
  51368. * @hidden
  51369. */
  51370. get leftHMatrix(): Matrix;
  51371. /**
  51372. * @hidden
  51373. */
  51374. get rightHMatrix(): Matrix;
  51375. /**
  51376. * @hidden
  51377. */
  51378. get leftPreViewMatrix(): Matrix;
  51379. /**
  51380. * @hidden
  51381. */
  51382. get rightPreViewMatrix(): Matrix;
  51383. /**
  51384. * Get the default VRMetrics based on the most generic setup.
  51385. * @returns the default vr metrics
  51386. */
  51387. static GetDefault(): VRCameraMetrics;
  51388. }
  51389. }
  51390. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51391. /** @hidden */
  51392. export var vrDistortionCorrectionPixelShader: {
  51393. name: string;
  51394. shader: string;
  51395. };
  51396. }
  51397. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51398. import { Camera } from "babylonjs/Cameras/camera";
  51399. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51400. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51401. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51402. /**
  51403. * VRDistortionCorrectionPostProcess used for mobile VR
  51404. */
  51405. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51406. private _isRightEye;
  51407. private _distortionFactors;
  51408. private _postProcessScaleFactor;
  51409. private _lensCenterOffset;
  51410. private _scaleIn;
  51411. private _scaleFactor;
  51412. private _lensCenter;
  51413. /**
  51414. * Gets a string identifying the name of the class
  51415. * @returns "VRDistortionCorrectionPostProcess" string
  51416. */
  51417. getClassName(): string;
  51418. /**
  51419. * Initializes the VRDistortionCorrectionPostProcess
  51420. * @param name The name of the effect.
  51421. * @param camera The camera to apply the render pass to.
  51422. * @param isRightEye If this is for the right eye distortion
  51423. * @param vrMetrics All the required metrics for the VR camera
  51424. */
  51425. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51426. }
  51427. }
  51428. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51429. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51430. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51431. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51432. import { Scene } from "babylonjs/scene";
  51433. import { Vector3 } from "babylonjs/Maths/math.vector";
  51434. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51435. import "babylonjs/Cameras/RigModes/vrRigMode";
  51436. /**
  51437. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51438. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51439. */
  51440. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51441. /**
  51442. * Creates a new VRDeviceOrientationArcRotateCamera
  51443. * @param name defines camera name
  51444. * @param alpha defines the camera rotation along the logitudinal axis
  51445. * @param beta defines the camera rotation along the latitudinal axis
  51446. * @param radius defines the camera distance from its target
  51447. * @param target defines the camera target
  51448. * @param scene defines the scene the camera belongs to
  51449. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51450. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51451. */
  51452. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51453. /**
  51454. * Gets camera class name
  51455. * @returns VRDeviceOrientationArcRotateCamera
  51456. */
  51457. getClassName(): string;
  51458. }
  51459. }
  51460. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51461. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51462. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51463. import { Scene } from "babylonjs/scene";
  51464. import { Vector3 } from "babylonjs/Maths/math.vector";
  51465. import "babylonjs/Cameras/RigModes/vrRigMode";
  51466. /**
  51467. * Camera used to simulate VR rendering (based on FreeCamera)
  51468. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51469. */
  51470. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51471. /**
  51472. * Creates a new VRDeviceOrientationFreeCamera
  51473. * @param name defines camera name
  51474. * @param position defines the start position of the camera
  51475. * @param scene defines the scene the camera belongs to
  51476. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51477. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51478. */
  51479. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51480. /**
  51481. * Gets camera class name
  51482. * @returns VRDeviceOrientationFreeCamera
  51483. */
  51484. getClassName(): string;
  51485. }
  51486. }
  51487. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51488. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51489. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51490. import { Scene } from "babylonjs/scene";
  51491. import { Vector3 } from "babylonjs/Maths/math.vector";
  51492. import "babylonjs/Gamepads/gamepadSceneComponent";
  51493. /**
  51494. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51495. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51496. */
  51497. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51498. /**
  51499. * Creates a new VRDeviceOrientationGamepadCamera
  51500. * @param name defines camera name
  51501. * @param position defines the start position of the camera
  51502. * @param scene defines the scene the camera belongs to
  51503. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51504. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51505. */
  51506. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51507. /**
  51508. * Gets camera class name
  51509. * @returns VRDeviceOrientationGamepadCamera
  51510. */
  51511. getClassName(): string;
  51512. }
  51513. }
  51514. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51515. import { Scene } from "babylonjs/scene";
  51516. import { Texture } from "babylonjs/Materials/Textures/texture";
  51517. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51518. /**
  51519. * A class extending Texture allowing drawing on a texture
  51520. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51521. */
  51522. export class DynamicTexture extends Texture {
  51523. private _generateMipMaps;
  51524. private _canvas;
  51525. private _context;
  51526. /**
  51527. * Creates a DynamicTexture
  51528. * @param name defines the name of the texture
  51529. * @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
  51530. * @param scene defines the scene where you want the texture
  51531. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51532. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51533. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51534. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51535. */
  51536. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51537. /**
  51538. * Get the current class name of the texture useful for serialization or dynamic coding.
  51539. * @returns "DynamicTexture"
  51540. */
  51541. getClassName(): string;
  51542. /**
  51543. * Gets the current state of canRescale
  51544. */
  51545. get canRescale(): boolean;
  51546. private _recreate;
  51547. /**
  51548. * Scales the texture
  51549. * @param ratio the scale factor to apply to both width and height
  51550. */
  51551. scale(ratio: number): void;
  51552. /**
  51553. * Resizes the texture
  51554. * @param width the new width
  51555. * @param height the new height
  51556. */
  51557. scaleTo(width: number, height: number): void;
  51558. /**
  51559. * Gets the context of the canvas used by the texture
  51560. * @returns the canvas context of the dynamic texture
  51561. */
  51562. getContext(): CanvasRenderingContext2D;
  51563. /**
  51564. * Clears the texture
  51565. */
  51566. clear(): void;
  51567. /**
  51568. * Updates the texture
  51569. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51570. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51571. */
  51572. update(invertY?: boolean, premulAlpha?: boolean): void;
  51573. /**
  51574. * Draws text onto the texture
  51575. * @param text defines the text to be drawn
  51576. * @param x defines the placement of the text from the left
  51577. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51578. * @param font defines the font to be used with font-style, font-size, font-name
  51579. * @param color defines the color used for the text
  51580. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51581. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51582. * @param update defines whether texture is immediately update (default is true)
  51583. */
  51584. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51585. /**
  51586. * Clones the texture
  51587. * @returns the clone of the texture.
  51588. */
  51589. clone(): DynamicTexture;
  51590. /**
  51591. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51592. * @returns a serialized dynamic texture object
  51593. */
  51594. serialize(): any;
  51595. private _IsCanvasElement;
  51596. /** @hidden */
  51597. _rebuild(): void;
  51598. }
  51599. }
  51600. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51601. import { Scene } from "babylonjs/scene";
  51602. import { Color3 } from "babylonjs/Maths/math.color";
  51603. import { Mesh } from "babylonjs/Meshes/mesh";
  51604. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51605. import { Nullable } from "babylonjs/types";
  51606. /**
  51607. * Class containing static functions to help procedurally build meshes
  51608. */
  51609. export class GroundBuilder {
  51610. /**
  51611. * Creates a ground mesh
  51612. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51613. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51615. * @param name defines the name of the mesh
  51616. * @param options defines the options used to create the mesh
  51617. * @param scene defines the hosting scene
  51618. * @returns the ground mesh
  51619. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51620. */
  51621. static CreateGround(name: string, options: {
  51622. width?: number;
  51623. height?: number;
  51624. subdivisions?: number;
  51625. subdivisionsX?: number;
  51626. subdivisionsY?: number;
  51627. updatable?: boolean;
  51628. }, scene: any): Mesh;
  51629. /**
  51630. * Creates a tiled ground mesh
  51631. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51632. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51633. * * 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
  51634. * * 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
  51635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51636. * @param name defines the name of the mesh
  51637. * @param options defines the options used to create the mesh
  51638. * @param scene defines the hosting scene
  51639. * @returns the tiled ground mesh
  51640. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51641. */
  51642. static CreateTiledGround(name: string, options: {
  51643. xmin: number;
  51644. zmin: number;
  51645. xmax: number;
  51646. zmax: number;
  51647. subdivisions?: {
  51648. w: number;
  51649. h: number;
  51650. };
  51651. precision?: {
  51652. w: number;
  51653. h: number;
  51654. };
  51655. updatable?: boolean;
  51656. }, scene?: Nullable<Scene>): Mesh;
  51657. /**
  51658. * Creates a ground mesh from a height map
  51659. * * The parameter `url` sets the URL of the height map image resource.
  51660. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51661. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51662. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51663. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51664. * * 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.
  51665. * * 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).
  51666. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51668. * @param name defines the name of the mesh
  51669. * @param url defines the url to the height map
  51670. * @param options defines the options used to create the mesh
  51671. * @param scene defines the hosting scene
  51672. * @returns the ground mesh
  51673. * @see https://doc.babylonjs.com/babylon101/height_map
  51674. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51675. */
  51676. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51677. width?: number;
  51678. height?: number;
  51679. subdivisions?: number;
  51680. minHeight?: number;
  51681. maxHeight?: number;
  51682. colorFilter?: Color3;
  51683. alphaFilter?: number;
  51684. updatable?: boolean;
  51685. onReady?: (mesh: GroundMesh) => void;
  51686. }, scene?: Nullable<Scene>): GroundMesh;
  51687. }
  51688. }
  51689. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  51690. import { Vector4 } from "babylonjs/Maths/math.vector";
  51691. import { Mesh } from "babylonjs/Meshes/mesh";
  51692. /**
  51693. * Class containing static functions to help procedurally build meshes
  51694. */
  51695. export class TorusBuilder {
  51696. /**
  51697. * Creates a torus mesh
  51698. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51699. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51700. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51704. * @param name defines the name of the mesh
  51705. * @param options defines the options used to create the mesh
  51706. * @param scene defines the hosting scene
  51707. * @returns the torus mesh
  51708. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51709. */
  51710. static CreateTorus(name: string, options: {
  51711. diameter?: number;
  51712. thickness?: number;
  51713. tessellation?: number;
  51714. updatable?: boolean;
  51715. sideOrientation?: number;
  51716. frontUVs?: Vector4;
  51717. backUVs?: Vector4;
  51718. }, scene: any): Mesh;
  51719. }
  51720. }
  51721. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  51722. import { Vector4 } from "babylonjs/Maths/math.vector";
  51723. import { Color4 } from "babylonjs/Maths/math.color";
  51724. import { Mesh } from "babylonjs/Meshes/mesh";
  51725. /**
  51726. * Class containing static functions to help procedurally build meshes
  51727. */
  51728. export class CylinderBuilder {
  51729. /**
  51730. * Creates a cylinder or a cone mesh
  51731. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51732. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51733. * * 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.
  51734. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51735. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51736. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51737. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51738. * * 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).
  51739. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51740. * * 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).
  51741. * * 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
  51742. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51743. * * 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
  51744. * * 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.
  51745. * * If `enclose` is false, a ring surface is one element.
  51746. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51747. * * 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
  51748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51751. * @param name defines the name of the mesh
  51752. * @param options defines the options used to create the mesh
  51753. * @param scene defines the hosting scene
  51754. * @returns the cylinder mesh
  51755. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51756. */
  51757. static CreateCylinder(name: string, options: {
  51758. height?: number;
  51759. diameterTop?: number;
  51760. diameterBottom?: number;
  51761. diameter?: number;
  51762. tessellation?: number;
  51763. subdivisions?: number;
  51764. arc?: number;
  51765. faceColors?: Color4[];
  51766. faceUV?: Vector4[];
  51767. updatable?: boolean;
  51768. hasRings?: boolean;
  51769. enclose?: boolean;
  51770. cap?: number;
  51771. sideOrientation?: number;
  51772. frontUVs?: Vector4;
  51773. backUVs?: Vector4;
  51774. }, scene: any): Mesh;
  51775. }
  51776. }
  51777. declare module "babylonjs/XR/webXRTypes" {
  51778. import { Nullable } from "babylonjs/types";
  51779. import { IDisposable } from "babylonjs/scene";
  51780. /**
  51781. * States of the webXR experience
  51782. */
  51783. export enum WebXRState {
  51784. /**
  51785. * Transitioning to being in XR mode
  51786. */
  51787. ENTERING_XR = 0,
  51788. /**
  51789. * Transitioning to non XR mode
  51790. */
  51791. EXITING_XR = 1,
  51792. /**
  51793. * In XR mode and presenting
  51794. */
  51795. IN_XR = 2,
  51796. /**
  51797. * Not entered XR mode
  51798. */
  51799. NOT_IN_XR = 3
  51800. }
  51801. /**
  51802. * Abstraction of the XR render target
  51803. */
  51804. export interface WebXRRenderTarget extends IDisposable {
  51805. /**
  51806. * xrpresent context of the canvas which can be used to display/mirror xr content
  51807. */
  51808. canvasContext: WebGLRenderingContext;
  51809. /**
  51810. * xr layer for the canvas
  51811. */
  51812. xrLayer: Nullable<XRWebGLLayer>;
  51813. /**
  51814. * Initializes the xr layer for the session
  51815. * @param xrSession xr session
  51816. * @returns a promise that will resolve once the XR Layer has been created
  51817. */
  51818. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51819. }
  51820. }
  51821. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  51822. import { Nullable } from "babylonjs/types";
  51823. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51824. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51825. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51826. import { Observable } from "babylonjs/Misc/observable";
  51827. /**
  51828. * COnfiguration object for WebXR output canvas
  51829. */
  51830. export class WebXRManagedOutputCanvasOptions {
  51831. /**
  51832. * An optional canvas in case you wish to create it yourself and provide it here.
  51833. * If not provided, a new canvas will be created
  51834. */
  51835. canvasElement?: HTMLCanvasElement;
  51836. /**
  51837. * Options for this XR Layer output
  51838. */
  51839. canvasOptions?: XRWebGLLayerOptions;
  51840. /**
  51841. * CSS styling for a newly created canvas (if not provided)
  51842. */
  51843. newCanvasCssStyle?: string;
  51844. /**
  51845. * Get the default values of the configuration object
  51846. * @param engine defines the engine to use (can be null)
  51847. * @returns default values of this configuration object
  51848. */
  51849. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  51850. }
  51851. /**
  51852. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  51853. */
  51854. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  51855. private _options;
  51856. private _canvas;
  51857. private _engine;
  51858. private _originalCanvasSize;
  51859. /**
  51860. * Rendering context of the canvas which can be used to display/mirror xr content
  51861. */
  51862. canvasContext: WebGLRenderingContext;
  51863. /**
  51864. * xr layer for the canvas
  51865. */
  51866. xrLayer: Nullable<XRWebGLLayer>;
  51867. /**
  51868. * Obseervers registered here will be triggered when the xr layer was initialized
  51869. */
  51870. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  51871. /**
  51872. * Initializes the canvas to be added/removed upon entering/exiting xr
  51873. * @param _xrSessionManager The XR Session manager
  51874. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  51875. */
  51876. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  51877. /**
  51878. * Disposes of the object
  51879. */
  51880. dispose(): void;
  51881. /**
  51882. * Initializes the xr layer for the session
  51883. * @param xrSession xr session
  51884. * @returns a promise that will resolve once the XR Layer has been created
  51885. */
  51886. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  51887. private _addCanvas;
  51888. private _removeCanvas;
  51889. private _setCanvasSize;
  51890. private _setManagedOutputCanvas;
  51891. }
  51892. }
  51893. declare module "babylonjs/XR/webXRSessionManager" {
  51894. import { Observable } from "babylonjs/Misc/observable";
  51895. import { Nullable } from "babylonjs/types";
  51896. import { IDisposable, Scene } from "babylonjs/scene";
  51897. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51898. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51899. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51900. /**
  51901. * Manages an XRSession to work with Babylon's engine
  51902. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  51903. */
  51904. export class WebXRSessionManager implements IDisposable {
  51905. /** The scene which the session should be created for */
  51906. scene: Scene;
  51907. private _referenceSpace;
  51908. private _rttProvider;
  51909. private _sessionEnded;
  51910. private _xrNavigator;
  51911. private baseLayer;
  51912. /**
  51913. * The base reference space from which the session started. good if you want to reset your
  51914. * reference space
  51915. */
  51916. baseReferenceSpace: XRReferenceSpace;
  51917. /**
  51918. * Current XR frame
  51919. */
  51920. currentFrame: Nullable<XRFrame>;
  51921. /** WebXR timestamp updated every frame */
  51922. currentTimestamp: number;
  51923. /**
  51924. * Used just in case of a failure to initialize an immersive session.
  51925. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  51926. */
  51927. defaultHeightCompensation: number;
  51928. /**
  51929. * Fires every time a new xrFrame arrives which can be used to update the camera
  51930. */
  51931. onXRFrameObservable: Observable<XRFrame>;
  51932. /**
  51933. * Fires when the reference space changed
  51934. */
  51935. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  51936. /**
  51937. * Fires when the xr session is ended either by the device or manually done
  51938. */
  51939. onXRSessionEnded: Observable<any>;
  51940. /**
  51941. * Fires when the xr session is ended either by the device or manually done
  51942. */
  51943. onXRSessionInit: Observable<XRSession>;
  51944. /**
  51945. * Underlying xr session
  51946. */
  51947. session: XRSession;
  51948. /**
  51949. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  51950. * or get the offset the player is currently at.
  51951. */
  51952. viewerReferenceSpace: XRReferenceSpace;
  51953. /**
  51954. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  51955. * @param scene The scene which the session should be created for
  51956. */
  51957. constructor(
  51958. /** The scene which the session should be created for */
  51959. scene: Scene);
  51960. /**
  51961. * The current reference space used in this session. This reference space can constantly change!
  51962. * It is mainly used to offset the camera's position.
  51963. */
  51964. get referenceSpace(): XRReferenceSpace;
  51965. /**
  51966. * Set a new reference space and triggers the observable
  51967. */
  51968. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  51969. /**
  51970. * Disposes of the session manager
  51971. */
  51972. dispose(): void;
  51973. /**
  51974. * Stops the xrSession and restores the render loop
  51975. * @returns Promise which resolves after it exits XR
  51976. */
  51977. exitXRAsync(): Promise<void>;
  51978. /**
  51979. * Gets the correct render target texture to be rendered this frame for this eye
  51980. * @param eye the eye for which to get the render target
  51981. * @returns the render target for the specified eye
  51982. */
  51983. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  51984. /**
  51985. * Creates a WebXRRenderTarget object for the XR session
  51986. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  51987. * @param options optional options to provide when creating a new render target
  51988. * @returns a WebXR render target to which the session can render
  51989. */
  51990. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  51991. /**
  51992. * Initializes the manager
  51993. * After initialization enterXR can be called to start an XR session
  51994. * @returns Promise which resolves after it is initialized
  51995. */
  51996. initializeAsync(): Promise<void>;
  51997. /**
  51998. * Initializes an xr session
  51999. * @param xrSessionMode mode to initialize
  52000. * @param xrSessionInit defines optional and required values to pass to the session builder
  52001. * @returns a promise which will resolve once the session has been initialized
  52002. */
  52003. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52004. /**
  52005. * Checks if a session would be supported for the creation options specified
  52006. * @param sessionMode session mode to check if supported eg. immersive-vr
  52007. * @returns A Promise that resolves to true if supported and false if not
  52008. */
  52009. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52010. /**
  52011. * Resets the reference space to the one started the session
  52012. */
  52013. resetReferenceSpace(): void;
  52014. /**
  52015. * Starts rendering to the xr layer
  52016. */
  52017. runXRRenderLoop(): void;
  52018. /**
  52019. * Sets the reference space on the xr session
  52020. * @param referenceSpaceType space to set
  52021. * @returns a promise that will resolve once the reference space has been set
  52022. */
  52023. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52024. /**
  52025. * Updates the render state of the session
  52026. * @param state state to set
  52027. * @returns a promise that resolves once the render state has been updated
  52028. */
  52029. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52030. /**
  52031. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52032. * @param sessionMode defines the session to test
  52033. * @returns a promise with boolean as final value
  52034. */
  52035. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52036. private _createRenderTargetTexture;
  52037. }
  52038. }
  52039. declare module "babylonjs/XR/webXRCamera" {
  52040. import { Vector3 } from "babylonjs/Maths/math.vector";
  52041. import { Scene } from "babylonjs/scene";
  52042. import { Camera } from "babylonjs/Cameras/camera";
  52043. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52044. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52045. import { Observable } from "babylonjs/Misc/observable";
  52046. /**
  52047. * WebXR Camera which holds the views for the xrSession
  52048. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52049. */
  52050. export class WebXRCamera extends FreeCamera {
  52051. private _xrSessionManager;
  52052. private _firstFrame;
  52053. private _referenceQuaternion;
  52054. private _referencedPosition;
  52055. private _xrInvPositionCache;
  52056. private _xrInvQuaternionCache;
  52057. /**
  52058. * Observable raised before camera teleportation
  52059. */
  52060. onBeforeCameraTeleport: Observable<Vector3>;
  52061. /**
  52062. * Observable raised after camera teleportation
  52063. */
  52064. onAfterCameraTeleport: Observable<Vector3>;
  52065. /**
  52066. * Should position compensation execute on first frame.
  52067. * This is used when copying the position from a native (non XR) camera
  52068. */
  52069. compensateOnFirstFrame: boolean;
  52070. /**
  52071. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52072. * @param name the name of the camera
  52073. * @param scene the scene to add the camera to
  52074. * @param _xrSessionManager a constructed xr session manager
  52075. */
  52076. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52077. /**
  52078. * Return the user's height, unrelated to the current ground.
  52079. * This will be the y position of this camera, when ground level is 0.
  52080. */
  52081. get realWorldHeight(): number;
  52082. /** @hidden */
  52083. _updateForDualEyeDebugging(): void;
  52084. /**
  52085. * Sets this camera's transformation based on a non-vr camera
  52086. * @param otherCamera the non-vr camera to copy the transformation from
  52087. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52088. */
  52089. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52090. /**
  52091. * Gets the current instance class name ("WebXRCamera").
  52092. * @returns the class name
  52093. */
  52094. getClassName(): string;
  52095. private _rotate180;
  52096. private _updateFromXRSession;
  52097. private _updateNumberOfRigCameras;
  52098. private _updateReferenceSpace;
  52099. private _updateReferenceSpaceOffset;
  52100. }
  52101. }
  52102. declare module "babylonjs/XR/webXRFeaturesManager" {
  52103. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52104. import { IDisposable } from "babylonjs/scene";
  52105. /**
  52106. * Defining the interface required for a (webxr) feature
  52107. */
  52108. export interface IWebXRFeature extends IDisposable {
  52109. /**
  52110. * Is this feature attached
  52111. */
  52112. attached: boolean;
  52113. /**
  52114. * Should auto-attach be disabled?
  52115. */
  52116. disableAutoAttach: boolean;
  52117. /**
  52118. * Attach the feature to the session
  52119. * Will usually be called by the features manager
  52120. *
  52121. * @param force should attachment be forced (even when already attached)
  52122. * @returns true if successful.
  52123. */
  52124. attach(force?: boolean): boolean;
  52125. /**
  52126. * Detach the feature from the session
  52127. * Will usually be called by the features manager
  52128. *
  52129. * @returns true if successful.
  52130. */
  52131. detach(): boolean;
  52132. /**
  52133. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52134. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52135. *
  52136. * @returns whether or not the feature is compatible in this environment
  52137. */
  52138. isCompatible(): boolean;
  52139. /**
  52140. * Was this feature disposed;
  52141. */
  52142. isDisposed: boolean;
  52143. /**
  52144. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52145. */
  52146. xrNativeFeatureName?: string;
  52147. /**
  52148. * A list of (Babylon WebXR) features this feature depends on
  52149. */
  52150. dependsOn?: string[];
  52151. }
  52152. /**
  52153. * A list of the currently available features without referencing them
  52154. */
  52155. export class WebXRFeatureName {
  52156. /**
  52157. * The name of the anchor system feature
  52158. */
  52159. static readonly ANCHOR_SYSTEM: string;
  52160. /**
  52161. * The name of the background remover feature
  52162. */
  52163. static readonly BACKGROUND_REMOVER: string;
  52164. /**
  52165. * The name of the hit test feature
  52166. */
  52167. static readonly HIT_TEST: string;
  52168. /**
  52169. * physics impostors for xr controllers feature
  52170. */
  52171. static readonly PHYSICS_CONTROLLERS: string;
  52172. /**
  52173. * The name of the plane detection feature
  52174. */
  52175. static readonly PLANE_DETECTION: string;
  52176. /**
  52177. * The name of the pointer selection feature
  52178. */
  52179. static readonly POINTER_SELECTION: string;
  52180. /**
  52181. * The name of the teleportation feature
  52182. */
  52183. static readonly TELEPORTATION: string;
  52184. /**
  52185. * The name of the feature points feature.
  52186. */
  52187. static readonly FEATURE_POINTS: string;
  52188. /**
  52189. * The name of the hand tracking feature.
  52190. */
  52191. static readonly HAND_TRACKING: string;
  52192. }
  52193. /**
  52194. * Defining the constructor of a feature. Used to register the modules.
  52195. */
  52196. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52197. /**
  52198. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52199. * It is mainly used in AR sessions.
  52200. *
  52201. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52202. */
  52203. export class WebXRFeaturesManager implements IDisposable {
  52204. private _xrSessionManager;
  52205. private static readonly _AvailableFeatures;
  52206. private _features;
  52207. /**
  52208. * constructs a new features manages.
  52209. *
  52210. * @param _xrSessionManager an instance of WebXRSessionManager
  52211. */
  52212. constructor(_xrSessionManager: WebXRSessionManager);
  52213. /**
  52214. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52215. * Mainly used internally.
  52216. *
  52217. * @param featureName the name of the feature to register
  52218. * @param constructorFunction the function used to construct the module
  52219. * @param version the (babylon) version of the module
  52220. * @param stable is that a stable version of this module
  52221. */
  52222. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52223. /**
  52224. * Returns a constructor of a specific feature.
  52225. *
  52226. * @param featureName the name of the feature to construct
  52227. * @param version the version of the feature to load
  52228. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52229. * @param options optional options provided to the module.
  52230. * @returns a function that, when called, will return a new instance of this feature
  52231. */
  52232. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52233. /**
  52234. * Can be used to return the list of features currently registered
  52235. *
  52236. * @returns an Array of available features
  52237. */
  52238. static GetAvailableFeatures(): string[];
  52239. /**
  52240. * Gets the versions available for a specific feature
  52241. * @param featureName the name of the feature
  52242. * @returns an array with the available versions
  52243. */
  52244. static GetAvailableVersions(featureName: string): string[];
  52245. /**
  52246. * Return the latest unstable version of this feature
  52247. * @param featureName the name of the feature to search
  52248. * @returns the version number. if not found will return -1
  52249. */
  52250. static GetLatestVersionOfFeature(featureName: string): number;
  52251. /**
  52252. * Return the latest stable version of this feature
  52253. * @param featureName the name of the feature to search
  52254. * @returns the version number. if not found will return -1
  52255. */
  52256. static GetStableVersionOfFeature(featureName: string): number;
  52257. /**
  52258. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52259. * Can be used during a session to start a feature
  52260. * @param featureName the name of feature to attach
  52261. */
  52262. attachFeature(featureName: string): void;
  52263. /**
  52264. * Can be used inside a session or when the session ends to detach a specific feature
  52265. * @param featureName the name of the feature to detach
  52266. */
  52267. detachFeature(featureName: string): void;
  52268. /**
  52269. * Used to disable an already-enabled feature
  52270. * The feature will be disposed and will be recreated once enabled.
  52271. * @param featureName the feature to disable
  52272. * @returns true if disable was successful
  52273. */
  52274. disableFeature(featureName: string | {
  52275. Name: string;
  52276. }): boolean;
  52277. /**
  52278. * dispose this features manager
  52279. */
  52280. dispose(): void;
  52281. /**
  52282. * 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.
  52283. * 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.
  52284. *
  52285. * @param featureName the name of the feature to load or the class of the feature
  52286. * @param version optional version to load. if not provided the latest version will be enabled
  52287. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52288. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52289. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52290. * @returns a new constructed feature or throws an error if feature not found.
  52291. */
  52292. enableFeature(featureName: string | {
  52293. Name: string;
  52294. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52295. /**
  52296. * get the implementation of an enabled feature.
  52297. * @param featureName the name of the feature to load
  52298. * @returns the feature class, if found
  52299. */
  52300. getEnabledFeature(featureName: string): IWebXRFeature;
  52301. /**
  52302. * Get the list of enabled features
  52303. * @returns an array of enabled features
  52304. */
  52305. getEnabledFeatures(): string[];
  52306. /**
  52307. * This function will exten the session creation configuration object with enabled features.
  52308. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52309. * according to the defined "required" variable, provided during enableFeature call
  52310. * @param xrSessionInit the xr Session init object to extend
  52311. *
  52312. * @returns an extended XRSessionInit object
  52313. */
  52314. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52315. }
  52316. }
  52317. declare module "babylonjs/XR/webXRExperienceHelper" {
  52318. import { Observable } from "babylonjs/Misc/observable";
  52319. import { IDisposable, Scene } from "babylonjs/scene";
  52320. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52321. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52322. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52323. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52324. /**
  52325. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52326. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52327. */
  52328. export class WebXRExperienceHelper implements IDisposable {
  52329. private scene;
  52330. private _nonVRCamera;
  52331. private _originalSceneAutoClear;
  52332. private _supported;
  52333. /**
  52334. * Camera used to render xr content
  52335. */
  52336. camera: WebXRCamera;
  52337. /** A features manager for this xr session */
  52338. featuresManager: WebXRFeaturesManager;
  52339. /**
  52340. * Observers registered here will be triggered after the camera's initial transformation is set
  52341. * This can be used to set a different ground level or an extra rotation.
  52342. *
  52343. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52344. * to the position set after this observable is done executing.
  52345. */
  52346. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52347. /**
  52348. * Fires when the state of the experience helper has changed
  52349. */
  52350. onStateChangedObservable: Observable<WebXRState>;
  52351. /** Session manager used to keep track of xr session */
  52352. sessionManager: WebXRSessionManager;
  52353. /**
  52354. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52355. */
  52356. state: WebXRState;
  52357. /**
  52358. * Creates a WebXRExperienceHelper
  52359. * @param scene The scene the helper should be created in
  52360. */
  52361. private constructor();
  52362. /**
  52363. * Creates the experience helper
  52364. * @param scene the scene to attach the experience helper to
  52365. * @returns a promise for the experience helper
  52366. */
  52367. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52368. /**
  52369. * Disposes of the experience helper
  52370. */
  52371. dispose(): void;
  52372. /**
  52373. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52374. * @param sessionMode options for the XR session
  52375. * @param referenceSpaceType frame of reference of the XR session
  52376. * @param renderTarget the output canvas that will be used to enter XR mode
  52377. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52378. * @returns promise that resolves after xr mode has entered
  52379. */
  52380. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52381. /**
  52382. * Exits XR mode and returns the scene to its original state
  52383. * @returns promise that resolves after xr mode has exited
  52384. */
  52385. exitXRAsync(): Promise<void>;
  52386. private _nonXRToXRCamera;
  52387. private _setState;
  52388. }
  52389. }
  52390. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52391. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52392. import { Observable } from "babylonjs/Misc/observable";
  52393. import { IDisposable } from "babylonjs/scene";
  52394. /**
  52395. * X-Y values for axes in WebXR
  52396. */
  52397. export interface IWebXRMotionControllerAxesValue {
  52398. /**
  52399. * The value of the x axis
  52400. */
  52401. x: number;
  52402. /**
  52403. * The value of the y-axis
  52404. */
  52405. y: number;
  52406. }
  52407. /**
  52408. * changed / previous values for the values of this component
  52409. */
  52410. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52411. /**
  52412. * current (this frame) value
  52413. */
  52414. current: T;
  52415. /**
  52416. * previous (last change) value
  52417. */
  52418. previous: T;
  52419. }
  52420. /**
  52421. * Represents changes in the component between current frame and last values recorded
  52422. */
  52423. export interface IWebXRMotionControllerComponentChanges {
  52424. /**
  52425. * will be populated with previous and current values if axes changed
  52426. */
  52427. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52428. /**
  52429. * will be populated with previous and current values if pressed changed
  52430. */
  52431. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52432. /**
  52433. * will be populated with previous and current values if touched changed
  52434. */
  52435. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52436. /**
  52437. * will be populated with previous and current values if value changed
  52438. */
  52439. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52440. }
  52441. /**
  52442. * This class represents a single component (for example button or thumbstick) of a motion controller
  52443. */
  52444. export class WebXRControllerComponent implements IDisposable {
  52445. /**
  52446. * the id of this component
  52447. */
  52448. id: string;
  52449. /**
  52450. * the type of the component
  52451. */
  52452. type: MotionControllerComponentType;
  52453. private _buttonIndex;
  52454. private _axesIndices;
  52455. private _axes;
  52456. private _changes;
  52457. private _currentValue;
  52458. private _hasChanges;
  52459. private _pressed;
  52460. private _touched;
  52461. /**
  52462. * button component type
  52463. */
  52464. static BUTTON_TYPE: MotionControllerComponentType;
  52465. /**
  52466. * squeeze component type
  52467. */
  52468. static SQUEEZE_TYPE: MotionControllerComponentType;
  52469. /**
  52470. * Thumbstick component type
  52471. */
  52472. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52473. /**
  52474. * Touchpad component type
  52475. */
  52476. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52477. /**
  52478. * trigger component type
  52479. */
  52480. static TRIGGER_TYPE: MotionControllerComponentType;
  52481. /**
  52482. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52483. * the axes data changes
  52484. */
  52485. onAxisValueChangedObservable: Observable<{
  52486. x: number;
  52487. y: number;
  52488. }>;
  52489. /**
  52490. * Observers registered here will be triggered when the state of a button changes
  52491. * State change is either pressed / touched / value
  52492. */
  52493. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52494. /**
  52495. * Creates a new component for a motion controller.
  52496. * It is created by the motion controller itself
  52497. *
  52498. * @param id the id of this component
  52499. * @param type the type of the component
  52500. * @param _buttonIndex index in the buttons array of the gamepad
  52501. * @param _axesIndices indices of the values in the axes array of the gamepad
  52502. */
  52503. constructor(
  52504. /**
  52505. * the id of this component
  52506. */
  52507. id: string,
  52508. /**
  52509. * the type of the component
  52510. */
  52511. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52512. /**
  52513. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52514. */
  52515. get axes(): IWebXRMotionControllerAxesValue;
  52516. /**
  52517. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52518. */
  52519. get changes(): IWebXRMotionControllerComponentChanges;
  52520. /**
  52521. * Return whether or not the component changed the last frame
  52522. */
  52523. get hasChanges(): boolean;
  52524. /**
  52525. * is the button currently pressed
  52526. */
  52527. get pressed(): boolean;
  52528. /**
  52529. * is the button currently touched
  52530. */
  52531. get touched(): boolean;
  52532. /**
  52533. * Get the current value of this component
  52534. */
  52535. get value(): number;
  52536. /**
  52537. * Dispose this component
  52538. */
  52539. dispose(): void;
  52540. /**
  52541. * Are there axes correlating to this component
  52542. * @return true is axes data is available
  52543. */
  52544. isAxes(): boolean;
  52545. /**
  52546. * Is this component a button (hence - pressable)
  52547. * @returns true if can be pressed
  52548. */
  52549. isButton(): boolean;
  52550. /**
  52551. * update this component using the gamepad object it is in. Called on every frame
  52552. * @param nativeController the native gamepad controller object
  52553. */
  52554. update(nativeController: IMinimalMotionControllerObject): void;
  52555. }
  52556. }
  52557. declare module "babylonjs/Loading/sceneLoader" {
  52558. import { Observable } from "babylonjs/Misc/observable";
  52559. import { Nullable } from "babylonjs/types";
  52560. import { Scene } from "babylonjs/scene";
  52561. import { Engine } from "babylonjs/Engines/engine";
  52562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52563. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52564. import { AssetContainer } from "babylonjs/assetContainer";
  52565. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52566. import { Skeleton } from "babylonjs/Bones/skeleton";
  52567. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52568. import { WebRequest } from "babylonjs/Misc/webRequest";
  52569. /**
  52570. * Interface used to represent data loading progression
  52571. */
  52572. export interface ISceneLoaderProgressEvent {
  52573. /**
  52574. * Defines if data length to load can be evaluated
  52575. */
  52576. readonly lengthComputable: boolean;
  52577. /**
  52578. * Defines the loaded data length
  52579. */
  52580. readonly loaded: number;
  52581. /**
  52582. * Defines the data length to load
  52583. */
  52584. readonly total: number;
  52585. }
  52586. /**
  52587. * Interface used by SceneLoader plugins to define supported file extensions
  52588. */
  52589. export interface ISceneLoaderPluginExtensions {
  52590. /**
  52591. * Defines the list of supported extensions
  52592. */
  52593. [extension: string]: {
  52594. isBinary: boolean;
  52595. };
  52596. }
  52597. /**
  52598. * Interface used by SceneLoader plugin factory
  52599. */
  52600. export interface ISceneLoaderPluginFactory {
  52601. /**
  52602. * Defines the name of the factory
  52603. */
  52604. name: string;
  52605. /**
  52606. * Function called to create a new plugin
  52607. * @return the new plugin
  52608. */
  52609. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52610. /**
  52611. * The callback that returns true if the data can be directly loaded.
  52612. * @param data string containing the file data
  52613. * @returns if the data can be loaded directly
  52614. */
  52615. canDirectLoad?(data: string): boolean;
  52616. }
  52617. /**
  52618. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  52619. */
  52620. export interface ISceneLoaderPluginBase {
  52621. /**
  52622. * The friendly name of this plugin.
  52623. */
  52624. name: string;
  52625. /**
  52626. * The file extensions supported by this plugin.
  52627. */
  52628. extensions: string | ISceneLoaderPluginExtensions;
  52629. /**
  52630. * The callback called when loading from a url.
  52631. * @param scene scene loading this url
  52632. * @param url url to load
  52633. * @param onSuccess callback called when the file successfully loads
  52634. * @param onProgress callback called while file is loading (if the server supports this mode)
  52635. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  52636. * @param onError callback called when the file fails to load
  52637. * @returns a file request object
  52638. */
  52639. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52640. /**
  52641. * The callback called when loading from a file object.
  52642. * @param scene scene loading this file
  52643. * @param file defines the file to load
  52644. * @param onSuccess defines the callback to call when data is loaded
  52645. * @param onProgress defines the callback to call during loading process
  52646. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  52647. * @param onError defines the callback to call when an error occurs
  52648. * @returns a file request object
  52649. */
  52650. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  52651. /**
  52652. * The callback that returns true if the data can be directly loaded.
  52653. * @param data string containing the file data
  52654. * @returns if the data can be loaded directly
  52655. */
  52656. canDirectLoad?(data: string): boolean;
  52657. /**
  52658. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  52659. * @param scene scene loading this data
  52660. * @param data string containing the data
  52661. * @returns data to pass to the plugin
  52662. */
  52663. directLoad?(scene: Scene, data: string): any;
  52664. /**
  52665. * The callback that allows custom handling of the root url based on the response url.
  52666. * @param rootUrl the original root url
  52667. * @param responseURL the response url if available
  52668. * @returns the new root url
  52669. */
  52670. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  52671. }
  52672. /**
  52673. * Interface used to define a SceneLoader plugin
  52674. */
  52675. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  52676. /**
  52677. * Import meshes into a scene.
  52678. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52679. * @param scene The scene to import into
  52680. * @param data The data to import
  52681. * @param rootUrl The root url for scene and resources
  52682. * @param meshes The meshes array to import into
  52683. * @param particleSystems The particle systems array to import into
  52684. * @param skeletons The skeletons array to import into
  52685. * @param onError The callback when import fails
  52686. * @returns True if successful or false otherwise
  52687. */
  52688. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  52689. /**
  52690. * Load into a scene.
  52691. * @param scene The scene to load into
  52692. * @param data The data to import
  52693. * @param rootUrl The root url for scene and resources
  52694. * @param onError The callback when import fails
  52695. * @returns True if successful or false otherwise
  52696. */
  52697. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  52698. /**
  52699. * Load into an asset container.
  52700. * @param scene The scene to load into
  52701. * @param data The data to import
  52702. * @param rootUrl The root url for scene and resources
  52703. * @param onError The callback when import fails
  52704. * @returns The loaded asset container
  52705. */
  52706. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  52707. }
  52708. /**
  52709. * Interface used to define an async SceneLoader plugin
  52710. */
  52711. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  52712. /**
  52713. * Import meshes into a scene.
  52714. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52715. * @param scene The scene to import into
  52716. * @param data The data to import
  52717. * @param rootUrl The root url for scene and resources
  52718. * @param onProgress The callback when the load progresses
  52719. * @param fileName Defines the name of the file to load
  52720. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  52721. */
  52722. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  52723. meshes: AbstractMesh[];
  52724. particleSystems: IParticleSystem[];
  52725. skeletons: Skeleton[];
  52726. animationGroups: AnimationGroup[];
  52727. }>;
  52728. /**
  52729. * Load into a scene.
  52730. * @param scene The scene to load into
  52731. * @param data The data to import
  52732. * @param rootUrl The root url for scene and resources
  52733. * @param onProgress The callback when the load progresses
  52734. * @param fileName Defines the name of the file to load
  52735. * @returns Nothing
  52736. */
  52737. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  52738. /**
  52739. * Load into an asset container.
  52740. * @param scene The scene to load into
  52741. * @param data The data to import
  52742. * @param rootUrl The root url for scene and resources
  52743. * @param onProgress The callback when the load progresses
  52744. * @param fileName Defines the name of the file to load
  52745. * @returns The loaded asset container
  52746. */
  52747. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  52748. }
  52749. /**
  52750. * Mode that determines how to handle old animation groups before loading new ones.
  52751. */
  52752. export enum SceneLoaderAnimationGroupLoadingMode {
  52753. /**
  52754. * Reset all old animations to initial state then dispose them.
  52755. */
  52756. Clean = 0,
  52757. /**
  52758. * Stop all old animations.
  52759. */
  52760. Stop = 1,
  52761. /**
  52762. * Restart old animations from first frame.
  52763. */
  52764. Sync = 2,
  52765. /**
  52766. * Old animations remains untouched.
  52767. */
  52768. NoSync = 3
  52769. }
  52770. /**
  52771. * Defines a plugin registered by the SceneLoader
  52772. */
  52773. interface IRegisteredPlugin {
  52774. /**
  52775. * Defines the plugin to use
  52776. */
  52777. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52778. /**
  52779. * Defines if the plugin supports binary data
  52780. */
  52781. isBinary: boolean;
  52782. }
  52783. /**
  52784. * Class used to load scene from various file formats using registered plugins
  52785. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  52786. */
  52787. export class SceneLoader {
  52788. /**
  52789. * No logging while loading
  52790. */
  52791. static readonly NO_LOGGING: number;
  52792. /**
  52793. * Minimal logging while loading
  52794. */
  52795. static readonly MINIMAL_LOGGING: number;
  52796. /**
  52797. * Summary logging while loading
  52798. */
  52799. static readonly SUMMARY_LOGGING: number;
  52800. /**
  52801. * Detailled logging while loading
  52802. */
  52803. static readonly DETAILED_LOGGING: number;
  52804. /**
  52805. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  52806. */
  52807. static get ForceFullSceneLoadingForIncremental(): boolean;
  52808. static set ForceFullSceneLoadingForIncremental(value: boolean);
  52809. /**
  52810. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  52811. */
  52812. static get ShowLoadingScreen(): boolean;
  52813. static set ShowLoadingScreen(value: boolean);
  52814. /**
  52815. * Defines the current logging level (while loading the scene)
  52816. * @ignorenaming
  52817. */
  52818. static get loggingLevel(): number;
  52819. static set loggingLevel(value: number);
  52820. /**
  52821. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  52822. */
  52823. static get CleanBoneMatrixWeights(): boolean;
  52824. static set CleanBoneMatrixWeights(value: boolean);
  52825. /**
  52826. * Event raised when a plugin is used to load a scene
  52827. */
  52828. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  52829. private static _registeredPlugins;
  52830. private static _showingLoadingScreen;
  52831. /**
  52832. * Gets the default plugin (used to load Babylon files)
  52833. * @returns the .babylon plugin
  52834. */
  52835. static GetDefaultPlugin(): IRegisteredPlugin;
  52836. private static _GetPluginForExtension;
  52837. private static _GetPluginForDirectLoad;
  52838. private static _GetPluginForFilename;
  52839. private static _GetDirectLoad;
  52840. private static _LoadData;
  52841. private static _GetFileInfo;
  52842. /**
  52843. * Gets a plugin that can load the given extension
  52844. * @param extension defines the extension to load
  52845. * @returns a plugin or null if none works
  52846. */
  52847. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  52848. /**
  52849. * Gets a boolean indicating that the given extension can be loaded
  52850. * @param extension defines the extension to load
  52851. * @returns true if the extension is supported
  52852. */
  52853. static IsPluginForExtensionAvailable(extension: string): boolean;
  52854. /**
  52855. * Adds a new plugin to the list of registered plugins
  52856. * @param plugin defines the plugin to add
  52857. */
  52858. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  52859. /**
  52860. * Import meshes into a scene
  52861. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52862. * @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)
  52863. * @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)
  52864. * @param scene the instance of BABYLON.Scene to append to
  52865. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  52866. * @param onProgress a callback with a progress event for each file being loaded
  52867. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52868. * @param pluginExtension the extension used to determine the plugin
  52869. * @returns The loaded plugin
  52870. */
  52871. 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>;
  52872. /**
  52873. * Import meshes into a scene
  52874. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  52875. * @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)
  52876. * @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)
  52877. * @param scene the instance of BABYLON.Scene to append to
  52878. * @param onProgress a callback with a progress event for each file being loaded
  52879. * @param pluginExtension the extension used to determine the plugin
  52880. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  52881. */
  52882. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  52883. meshes: AbstractMesh[];
  52884. particleSystems: IParticleSystem[];
  52885. skeletons: Skeleton[];
  52886. animationGroups: AnimationGroup[];
  52887. }>;
  52888. /**
  52889. * Load a scene
  52890. * @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)
  52891. * @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)
  52892. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52893. * @param onSuccess a callback with the scene when import succeeds
  52894. * @param onProgress a callback with a progress event for each file being loaded
  52895. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52896. * @param pluginExtension the extension used to determine the plugin
  52897. * @returns The loaded plugin
  52898. */
  52899. 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>;
  52900. /**
  52901. * Load a scene
  52902. * @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)
  52903. * @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)
  52904. * @param engine is the instance of BABYLON.Engine to use to create the scene
  52905. * @param onProgress a callback with a progress event for each file being loaded
  52906. * @param pluginExtension the extension used to determine the plugin
  52907. * @returns The loaded scene
  52908. */
  52909. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52910. /**
  52911. * Append a scene
  52912. * @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)
  52913. * @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)
  52914. * @param scene is the instance of BABYLON.Scene to append to
  52915. * @param onSuccess a callback with the scene when import succeeds
  52916. * @param onProgress a callback with a progress event for each file being loaded
  52917. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52918. * @param pluginExtension the extension used to determine the plugin
  52919. * @returns The loaded plugin
  52920. */
  52921. 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>;
  52922. /**
  52923. * Append a scene
  52924. * @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)
  52925. * @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)
  52926. * @param scene is the instance of BABYLON.Scene to append to
  52927. * @param onProgress a callback with a progress event for each file being loaded
  52928. * @param pluginExtension the extension used to determine the plugin
  52929. * @returns The given scene
  52930. */
  52931. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  52932. /**
  52933. * Load a scene into an asset container
  52934. * @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)
  52935. * @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)
  52936. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52937. * @param onSuccess a callback with the scene when import succeeds
  52938. * @param onProgress a callback with a progress event for each file being loaded
  52939. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52940. * @param pluginExtension the extension used to determine the plugin
  52941. * @returns The loaded plugin
  52942. */
  52943. 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>;
  52944. /**
  52945. * Load a scene into an asset container
  52946. * @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)
  52947. * @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)
  52948. * @param scene is the instance of Scene to append to
  52949. * @param onProgress a callback with a progress event for each file being loaded
  52950. * @param pluginExtension the extension used to determine the plugin
  52951. * @returns The loaded asset container
  52952. */
  52953. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  52954. /**
  52955. * Import animations from a file into a scene
  52956. * @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)
  52957. * @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)
  52958. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52959. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  52960. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  52961. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  52962. * @param onSuccess a callback with the scene when import succeeds
  52963. * @param onProgress a callback with a progress event for each file being loaded
  52964. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52965. * @param pluginExtension the extension used to determine the plugin
  52966. */
  52967. 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;
  52968. /**
  52969. * Import animations from a file into a scene
  52970. * @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)
  52971. * @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)
  52972. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  52973. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  52974. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  52975. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  52976. * @param onSuccess a callback with the scene when import succeeds
  52977. * @param onProgress a callback with a progress event for each file being loaded
  52978. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  52979. * @param pluginExtension the extension used to determine the plugin
  52980. * @returns the updated scene with imported animations
  52981. */
  52982. 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>;
  52983. }
  52984. }
  52985. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  52986. import { IDisposable, Scene } from "babylonjs/scene";
  52987. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  52988. import { Observable } from "babylonjs/Misc/observable";
  52989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52990. import { Nullable } from "babylonjs/types";
  52991. /**
  52992. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  52993. */
  52994. export type MotionControllerHandedness = "none" | "left" | "right";
  52995. /**
  52996. * The type of components available in motion controllers.
  52997. * This is not the name of the component.
  52998. */
  52999. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53000. /**
  53001. * The state of a controller component
  53002. */
  53003. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53004. /**
  53005. * The schema of motion controller layout.
  53006. * No object will be initialized using this interface
  53007. * This is used just to define the profile.
  53008. */
  53009. export interface IMotionControllerLayout {
  53010. /**
  53011. * Path to load the assets. Usually relative to the base path
  53012. */
  53013. assetPath: string;
  53014. /**
  53015. * Available components (unsorted)
  53016. */
  53017. components: {
  53018. /**
  53019. * A map of component Ids
  53020. */
  53021. [componentId: string]: {
  53022. /**
  53023. * The type of input the component outputs
  53024. */
  53025. type: MotionControllerComponentType;
  53026. /**
  53027. * The indices of this component in the gamepad object
  53028. */
  53029. gamepadIndices: {
  53030. /**
  53031. * Index of button
  53032. */
  53033. button?: number;
  53034. /**
  53035. * If available, index of x-axis
  53036. */
  53037. xAxis?: number;
  53038. /**
  53039. * If available, index of y-axis
  53040. */
  53041. yAxis?: number;
  53042. };
  53043. /**
  53044. * The mesh's root node name
  53045. */
  53046. rootNodeName: string;
  53047. /**
  53048. * Animation definitions for this model
  53049. */
  53050. visualResponses: {
  53051. [stateKey: string]: {
  53052. /**
  53053. * What property will be animated
  53054. */
  53055. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53056. /**
  53057. * What states influence this visual response
  53058. */
  53059. states: MotionControllerComponentStateType[];
  53060. /**
  53061. * Type of animation - movement or visibility
  53062. */
  53063. valueNodeProperty: "transform" | "visibility";
  53064. /**
  53065. * Base node name to move. Its position will be calculated according to the min and max nodes
  53066. */
  53067. valueNodeName?: string;
  53068. /**
  53069. * Minimum movement node
  53070. */
  53071. minNodeName?: string;
  53072. /**
  53073. * Max movement node
  53074. */
  53075. maxNodeName?: string;
  53076. };
  53077. };
  53078. /**
  53079. * If touch enabled, what is the name of node to display user feedback
  53080. */
  53081. touchPointNodeName?: string;
  53082. };
  53083. };
  53084. /**
  53085. * Is it xr standard mapping or not
  53086. */
  53087. gamepadMapping: "" | "xr-standard";
  53088. /**
  53089. * Base root node of this entire model
  53090. */
  53091. rootNodeName: string;
  53092. /**
  53093. * Defines the main button component id
  53094. */
  53095. selectComponentId: string;
  53096. }
  53097. /**
  53098. * A definition for the layout map in the input profile
  53099. */
  53100. export interface IMotionControllerLayoutMap {
  53101. /**
  53102. * Layouts with handedness type as a key
  53103. */
  53104. [handedness: string]: IMotionControllerLayout;
  53105. }
  53106. /**
  53107. * The XR Input profile schema
  53108. * Profiles can be found here:
  53109. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53110. */
  53111. export interface IMotionControllerProfile {
  53112. /**
  53113. * fallback profiles for this profileId
  53114. */
  53115. fallbackProfileIds: string[];
  53116. /**
  53117. * The layout map, with handedness as key
  53118. */
  53119. layouts: IMotionControllerLayoutMap;
  53120. /**
  53121. * The id of this profile
  53122. * correlates to the profile(s) in the xrInput.profiles array
  53123. */
  53124. profileId: string;
  53125. }
  53126. /**
  53127. * A helper-interface for the 3 meshes needed for controller button animation
  53128. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53129. */
  53130. export interface IMotionControllerButtonMeshMap {
  53131. /**
  53132. * the mesh that defines the pressed value mesh position.
  53133. * This is used to find the max-position of this button
  53134. */
  53135. pressedMesh: AbstractMesh;
  53136. /**
  53137. * the mesh that defines the unpressed value mesh position.
  53138. * This is used to find the min (or initial) position of this button
  53139. */
  53140. unpressedMesh: AbstractMesh;
  53141. /**
  53142. * The mesh that will be changed when value changes
  53143. */
  53144. valueMesh: AbstractMesh;
  53145. }
  53146. /**
  53147. * A helper-interface for the 3 meshes needed for controller axis animation.
  53148. * This will be expanded when touchpad animations are fully supported
  53149. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53150. */
  53151. export interface IMotionControllerMeshMap {
  53152. /**
  53153. * the mesh that defines the maximum value mesh position.
  53154. */
  53155. maxMesh?: AbstractMesh;
  53156. /**
  53157. * the mesh that defines the minimum value mesh position.
  53158. */
  53159. minMesh?: AbstractMesh;
  53160. /**
  53161. * The mesh that will be changed when axis value changes
  53162. */
  53163. valueMesh?: AbstractMesh;
  53164. }
  53165. /**
  53166. * The elements needed for change-detection of the gamepad objects in motion controllers
  53167. */
  53168. export interface IMinimalMotionControllerObject {
  53169. /**
  53170. * Available axes of this controller
  53171. */
  53172. axes: number[];
  53173. /**
  53174. * An array of available buttons
  53175. */
  53176. buttons: Array<{
  53177. /**
  53178. * Value of the button/trigger
  53179. */
  53180. value: number;
  53181. /**
  53182. * If the button/trigger is currently touched
  53183. */
  53184. touched: boolean;
  53185. /**
  53186. * If the button/trigger is currently pressed
  53187. */
  53188. pressed: boolean;
  53189. }>;
  53190. /**
  53191. * EXPERIMENTAL haptic support.
  53192. */
  53193. hapticActuators?: Array<{
  53194. pulse: (value: number, duration: number) => Promise<boolean>;
  53195. }>;
  53196. }
  53197. /**
  53198. * An Abstract Motion controller
  53199. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53200. * Each component has an observable to check for changes in value and state
  53201. */
  53202. export abstract class WebXRAbstractMotionController implements IDisposable {
  53203. protected scene: Scene;
  53204. protected layout: IMotionControllerLayout;
  53205. /**
  53206. * The gamepad object correlating to this controller
  53207. */
  53208. gamepadObject: IMinimalMotionControllerObject;
  53209. /**
  53210. * handedness (left/right/none) of this controller
  53211. */
  53212. handedness: MotionControllerHandedness;
  53213. private _initComponent;
  53214. private _modelReady;
  53215. /**
  53216. * A map of components (WebXRControllerComponent) in this motion controller
  53217. * Components have a ComponentType and can also have both button and axis definitions
  53218. */
  53219. readonly components: {
  53220. [id: string]: WebXRControllerComponent;
  53221. };
  53222. /**
  53223. * Disable the model's animation. Can be set at any time.
  53224. */
  53225. disableAnimation: boolean;
  53226. /**
  53227. * Observers registered here will be triggered when the model of this controller is done loading
  53228. */
  53229. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53230. /**
  53231. * The profile id of this motion controller
  53232. */
  53233. abstract profileId: string;
  53234. /**
  53235. * The root mesh of the model. It is null if the model was not yet initialized
  53236. */
  53237. rootMesh: Nullable<AbstractMesh>;
  53238. /**
  53239. * constructs a new abstract motion controller
  53240. * @param scene the scene to which the model of the controller will be added
  53241. * @param layout The profile layout to load
  53242. * @param gamepadObject The gamepad object correlating to this controller
  53243. * @param handedness handedness (left/right/none) of this controller
  53244. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53245. */
  53246. constructor(scene: Scene, layout: IMotionControllerLayout,
  53247. /**
  53248. * The gamepad object correlating to this controller
  53249. */
  53250. gamepadObject: IMinimalMotionControllerObject,
  53251. /**
  53252. * handedness (left/right/none) of this controller
  53253. */
  53254. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53255. /**
  53256. * Dispose this controller, the model mesh and all its components
  53257. */
  53258. dispose(): void;
  53259. /**
  53260. * Returns all components of specific type
  53261. * @param type the type to search for
  53262. * @return an array of components with this type
  53263. */
  53264. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53265. /**
  53266. * get a component based an its component id as defined in layout.components
  53267. * @param id the id of the component
  53268. * @returns the component correlates to the id or undefined if not found
  53269. */
  53270. getComponent(id: string): WebXRControllerComponent;
  53271. /**
  53272. * Get the list of components available in this motion controller
  53273. * @returns an array of strings correlating to available components
  53274. */
  53275. getComponentIds(): string[];
  53276. /**
  53277. * Get the first component of specific type
  53278. * @param type type of component to find
  53279. * @return a controller component or null if not found
  53280. */
  53281. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53282. /**
  53283. * Get the main (Select) component of this controller as defined in the layout
  53284. * @returns the main component of this controller
  53285. */
  53286. getMainComponent(): WebXRControllerComponent;
  53287. /**
  53288. * Loads the model correlating to this controller
  53289. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53290. * @returns A promise fulfilled with the result of the model loading
  53291. */
  53292. loadModel(): Promise<boolean>;
  53293. /**
  53294. * Update this model using the current XRFrame
  53295. * @param xrFrame the current xr frame to use and update the model
  53296. */
  53297. updateFromXRFrame(xrFrame: XRFrame): void;
  53298. /**
  53299. * Backwards compatibility due to a deeply-integrated typo
  53300. */
  53301. get handness(): XREye;
  53302. /**
  53303. * Pulse (vibrate) this controller
  53304. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53305. * Consecutive calls to this function will cancel the last pulse call
  53306. *
  53307. * @param value the strength of the pulse in 0.0...1.0 range
  53308. * @param duration Duration of the pulse in milliseconds
  53309. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53310. * @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
  53311. */
  53312. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53313. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53314. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53315. /**
  53316. * Moves the axis on the controller mesh based on its current state
  53317. * @param axis the index of the axis
  53318. * @param axisValue the value of the axis which determines the meshes new position
  53319. * @hidden
  53320. */
  53321. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53322. /**
  53323. * Update the model itself with the current frame data
  53324. * @param xrFrame the frame to use for updating the model mesh
  53325. */
  53326. protected updateModel(xrFrame: XRFrame): void;
  53327. /**
  53328. * Get the filename and path for this controller's model
  53329. * @returns a map of filename and path
  53330. */
  53331. protected abstract _getFilenameAndPath(): {
  53332. filename: string;
  53333. path: string;
  53334. };
  53335. /**
  53336. * This function is called before the mesh is loaded. It checks for loading constraints.
  53337. * For example, this function can check if the GLB loader is available
  53338. * If this function returns false, the generic controller will be loaded instead
  53339. * @returns Is the client ready to load the mesh
  53340. */
  53341. protected abstract _getModelLoadingConstraints(): boolean;
  53342. /**
  53343. * This function will be called after the model was successfully loaded and can be used
  53344. * for mesh transformations before it is available for the user
  53345. * @param meshes the loaded meshes
  53346. */
  53347. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53348. /**
  53349. * Set the root mesh for this controller. Important for the WebXR controller class
  53350. * @param meshes the loaded meshes
  53351. */
  53352. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53353. /**
  53354. * A function executed each frame that updates the mesh (if needed)
  53355. * @param xrFrame the current xrFrame
  53356. */
  53357. protected abstract _updateModel(xrFrame: XRFrame): void;
  53358. private _getGenericFilenameAndPath;
  53359. private _getGenericParentMesh;
  53360. }
  53361. }
  53362. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53363. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53365. import { Scene } from "babylonjs/scene";
  53366. /**
  53367. * A generic trigger-only motion controller for WebXR
  53368. */
  53369. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53370. /**
  53371. * Static version of the profile id of this controller
  53372. */
  53373. static ProfileId: string;
  53374. profileId: string;
  53375. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53376. protected _getFilenameAndPath(): {
  53377. filename: string;
  53378. path: string;
  53379. };
  53380. protected _getModelLoadingConstraints(): boolean;
  53381. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53382. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53383. protected _updateModel(): void;
  53384. }
  53385. }
  53386. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53387. import { Vector4 } from "babylonjs/Maths/math.vector";
  53388. import { Mesh } from "babylonjs/Meshes/mesh";
  53389. import { Scene } from "babylonjs/scene";
  53390. import { Nullable } from "babylonjs/types";
  53391. /**
  53392. * Class containing static functions to help procedurally build meshes
  53393. */
  53394. export class SphereBuilder {
  53395. /**
  53396. * Creates a sphere mesh
  53397. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53398. * * 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`)
  53399. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53400. * * 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
  53401. * * 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)
  53402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53405. * @param name defines the name of the mesh
  53406. * @param options defines the options used to create the mesh
  53407. * @param scene defines the hosting scene
  53408. * @returns the sphere mesh
  53409. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53410. */
  53411. static CreateSphere(name: string, options: {
  53412. segments?: number;
  53413. diameter?: number;
  53414. diameterX?: number;
  53415. diameterY?: number;
  53416. diameterZ?: number;
  53417. arc?: number;
  53418. slice?: number;
  53419. sideOrientation?: number;
  53420. frontUVs?: Vector4;
  53421. backUVs?: Vector4;
  53422. updatable?: boolean;
  53423. }, scene?: Nullable<Scene>): Mesh;
  53424. }
  53425. }
  53426. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53428. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53429. import { Scene } from "babylonjs/scene";
  53430. /**
  53431. * A profiled motion controller has its profile loaded from an online repository.
  53432. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53433. */
  53434. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53435. private _repositoryUrl;
  53436. private _buttonMeshMapping;
  53437. private _touchDots;
  53438. /**
  53439. * The profile ID of this controller. Will be populated when the controller initializes.
  53440. */
  53441. profileId: string;
  53442. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53443. dispose(): void;
  53444. protected _getFilenameAndPath(): {
  53445. filename: string;
  53446. path: string;
  53447. };
  53448. protected _getModelLoadingConstraints(): boolean;
  53449. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53450. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53451. protected _updateModel(_xrFrame: XRFrame): void;
  53452. }
  53453. }
  53454. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53455. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53456. import { Scene } from "babylonjs/scene";
  53457. /**
  53458. * A construction function type to create a new controller based on an xrInput object
  53459. */
  53460. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53461. /**
  53462. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53463. *
  53464. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53465. * it should be replaced with auto-loaded controllers.
  53466. *
  53467. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53468. */
  53469. export class WebXRMotionControllerManager {
  53470. private static _AvailableControllers;
  53471. private static _Fallbacks;
  53472. private static _ProfileLoadingPromises;
  53473. private static _ProfilesList;
  53474. /**
  53475. * The base URL of the online controller repository. Can be changed at any time.
  53476. */
  53477. static BaseRepositoryUrl: string;
  53478. /**
  53479. * Which repository gets priority - local or online
  53480. */
  53481. static PrioritizeOnlineRepository: boolean;
  53482. /**
  53483. * Use the online repository, or use only locally-defined controllers
  53484. */
  53485. static UseOnlineRepository: boolean;
  53486. /**
  53487. * Clear the cache used for profile loading and reload when requested again
  53488. */
  53489. static ClearProfilesCache(): void;
  53490. /**
  53491. * Register the default fallbacks.
  53492. * This function is called automatically when this file is imported.
  53493. */
  53494. static DefaultFallbacks(): void;
  53495. /**
  53496. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53497. * @param profileId the profile to which a fallback needs to be found
  53498. * @return an array with corresponding fallback profiles
  53499. */
  53500. static FindFallbackWithProfileId(profileId: string): string[];
  53501. /**
  53502. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53503. * The order of search:
  53504. *
  53505. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53506. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53507. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53508. * 4) return the generic trigger controller if none were found
  53509. *
  53510. * @param xrInput the xrInput to which a new controller is initialized
  53511. * @param scene the scene to which the model will be added
  53512. * @param forceProfile force a certain profile for this controller
  53513. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53514. */
  53515. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53516. /**
  53517. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53518. *
  53519. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53520. *
  53521. * @param type the profile type to register
  53522. * @param constructFunction the function to be called when loading this profile
  53523. */
  53524. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53525. /**
  53526. * Register a fallback to a specific profile.
  53527. * @param profileId the profileId that will receive the fallbacks
  53528. * @param fallbacks A list of fallback profiles
  53529. */
  53530. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53531. /**
  53532. * Will update the list of profiles available in the repository
  53533. * @return a promise that resolves to a map of profiles available online
  53534. */
  53535. static UpdateProfilesList(): Promise<{
  53536. [profile: string]: string;
  53537. }>;
  53538. private static _LoadProfileFromRepository;
  53539. private static _LoadProfilesFromAvailableControllers;
  53540. }
  53541. }
  53542. declare module "babylonjs/XR/webXRInputSource" {
  53543. import { Observable } from "babylonjs/Misc/observable";
  53544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53545. import { Ray } from "babylonjs/Culling/ray";
  53546. import { Scene } from "babylonjs/scene";
  53547. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53548. /**
  53549. * Configuration options for the WebXR controller creation
  53550. */
  53551. export interface IWebXRControllerOptions {
  53552. /**
  53553. * Should the controller mesh be animated when a user interacts with it
  53554. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53555. */
  53556. disableMotionControllerAnimation?: boolean;
  53557. /**
  53558. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53559. */
  53560. doNotLoadControllerMesh?: boolean;
  53561. /**
  53562. * Force a specific controller type for this controller.
  53563. * This can be used when creating your own profile or when testing different controllers
  53564. */
  53565. forceControllerProfile?: string;
  53566. /**
  53567. * Defines a rendering group ID for meshes that will be loaded.
  53568. * This is for the default controllers only.
  53569. */
  53570. renderingGroupId?: number;
  53571. }
  53572. /**
  53573. * Represents an XR controller
  53574. */
  53575. export class WebXRInputSource {
  53576. private _scene;
  53577. /** The underlying input source for the controller */
  53578. inputSource: XRInputSource;
  53579. private _options;
  53580. private _tmpVector;
  53581. private _uniqueId;
  53582. private _disposed;
  53583. /**
  53584. * 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
  53585. */
  53586. grip?: AbstractMesh;
  53587. /**
  53588. * If available, this is the gamepad object related to this controller.
  53589. * Using this object it is possible to get click events and trackpad changes of the
  53590. * webxr controller that is currently being used.
  53591. */
  53592. motionController?: WebXRAbstractMotionController;
  53593. /**
  53594. * Event that fires when the controller is removed/disposed.
  53595. * The object provided as event data is this controller, after associated assets were disposed.
  53596. * uniqueId is still available.
  53597. */
  53598. onDisposeObservable: Observable<WebXRInputSource>;
  53599. /**
  53600. * Will be triggered when the mesh associated with the motion controller is done loading.
  53601. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53602. * A shortened version of controller -> motion controller -> on mesh loaded.
  53603. */
  53604. onMeshLoadedObservable: Observable<AbstractMesh>;
  53605. /**
  53606. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53607. */
  53608. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53609. /**
  53610. * Pointer which can be used to select objects or attach a visible laser to
  53611. */
  53612. pointer: AbstractMesh;
  53613. /**
  53614. * Creates the input source object
  53615. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  53616. * @param _scene the scene which the controller should be associated to
  53617. * @param inputSource the underlying input source for the controller
  53618. * @param _options options for this controller creation
  53619. */
  53620. constructor(_scene: Scene,
  53621. /** The underlying input source for the controller */
  53622. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  53623. /**
  53624. * Get this controllers unique id
  53625. */
  53626. get uniqueId(): string;
  53627. /**
  53628. * Disposes of the object
  53629. */
  53630. dispose(): void;
  53631. /**
  53632. * Gets a world space ray coming from the pointer or grip
  53633. * @param result the resulting ray
  53634. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  53635. */
  53636. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  53637. /**
  53638. * Updates the controller pose based on the given XRFrame
  53639. * @param xrFrame xr frame to update the pose with
  53640. * @param referenceSpace reference space to use
  53641. */
  53642. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  53643. }
  53644. }
  53645. declare module "babylonjs/XR/webXRInput" {
  53646. import { Observable } from "babylonjs/Misc/observable";
  53647. import { IDisposable } from "babylonjs/scene";
  53648. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  53649. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53650. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53651. /**
  53652. * The schema for initialization options of the XR Input class
  53653. */
  53654. export interface IWebXRInputOptions {
  53655. /**
  53656. * If set to true no model will be automatically loaded
  53657. */
  53658. doNotLoadControllerMeshes?: boolean;
  53659. /**
  53660. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  53661. * If not found, the xr input profile data will be used.
  53662. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  53663. */
  53664. forceInputProfile?: string;
  53665. /**
  53666. * Do not send a request to the controller repository to load the profile.
  53667. *
  53668. * Instead, use the controllers available in babylon itself.
  53669. */
  53670. disableOnlineControllerRepository?: boolean;
  53671. /**
  53672. * A custom URL for the controllers repository
  53673. */
  53674. customControllersRepositoryURL?: string;
  53675. /**
  53676. * Should the controller model's components not move according to the user input
  53677. */
  53678. disableControllerAnimation?: boolean;
  53679. /**
  53680. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  53681. */
  53682. controllerOptions?: IWebXRControllerOptions;
  53683. }
  53684. /**
  53685. * XR input used to track XR inputs such as controllers/rays
  53686. */
  53687. export class WebXRInput implements IDisposable {
  53688. /**
  53689. * the xr session manager for this session
  53690. */
  53691. xrSessionManager: WebXRSessionManager;
  53692. /**
  53693. * the WebXR camera for this session. Mainly used for teleportation
  53694. */
  53695. xrCamera: WebXRCamera;
  53696. private readonly options;
  53697. /**
  53698. * XR controllers being tracked
  53699. */
  53700. controllers: Array<WebXRInputSource>;
  53701. private _frameObserver;
  53702. private _sessionEndedObserver;
  53703. private _sessionInitObserver;
  53704. /**
  53705. * Event when a controller has been connected/added
  53706. */
  53707. onControllerAddedObservable: Observable<WebXRInputSource>;
  53708. /**
  53709. * Event when a controller has been removed/disconnected
  53710. */
  53711. onControllerRemovedObservable: Observable<WebXRInputSource>;
  53712. /**
  53713. * Initializes the WebXRInput
  53714. * @param xrSessionManager the xr session manager for this session
  53715. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  53716. * @param options = initialization options for this xr input
  53717. */
  53718. constructor(
  53719. /**
  53720. * the xr session manager for this session
  53721. */
  53722. xrSessionManager: WebXRSessionManager,
  53723. /**
  53724. * the WebXR camera for this session. Mainly used for teleportation
  53725. */
  53726. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  53727. private _onInputSourcesChange;
  53728. private _addAndRemoveControllers;
  53729. /**
  53730. * Disposes of the object
  53731. */
  53732. dispose(): void;
  53733. }
  53734. }
  53735. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  53736. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  53737. import { Observable, EventState } from "babylonjs/Misc/observable";
  53738. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53739. /**
  53740. * This is the base class for all WebXR features.
  53741. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  53742. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  53743. */
  53744. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  53745. protected _xrSessionManager: WebXRSessionManager;
  53746. private _attached;
  53747. private _removeOnDetach;
  53748. /**
  53749. * Is this feature disposed?
  53750. */
  53751. isDisposed: boolean;
  53752. /**
  53753. * Should auto-attach be disabled?
  53754. */
  53755. disableAutoAttach: boolean;
  53756. /**
  53757. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  53758. */
  53759. xrNativeFeatureName: string;
  53760. /**
  53761. * Construct a new (abstract) WebXR feature
  53762. * @param _xrSessionManager the xr session manager for this feature
  53763. */
  53764. constructor(_xrSessionManager: WebXRSessionManager);
  53765. /**
  53766. * Is this feature attached
  53767. */
  53768. get attached(): boolean;
  53769. /**
  53770. * attach this feature
  53771. *
  53772. * @param force should attachment be forced (even when already attached)
  53773. * @returns true if successful, false is failed or already attached
  53774. */
  53775. attach(force?: boolean): boolean;
  53776. /**
  53777. * detach this feature.
  53778. *
  53779. * @returns true if successful, false if failed or already detached
  53780. */
  53781. detach(): boolean;
  53782. /**
  53783. * Dispose this feature and all of the resources attached
  53784. */
  53785. dispose(): void;
  53786. /**
  53787. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53788. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53789. *
  53790. * @returns whether or not the feature is compatible in this environment
  53791. */
  53792. isCompatible(): boolean;
  53793. /**
  53794. * This is used to register callbacks that will automatically be removed when detach is called.
  53795. * @param observable the observable to which the observer will be attached
  53796. * @param callback the callback to register
  53797. */
  53798. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  53799. /**
  53800. * Code in this function will be executed on each xrFrame received from the browser.
  53801. * This function will not execute after the feature is detached.
  53802. * @param _xrFrame the current frame
  53803. */
  53804. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  53805. }
  53806. }
  53807. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  53808. import { IDisposable, Scene } from "babylonjs/scene";
  53809. import { Nullable } from "babylonjs/types";
  53810. import { Observable } from "babylonjs/Misc/observable";
  53811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53812. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  53813. import { Camera } from "babylonjs/Cameras/camera";
  53814. /**
  53815. * Renders a layer on top of an existing scene
  53816. */
  53817. export class UtilityLayerRenderer implements IDisposable {
  53818. /** the original scene that will be rendered on top of */
  53819. originalScene: Scene;
  53820. private _pointerCaptures;
  53821. private _lastPointerEvents;
  53822. private static _DefaultUtilityLayer;
  53823. private static _DefaultKeepDepthUtilityLayer;
  53824. private _sharedGizmoLight;
  53825. private _renderCamera;
  53826. /**
  53827. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  53828. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  53829. * @returns the camera that is used when rendering the utility layer
  53830. */
  53831. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  53832. /**
  53833. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  53834. * @param cam the camera that should be used when rendering the utility layer
  53835. */
  53836. setRenderCamera(cam: Nullable<Camera>): void;
  53837. /**
  53838. * @hidden
  53839. * Light which used by gizmos to get light shading
  53840. */
  53841. _getSharedGizmoLight(): HemisphericLight;
  53842. /**
  53843. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  53844. */
  53845. pickUtilitySceneFirst: boolean;
  53846. /**
  53847. * 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)
  53848. */
  53849. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  53850. /**
  53851. * 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)
  53852. */
  53853. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  53854. /**
  53855. * The scene that is rendered on top of the original scene
  53856. */
  53857. utilityLayerScene: Scene;
  53858. /**
  53859. * If the utility layer should automatically be rendered on top of existing scene
  53860. */
  53861. shouldRender: boolean;
  53862. /**
  53863. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  53864. */
  53865. onlyCheckPointerDownEvents: boolean;
  53866. /**
  53867. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  53868. */
  53869. processAllEvents: boolean;
  53870. /**
  53871. * Observable raised when the pointer move from the utility layer scene to the main scene
  53872. */
  53873. onPointerOutObservable: Observable<number>;
  53874. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  53875. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  53876. private _afterRenderObserver;
  53877. private _sceneDisposeObserver;
  53878. private _originalPointerObserver;
  53879. /**
  53880. * Instantiates a UtilityLayerRenderer
  53881. * @param originalScene the original scene that will be rendered on top of
  53882. * @param handleEvents boolean indicating if the utility layer should handle events
  53883. */
  53884. constructor(
  53885. /** the original scene that will be rendered on top of */
  53886. originalScene: Scene, handleEvents?: boolean);
  53887. private _notifyObservers;
  53888. /**
  53889. * Renders the utility layers scene on top of the original scene
  53890. */
  53891. render(): void;
  53892. /**
  53893. * Disposes of the renderer
  53894. */
  53895. dispose(): void;
  53896. private _updateCamera;
  53897. }
  53898. }
  53899. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  53900. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53902. import { WebXRInput } from "babylonjs/XR/webXRInput";
  53903. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  53904. import { Scene } from "babylonjs/scene";
  53905. import { Nullable } from "babylonjs/types";
  53906. import { Color3 } from "babylonjs/Maths/math.color";
  53907. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  53908. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53909. /**
  53910. * Options interface for the pointer selection module
  53911. */
  53912. export interface IWebXRControllerPointerSelectionOptions {
  53913. /**
  53914. * if provided, this scene will be used to render meshes.
  53915. */
  53916. customUtilityLayerScene?: Scene;
  53917. /**
  53918. * 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)
  53919. * If not disabled, the last picked point will be used to execute a pointer up event
  53920. * If disabled, pointer up event will be triggered right after the pointer down event.
  53921. * Used in screen and gaze target ray mode only
  53922. */
  53923. disablePointerUpOnTouchOut: boolean;
  53924. /**
  53925. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  53926. */
  53927. forceGazeMode: boolean;
  53928. /**
  53929. * 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
  53930. * to start a new countdown to the pointer down event.
  53931. * Defaults to 1.
  53932. */
  53933. gazeModePointerMovedFactor?: number;
  53934. /**
  53935. * Different button type to use instead of the main component
  53936. */
  53937. overrideButtonId?: string;
  53938. /**
  53939. * use this rendering group id for the meshes (optional)
  53940. */
  53941. renderingGroupId?: number;
  53942. /**
  53943. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  53944. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  53945. * 3000 means 3 seconds between pointing at something and selecting it
  53946. */
  53947. timeToSelect?: number;
  53948. /**
  53949. * Should meshes created here be added to a utility layer or the main scene
  53950. */
  53951. useUtilityLayer?: boolean;
  53952. /**
  53953. * Optional WebXR camera to be used for gaze selection
  53954. */
  53955. gazeCamera?: WebXRCamera;
  53956. /**
  53957. * the xr input to use with this pointer selection
  53958. */
  53959. xrInput: WebXRInput;
  53960. }
  53961. /**
  53962. * A module that will enable pointer selection for motion controllers of XR Input Sources
  53963. */
  53964. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  53965. private readonly _options;
  53966. private static _idCounter;
  53967. private _attachController;
  53968. private _controllers;
  53969. private _scene;
  53970. private _tmpVectorForPickCompare;
  53971. /**
  53972. * The module's name
  53973. */
  53974. static readonly Name: string;
  53975. /**
  53976. * The (Babylon) version of this module.
  53977. * This is an integer representing the implementation version.
  53978. * This number does not correspond to the WebXR specs version
  53979. */
  53980. static readonly Version: number;
  53981. /**
  53982. * Disable lighting on the laser pointer (so it will always be visible)
  53983. */
  53984. disablePointerLighting: boolean;
  53985. /**
  53986. * Disable lighting on the selection mesh (so it will always be visible)
  53987. */
  53988. disableSelectionMeshLighting: boolean;
  53989. /**
  53990. * Should the laser pointer be displayed
  53991. */
  53992. displayLaserPointer: boolean;
  53993. /**
  53994. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  53995. */
  53996. displaySelectionMesh: boolean;
  53997. /**
  53998. * This color will be set to the laser pointer when selection is triggered
  53999. */
  54000. laserPointerPickedColor: Color3;
  54001. /**
  54002. * Default color of the laser pointer
  54003. */
  54004. laserPointerDefaultColor: Color3;
  54005. /**
  54006. * default color of the selection ring
  54007. */
  54008. selectionMeshDefaultColor: Color3;
  54009. /**
  54010. * This color will be applied to the selection ring when selection is triggered
  54011. */
  54012. selectionMeshPickedColor: Color3;
  54013. /**
  54014. * Optional filter to be used for ray selection. This predicate shares behavior with
  54015. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54016. */
  54017. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54018. /**
  54019. * constructs a new background remover module
  54020. * @param _xrSessionManager the session manager for this module
  54021. * @param _options read-only options to be used in this module
  54022. */
  54023. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54024. /**
  54025. * attach this feature
  54026. * Will usually be called by the features manager
  54027. *
  54028. * @returns true if successful.
  54029. */
  54030. attach(): boolean;
  54031. /**
  54032. * detach this feature.
  54033. * Will usually be called by the features manager
  54034. *
  54035. * @returns true if successful.
  54036. */
  54037. detach(): boolean;
  54038. /**
  54039. * Will get the mesh under a specific pointer.
  54040. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54041. * @param controllerId the controllerId to check
  54042. * @returns The mesh under pointer or null if no mesh is under the pointer
  54043. */
  54044. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54045. /**
  54046. * Get the xr controller that correlates to the pointer id in the pointer event
  54047. *
  54048. * @param id the pointer id to search for
  54049. * @returns the controller that correlates to this id or null if not found
  54050. */
  54051. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54052. protected _onXRFrame(_xrFrame: XRFrame): void;
  54053. private _attachGazeMode;
  54054. private _attachScreenRayMode;
  54055. private _attachTrackedPointerRayMode;
  54056. private _convertNormalToDirectionOfRay;
  54057. private _detachController;
  54058. private _generateNewMeshPair;
  54059. private _pickingMoved;
  54060. private _updatePointerDistance;
  54061. /** @hidden */
  54062. get lasterPointerDefaultColor(): Color3;
  54063. }
  54064. }
  54065. declare module "babylonjs/XR/webXREnterExitUI" {
  54066. import { Nullable } from "babylonjs/types";
  54067. import { Observable } from "babylonjs/Misc/observable";
  54068. import { IDisposable, Scene } from "babylonjs/scene";
  54069. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54070. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54071. /**
  54072. * Button which can be used to enter a different mode of XR
  54073. */
  54074. export class WebXREnterExitUIButton {
  54075. /** button element */
  54076. element: HTMLElement;
  54077. /** XR initialization options for the button */
  54078. sessionMode: XRSessionMode;
  54079. /** Reference space type */
  54080. referenceSpaceType: XRReferenceSpaceType;
  54081. /**
  54082. * Creates a WebXREnterExitUIButton
  54083. * @param element button element
  54084. * @param sessionMode XR initialization session mode
  54085. * @param referenceSpaceType the type of reference space to be used
  54086. */
  54087. constructor(
  54088. /** button element */
  54089. element: HTMLElement,
  54090. /** XR initialization options for the button */
  54091. sessionMode: XRSessionMode,
  54092. /** Reference space type */
  54093. referenceSpaceType: XRReferenceSpaceType);
  54094. /**
  54095. * Extendable function which can be used to update the button's visuals when the state changes
  54096. * @param activeButton the current active button in the UI
  54097. */
  54098. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54099. }
  54100. /**
  54101. * Options to create the webXR UI
  54102. */
  54103. export class WebXREnterExitUIOptions {
  54104. /**
  54105. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54106. */
  54107. customButtons?: Array<WebXREnterExitUIButton>;
  54108. /**
  54109. * A reference space type to use when creating the default button.
  54110. * Default is local-floor
  54111. */
  54112. referenceSpaceType?: XRReferenceSpaceType;
  54113. /**
  54114. * Context to enter xr with
  54115. */
  54116. renderTarget?: Nullable<WebXRRenderTarget>;
  54117. /**
  54118. * A session mode to use when creating the default button.
  54119. * Default is immersive-vr
  54120. */
  54121. sessionMode?: XRSessionMode;
  54122. /**
  54123. * A list of optional features to init the session with
  54124. */
  54125. optionalFeatures?: string[];
  54126. /**
  54127. * A list of optional features to init the session with
  54128. */
  54129. requiredFeatures?: string[];
  54130. }
  54131. /**
  54132. * UI to allow the user to enter/exit XR mode
  54133. */
  54134. export class WebXREnterExitUI implements IDisposable {
  54135. private scene;
  54136. /** version of the options passed to this UI */
  54137. options: WebXREnterExitUIOptions;
  54138. private _activeButton;
  54139. private _buttons;
  54140. /**
  54141. * The HTML Div Element to which buttons are added.
  54142. */
  54143. readonly overlay: HTMLDivElement;
  54144. /**
  54145. * Fired every time the active button is changed.
  54146. *
  54147. * When xr is entered via a button that launches xr that button will be the callback parameter
  54148. *
  54149. * When exiting xr the callback parameter will be null)
  54150. */
  54151. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54152. /**
  54153. *
  54154. * @param scene babylon scene object to use
  54155. * @param options (read-only) version of the options passed to this UI
  54156. */
  54157. private constructor();
  54158. /**
  54159. * Creates UI to allow the user to enter/exit XR mode
  54160. * @param scene the scene to add the ui to
  54161. * @param helper the xr experience helper to enter/exit xr with
  54162. * @param options options to configure the UI
  54163. * @returns the created ui
  54164. */
  54165. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54166. /**
  54167. * Disposes of the XR UI component
  54168. */
  54169. dispose(): void;
  54170. private _updateButtons;
  54171. }
  54172. }
  54173. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54174. import { Vector3 } from "babylonjs/Maths/math.vector";
  54175. import { Color4 } from "babylonjs/Maths/math.color";
  54176. import { Nullable } from "babylonjs/types";
  54177. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54178. import { Scene } from "babylonjs/scene";
  54179. /**
  54180. * Class containing static functions to help procedurally build meshes
  54181. */
  54182. export class LinesBuilder {
  54183. /**
  54184. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54185. * * 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
  54186. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54187. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54188. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54189. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54190. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54191. * * 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
  54192. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54194. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54195. * @param name defines the name of the new line system
  54196. * @param options defines the options used to create the line system
  54197. * @param scene defines the hosting scene
  54198. * @returns a new line system mesh
  54199. */
  54200. static CreateLineSystem(name: string, options: {
  54201. lines: Vector3[][];
  54202. updatable?: boolean;
  54203. instance?: Nullable<LinesMesh>;
  54204. colors?: Nullable<Color4[][]>;
  54205. useVertexAlpha?: boolean;
  54206. }, scene: Nullable<Scene>): LinesMesh;
  54207. /**
  54208. * Creates a line mesh
  54209. * 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
  54210. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54211. * * The parameter `points` is an array successive Vector3
  54212. * * 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
  54213. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54214. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54215. * * When updating an instance, remember that only point positions can change, not the number of points
  54216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54218. * @param name defines the name of the new line system
  54219. * @param options defines the options used to create the line system
  54220. * @param scene defines the hosting scene
  54221. * @returns a new line mesh
  54222. */
  54223. static CreateLines(name: string, options: {
  54224. points: Vector3[];
  54225. updatable?: boolean;
  54226. instance?: Nullable<LinesMesh>;
  54227. colors?: Color4[];
  54228. useVertexAlpha?: boolean;
  54229. }, scene?: Nullable<Scene>): LinesMesh;
  54230. /**
  54231. * Creates a dashed line mesh
  54232. * * 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
  54233. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54234. * * The parameter `points` is an array successive Vector3
  54235. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54236. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54237. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54238. * * 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
  54239. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54240. * * When updating an instance, remember that only point positions can change, not the number of points
  54241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54242. * @param name defines the name of the mesh
  54243. * @param options defines the options used to create the mesh
  54244. * @param scene defines the hosting scene
  54245. * @returns the dashed line mesh
  54246. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54247. */
  54248. static CreateDashedLines(name: string, options: {
  54249. points: Vector3[];
  54250. dashSize?: number;
  54251. gapSize?: number;
  54252. dashNb?: number;
  54253. updatable?: boolean;
  54254. instance?: LinesMesh;
  54255. useVertexAlpha?: boolean;
  54256. }, scene?: Nullable<Scene>): LinesMesh;
  54257. }
  54258. }
  54259. declare module "babylonjs/Misc/timer" {
  54260. import { Observable, Observer } from "babylonjs/Misc/observable";
  54261. import { Nullable } from "babylonjs/types";
  54262. import { IDisposable } from "babylonjs/scene";
  54263. /**
  54264. * Construction options for a timer
  54265. */
  54266. export interface ITimerOptions<T> {
  54267. /**
  54268. * Time-to-end
  54269. */
  54270. timeout: number;
  54271. /**
  54272. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54273. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54274. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54275. */
  54276. contextObservable: Observable<T>;
  54277. /**
  54278. * Optional parameters when adding an observer to the observable
  54279. */
  54280. observableParameters?: {
  54281. mask?: number;
  54282. insertFirst?: boolean;
  54283. scope?: any;
  54284. };
  54285. /**
  54286. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54287. */
  54288. breakCondition?: (data?: ITimerData<T>) => boolean;
  54289. /**
  54290. * Will be triggered when the time condition has met
  54291. */
  54292. onEnded?: (data: ITimerData<any>) => void;
  54293. /**
  54294. * Will be triggered when the break condition has met (prematurely ended)
  54295. */
  54296. onAborted?: (data: ITimerData<any>) => void;
  54297. /**
  54298. * Optional function to execute on each tick (or count)
  54299. */
  54300. onTick?: (data: ITimerData<any>) => void;
  54301. }
  54302. /**
  54303. * An interface defining the data sent by the timer
  54304. */
  54305. export interface ITimerData<T> {
  54306. /**
  54307. * When did it start
  54308. */
  54309. startTime: number;
  54310. /**
  54311. * Time now
  54312. */
  54313. currentTime: number;
  54314. /**
  54315. * Time passed since started
  54316. */
  54317. deltaTime: number;
  54318. /**
  54319. * How much is completed, in [0.0...1.0].
  54320. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54321. */
  54322. completeRate: number;
  54323. /**
  54324. * What the registered observable sent in the last count
  54325. */
  54326. payload: T;
  54327. }
  54328. /**
  54329. * The current state of the timer
  54330. */
  54331. export enum TimerState {
  54332. /**
  54333. * Timer initialized, not yet started
  54334. */
  54335. INIT = 0,
  54336. /**
  54337. * Timer started and counting
  54338. */
  54339. STARTED = 1,
  54340. /**
  54341. * Timer ended (whether aborted or time reached)
  54342. */
  54343. ENDED = 2
  54344. }
  54345. /**
  54346. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54347. *
  54348. * @param options options with which to initialize this timer
  54349. */
  54350. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54351. /**
  54352. * An advanced implementation of a timer class
  54353. */
  54354. export class AdvancedTimer<T = any> implements IDisposable {
  54355. /**
  54356. * Will notify each time the timer calculates the remaining time
  54357. */
  54358. onEachCountObservable: Observable<ITimerData<T>>;
  54359. /**
  54360. * Will trigger when the timer was aborted due to the break condition
  54361. */
  54362. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54363. /**
  54364. * Will trigger when the timer ended successfully
  54365. */
  54366. onTimerEndedObservable: Observable<ITimerData<T>>;
  54367. /**
  54368. * Will trigger when the timer state has changed
  54369. */
  54370. onStateChangedObservable: Observable<TimerState>;
  54371. private _observer;
  54372. private _contextObservable;
  54373. private _observableParameters;
  54374. private _startTime;
  54375. private _timer;
  54376. private _state;
  54377. private _breakCondition;
  54378. private _timeToEnd;
  54379. private _breakOnNextTick;
  54380. /**
  54381. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54382. * @param options construction options for this advanced timer
  54383. */
  54384. constructor(options: ITimerOptions<T>);
  54385. /**
  54386. * set a breaking condition for this timer. Default is to never break during count
  54387. * @param predicate the new break condition. Returns true to break, false otherwise
  54388. */
  54389. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54390. /**
  54391. * Reset ALL associated observables in this advanced timer
  54392. */
  54393. clearObservables(): void;
  54394. /**
  54395. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54396. *
  54397. * @param timeToEnd how much time to measure until timer ended
  54398. */
  54399. start(timeToEnd?: number): void;
  54400. /**
  54401. * Will force a stop on the next tick.
  54402. */
  54403. stop(): void;
  54404. /**
  54405. * Dispose this timer, clearing all resources
  54406. */
  54407. dispose(): void;
  54408. private _setState;
  54409. private _tick;
  54410. private _stop;
  54411. }
  54412. }
  54413. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54414. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54415. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54416. import { Nullable } from "babylonjs/types";
  54417. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54419. import { Vector3 } from "babylonjs/Maths/math.vector";
  54420. import { Material } from "babylonjs/Materials/material";
  54421. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54422. import { Scene } from "babylonjs/scene";
  54423. /**
  54424. * The options container for the teleportation module
  54425. */
  54426. export interface IWebXRTeleportationOptions {
  54427. /**
  54428. * if provided, this scene will be used to render meshes.
  54429. */
  54430. customUtilityLayerScene?: Scene;
  54431. /**
  54432. * Values to configure the default target mesh
  54433. */
  54434. defaultTargetMeshOptions?: {
  54435. /**
  54436. * Fill color of the teleportation area
  54437. */
  54438. teleportationFillColor?: string;
  54439. /**
  54440. * Border color for the teleportation area
  54441. */
  54442. teleportationBorderColor?: string;
  54443. /**
  54444. * Disable the mesh's animation sequence
  54445. */
  54446. disableAnimation?: boolean;
  54447. /**
  54448. * Disable lighting on the material or the ring and arrow
  54449. */
  54450. disableLighting?: boolean;
  54451. /**
  54452. * Override the default material of the torus and arrow
  54453. */
  54454. torusArrowMaterial?: Material;
  54455. };
  54456. /**
  54457. * A list of meshes to use as floor meshes.
  54458. * Meshes can be added and removed after initializing the feature using the
  54459. * addFloorMesh and removeFloorMesh functions
  54460. * If empty, rotation will still work
  54461. */
  54462. floorMeshes?: AbstractMesh[];
  54463. /**
  54464. * use this rendering group id for the meshes (optional)
  54465. */
  54466. renderingGroupId?: number;
  54467. /**
  54468. * Should teleportation move only to snap points
  54469. */
  54470. snapPointsOnly?: boolean;
  54471. /**
  54472. * An array of points to which the teleportation will snap to.
  54473. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54474. */
  54475. snapPositions?: Vector3[];
  54476. /**
  54477. * How close should the teleportation ray be in order to snap to position.
  54478. * Default to 0.8 units (meters)
  54479. */
  54480. snapToPositionRadius?: number;
  54481. /**
  54482. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54483. * If you want to support rotation, make sure your mesh has a direction indicator.
  54484. *
  54485. * When left untouched, the default mesh will be initialized.
  54486. */
  54487. teleportationTargetMesh?: AbstractMesh;
  54488. /**
  54489. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54490. */
  54491. timeToTeleport?: number;
  54492. /**
  54493. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54494. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54495. */
  54496. useMainComponentOnly?: boolean;
  54497. /**
  54498. * Should meshes created here be added to a utility layer or the main scene
  54499. */
  54500. useUtilityLayer?: boolean;
  54501. /**
  54502. * Babylon XR Input class for controller
  54503. */
  54504. xrInput: WebXRInput;
  54505. /**
  54506. * Meshes that the teleportation ray cannot go through
  54507. */
  54508. pickBlockerMeshes?: AbstractMesh[];
  54509. }
  54510. /**
  54511. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54512. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54513. * the input of the attached controllers.
  54514. */
  54515. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54516. private _options;
  54517. private _controllers;
  54518. private _currentTeleportationControllerId;
  54519. private _floorMeshes;
  54520. private _quadraticBezierCurve;
  54521. private _selectionFeature;
  54522. private _snapToPositions;
  54523. private _snappedToPoint;
  54524. private _teleportationRingMaterial?;
  54525. private _tmpRay;
  54526. private _tmpVector;
  54527. private _tmpQuaternion;
  54528. /**
  54529. * The module's name
  54530. */
  54531. static readonly Name: string;
  54532. /**
  54533. * The (Babylon) version of this module.
  54534. * This is an integer representing the implementation version.
  54535. * This number does not correspond to the webxr specs version
  54536. */
  54537. static readonly Version: number;
  54538. /**
  54539. * Is movement backwards enabled
  54540. */
  54541. backwardsMovementEnabled: boolean;
  54542. /**
  54543. * Distance to travel when moving backwards
  54544. */
  54545. backwardsTeleportationDistance: number;
  54546. /**
  54547. * The distance from the user to the inspection point in the direction of the controller
  54548. * A higher number will allow the user to move further
  54549. * defaults to 5 (meters, in xr units)
  54550. */
  54551. parabolicCheckRadius: number;
  54552. /**
  54553. * Should the module support parabolic ray on top of direct ray
  54554. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54555. * Very helpful when moving between floors / different heights
  54556. */
  54557. parabolicRayEnabled: boolean;
  54558. /**
  54559. * How much rotation should be applied when rotating right and left
  54560. */
  54561. rotationAngle: number;
  54562. /**
  54563. * Is rotation enabled when moving forward?
  54564. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54565. */
  54566. rotationEnabled: boolean;
  54567. /**
  54568. * constructs a new anchor system
  54569. * @param _xrSessionManager an instance of WebXRSessionManager
  54570. * @param _options configuration object for this feature
  54571. */
  54572. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54573. /**
  54574. * Get the snapPointsOnly flag
  54575. */
  54576. get snapPointsOnly(): boolean;
  54577. /**
  54578. * Sets the snapPointsOnly flag
  54579. * @param snapToPoints should teleportation be exclusively to snap points
  54580. */
  54581. set snapPointsOnly(snapToPoints: boolean);
  54582. /**
  54583. * Add a new mesh to the floor meshes array
  54584. * @param mesh the mesh to use as floor mesh
  54585. */
  54586. addFloorMesh(mesh: AbstractMesh): void;
  54587. /**
  54588. * Add a new snap-to point to fix teleportation to this position
  54589. * @param newSnapPoint The new Snap-To point
  54590. */
  54591. addSnapPoint(newSnapPoint: Vector3): void;
  54592. attach(): boolean;
  54593. detach(): boolean;
  54594. dispose(): void;
  54595. /**
  54596. * Remove a mesh from the floor meshes array
  54597. * @param mesh the mesh to remove
  54598. */
  54599. removeFloorMesh(mesh: AbstractMesh): void;
  54600. /**
  54601. * Remove a mesh from the floor meshes array using its name
  54602. * @param name the mesh name to remove
  54603. */
  54604. removeFloorMeshByName(name: string): void;
  54605. /**
  54606. * 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
  54607. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  54608. * @returns was the point found and removed or not
  54609. */
  54610. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  54611. /**
  54612. * This function sets a selection feature that will be disabled when
  54613. * the forward ray is shown and will be reattached when hidden.
  54614. * This is used to remove the selection rays when moving.
  54615. * @param selectionFeature the feature to disable when forward movement is enabled
  54616. */
  54617. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  54618. protected _onXRFrame(_xrFrame: XRFrame): void;
  54619. private _attachController;
  54620. private _createDefaultTargetMesh;
  54621. private _detachController;
  54622. private _findClosestSnapPointWithRadius;
  54623. private _setTargetMeshPosition;
  54624. private _setTargetMeshVisibility;
  54625. private _showParabolicPath;
  54626. private _teleportForward;
  54627. }
  54628. }
  54629. declare module "babylonjs/XR/webXRDefaultExperience" {
  54630. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54631. import { Scene } from "babylonjs/scene";
  54632. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  54633. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  54634. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54635. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  54636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54637. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  54638. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  54639. /**
  54640. * Options for the default xr helper
  54641. */
  54642. export class WebXRDefaultExperienceOptions {
  54643. /**
  54644. * Enable or disable default UI to enter XR
  54645. */
  54646. disableDefaultUI?: boolean;
  54647. /**
  54648. * Should teleportation not initialize. defaults to false.
  54649. */
  54650. disableTeleportation?: boolean;
  54651. /**
  54652. * Floor meshes that will be used for teleport
  54653. */
  54654. floorMeshes?: Array<AbstractMesh>;
  54655. /**
  54656. * If set to true, the first frame will not be used to reset position
  54657. * The first frame is mainly used when copying transformation from the old camera
  54658. * Mainly used in AR
  54659. */
  54660. ignoreNativeCameraTransformation?: boolean;
  54661. /**
  54662. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  54663. */
  54664. inputOptions?: IWebXRInputOptions;
  54665. /**
  54666. * optional configuration for the output canvas
  54667. */
  54668. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  54669. /**
  54670. * optional UI options. This can be used among other to change session mode and reference space type
  54671. */
  54672. uiOptions?: WebXREnterExitUIOptions;
  54673. /**
  54674. * When loading teleportation and pointer select, use stable versions instead of latest.
  54675. */
  54676. useStablePlugins?: boolean;
  54677. /**
  54678. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  54679. */
  54680. renderingGroupId?: number;
  54681. /**
  54682. * A list of optional features to init the session with
  54683. * If set to true, all features we support will be added
  54684. */
  54685. optionalFeatures?: boolean | string[];
  54686. }
  54687. /**
  54688. * Default experience which provides a similar setup to the previous webVRExperience
  54689. */
  54690. export class WebXRDefaultExperience {
  54691. /**
  54692. * Base experience
  54693. */
  54694. baseExperience: WebXRExperienceHelper;
  54695. /**
  54696. * Enables ui for entering/exiting xr
  54697. */
  54698. enterExitUI: WebXREnterExitUI;
  54699. /**
  54700. * Input experience extension
  54701. */
  54702. input: WebXRInput;
  54703. /**
  54704. * Enables laser pointer and selection
  54705. */
  54706. pointerSelection: WebXRControllerPointerSelection;
  54707. /**
  54708. * Default target xr should render to
  54709. */
  54710. renderTarget: WebXRRenderTarget;
  54711. /**
  54712. * Enables teleportation
  54713. */
  54714. teleportation: WebXRMotionControllerTeleportation;
  54715. private constructor();
  54716. /**
  54717. * Creates the default xr experience
  54718. * @param scene scene
  54719. * @param options options for basic configuration
  54720. * @returns resulting WebXRDefaultExperience
  54721. */
  54722. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54723. /**
  54724. * DIsposes of the experience helper
  54725. */
  54726. dispose(): void;
  54727. }
  54728. }
  54729. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  54730. import { Observable } from "babylonjs/Misc/observable";
  54731. import { Nullable } from "babylonjs/types";
  54732. import { Camera } from "babylonjs/Cameras/camera";
  54733. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  54734. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  54735. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  54736. import { Scene } from "babylonjs/scene";
  54737. import { Vector3 } from "babylonjs/Maths/math.vector";
  54738. import { Color3 } from "babylonjs/Maths/math.color";
  54739. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54741. import { Mesh } from "babylonjs/Meshes/mesh";
  54742. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  54743. import { EasingFunction } from "babylonjs/Animations/easing";
  54744. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54745. import "babylonjs/Meshes/Builders/groundBuilder";
  54746. import "babylonjs/Meshes/Builders/torusBuilder";
  54747. import "babylonjs/Meshes/Builders/cylinderBuilder";
  54748. import "babylonjs/Gamepads/gamepadSceneComponent";
  54749. import "babylonjs/Animations/animatable";
  54750. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  54751. /**
  54752. * Options to modify the vr teleportation behavior.
  54753. */
  54754. export interface VRTeleportationOptions {
  54755. /**
  54756. * The name of the mesh which should be used as the teleportation floor. (default: null)
  54757. */
  54758. floorMeshName?: string;
  54759. /**
  54760. * A list of meshes to be used as the teleportation floor. (default: empty)
  54761. */
  54762. floorMeshes?: Mesh[];
  54763. /**
  54764. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  54765. */
  54766. teleportationMode?: number;
  54767. /**
  54768. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  54769. */
  54770. teleportationTime?: number;
  54771. /**
  54772. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  54773. */
  54774. teleportationSpeed?: number;
  54775. /**
  54776. * The easing function used in the animation or null for Linear. (default CircleEase)
  54777. */
  54778. easingFunction?: EasingFunction;
  54779. }
  54780. /**
  54781. * Options to modify the vr experience helper's behavior.
  54782. */
  54783. export interface VRExperienceHelperOptions extends WebVROptions {
  54784. /**
  54785. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  54786. */
  54787. createDeviceOrientationCamera?: boolean;
  54788. /**
  54789. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  54790. */
  54791. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  54792. /**
  54793. * Uses the main button on the controller to toggle the laser casted. (default: true)
  54794. */
  54795. laserToggle?: boolean;
  54796. /**
  54797. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  54798. */
  54799. floorMeshes?: Mesh[];
  54800. /**
  54801. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  54802. */
  54803. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  54804. /**
  54805. * Defines if WebXR should be used instead of WebVR (if available)
  54806. */
  54807. useXR?: boolean;
  54808. }
  54809. /**
  54810. * Event containing information after VR has been entered
  54811. */
  54812. export class OnAfterEnteringVRObservableEvent {
  54813. /**
  54814. * If entering vr was successful
  54815. */
  54816. success: boolean;
  54817. }
  54818. /**
  54819. * Helps to quickly add VR support to an existing scene.
  54820. * See https://doc.babylonjs.com/how_to/webvr_helper
  54821. */
  54822. export class VRExperienceHelper {
  54823. /** Options to modify the vr experience helper's behavior. */
  54824. webVROptions: VRExperienceHelperOptions;
  54825. private _scene;
  54826. private _position;
  54827. private _btnVR;
  54828. private _btnVRDisplayed;
  54829. private _webVRsupported;
  54830. private _webVRready;
  54831. private _webVRrequesting;
  54832. private _webVRpresenting;
  54833. private _hasEnteredVR;
  54834. private _fullscreenVRpresenting;
  54835. private _inputElement;
  54836. private _webVRCamera;
  54837. private _vrDeviceOrientationCamera;
  54838. private _deviceOrientationCamera;
  54839. private _existingCamera;
  54840. private _onKeyDown;
  54841. private _onVrDisplayPresentChange;
  54842. private _onVRDisplayChanged;
  54843. private _onVRRequestPresentStart;
  54844. private _onVRRequestPresentComplete;
  54845. /**
  54846. * 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)
  54847. */
  54848. enableGazeEvenWhenNoPointerLock: boolean;
  54849. /**
  54850. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  54851. */
  54852. exitVROnDoubleTap: boolean;
  54853. /**
  54854. * Observable raised right before entering VR.
  54855. */
  54856. onEnteringVRObservable: Observable<VRExperienceHelper>;
  54857. /**
  54858. * Observable raised when entering VR has completed.
  54859. */
  54860. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  54861. /**
  54862. * Observable raised when exiting VR.
  54863. */
  54864. onExitingVRObservable: Observable<VRExperienceHelper>;
  54865. /**
  54866. * Observable raised when controller mesh is loaded.
  54867. */
  54868. onControllerMeshLoadedObservable: Observable<WebVRController>;
  54869. /** Return this.onEnteringVRObservable
  54870. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  54871. */
  54872. get onEnteringVR(): Observable<VRExperienceHelper>;
  54873. /** Return this.onExitingVRObservable
  54874. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  54875. */
  54876. get onExitingVR(): Observable<VRExperienceHelper>;
  54877. /** Return this.onControllerMeshLoadedObservable
  54878. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  54879. */
  54880. get onControllerMeshLoaded(): Observable<WebVRController>;
  54881. private _rayLength;
  54882. private _useCustomVRButton;
  54883. private _teleportationRequested;
  54884. private _teleportActive;
  54885. private _floorMeshName;
  54886. private _floorMeshesCollection;
  54887. private _teleportationMode;
  54888. private _teleportationTime;
  54889. private _teleportationSpeed;
  54890. private _teleportationEasing;
  54891. private _rotationAllowed;
  54892. private _teleportBackwardsVector;
  54893. private _teleportationTarget;
  54894. private _isDefaultTeleportationTarget;
  54895. private _postProcessMove;
  54896. private _teleportationFillColor;
  54897. private _teleportationBorderColor;
  54898. private _rotationAngle;
  54899. private _haloCenter;
  54900. private _cameraGazer;
  54901. private _padSensibilityUp;
  54902. private _padSensibilityDown;
  54903. private _leftController;
  54904. private _rightController;
  54905. private _gazeColor;
  54906. private _laserColor;
  54907. private _pickedLaserColor;
  54908. private _pickedGazeColor;
  54909. /**
  54910. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  54911. */
  54912. onNewMeshSelected: Observable<AbstractMesh>;
  54913. /**
  54914. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  54915. * This observable will provide the mesh and the controller used to select the mesh
  54916. */
  54917. onMeshSelectedWithController: Observable<{
  54918. mesh: AbstractMesh;
  54919. controller: WebVRController;
  54920. }>;
  54921. /**
  54922. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  54923. */
  54924. onNewMeshPicked: Observable<PickingInfo>;
  54925. private _circleEase;
  54926. /**
  54927. * Observable raised before camera teleportation
  54928. */
  54929. onBeforeCameraTeleport: Observable<Vector3>;
  54930. /**
  54931. * Observable raised after camera teleportation
  54932. */
  54933. onAfterCameraTeleport: Observable<Vector3>;
  54934. /**
  54935. * Observable raised when current selected mesh gets unselected
  54936. */
  54937. onSelectedMeshUnselected: Observable<AbstractMesh>;
  54938. private _raySelectionPredicate;
  54939. /**
  54940. * To be optionaly changed by user to define custom ray selection
  54941. */
  54942. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54943. /**
  54944. * To be optionaly changed by user to define custom selection logic (after ray selection)
  54945. */
  54946. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54947. /**
  54948. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  54949. */
  54950. teleportationEnabled: boolean;
  54951. private _defaultHeight;
  54952. private _teleportationInitialized;
  54953. private _interactionsEnabled;
  54954. private _interactionsRequested;
  54955. private _displayGaze;
  54956. private _displayLaserPointer;
  54957. /**
  54958. * The mesh used to display where the user is going to teleport.
  54959. */
  54960. get teleportationTarget(): Mesh;
  54961. /**
  54962. * Sets the mesh to be used to display where the user is going to teleport.
  54963. */
  54964. set teleportationTarget(value: Mesh);
  54965. /**
  54966. * 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
  54967. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  54968. * See https://doc.babylonjs.com/resources/baking_transformations
  54969. */
  54970. get gazeTrackerMesh(): Mesh;
  54971. set gazeTrackerMesh(value: Mesh);
  54972. /**
  54973. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  54974. */
  54975. updateGazeTrackerScale: boolean;
  54976. /**
  54977. * If the gaze trackers color should be updated when selecting meshes
  54978. */
  54979. updateGazeTrackerColor: boolean;
  54980. /**
  54981. * If the controller laser color should be updated when selecting meshes
  54982. */
  54983. updateControllerLaserColor: boolean;
  54984. /**
  54985. * The gaze tracking mesh corresponding to the left controller
  54986. */
  54987. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  54988. /**
  54989. * The gaze tracking mesh corresponding to the right controller
  54990. */
  54991. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  54992. /**
  54993. * If the ray of the gaze should be displayed.
  54994. */
  54995. get displayGaze(): boolean;
  54996. /**
  54997. * Sets if the ray of the gaze should be displayed.
  54998. */
  54999. set displayGaze(value: boolean);
  55000. /**
  55001. * If the ray of the LaserPointer should be displayed.
  55002. */
  55003. get displayLaserPointer(): boolean;
  55004. /**
  55005. * Sets if the ray of the LaserPointer should be displayed.
  55006. */
  55007. set displayLaserPointer(value: boolean);
  55008. /**
  55009. * The deviceOrientationCamera used as the camera when not in VR.
  55010. */
  55011. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55012. /**
  55013. * Based on the current WebVR support, returns the current VR camera used.
  55014. */
  55015. get currentVRCamera(): Nullable<Camera>;
  55016. /**
  55017. * The webVRCamera which is used when in VR.
  55018. */
  55019. get webVRCamera(): WebVRFreeCamera;
  55020. /**
  55021. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55022. */
  55023. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55024. /**
  55025. * The html button that is used to trigger entering into VR.
  55026. */
  55027. get vrButton(): Nullable<HTMLButtonElement>;
  55028. private get _teleportationRequestInitiated();
  55029. /**
  55030. * Defines whether or not Pointer lock should be requested when switching to
  55031. * full screen.
  55032. */
  55033. requestPointerLockOnFullScreen: boolean;
  55034. /**
  55035. * If asking to force XR, this will be populated with the default xr experience
  55036. */
  55037. xr: WebXRDefaultExperience;
  55038. /**
  55039. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55040. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55041. */
  55042. xrTestDone: boolean;
  55043. /**
  55044. * Instantiates a VRExperienceHelper.
  55045. * Helps to quickly add VR support to an existing scene.
  55046. * @param scene The scene the VRExperienceHelper belongs to.
  55047. * @param webVROptions Options to modify the vr experience helper's behavior.
  55048. */
  55049. constructor(scene: Scene,
  55050. /** Options to modify the vr experience helper's behavior. */
  55051. webVROptions?: VRExperienceHelperOptions);
  55052. private completeVRInit;
  55053. private _onDefaultMeshLoaded;
  55054. private _onResize;
  55055. private _onFullscreenChange;
  55056. /**
  55057. * Gets a value indicating if we are currently in VR mode.
  55058. */
  55059. get isInVRMode(): boolean;
  55060. private onVrDisplayPresentChange;
  55061. private onVRDisplayChanged;
  55062. private moveButtonToBottomRight;
  55063. private displayVRButton;
  55064. private updateButtonVisibility;
  55065. private _cachedAngularSensibility;
  55066. /**
  55067. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55068. * Otherwise, will use the fullscreen API.
  55069. */
  55070. enterVR(): void;
  55071. /**
  55072. * Attempt to exit VR, or fullscreen.
  55073. */
  55074. exitVR(): void;
  55075. /**
  55076. * The position of the vr experience helper.
  55077. */
  55078. get position(): Vector3;
  55079. /**
  55080. * Sets the position of the vr experience helper.
  55081. */
  55082. set position(value: Vector3);
  55083. /**
  55084. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55085. */
  55086. enableInteractions(): void;
  55087. private get _noControllerIsActive();
  55088. private beforeRender;
  55089. private _isTeleportationFloor;
  55090. /**
  55091. * Adds a floor mesh to be used for teleportation.
  55092. * @param floorMesh the mesh to be used for teleportation.
  55093. */
  55094. addFloorMesh(floorMesh: Mesh): void;
  55095. /**
  55096. * Removes a floor mesh from being used for teleportation.
  55097. * @param floorMesh the mesh to be removed.
  55098. */
  55099. removeFloorMesh(floorMesh: Mesh): void;
  55100. /**
  55101. * Enables interactions and teleportation using the VR controllers and gaze.
  55102. * @param vrTeleportationOptions options to modify teleportation behavior.
  55103. */
  55104. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55105. private _onNewGamepadConnected;
  55106. private _tryEnableInteractionOnController;
  55107. private _onNewGamepadDisconnected;
  55108. private _enableInteractionOnController;
  55109. private _checkTeleportWithRay;
  55110. private _checkRotate;
  55111. private _checkTeleportBackwards;
  55112. private _enableTeleportationOnController;
  55113. private _createTeleportationCircles;
  55114. private _displayTeleportationTarget;
  55115. private _hideTeleportationTarget;
  55116. private _rotateCamera;
  55117. private _moveTeleportationSelectorTo;
  55118. private _workingVector;
  55119. private _workingQuaternion;
  55120. private _workingMatrix;
  55121. /**
  55122. * Time Constant Teleportation Mode
  55123. */
  55124. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55125. /**
  55126. * Speed Constant Teleportation Mode
  55127. */
  55128. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55129. /**
  55130. * Teleports the users feet to the desired location
  55131. * @param location The location where the user's feet should be placed
  55132. */
  55133. teleportCamera(location: Vector3): void;
  55134. private _convertNormalToDirectionOfRay;
  55135. private _castRayAndSelectObject;
  55136. private _notifySelectedMeshUnselected;
  55137. /**
  55138. * Permanently set new colors for the laser pointer
  55139. * @param color the new laser color
  55140. * @param pickedColor the new laser color when picked mesh detected
  55141. */
  55142. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55143. /**
  55144. * Set lighting enabled / disabled on the laser pointer of both controllers
  55145. * @param enabled should the lighting be enabled on the laser pointer
  55146. */
  55147. setLaserLightingState(enabled?: boolean): void;
  55148. /**
  55149. * Permanently set new colors for the gaze pointer
  55150. * @param color the new gaze color
  55151. * @param pickedColor the new gaze color when picked mesh detected
  55152. */
  55153. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55154. /**
  55155. * Sets the color of the laser ray from the vr controllers.
  55156. * @param color new color for the ray.
  55157. */
  55158. changeLaserColor(color: Color3): void;
  55159. /**
  55160. * Sets the color of the ray from the vr headsets gaze.
  55161. * @param color new color for the ray.
  55162. */
  55163. changeGazeColor(color: Color3): void;
  55164. /**
  55165. * Exits VR and disposes of the vr experience helper
  55166. */
  55167. dispose(): void;
  55168. /**
  55169. * Gets the name of the VRExperienceHelper class
  55170. * @returns "VRExperienceHelper"
  55171. */
  55172. getClassName(): string;
  55173. }
  55174. }
  55175. declare module "babylonjs/Cameras/VR/index" {
  55176. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55177. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55178. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55179. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55180. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55181. export * from "babylonjs/Cameras/VR/webVRCamera";
  55182. }
  55183. declare module "babylonjs/Cameras/RigModes/index" {
  55184. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55185. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55186. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55187. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55188. }
  55189. declare module "babylonjs/Cameras/index" {
  55190. export * from "babylonjs/Cameras/Inputs/index";
  55191. export * from "babylonjs/Cameras/cameraInputsManager";
  55192. export * from "babylonjs/Cameras/camera";
  55193. export * from "babylonjs/Cameras/targetCamera";
  55194. export * from "babylonjs/Cameras/freeCamera";
  55195. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55196. export * from "babylonjs/Cameras/touchCamera";
  55197. export * from "babylonjs/Cameras/arcRotateCamera";
  55198. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55199. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55200. export * from "babylonjs/Cameras/flyCamera";
  55201. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55202. export * from "babylonjs/Cameras/followCamera";
  55203. export * from "babylonjs/Cameras/followCameraInputsManager";
  55204. export * from "babylonjs/Cameras/gamepadCamera";
  55205. export * from "babylonjs/Cameras/Stereoscopic/index";
  55206. export * from "babylonjs/Cameras/universalCamera";
  55207. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55208. export * from "babylonjs/Cameras/VR/index";
  55209. export * from "babylonjs/Cameras/RigModes/index";
  55210. }
  55211. declare module "babylonjs/Collisions/index" {
  55212. export * from "babylonjs/Collisions/collider";
  55213. export * from "babylonjs/Collisions/collisionCoordinator";
  55214. export * from "babylonjs/Collisions/pickingInfo";
  55215. export * from "babylonjs/Collisions/intersectionInfo";
  55216. export * from "babylonjs/Collisions/meshCollisionData";
  55217. }
  55218. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55219. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55220. import { Vector3 } from "babylonjs/Maths/math.vector";
  55221. import { Ray } from "babylonjs/Culling/ray";
  55222. import { Plane } from "babylonjs/Maths/math.plane";
  55223. /**
  55224. * Contains an array of blocks representing the octree
  55225. */
  55226. export interface IOctreeContainer<T> {
  55227. /**
  55228. * Blocks within the octree
  55229. */
  55230. blocks: Array<OctreeBlock<T>>;
  55231. }
  55232. /**
  55233. * Class used to store a cell in an octree
  55234. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55235. */
  55236. export class OctreeBlock<T> {
  55237. /**
  55238. * Gets the content of the current block
  55239. */
  55240. entries: T[];
  55241. /**
  55242. * Gets the list of block children
  55243. */
  55244. blocks: Array<OctreeBlock<T>>;
  55245. private _depth;
  55246. private _maxDepth;
  55247. private _capacity;
  55248. private _minPoint;
  55249. private _maxPoint;
  55250. private _boundingVectors;
  55251. private _creationFunc;
  55252. /**
  55253. * Creates a new block
  55254. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55255. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55256. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55257. * @param depth defines the current depth of this block in the octree
  55258. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55259. * @param creationFunc defines a callback to call when an element is added to the block
  55260. */
  55261. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55262. /**
  55263. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55264. */
  55265. get capacity(): number;
  55266. /**
  55267. * Gets the minimum vector (in world space) of the block's bounding box
  55268. */
  55269. get minPoint(): Vector3;
  55270. /**
  55271. * Gets the maximum vector (in world space) of the block's bounding box
  55272. */
  55273. get maxPoint(): Vector3;
  55274. /**
  55275. * Add a new element to this block
  55276. * @param entry defines the element to add
  55277. */
  55278. addEntry(entry: T): void;
  55279. /**
  55280. * Remove an element from this block
  55281. * @param entry defines the element to remove
  55282. */
  55283. removeEntry(entry: T): void;
  55284. /**
  55285. * Add an array of elements to this block
  55286. * @param entries defines the array of elements to add
  55287. */
  55288. addEntries(entries: T[]): void;
  55289. /**
  55290. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55291. * @param frustumPlanes defines the frustum planes to test
  55292. * @param selection defines the array to store current content if selection is positive
  55293. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55294. */
  55295. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55296. /**
  55297. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55298. * @param sphereCenter defines the bounding sphere center
  55299. * @param sphereRadius defines the bounding sphere radius
  55300. * @param selection defines the array to store current content if selection is positive
  55301. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55302. */
  55303. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55304. /**
  55305. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55306. * @param ray defines the ray to test with
  55307. * @param selection defines the array to store current content if selection is positive
  55308. */
  55309. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55310. /**
  55311. * Subdivide the content into child blocks (this block will then be empty)
  55312. */
  55313. createInnerBlocks(): void;
  55314. /**
  55315. * @hidden
  55316. */
  55317. 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;
  55318. }
  55319. }
  55320. declare module "babylonjs/Culling/Octrees/octree" {
  55321. import { SmartArray } from "babylonjs/Misc/smartArray";
  55322. import { Vector3 } from "babylonjs/Maths/math.vector";
  55323. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55325. import { Ray } from "babylonjs/Culling/ray";
  55326. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55327. import { Plane } from "babylonjs/Maths/math.plane";
  55328. /**
  55329. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55330. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55331. */
  55332. export class Octree<T> {
  55333. /** 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.) */
  55334. maxDepth: number;
  55335. /**
  55336. * Blocks within the octree containing objects
  55337. */
  55338. blocks: Array<OctreeBlock<T>>;
  55339. /**
  55340. * Content stored in the octree
  55341. */
  55342. dynamicContent: T[];
  55343. private _maxBlockCapacity;
  55344. private _selectionContent;
  55345. private _creationFunc;
  55346. /**
  55347. * Creates a octree
  55348. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55349. * @param creationFunc function to be used to instatiate the octree
  55350. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55351. * @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.)
  55352. */
  55353. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55354. /** 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.) */
  55355. maxDepth?: number);
  55356. /**
  55357. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55358. * @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);
  55359. * @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);
  55360. * @param entries meshes to be added to the octree blocks
  55361. */
  55362. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55363. /**
  55364. * Adds a mesh to the octree
  55365. * @param entry Mesh to add to the octree
  55366. */
  55367. addMesh(entry: T): void;
  55368. /**
  55369. * Remove an element from the octree
  55370. * @param entry defines the element to remove
  55371. */
  55372. removeMesh(entry: T): void;
  55373. /**
  55374. * Selects an array of meshes within the frustum
  55375. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55376. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55377. * @returns array of meshes within the frustum
  55378. */
  55379. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55380. /**
  55381. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55382. * @param sphereCenter defines the bounding sphere center
  55383. * @param sphereRadius defines the bounding sphere radius
  55384. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55385. * @returns an array of objects that intersect the sphere
  55386. */
  55387. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55388. /**
  55389. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55390. * @param ray defines the ray to test with
  55391. * @returns array of intersected objects
  55392. */
  55393. intersectsRay(ray: Ray): SmartArray<T>;
  55394. /**
  55395. * Adds a mesh into the octree block if it intersects the block
  55396. */
  55397. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55398. /**
  55399. * Adds a submesh into the octree block if it intersects the block
  55400. */
  55401. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55402. }
  55403. }
  55404. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55405. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55406. import { Scene } from "babylonjs/scene";
  55407. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55409. import { Ray } from "babylonjs/Culling/ray";
  55410. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55411. import { Collider } from "babylonjs/Collisions/collider";
  55412. module "babylonjs/scene" {
  55413. interface Scene {
  55414. /**
  55415. * @hidden
  55416. * Backing Filed
  55417. */
  55418. _selectionOctree: Octree<AbstractMesh>;
  55419. /**
  55420. * Gets the octree used to boost mesh selection (picking)
  55421. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55422. */
  55423. selectionOctree: Octree<AbstractMesh>;
  55424. /**
  55425. * Creates or updates the octree used to boost selection (picking)
  55426. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55427. * @param maxCapacity defines the maximum capacity per leaf
  55428. * @param maxDepth defines the maximum depth of the octree
  55429. * @returns an octree of AbstractMesh
  55430. */
  55431. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55432. }
  55433. }
  55434. module "babylonjs/Meshes/abstractMesh" {
  55435. interface AbstractMesh {
  55436. /**
  55437. * @hidden
  55438. * Backing Field
  55439. */
  55440. _submeshesOctree: Octree<SubMesh>;
  55441. /**
  55442. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55443. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55444. * @param maxCapacity defines the maximum size of each block (64 by default)
  55445. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55446. * @returns the new octree
  55447. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55448. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55449. */
  55450. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55451. }
  55452. }
  55453. /**
  55454. * Defines the octree scene component responsible to manage any octrees
  55455. * in a given scene.
  55456. */
  55457. export class OctreeSceneComponent {
  55458. /**
  55459. * The component name help to identify the component in the list of scene components.
  55460. */
  55461. readonly name: string;
  55462. /**
  55463. * The scene the component belongs to.
  55464. */
  55465. scene: Scene;
  55466. /**
  55467. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55468. */
  55469. readonly checksIsEnabled: boolean;
  55470. /**
  55471. * Creates a new instance of the component for the given scene
  55472. * @param scene Defines the scene to register the component in
  55473. */
  55474. constructor(scene: Scene);
  55475. /**
  55476. * Registers the component in a given scene
  55477. */
  55478. register(): void;
  55479. /**
  55480. * Return the list of active meshes
  55481. * @returns the list of active meshes
  55482. */
  55483. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55484. /**
  55485. * Return the list of active sub meshes
  55486. * @param mesh The mesh to get the candidates sub meshes from
  55487. * @returns the list of active sub meshes
  55488. */
  55489. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55490. private _tempRay;
  55491. /**
  55492. * Return the list of sub meshes intersecting with a given local ray
  55493. * @param mesh defines the mesh to find the submesh for
  55494. * @param localRay defines the ray in local space
  55495. * @returns the list of intersecting sub meshes
  55496. */
  55497. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55498. /**
  55499. * Return the list of sub meshes colliding with a collider
  55500. * @param mesh defines the mesh to find the submesh for
  55501. * @param collider defines the collider to evaluate the collision against
  55502. * @returns the list of colliding sub meshes
  55503. */
  55504. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55505. /**
  55506. * Rebuilds the elements related to this component in case of
  55507. * context lost for instance.
  55508. */
  55509. rebuild(): void;
  55510. /**
  55511. * Disposes the component and the associated ressources.
  55512. */
  55513. dispose(): void;
  55514. }
  55515. }
  55516. declare module "babylonjs/Culling/Octrees/index" {
  55517. export * from "babylonjs/Culling/Octrees/octree";
  55518. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55519. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55520. }
  55521. declare module "babylonjs/Culling/index" {
  55522. export * from "babylonjs/Culling/boundingBox";
  55523. export * from "babylonjs/Culling/boundingInfo";
  55524. export * from "babylonjs/Culling/boundingSphere";
  55525. export * from "babylonjs/Culling/Octrees/index";
  55526. export * from "babylonjs/Culling/ray";
  55527. }
  55528. declare module "babylonjs/Gizmos/gizmo" {
  55529. import { Nullable } from "babylonjs/types";
  55530. import { IDisposable } from "babylonjs/scene";
  55531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55532. import { Mesh } from "babylonjs/Meshes/mesh";
  55533. import { Node } from "babylonjs/node";
  55534. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55535. /**
  55536. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55537. */
  55538. export class Gizmo implements IDisposable {
  55539. /** The utility layer the gizmo will be added to */
  55540. gizmoLayer: UtilityLayerRenderer;
  55541. /**
  55542. * The root mesh of the gizmo
  55543. */
  55544. _rootMesh: Mesh;
  55545. private _attachedMesh;
  55546. private _attachedNode;
  55547. /**
  55548. * Ratio for the scale of the gizmo (Default: 1)
  55549. */
  55550. protected _scaleRatio: number;
  55551. /**
  55552. * boolean updated by pointermove when a gizmo mesh is hovered
  55553. */
  55554. protected _isHovered: boolean;
  55555. /**
  55556. * Ratio for the scale of the gizmo (Default: 1)
  55557. */
  55558. set scaleRatio(value: number);
  55559. get scaleRatio(): number;
  55560. /**
  55561. * True when the mouse pointer is hovered a gizmo mesh
  55562. */
  55563. get isHovered(): boolean;
  55564. /**
  55565. * If a custom mesh has been set (Default: false)
  55566. */
  55567. protected _customMeshSet: boolean;
  55568. /**
  55569. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55570. * * When set, interactions will be enabled
  55571. */
  55572. get attachedMesh(): Nullable<AbstractMesh>;
  55573. set attachedMesh(value: Nullable<AbstractMesh>);
  55574. /**
  55575. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55576. * * When set, interactions will be enabled
  55577. */
  55578. get attachedNode(): Nullable<Node>;
  55579. set attachedNode(value: Nullable<Node>);
  55580. /**
  55581. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55582. * @param mesh The mesh to replace the default mesh of the gizmo
  55583. */
  55584. setCustomMesh(mesh: Mesh): void;
  55585. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  55586. /**
  55587. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  55588. */
  55589. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55590. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55591. /**
  55592. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  55593. */
  55594. updateGizmoPositionToMatchAttachedMesh: boolean;
  55595. /**
  55596. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  55597. */
  55598. updateScale: boolean;
  55599. protected _interactionsEnabled: boolean;
  55600. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55601. private _beforeRenderObserver;
  55602. private _tempQuaternion;
  55603. private _tempVector;
  55604. private _tempVector2;
  55605. private _tempMatrix1;
  55606. private _tempMatrix2;
  55607. private _rightHandtoLeftHandMatrix;
  55608. /**
  55609. * Creates a gizmo
  55610. * @param gizmoLayer The utility layer the gizmo will be added to
  55611. */
  55612. constructor(
  55613. /** The utility layer the gizmo will be added to */
  55614. gizmoLayer?: UtilityLayerRenderer);
  55615. /**
  55616. * Updates the gizmo to match the attached mesh's position/rotation
  55617. */
  55618. protected _update(): void;
  55619. /**
  55620. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  55621. * @param value Node, TransformNode or mesh
  55622. */
  55623. protected _matrixChanged(): void;
  55624. /**
  55625. * Disposes of the gizmo
  55626. */
  55627. dispose(): void;
  55628. }
  55629. }
  55630. declare module "babylonjs/Gizmos/planeDragGizmo" {
  55631. import { Observable } from "babylonjs/Misc/observable";
  55632. import { Nullable } from "babylonjs/types";
  55633. import { Vector3 } from "babylonjs/Maths/math.vector";
  55634. import { Color3 } from "babylonjs/Maths/math.color";
  55635. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55636. import { Node } from "babylonjs/node";
  55637. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55638. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55639. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55640. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55641. import { Scene } from "babylonjs/scene";
  55642. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55643. /**
  55644. * Single plane drag gizmo
  55645. */
  55646. export class PlaneDragGizmo extends Gizmo {
  55647. /**
  55648. * Drag behavior responsible for the gizmos dragging interactions
  55649. */
  55650. dragBehavior: PointerDragBehavior;
  55651. private _pointerObserver;
  55652. /**
  55653. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55654. */
  55655. snapDistance: number;
  55656. /**
  55657. * Event that fires each time the gizmo snaps to a new location.
  55658. * * snapDistance is the the change in distance
  55659. */
  55660. onSnapObservable: Observable<{
  55661. snapDistance: number;
  55662. }>;
  55663. private _plane;
  55664. private _coloredMaterial;
  55665. private _hoverMaterial;
  55666. private _isEnabled;
  55667. private _parent;
  55668. /** @hidden */
  55669. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  55670. /** @hidden */
  55671. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55672. /**
  55673. * Creates a PlaneDragGizmo
  55674. * @param gizmoLayer The utility layer the gizmo will be added to
  55675. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  55676. * @param color The color of the gizmo
  55677. */
  55678. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  55679. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55680. /**
  55681. * If the gizmo is enabled
  55682. */
  55683. set isEnabled(value: boolean);
  55684. get isEnabled(): boolean;
  55685. /**
  55686. * Disposes of the gizmo
  55687. */
  55688. dispose(): void;
  55689. }
  55690. }
  55691. declare module "babylonjs/Gizmos/positionGizmo" {
  55692. import { Observable } from "babylonjs/Misc/observable";
  55693. import { Nullable } from "babylonjs/types";
  55694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55695. import { Node } from "babylonjs/node";
  55696. import { Mesh } from "babylonjs/Meshes/mesh";
  55697. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55698. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  55699. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  55700. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55701. /**
  55702. * Gizmo that enables dragging a mesh along 3 axis
  55703. */
  55704. export class PositionGizmo extends Gizmo {
  55705. /**
  55706. * Internal gizmo used for interactions on the x axis
  55707. */
  55708. xGizmo: AxisDragGizmo;
  55709. /**
  55710. * Internal gizmo used for interactions on the y axis
  55711. */
  55712. yGizmo: AxisDragGizmo;
  55713. /**
  55714. * Internal gizmo used for interactions on the z axis
  55715. */
  55716. zGizmo: AxisDragGizmo;
  55717. /**
  55718. * Internal gizmo used for interactions on the yz plane
  55719. */
  55720. xPlaneGizmo: PlaneDragGizmo;
  55721. /**
  55722. * Internal gizmo used for interactions on the xz plane
  55723. */
  55724. yPlaneGizmo: PlaneDragGizmo;
  55725. /**
  55726. * Internal gizmo used for interactions on the xy plane
  55727. */
  55728. zPlaneGizmo: PlaneDragGizmo;
  55729. /**
  55730. * private variables
  55731. */
  55732. private _meshAttached;
  55733. private _nodeAttached;
  55734. private _snapDistance;
  55735. /** Fires an event when any of it's sub gizmos are dragged */
  55736. onDragStartObservable: Observable<unknown>;
  55737. /** Fires an event when any of it's sub gizmos are released from dragging */
  55738. onDragEndObservable: Observable<unknown>;
  55739. /**
  55740. * If set to true, planar drag is enabled
  55741. */
  55742. private _planarGizmoEnabled;
  55743. get attachedMesh(): Nullable<AbstractMesh>;
  55744. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55745. get attachedNode(): Nullable<Node>;
  55746. set attachedNode(node: Nullable<Node>);
  55747. /**
  55748. * True when the mouse pointer is hovering a gizmo mesh
  55749. */
  55750. get isHovered(): boolean;
  55751. /**
  55752. * Creates a PositionGizmo
  55753. * @param gizmoLayer The utility layer the gizmo will be added to
  55754. @param thickness display gizmo axis thickness
  55755. */
  55756. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55757. /**
  55758. * If the planar drag gizmo is enabled
  55759. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  55760. */
  55761. set planarGizmoEnabled(value: boolean);
  55762. get planarGizmoEnabled(): boolean;
  55763. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55764. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55765. /**
  55766. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55767. */
  55768. set snapDistance(value: number);
  55769. get snapDistance(): number;
  55770. /**
  55771. * Ratio for the scale of the gizmo (Default: 1)
  55772. */
  55773. set scaleRatio(value: number);
  55774. get scaleRatio(): number;
  55775. /**
  55776. * Disposes of the gizmo
  55777. */
  55778. dispose(): void;
  55779. /**
  55780. * CustomMeshes are not supported by this gizmo
  55781. * @param mesh The mesh to replace the default mesh of the gizmo
  55782. */
  55783. setCustomMesh(mesh: Mesh): void;
  55784. }
  55785. }
  55786. declare module "babylonjs/Gizmos/axisDragGizmo" {
  55787. import { Observable } from "babylonjs/Misc/observable";
  55788. import { Nullable } from "babylonjs/types";
  55789. import { Vector3 } from "babylonjs/Maths/math.vector";
  55790. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55791. import { Node } from "babylonjs/node";
  55792. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55793. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55794. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55795. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55796. import { Scene } from "babylonjs/scene";
  55797. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55798. import { Color3 } from "babylonjs/Maths/math.color";
  55799. /**
  55800. * Single axis drag gizmo
  55801. */
  55802. export class AxisDragGizmo extends Gizmo {
  55803. /**
  55804. * Drag behavior responsible for the gizmos dragging interactions
  55805. */
  55806. dragBehavior: PointerDragBehavior;
  55807. private _pointerObserver;
  55808. /**
  55809. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55810. */
  55811. snapDistance: number;
  55812. /**
  55813. * Event that fires each time the gizmo snaps to a new location.
  55814. * * snapDistance is the the change in distance
  55815. */
  55816. onSnapObservable: Observable<{
  55817. snapDistance: number;
  55818. }>;
  55819. private _isEnabled;
  55820. private _parent;
  55821. private _arrow;
  55822. private _coloredMaterial;
  55823. private _hoverMaterial;
  55824. /** @hidden */
  55825. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  55826. /** @hidden */
  55827. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55828. /**
  55829. * Creates an AxisDragGizmo
  55830. * @param gizmoLayer The utility layer the gizmo will be added to
  55831. * @param dragAxis The axis which the gizmo will be able to drag on
  55832. * @param color The color of the gizmo
  55833. * @param thickness display gizmo axis thickness
  55834. */
  55835. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55836. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55837. /**
  55838. * If the gizmo is enabled
  55839. */
  55840. set isEnabled(value: boolean);
  55841. get isEnabled(): boolean;
  55842. /**
  55843. * Disposes of the gizmo
  55844. */
  55845. dispose(): void;
  55846. }
  55847. }
  55848. declare module "babylonjs/Debug/axesViewer" {
  55849. import { Vector3 } from "babylonjs/Maths/math.vector";
  55850. import { Nullable } from "babylonjs/types";
  55851. import { Scene } from "babylonjs/scene";
  55852. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55853. /**
  55854. * The Axes viewer will show 3 axes in a specific point in space
  55855. */
  55856. export class AxesViewer {
  55857. private _xAxis;
  55858. private _yAxis;
  55859. private _zAxis;
  55860. private _scaleLinesFactor;
  55861. private _instanced;
  55862. /**
  55863. * Gets the hosting scene
  55864. */
  55865. scene: Nullable<Scene>;
  55866. /**
  55867. * Gets or sets a number used to scale line length
  55868. */
  55869. scaleLines: number;
  55870. /** Gets the node hierarchy used to render x-axis */
  55871. get xAxis(): TransformNode;
  55872. /** Gets the node hierarchy used to render y-axis */
  55873. get yAxis(): TransformNode;
  55874. /** Gets the node hierarchy used to render z-axis */
  55875. get zAxis(): TransformNode;
  55876. /**
  55877. * Creates a new AxesViewer
  55878. * @param scene defines the hosting scene
  55879. * @param scaleLines defines a number used to scale line length (1 by default)
  55880. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55881. * @param xAxis defines the node hierarchy used to render the x-axis
  55882. * @param yAxis defines the node hierarchy used to render the y-axis
  55883. * @param zAxis defines the node hierarchy used to render the z-axis
  55884. */
  55885. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55886. /**
  55887. * Force the viewer to update
  55888. * @param position defines the position of the viewer
  55889. * @param xaxis defines the x axis of the viewer
  55890. * @param yaxis defines the y axis of the viewer
  55891. * @param zaxis defines the z axis of the viewer
  55892. */
  55893. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55894. /**
  55895. * Creates an instance of this axes viewer.
  55896. * @returns a new axes viewer with instanced meshes
  55897. */
  55898. createInstance(): AxesViewer;
  55899. /** Releases resources */
  55900. dispose(): void;
  55901. private static _SetRenderingGroupId;
  55902. }
  55903. }
  55904. declare module "babylonjs/Debug/boneAxesViewer" {
  55905. import { Nullable } from "babylonjs/types";
  55906. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  55907. import { Vector3 } from "babylonjs/Maths/math.vector";
  55908. import { Mesh } from "babylonjs/Meshes/mesh";
  55909. import { Bone } from "babylonjs/Bones/bone";
  55910. import { Scene } from "babylonjs/scene";
  55911. /**
  55912. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55913. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55914. */
  55915. export class BoneAxesViewer extends AxesViewer {
  55916. /**
  55917. * Gets or sets the target mesh where to display the axes viewer
  55918. */
  55919. mesh: Nullable<Mesh>;
  55920. /**
  55921. * Gets or sets the target bone where to display the axes viewer
  55922. */
  55923. bone: Nullable<Bone>;
  55924. /** Gets current position */
  55925. pos: Vector3;
  55926. /** Gets direction of X axis */
  55927. xaxis: Vector3;
  55928. /** Gets direction of Y axis */
  55929. yaxis: Vector3;
  55930. /** Gets direction of Z axis */
  55931. zaxis: Vector3;
  55932. /**
  55933. * Creates a new BoneAxesViewer
  55934. * @param scene defines the hosting scene
  55935. * @param bone defines the target bone
  55936. * @param mesh defines the target mesh
  55937. * @param scaleLines defines a scaling factor for line length (1 by default)
  55938. */
  55939. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55940. /**
  55941. * Force the viewer to update
  55942. */
  55943. update(): void;
  55944. /** Releases resources */
  55945. dispose(): void;
  55946. }
  55947. }
  55948. declare module "babylonjs/Debug/debugLayer" {
  55949. import { Scene } from "babylonjs/scene";
  55950. /**
  55951. * Interface used to define scene explorer extensibility option
  55952. */
  55953. export interface IExplorerExtensibilityOption {
  55954. /**
  55955. * Define the option label
  55956. */
  55957. label: string;
  55958. /**
  55959. * Defines the action to execute on click
  55960. */
  55961. action: (entity: any) => void;
  55962. }
  55963. /**
  55964. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55965. */
  55966. export interface IExplorerExtensibilityGroup {
  55967. /**
  55968. * Defines a predicate to test if a given type mut be extended
  55969. */
  55970. predicate: (entity: any) => boolean;
  55971. /**
  55972. * Gets the list of options added to a type
  55973. */
  55974. entries: IExplorerExtensibilityOption[];
  55975. }
  55976. /**
  55977. * Interface used to define the options to use to create the Inspector
  55978. */
  55979. export interface IInspectorOptions {
  55980. /**
  55981. * Display in overlay mode (default: false)
  55982. */
  55983. overlay?: boolean;
  55984. /**
  55985. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55986. */
  55987. globalRoot?: HTMLElement;
  55988. /**
  55989. * Display the Scene explorer
  55990. */
  55991. showExplorer?: boolean;
  55992. /**
  55993. * Display the property inspector
  55994. */
  55995. showInspector?: boolean;
  55996. /**
  55997. * Display in embed mode (both panes on the right)
  55998. */
  55999. embedMode?: boolean;
  56000. /**
  56001. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  56002. */
  56003. handleResize?: boolean;
  56004. /**
  56005. * Allow the panes to popup (default: true)
  56006. */
  56007. enablePopup?: boolean;
  56008. /**
  56009. * Allow the panes to be closed by users (default: true)
  56010. */
  56011. enableClose?: boolean;
  56012. /**
  56013. * Optional list of extensibility entries
  56014. */
  56015. explorerExtensibility?: IExplorerExtensibilityGroup[];
  56016. /**
  56017. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  56018. */
  56019. inspectorURL?: string;
  56020. /**
  56021. * Optional initial tab (default to DebugLayerTab.Properties)
  56022. */
  56023. initialTab?: DebugLayerTab;
  56024. }
  56025. module "babylonjs/scene" {
  56026. interface Scene {
  56027. /**
  56028. * @hidden
  56029. * Backing field
  56030. */
  56031. _debugLayer: DebugLayer;
  56032. /**
  56033. * Gets the debug layer (aka Inspector) associated with the scene
  56034. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56035. */
  56036. debugLayer: DebugLayer;
  56037. }
  56038. }
  56039. /**
  56040. * Enum of inspector action tab
  56041. */
  56042. export enum DebugLayerTab {
  56043. /**
  56044. * Properties tag (default)
  56045. */
  56046. Properties = 0,
  56047. /**
  56048. * Debug tab
  56049. */
  56050. Debug = 1,
  56051. /**
  56052. * Statistics tab
  56053. */
  56054. Statistics = 2,
  56055. /**
  56056. * Tools tab
  56057. */
  56058. Tools = 3,
  56059. /**
  56060. * Settings tab
  56061. */
  56062. Settings = 4
  56063. }
  56064. /**
  56065. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56066. * what is happening in your scene
  56067. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56068. */
  56069. export class DebugLayer {
  56070. /**
  56071. * Define the url to get the inspector script from.
  56072. * By default it uses the babylonjs CDN.
  56073. * @ignoreNaming
  56074. */
  56075. static InspectorURL: string;
  56076. private _scene;
  56077. private BJSINSPECTOR;
  56078. private _onPropertyChangedObservable?;
  56079. /**
  56080. * Observable triggered when a property is changed through the inspector.
  56081. */
  56082. get onPropertyChangedObservable(): any;
  56083. /**
  56084. * Instantiates a new debug layer.
  56085. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56086. * what is happening in your scene
  56087. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56088. * @param scene Defines the scene to inspect
  56089. */
  56090. constructor(scene: Scene);
  56091. /** Creates the inspector window. */
  56092. private _createInspector;
  56093. /**
  56094. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56095. * @param entity defines the entity to select
  56096. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56097. */
  56098. select(entity: any, lineContainerTitles?: string | string[]): void;
  56099. /** Get the inspector from bundle or global */
  56100. private _getGlobalInspector;
  56101. /**
  56102. * Get if the inspector is visible or not.
  56103. * @returns true if visible otherwise, false
  56104. */
  56105. isVisible(): boolean;
  56106. /**
  56107. * Hide the inspector and close its window.
  56108. */
  56109. hide(): void;
  56110. /**
  56111. * Update the scene in the inspector
  56112. */
  56113. setAsActiveScene(): void;
  56114. /**
  56115. * Launch the debugLayer.
  56116. * @param config Define the configuration of the inspector
  56117. * @return a promise fulfilled when the debug layer is visible
  56118. */
  56119. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56120. }
  56121. }
  56122. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56123. import { Nullable } from "babylonjs/types";
  56124. import { Scene } from "babylonjs/scene";
  56125. import { Vector4 } from "babylonjs/Maths/math.vector";
  56126. import { Color4 } from "babylonjs/Maths/math.color";
  56127. import { Mesh } from "babylonjs/Meshes/mesh";
  56128. /**
  56129. * Class containing static functions to help procedurally build meshes
  56130. */
  56131. export class BoxBuilder {
  56132. /**
  56133. * Creates a box mesh
  56134. * * The parameter `size` sets the size (float) of each box side (default 1)
  56135. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56136. * * 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)
  56137. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56141. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56142. * @param name defines the name of the mesh
  56143. * @param options defines the options used to create the mesh
  56144. * @param scene defines the hosting scene
  56145. * @returns the box mesh
  56146. */
  56147. static CreateBox(name: string, options: {
  56148. size?: number;
  56149. width?: number;
  56150. height?: number;
  56151. depth?: number;
  56152. faceUV?: Vector4[];
  56153. faceColors?: Color4[];
  56154. sideOrientation?: number;
  56155. frontUVs?: Vector4;
  56156. backUVs?: Vector4;
  56157. wrap?: boolean;
  56158. topBaseAt?: number;
  56159. bottomBaseAt?: number;
  56160. updatable?: boolean;
  56161. }, scene?: Nullable<Scene>): Mesh;
  56162. }
  56163. }
  56164. declare module "babylonjs/Debug/physicsViewer" {
  56165. import { Nullable } from "babylonjs/types";
  56166. import { Scene } from "babylonjs/scene";
  56167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56168. import { Mesh } from "babylonjs/Meshes/mesh";
  56169. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56170. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56171. /**
  56172. * Used to show the physics impostor around the specific mesh
  56173. */
  56174. export class PhysicsViewer {
  56175. /** @hidden */
  56176. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56177. /** @hidden */
  56178. protected _meshes: Array<Nullable<AbstractMesh>>;
  56179. /** @hidden */
  56180. protected _scene: Nullable<Scene>;
  56181. /** @hidden */
  56182. protected _numMeshes: number;
  56183. /** @hidden */
  56184. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56185. private _renderFunction;
  56186. private _utilityLayer;
  56187. private _debugBoxMesh;
  56188. private _debugSphereMesh;
  56189. private _debugCylinderMesh;
  56190. private _debugMaterial;
  56191. private _debugMeshMeshes;
  56192. /**
  56193. * Creates a new PhysicsViewer
  56194. * @param scene defines the hosting scene
  56195. */
  56196. constructor(scene: Scene);
  56197. /** @hidden */
  56198. protected _updateDebugMeshes(): void;
  56199. /**
  56200. * Renders a specified physic impostor
  56201. * @param impostor defines the impostor to render
  56202. * @param targetMesh defines the mesh represented by the impostor
  56203. * @returns the new debug mesh used to render the impostor
  56204. */
  56205. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56206. /**
  56207. * Hides a specified physic impostor
  56208. * @param impostor defines the impostor to hide
  56209. */
  56210. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56211. private _getDebugMaterial;
  56212. private _getDebugBoxMesh;
  56213. private _getDebugSphereMesh;
  56214. private _getDebugCylinderMesh;
  56215. private _getDebugMeshMesh;
  56216. private _getDebugMesh;
  56217. /** Releases all resources */
  56218. dispose(): void;
  56219. }
  56220. }
  56221. declare module "babylonjs/Debug/rayHelper" {
  56222. import { Nullable } from "babylonjs/types";
  56223. import { Ray } from "babylonjs/Culling/ray";
  56224. import { Vector3 } from "babylonjs/Maths/math.vector";
  56225. import { Color3 } from "babylonjs/Maths/math.color";
  56226. import { Scene } from "babylonjs/scene";
  56227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56228. import "babylonjs/Meshes/Builders/linesBuilder";
  56229. /**
  56230. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56231. * in order to better appreciate the issue one might have.
  56232. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56233. */
  56234. export class RayHelper {
  56235. /**
  56236. * Defines the ray we are currently tryin to visualize.
  56237. */
  56238. ray: Nullable<Ray>;
  56239. private _renderPoints;
  56240. private _renderLine;
  56241. private _renderFunction;
  56242. private _scene;
  56243. private _onAfterRenderObserver;
  56244. private _onAfterStepObserver;
  56245. private _attachedToMesh;
  56246. private _meshSpaceDirection;
  56247. private _meshSpaceOrigin;
  56248. /**
  56249. * Helper function to create a colored helper in a scene in one line.
  56250. * @param ray Defines the ray we are currently tryin to visualize
  56251. * @param scene Defines the scene the ray is used in
  56252. * @param color Defines the color we want to see the ray in
  56253. * @returns The newly created ray helper.
  56254. */
  56255. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56256. /**
  56257. * Instantiate a new ray helper.
  56258. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56259. * in order to better appreciate the issue one might have.
  56260. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56261. * @param ray Defines the ray we are currently tryin to visualize
  56262. */
  56263. constructor(ray: Ray);
  56264. /**
  56265. * Shows the ray we are willing to debug.
  56266. * @param scene Defines the scene the ray needs to be rendered in
  56267. * @param color Defines the color the ray needs to be rendered in
  56268. */
  56269. show(scene: Scene, color?: Color3): void;
  56270. /**
  56271. * Hides the ray we are debugging.
  56272. */
  56273. hide(): void;
  56274. private _render;
  56275. /**
  56276. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56277. * @param mesh Defines the mesh we want the helper attached to
  56278. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56279. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56280. * @param length Defines the length of the ray
  56281. */
  56282. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56283. /**
  56284. * Detach the ray helper from the mesh it has previously been attached to.
  56285. */
  56286. detachFromMesh(): void;
  56287. private _updateToMesh;
  56288. /**
  56289. * Dispose the helper and release its associated resources.
  56290. */
  56291. dispose(): void;
  56292. }
  56293. }
  56294. declare module "babylonjs/Debug/ISkeletonViewer" {
  56295. import { Skeleton } from "babylonjs/Bones/skeleton";
  56296. import { Color3 } from "babylonjs/Maths/math.color";
  56297. /**
  56298. * Defines the options associated with the creation of a SkeletonViewer.
  56299. */
  56300. export interface ISkeletonViewerOptions {
  56301. /** Should the system pause animations before building the Viewer? */
  56302. pauseAnimations: boolean;
  56303. /** Should the system return the skeleton to rest before building? */
  56304. returnToRest: boolean;
  56305. /** public Display Mode of the Viewer */
  56306. displayMode: number;
  56307. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56308. displayOptions: ISkeletonViewerDisplayOptions;
  56309. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56310. computeBonesUsingShaders: boolean;
  56311. /** Flag ignore non weighted bones */
  56312. useAllBones: boolean;
  56313. }
  56314. /**
  56315. * Defines how to display the various bone meshes for the viewer.
  56316. */
  56317. export interface ISkeletonViewerDisplayOptions {
  56318. /** How far down to start tapering the bone spurs */
  56319. midStep?: number;
  56320. /** How big is the midStep? */
  56321. midStepFactor?: number;
  56322. /** Base for the Sphere Size */
  56323. sphereBaseSize?: number;
  56324. /** The ratio of the sphere to the longest bone in units */
  56325. sphereScaleUnit?: number;
  56326. /** Ratio for the Sphere Size */
  56327. sphereFactor?: number;
  56328. /** Whether a spur should attach its far end to the child bone position */
  56329. spurFollowsChild?: boolean;
  56330. /** Whether to show local axes or not */
  56331. showLocalAxes?: boolean;
  56332. /** Length of each local axis */
  56333. localAxesSize?: number;
  56334. }
  56335. /**
  56336. * Defines the constructor options for the BoneWeight Shader.
  56337. */
  56338. export interface IBoneWeightShaderOptions {
  56339. /** Skeleton to Map */
  56340. skeleton: Skeleton;
  56341. /** Colors for Uninfluenced bones */
  56342. colorBase?: Color3;
  56343. /** Colors for 0.0-0.25 Weight bones */
  56344. colorZero?: Color3;
  56345. /** Color for 0.25-0.5 Weight Influence */
  56346. colorQuarter?: Color3;
  56347. /** Color for 0.5-0.75 Weight Influence */
  56348. colorHalf?: Color3;
  56349. /** Color for 0.75-1 Weight Influence */
  56350. colorFull?: Color3;
  56351. /** Color for Zero Weight Influence */
  56352. targetBoneIndex?: number;
  56353. }
  56354. /**
  56355. * Simple structure of the gradient steps for the Color Map.
  56356. */
  56357. export interface ISkeletonMapShaderColorMapKnot {
  56358. /** Color of the Knot */
  56359. color: Color3;
  56360. /** Location of the Knot */
  56361. location: number;
  56362. }
  56363. /**
  56364. * Defines the constructor options for the SkeletonMap Shader.
  56365. */
  56366. export interface ISkeletonMapShaderOptions {
  56367. /** Skeleton to Map */
  56368. skeleton: Skeleton;
  56369. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56370. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56371. }
  56372. }
  56373. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56374. import { Nullable } from "babylonjs/types";
  56375. import { Scene } from "babylonjs/scene";
  56376. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56377. import { Color4 } from "babylonjs/Maths/math.color";
  56378. import { Mesh } from "babylonjs/Meshes/mesh";
  56379. /**
  56380. * Class containing static functions to help procedurally build meshes
  56381. */
  56382. export class RibbonBuilder {
  56383. /**
  56384. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56385. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56386. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56387. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56388. * * 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
  56389. * * 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
  56390. * * 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
  56391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56394. * * 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
  56395. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56396. * * 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
  56397. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56399. * @param name defines the name of the mesh
  56400. * @param options defines the options used to create the mesh
  56401. * @param scene defines the hosting scene
  56402. * @returns the ribbon mesh
  56403. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56404. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56405. */
  56406. static CreateRibbon(name: string, options: {
  56407. pathArray: Vector3[][];
  56408. closeArray?: boolean;
  56409. closePath?: boolean;
  56410. offset?: number;
  56411. updatable?: boolean;
  56412. sideOrientation?: number;
  56413. frontUVs?: Vector4;
  56414. backUVs?: Vector4;
  56415. instance?: Mesh;
  56416. invertUV?: boolean;
  56417. uvs?: Vector2[];
  56418. colors?: Color4[];
  56419. }, scene?: Nullable<Scene>): Mesh;
  56420. }
  56421. }
  56422. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56423. import { Nullable } from "babylonjs/types";
  56424. import { Scene } from "babylonjs/scene";
  56425. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56426. import { Mesh } from "babylonjs/Meshes/mesh";
  56427. /**
  56428. * Class containing static functions to help procedurally build meshes
  56429. */
  56430. export class ShapeBuilder {
  56431. /**
  56432. * 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.
  56433. * * 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.
  56434. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56435. * * 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.
  56436. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56437. * * 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
  56438. * * 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
  56439. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56444. * @param name defines the name of the mesh
  56445. * @param options defines the options used to create the mesh
  56446. * @param scene defines the hosting scene
  56447. * @returns the extruded shape mesh
  56448. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56450. */
  56451. static ExtrudeShape(name: string, options: {
  56452. shape: Vector3[];
  56453. path: Vector3[];
  56454. scale?: number;
  56455. rotation?: number;
  56456. cap?: number;
  56457. updatable?: boolean;
  56458. sideOrientation?: number;
  56459. frontUVs?: Vector4;
  56460. backUVs?: Vector4;
  56461. instance?: Mesh;
  56462. invertUV?: boolean;
  56463. }, scene?: Nullable<Scene>): Mesh;
  56464. /**
  56465. * Creates an custom extruded shape mesh.
  56466. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56467. * * 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.
  56468. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56469. * * 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
  56470. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56471. * * 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
  56472. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56473. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56474. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56475. * * 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
  56476. * * 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
  56477. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56480. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56482. * @param name defines the name of the mesh
  56483. * @param options defines the options used to create the mesh
  56484. * @param scene defines the hosting scene
  56485. * @returns the custom extruded shape mesh
  56486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56487. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56489. */
  56490. static ExtrudeShapeCustom(name: string, options: {
  56491. shape: Vector3[];
  56492. path: Vector3[];
  56493. scaleFunction?: any;
  56494. rotationFunction?: any;
  56495. ribbonCloseArray?: boolean;
  56496. ribbonClosePath?: boolean;
  56497. cap?: number;
  56498. updatable?: boolean;
  56499. sideOrientation?: number;
  56500. frontUVs?: Vector4;
  56501. backUVs?: Vector4;
  56502. instance?: Mesh;
  56503. invertUV?: boolean;
  56504. }, scene?: Nullable<Scene>): Mesh;
  56505. private static _ExtrudeShapeGeneric;
  56506. }
  56507. }
  56508. declare module "babylonjs/Debug/skeletonViewer" {
  56509. import { Color3 } from "babylonjs/Maths/math.color";
  56510. import { Scene } from "babylonjs/scene";
  56511. import { Nullable } from "babylonjs/types";
  56512. import { Skeleton } from "babylonjs/Bones/skeleton";
  56513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56514. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56515. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56516. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56517. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56518. /**
  56519. * Class used to render a debug view of a given skeleton
  56520. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56521. */
  56522. export class SkeletonViewer {
  56523. /** defines the skeleton to render */
  56524. skeleton: Skeleton;
  56525. /** defines the mesh attached to the skeleton */
  56526. mesh: AbstractMesh;
  56527. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56528. autoUpdateBonesMatrices: boolean;
  56529. /** defines the rendering group id to use with the viewer */
  56530. renderingGroupId: number;
  56531. /** is the options for the viewer */
  56532. options: Partial<ISkeletonViewerOptions>;
  56533. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56534. static readonly DISPLAY_LINES: number;
  56535. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56536. static readonly DISPLAY_SPHERES: number;
  56537. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56538. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56539. /** public static method to create a BoneWeight Shader
  56540. * @param options The constructor options
  56541. * @param scene The scene that the shader is scoped to
  56542. * @returns The created ShaderMaterial
  56543. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56544. */
  56545. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56546. /** public static method to create a BoneWeight Shader
  56547. * @param options The constructor options
  56548. * @param scene The scene that the shader is scoped to
  56549. * @returns The created ShaderMaterial
  56550. */
  56551. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56552. /** private static method to create a BoneWeight Shader
  56553. * @param size The size of the buffer to create (usually the bone count)
  56554. * @param colorMap The gradient data to generate
  56555. * @param scene The scene that the shader is scoped to
  56556. * @returns an Array of floats from the color gradient values
  56557. */
  56558. private static _CreateBoneMapColorBuffer;
  56559. /** If SkeletonViewer scene scope. */
  56560. private _scene;
  56561. /** Gets or sets the color used to render the skeleton */
  56562. color: Color3;
  56563. /** Array of the points of the skeleton fo the line view. */
  56564. private _debugLines;
  56565. /** The SkeletonViewers Mesh. */
  56566. private _debugMesh;
  56567. /** The local axes Meshes. */
  56568. private _localAxes;
  56569. /** If SkeletonViewer is enabled. */
  56570. private _isEnabled;
  56571. /** If SkeletonViewer is ready. */
  56572. private _ready;
  56573. /** SkeletonViewer render observable. */
  56574. private _obs;
  56575. /** The Utility Layer to render the gizmos in. */
  56576. private _utilityLayer;
  56577. private _boneIndices;
  56578. /** Gets the Scene. */
  56579. get scene(): Scene;
  56580. /** Gets the utilityLayer. */
  56581. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  56582. /** Checks Ready Status. */
  56583. get isReady(): Boolean;
  56584. /** Sets Ready Status. */
  56585. set ready(value: boolean);
  56586. /** Gets the debugMesh */
  56587. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  56588. /** Sets the debugMesh */
  56589. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  56590. /** Gets the displayMode */
  56591. get displayMode(): number;
  56592. /** Sets the displayMode */
  56593. set displayMode(value: number);
  56594. /**
  56595. * Creates a new SkeletonViewer
  56596. * @param skeleton defines the skeleton to render
  56597. * @param mesh defines the mesh attached to the skeleton
  56598. * @param scene defines the hosting scene
  56599. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  56600. * @param renderingGroupId defines the rendering group id to use with the viewer
  56601. * @param options All of the extra constructor options for the SkeletonViewer
  56602. */
  56603. constructor(
  56604. /** defines the skeleton to render */
  56605. skeleton: Skeleton,
  56606. /** defines the mesh attached to the skeleton */
  56607. mesh: AbstractMesh,
  56608. /** The Scene scope*/
  56609. scene: Scene,
  56610. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56611. autoUpdateBonesMatrices?: boolean,
  56612. /** defines the rendering group id to use with the viewer */
  56613. renderingGroupId?: number,
  56614. /** is the options for the viewer */
  56615. options?: Partial<ISkeletonViewerOptions>);
  56616. /** The Dynamic bindings for the update functions */
  56617. private _bindObs;
  56618. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  56619. update(): void;
  56620. /** Gets or sets a boolean indicating if the viewer is enabled */
  56621. set isEnabled(value: boolean);
  56622. get isEnabled(): boolean;
  56623. private _getBonePosition;
  56624. private _getLinesForBonesWithLength;
  56625. private _getLinesForBonesNoLength;
  56626. /** function to revert the mesh and scene back to the initial state. */
  56627. private _revert;
  56628. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  56629. private _getAbsoluteBindPoseToRef;
  56630. /** function to build and bind sphere joint points and spur bone representations. */
  56631. private _buildSpheresAndSpurs;
  56632. private _buildLocalAxes;
  56633. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  56634. private _displayLinesUpdate;
  56635. /** Changes the displayMode of the skeleton viewer
  56636. * @param mode The displayMode numerical value
  56637. */
  56638. changeDisplayMode(mode: number): void;
  56639. /** Sets a display option of the skeleton viewer
  56640. *
  56641. * | Option | Type | Default | Description |
  56642. * | ---------------- | ------- | ------- | ----------- |
  56643. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56644. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56645. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56646. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  56647. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  56648. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  56649. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  56650. *
  56651. * @param option String of the option name
  56652. * @param value The numerical option value
  56653. */
  56654. changeDisplayOptions(option: string, value: number): void;
  56655. /** Release associated resources */
  56656. dispose(): void;
  56657. }
  56658. }
  56659. declare module "babylonjs/Debug/index" {
  56660. export * from "babylonjs/Debug/axesViewer";
  56661. export * from "babylonjs/Debug/boneAxesViewer";
  56662. export * from "babylonjs/Debug/debugLayer";
  56663. export * from "babylonjs/Debug/physicsViewer";
  56664. export * from "babylonjs/Debug/rayHelper";
  56665. export * from "babylonjs/Debug/skeletonViewer";
  56666. export * from "babylonjs/Debug/ISkeletonViewer";
  56667. }
  56668. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  56669. /**
  56670. * Enum for Device Types
  56671. */
  56672. export enum DeviceType {
  56673. /** Generic */
  56674. Generic = 0,
  56675. /** Keyboard */
  56676. Keyboard = 1,
  56677. /** Mouse */
  56678. Mouse = 2,
  56679. /** Touch Pointers */
  56680. Touch = 3,
  56681. /** PS4 Dual Shock */
  56682. DualShock = 4,
  56683. /** Xbox */
  56684. Xbox = 5,
  56685. /** Switch Controller */
  56686. Switch = 6
  56687. }
  56688. /**
  56689. * Enum for All Pointers (Touch/Mouse)
  56690. */
  56691. export enum PointerInput {
  56692. /** Horizontal Axis */
  56693. Horizontal = 0,
  56694. /** Vertical Axis */
  56695. Vertical = 1,
  56696. /** Left Click or Touch */
  56697. LeftClick = 2,
  56698. /** Middle Click */
  56699. MiddleClick = 3,
  56700. /** Right Click */
  56701. RightClick = 4,
  56702. /** Browser Back */
  56703. BrowserBack = 5,
  56704. /** Browser Forward */
  56705. BrowserForward = 6
  56706. }
  56707. /**
  56708. * Enum for Dual Shock Gamepad
  56709. */
  56710. export enum DualShockInput {
  56711. /** Cross */
  56712. Cross = 0,
  56713. /** Circle */
  56714. Circle = 1,
  56715. /** Square */
  56716. Square = 2,
  56717. /** Triangle */
  56718. Triangle = 3,
  56719. /** L1 */
  56720. L1 = 4,
  56721. /** R1 */
  56722. R1 = 5,
  56723. /** L2 */
  56724. L2 = 6,
  56725. /** R2 */
  56726. R2 = 7,
  56727. /** Share */
  56728. Share = 8,
  56729. /** Options */
  56730. Options = 9,
  56731. /** L3 */
  56732. L3 = 10,
  56733. /** R3 */
  56734. R3 = 11,
  56735. /** DPadUp */
  56736. DPadUp = 12,
  56737. /** DPadDown */
  56738. DPadDown = 13,
  56739. /** DPadLeft */
  56740. DPadLeft = 14,
  56741. /** DRight */
  56742. DPadRight = 15,
  56743. /** Home */
  56744. Home = 16,
  56745. /** TouchPad */
  56746. TouchPad = 17,
  56747. /** LStickXAxis */
  56748. LStickXAxis = 18,
  56749. /** LStickYAxis */
  56750. LStickYAxis = 19,
  56751. /** RStickXAxis */
  56752. RStickXAxis = 20,
  56753. /** RStickYAxis */
  56754. RStickYAxis = 21
  56755. }
  56756. /**
  56757. * Enum for Xbox Gamepad
  56758. */
  56759. export enum XboxInput {
  56760. /** A */
  56761. A = 0,
  56762. /** B */
  56763. B = 1,
  56764. /** X */
  56765. X = 2,
  56766. /** Y */
  56767. Y = 3,
  56768. /** LB */
  56769. LB = 4,
  56770. /** RB */
  56771. RB = 5,
  56772. /** LT */
  56773. LT = 6,
  56774. /** RT */
  56775. RT = 7,
  56776. /** Back */
  56777. Back = 8,
  56778. /** Start */
  56779. Start = 9,
  56780. /** LS */
  56781. LS = 10,
  56782. /** RS */
  56783. RS = 11,
  56784. /** DPadUp */
  56785. DPadUp = 12,
  56786. /** DPadDown */
  56787. DPadDown = 13,
  56788. /** DPadLeft */
  56789. DPadLeft = 14,
  56790. /** DRight */
  56791. DPadRight = 15,
  56792. /** Home */
  56793. Home = 16,
  56794. /** LStickXAxis */
  56795. LStickXAxis = 17,
  56796. /** LStickYAxis */
  56797. LStickYAxis = 18,
  56798. /** RStickXAxis */
  56799. RStickXAxis = 19,
  56800. /** RStickYAxis */
  56801. RStickYAxis = 20
  56802. }
  56803. /**
  56804. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  56805. */
  56806. export enum SwitchInput {
  56807. /** B */
  56808. B = 0,
  56809. /** A */
  56810. A = 1,
  56811. /** Y */
  56812. Y = 2,
  56813. /** X */
  56814. X = 3,
  56815. /** L */
  56816. L = 4,
  56817. /** R */
  56818. R = 5,
  56819. /** ZL */
  56820. ZL = 6,
  56821. /** ZR */
  56822. ZR = 7,
  56823. /** Minus */
  56824. Minus = 8,
  56825. /** Plus */
  56826. Plus = 9,
  56827. /** LS */
  56828. LS = 10,
  56829. /** RS */
  56830. RS = 11,
  56831. /** DPadUp */
  56832. DPadUp = 12,
  56833. /** DPadDown */
  56834. DPadDown = 13,
  56835. /** DPadLeft */
  56836. DPadLeft = 14,
  56837. /** DRight */
  56838. DPadRight = 15,
  56839. /** Home */
  56840. Home = 16,
  56841. /** Capture */
  56842. Capture = 17,
  56843. /** LStickXAxis */
  56844. LStickXAxis = 18,
  56845. /** LStickYAxis */
  56846. LStickYAxis = 19,
  56847. /** RStickXAxis */
  56848. RStickXAxis = 20,
  56849. /** RStickYAxis */
  56850. RStickYAxis = 21
  56851. }
  56852. }
  56853. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  56854. import { Engine } from "babylonjs/Engines/engine";
  56855. import { IDisposable } from "babylonjs/scene";
  56856. import { Nullable } from "babylonjs/types";
  56857. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56858. /**
  56859. * This class will take all inputs from Keyboard, Pointer, and
  56860. * any Gamepads and provide a polling system that all devices
  56861. * will use. This class assumes that there will only be one
  56862. * pointer device and one keyboard.
  56863. */
  56864. export class DeviceInputSystem implements IDisposable {
  56865. /**
  56866. * Callback to be triggered when a device is connected
  56867. */
  56868. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56869. /**
  56870. * Callback to be triggered when a device is disconnected
  56871. */
  56872. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  56873. /**
  56874. * Callback to be triggered when event driven input is updated
  56875. */
  56876. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  56877. private _inputs;
  56878. private _gamepads;
  56879. private _keyboardActive;
  56880. private _pointerActive;
  56881. private _elementToAttachTo;
  56882. private _keyboardDownEvent;
  56883. private _keyboardUpEvent;
  56884. private _pointerMoveEvent;
  56885. private _pointerDownEvent;
  56886. private _pointerUpEvent;
  56887. private _gamepadConnectedEvent;
  56888. private _gamepadDisconnectedEvent;
  56889. private static _MAX_KEYCODES;
  56890. private static _MAX_POINTER_INPUTS;
  56891. private constructor();
  56892. /**
  56893. * Creates a new DeviceInputSystem instance
  56894. * @param engine Engine to pull input element from
  56895. * @returns The new instance
  56896. */
  56897. static Create(engine: Engine): DeviceInputSystem;
  56898. /**
  56899. * Checks for current device input value, given an id and input index
  56900. * @param deviceName Id of connected device
  56901. * @param inputIndex Index of device input
  56902. * @returns Current value of input
  56903. */
  56904. /**
  56905. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  56906. * @param deviceType Enum specifiying device type
  56907. * @param deviceSlot "Slot" or index that device is referenced in
  56908. * @param inputIndex Id of input to be checked
  56909. * @returns Current value of input
  56910. */
  56911. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  56912. /**
  56913. * Dispose of all the eventlisteners
  56914. */
  56915. dispose(): void;
  56916. /**
  56917. * Add device and inputs to device array
  56918. * @param deviceType Enum specifiying device type
  56919. * @param deviceSlot "Slot" or index that device is referenced in
  56920. * @param numberOfInputs Number of input entries to create for given device
  56921. */
  56922. private _registerDevice;
  56923. /**
  56924. * Given a specific device name, remove that device from the device map
  56925. * @param deviceType Enum specifiying device type
  56926. * @param deviceSlot "Slot" or index that device is referenced in
  56927. */
  56928. private _unregisterDevice;
  56929. /**
  56930. * Handle all actions that come from keyboard interaction
  56931. */
  56932. private _handleKeyActions;
  56933. /**
  56934. * Handle all actions that come from pointer interaction
  56935. */
  56936. private _handlePointerActions;
  56937. /**
  56938. * Handle all actions that come from gamepad interaction
  56939. */
  56940. private _handleGamepadActions;
  56941. /**
  56942. * Update all non-event based devices with each frame
  56943. * @param deviceType Enum specifiying device type
  56944. * @param deviceSlot "Slot" or index that device is referenced in
  56945. * @param inputIndex Id of input to be checked
  56946. */
  56947. private _updateDevice;
  56948. /**
  56949. * Gets DeviceType from the device name
  56950. * @param deviceName Name of Device from DeviceInputSystem
  56951. * @returns DeviceType enum value
  56952. */
  56953. private _getGamepadDeviceType;
  56954. }
  56955. }
  56956. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  56957. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56958. /**
  56959. * Type to handle enforcement of inputs
  56960. */
  56961. 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;
  56962. }
  56963. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  56964. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  56965. import { Engine } from "babylonjs/Engines/engine";
  56966. import { IDisposable } from "babylonjs/scene";
  56967. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  56968. import { Nullable } from "babylonjs/types";
  56969. import { Observable } from "babylonjs/Misc/observable";
  56970. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  56971. /**
  56972. * Class that handles all input for a specific device
  56973. */
  56974. export class DeviceSource<T extends DeviceType> {
  56975. /** Type of device */
  56976. readonly deviceType: DeviceType;
  56977. /** "Slot" or index that device is referenced in */
  56978. readonly deviceSlot: number;
  56979. /**
  56980. * Observable to handle device input changes per device
  56981. */
  56982. readonly onInputChangedObservable: Observable<{
  56983. inputIndex: DeviceInput<T>;
  56984. previousState: Nullable<number>;
  56985. currentState: Nullable<number>;
  56986. }>;
  56987. private readonly _deviceInputSystem;
  56988. /**
  56989. * Default Constructor
  56990. * @param deviceInputSystem Reference to DeviceInputSystem
  56991. * @param deviceType Type of device
  56992. * @param deviceSlot "Slot" or index that device is referenced in
  56993. */
  56994. constructor(deviceInputSystem: DeviceInputSystem,
  56995. /** Type of device */
  56996. deviceType: DeviceType,
  56997. /** "Slot" or index that device is referenced in */
  56998. deviceSlot?: number);
  56999. /**
  57000. * Get input for specific input
  57001. * @param inputIndex index of specific input on device
  57002. * @returns Input value from DeviceInputSystem
  57003. */
  57004. getInput(inputIndex: DeviceInput<T>): number;
  57005. }
  57006. /**
  57007. * Class to keep track of devices
  57008. */
  57009. export class DeviceSourceManager implements IDisposable {
  57010. /**
  57011. * Observable to be triggered when before a device is connected
  57012. */
  57013. readonly onBeforeDeviceConnectedObservable: Observable<{
  57014. deviceType: DeviceType;
  57015. deviceSlot: number;
  57016. }>;
  57017. /**
  57018. * Observable to be triggered when before a device is disconnected
  57019. */
  57020. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  57021. deviceType: DeviceType;
  57022. deviceSlot: number;
  57023. }>;
  57024. /**
  57025. * Observable to be triggered when after a device is connected
  57026. */
  57027. readonly onAfterDeviceConnectedObservable: Observable<{
  57028. deviceType: DeviceType;
  57029. deviceSlot: number;
  57030. }>;
  57031. /**
  57032. * Observable to be triggered when after a device is disconnected
  57033. */
  57034. readonly onAfterDeviceDisconnectedObservable: Observable<{
  57035. deviceType: DeviceType;
  57036. deviceSlot: number;
  57037. }>;
  57038. private readonly _devices;
  57039. private readonly _firstDevice;
  57040. private readonly _deviceInputSystem;
  57041. /**
  57042. * Default Constructor
  57043. * @param engine engine to pull input element from
  57044. */
  57045. constructor(engine: Engine);
  57046. /**
  57047. * Gets a DeviceSource, given a type and slot
  57048. * @param deviceType Enum specifying device type
  57049. * @param deviceSlot "Slot" or index that device is referenced in
  57050. * @returns DeviceSource object
  57051. */
  57052. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  57053. /**
  57054. * Gets an array of DeviceSource objects for a given device type
  57055. * @param deviceType Enum specifying device type
  57056. * @returns Array of DeviceSource objects
  57057. */
  57058. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  57059. /**
  57060. * Dispose of DeviceInputSystem and other parts
  57061. */
  57062. dispose(): void;
  57063. /**
  57064. * Function to add device name to device list
  57065. * @param deviceType Enum specifying device type
  57066. * @param deviceSlot "Slot" or index that device is referenced in
  57067. */
  57068. private _addDevice;
  57069. /**
  57070. * Function to remove device name to device list
  57071. * @param deviceType Enum specifying device type
  57072. * @param deviceSlot "Slot" or index that device is referenced in
  57073. */
  57074. private _removeDevice;
  57075. /**
  57076. * Updates array storing first connected device of each type
  57077. * @param type Type of Device
  57078. */
  57079. private _updateFirstDevices;
  57080. }
  57081. }
  57082. declare module "babylonjs/DeviceInput/index" {
  57083. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57084. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57085. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57086. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57087. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57088. }
  57089. declare module "babylonjs/Engines/nullEngine" {
  57090. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57091. import { Engine } from "babylonjs/Engines/engine";
  57092. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57093. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57094. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57095. import { Effect } from "babylonjs/Materials/effect";
  57096. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57097. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57098. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57099. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57100. /**
  57101. * Options to create the null engine
  57102. */
  57103. export class NullEngineOptions {
  57104. /**
  57105. * Render width (Default: 512)
  57106. */
  57107. renderWidth: number;
  57108. /**
  57109. * Render height (Default: 256)
  57110. */
  57111. renderHeight: number;
  57112. /**
  57113. * Texture size (Default: 512)
  57114. */
  57115. textureSize: number;
  57116. /**
  57117. * If delta time between frames should be constant
  57118. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57119. */
  57120. deterministicLockstep: boolean;
  57121. /**
  57122. * Maximum about of steps between frames (Default: 4)
  57123. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57124. */
  57125. lockstepMaxSteps: number;
  57126. /**
  57127. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57128. */
  57129. useHighPrecisionMatrix?: boolean;
  57130. }
  57131. /**
  57132. * The null engine class provides support for headless version of babylon.js.
  57133. * This can be used in server side scenario or for testing purposes
  57134. */
  57135. export class NullEngine extends Engine {
  57136. private _options;
  57137. /**
  57138. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57139. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57140. * @returns true if engine is in deterministic lock step mode
  57141. */
  57142. isDeterministicLockStep(): boolean;
  57143. /**
  57144. * Gets the max steps when engine is running in deterministic lock step
  57145. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57146. * @returns the max steps
  57147. */
  57148. getLockstepMaxSteps(): number;
  57149. /**
  57150. * Gets the current hardware scaling level.
  57151. * By default the hardware scaling level is computed from the window device ratio.
  57152. * 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.
  57153. * @returns a number indicating the current hardware scaling level
  57154. */
  57155. getHardwareScalingLevel(): number;
  57156. constructor(options?: NullEngineOptions);
  57157. /**
  57158. * Creates a vertex buffer
  57159. * @param vertices the data for the vertex buffer
  57160. * @returns the new WebGL static buffer
  57161. */
  57162. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57163. /**
  57164. * Creates a new index buffer
  57165. * @param indices defines the content of the index buffer
  57166. * @param updatable defines if the index buffer must be updatable
  57167. * @returns a new webGL buffer
  57168. */
  57169. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57170. /**
  57171. * Clear the current render buffer or the current render target (if any is set up)
  57172. * @param color defines the color to use
  57173. * @param backBuffer defines if the back buffer must be cleared
  57174. * @param depth defines if the depth buffer must be cleared
  57175. * @param stencil defines if the stencil buffer must be cleared
  57176. */
  57177. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57178. /**
  57179. * Gets the current render width
  57180. * @param useScreen defines if screen size must be used (or the current render target if any)
  57181. * @returns a number defining the current render width
  57182. */
  57183. getRenderWidth(useScreen?: boolean): number;
  57184. /**
  57185. * Gets the current render height
  57186. * @param useScreen defines if screen size must be used (or the current render target if any)
  57187. * @returns a number defining the current render height
  57188. */
  57189. getRenderHeight(useScreen?: boolean): number;
  57190. /**
  57191. * Set the WebGL's viewport
  57192. * @param viewport defines the viewport element to be used
  57193. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57194. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57195. */
  57196. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57197. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57198. /**
  57199. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57200. * @param pipelineContext defines the pipeline context to use
  57201. * @param uniformsNames defines the list of uniform names
  57202. * @returns an array of webGL uniform locations
  57203. */
  57204. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57205. /**
  57206. * Gets the lsit of active attributes for a given webGL program
  57207. * @param pipelineContext defines the pipeline context to use
  57208. * @param attributesNames defines the list of attribute names to get
  57209. * @returns an array of indices indicating the offset of each attribute
  57210. */
  57211. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57212. /**
  57213. * Binds an effect to the webGL context
  57214. * @param effect defines the effect to bind
  57215. */
  57216. bindSamplers(effect: Effect): void;
  57217. /**
  57218. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57219. * @param effect defines the effect to activate
  57220. */
  57221. enableEffect(effect: Effect): void;
  57222. /**
  57223. * Set various states to the webGL context
  57224. * @param culling defines backface culling state
  57225. * @param zOffset defines the value to apply to zOffset (0 by default)
  57226. * @param force defines if states must be applied even if cache is up to date
  57227. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57228. */
  57229. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57230. /**
  57231. * Set the value of an uniform to an array of int32
  57232. * @param uniform defines the webGL uniform location where to store the value
  57233. * @param array defines the array of int32 to store
  57234. * @returns true if value was set
  57235. */
  57236. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57237. /**
  57238. * Set the value of an uniform to an array of int32 (stored as vec2)
  57239. * @param uniform defines the webGL uniform location where to store the value
  57240. * @param array defines the array of int32 to store
  57241. * @returns true if value was set
  57242. */
  57243. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57244. /**
  57245. * Set the value of an uniform to an array of int32 (stored as vec3)
  57246. * @param uniform defines the webGL uniform location where to store the value
  57247. * @param array defines the array of int32 to store
  57248. * @returns true if value was set
  57249. */
  57250. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57251. /**
  57252. * Set the value of an uniform to an array of int32 (stored as vec4)
  57253. * @param uniform defines the webGL uniform location where to store the value
  57254. * @param array defines the array of int32 to store
  57255. * @returns true if value was set
  57256. */
  57257. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57258. /**
  57259. * Set the value of an uniform to an array of float32
  57260. * @param uniform defines the webGL uniform location where to store the value
  57261. * @param array defines the array of float32 to store
  57262. * @returns true if value was set
  57263. */
  57264. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57265. /**
  57266. * Set the value of an uniform to an array of float32 (stored as vec2)
  57267. * @param uniform defines the webGL uniform location where to store the value
  57268. * @param array defines the array of float32 to store
  57269. * @returns true if value was set
  57270. */
  57271. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57272. /**
  57273. * Set the value of an uniform to an array of float32 (stored as vec3)
  57274. * @param uniform defines the webGL uniform location where to store the value
  57275. * @param array defines the array of float32 to store
  57276. * @returns true if value was set
  57277. */
  57278. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57279. /**
  57280. * Set the value of an uniform to an array of float32 (stored as vec4)
  57281. * @param uniform defines the webGL uniform location where to store the value
  57282. * @param array defines the array of float32 to store
  57283. * @returns true if value was set
  57284. */
  57285. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57286. /**
  57287. * Set the value of an uniform to an array of number
  57288. * @param uniform defines the webGL uniform location where to store the value
  57289. * @param array defines the array of number to store
  57290. * @returns true if value was set
  57291. */
  57292. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57293. /**
  57294. * Set the value of an uniform to an array of number (stored as vec2)
  57295. * @param uniform defines the webGL uniform location where to store the value
  57296. * @param array defines the array of number to store
  57297. * @returns true if value was set
  57298. */
  57299. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57300. /**
  57301. * Set the value of an uniform to an array of number (stored as vec3)
  57302. * @param uniform defines the webGL uniform location where to store the value
  57303. * @param array defines the array of number to store
  57304. * @returns true if value was set
  57305. */
  57306. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57307. /**
  57308. * Set the value of an uniform to an array of number (stored as vec4)
  57309. * @param uniform defines the webGL uniform location where to store the value
  57310. * @param array defines the array of number to store
  57311. * @returns true if value was set
  57312. */
  57313. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57314. /**
  57315. * Set the value of an uniform to an array of float32 (stored as matrices)
  57316. * @param uniform defines the webGL uniform location where to store the value
  57317. * @param matrices defines the array of float32 to store
  57318. * @returns true if value was set
  57319. */
  57320. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57321. /**
  57322. * Set the value of an uniform to a matrix (3x3)
  57323. * @param uniform defines the webGL uniform location where to store the value
  57324. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57325. * @returns true if value was set
  57326. */
  57327. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57328. /**
  57329. * Set the value of an uniform to a matrix (2x2)
  57330. * @param uniform defines the webGL uniform location where to store the value
  57331. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57332. * @returns true if value was set
  57333. */
  57334. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57335. /**
  57336. * Set the value of an uniform to a number (float)
  57337. * @param uniform defines the webGL uniform location where to store the value
  57338. * @param value defines the float number to store
  57339. * @returns true if value was set
  57340. */
  57341. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57342. /**
  57343. * Set the value of an uniform to a vec2
  57344. * @param uniform defines the webGL uniform location where to store the value
  57345. * @param x defines the 1st component of the value
  57346. * @param y defines the 2nd component of the value
  57347. * @returns true if value was set
  57348. */
  57349. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57350. /**
  57351. * Set the value of an uniform to a vec3
  57352. * @param uniform defines the webGL uniform location where to store the value
  57353. * @param x defines the 1st component of the value
  57354. * @param y defines the 2nd component of the value
  57355. * @param z defines the 3rd component of the value
  57356. * @returns true if value was set
  57357. */
  57358. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57359. /**
  57360. * Set the value of an uniform to a boolean
  57361. * @param uniform defines the webGL uniform location where to store the value
  57362. * @param bool defines the boolean to store
  57363. * @returns true if value was set
  57364. */
  57365. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57366. /**
  57367. * Set the value of an uniform to a vec4
  57368. * @param uniform defines the webGL uniform location where to store the value
  57369. * @param x defines the 1st component of the value
  57370. * @param y defines the 2nd component of the value
  57371. * @param z defines the 3rd component of the value
  57372. * @param w defines the 4th component of the value
  57373. * @returns true if value was set
  57374. */
  57375. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57376. /**
  57377. * Sets the current alpha mode
  57378. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57379. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57380. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57381. */
  57382. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57383. /**
  57384. * Bind webGl buffers directly to the webGL context
  57385. * @param vertexBuffers defines the vertex buffer to bind
  57386. * @param indexBuffer defines the index buffer to bind
  57387. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57388. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57389. * @param effect defines the effect associated with the vertex buffer
  57390. */
  57391. bindBuffers(vertexBuffers: {
  57392. [key: string]: VertexBuffer;
  57393. }, indexBuffer: DataBuffer, effect: Effect): void;
  57394. /**
  57395. * Force the entire cache to be cleared
  57396. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57397. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57398. */
  57399. wipeCaches(bruteForce?: boolean): void;
  57400. /**
  57401. * Send a draw order
  57402. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57403. * @param indexStart defines the starting index
  57404. * @param indexCount defines the number of index to draw
  57405. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57406. */
  57407. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57408. /**
  57409. * Draw a list of indexed primitives
  57410. * @param fillMode defines the primitive to use
  57411. * @param indexStart defines the starting index
  57412. * @param indexCount defines the number of index to draw
  57413. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57414. */
  57415. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57416. /**
  57417. * Draw a list of unindexed primitives
  57418. * @param fillMode defines the primitive to use
  57419. * @param verticesStart defines the index of first vertex to draw
  57420. * @param verticesCount defines the count of vertices to draw
  57421. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57422. */
  57423. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57424. /** @hidden */
  57425. _createTexture(): WebGLTexture;
  57426. /** @hidden */
  57427. _releaseTexture(texture: InternalTexture): void;
  57428. /**
  57429. * Usually called from Texture.ts.
  57430. * Passed information to create a WebGLTexture
  57431. * @param urlArg defines a value which contains one of the following:
  57432. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57433. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57434. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57435. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57436. * @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)
  57437. * @param scene needed for loading to the correct scene
  57438. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57439. * @param onLoad optional callback to be called upon successful completion
  57440. * @param onError optional callback to be called upon failure
  57441. * @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
  57442. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57443. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57444. * @param forcedExtension defines the extension to use to pick the right loader
  57445. * @param mimeType defines an optional mime type
  57446. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57447. */
  57448. 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;
  57449. /**
  57450. * Creates a new render target texture
  57451. * @param size defines the size of the texture
  57452. * @param options defines the options used to create the texture
  57453. * @returns a new render target texture stored in an InternalTexture
  57454. */
  57455. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57456. /**
  57457. * Update the sampling mode of a given texture
  57458. * @param samplingMode defines the required sampling mode
  57459. * @param texture defines the texture to update
  57460. */
  57461. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57462. /**
  57463. * Binds the frame buffer to the specified texture.
  57464. * @param texture The texture to render to or null for the default canvas
  57465. * @param faceIndex The face of the texture to render to in case of cube texture
  57466. * @param requiredWidth The width of the target to render to
  57467. * @param requiredHeight The height of the target to render to
  57468. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57469. * @param lodLevel defines le lod level to bind to the frame buffer
  57470. */
  57471. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57472. /**
  57473. * Unbind the current render target texture from the webGL context
  57474. * @param texture defines the render target texture to unbind
  57475. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57476. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57477. */
  57478. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57479. /**
  57480. * Creates a dynamic vertex buffer
  57481. * @param vertices the data for the dynamic vertex buffer
  57482. * @returns the new WebGL dynamic buffer
  57483. */
  57484. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57485. /**
  57486. * Update the content of a dynamic texture
  57487. * @param texture defines the texture to update
  57488. * @param canvas defines the canvas containing the source
  57489. * @param invertY defines if data must be stored with Y axis inverted
  57490. * @param premulAlpha defines if alpha is stored as premultiplied
  57491. * @param format defines the format of the data
  57492. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57493. */
  57494. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57495. /**
  57496. * Gets a boolean indicating if all created effects are ready
  57497. * @returns true if all effects are ready
  57498. */
  57499. areAllEffectsReady(): boolean;
  57500. /**
  57501. * @hidden
  57502. * Get the current error code of the webGL context
  57503. * @returns the error code
  57504. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57505. */
  57506. getError(): number;
  57507. /** @hidden */
  57508. _getUnpackAlignement(): number;
  57509. /** @hidden */
  57510. _unpackFlipY(value: boolean): void;
  57511. /**
  57512. * Update a dynamic index buffer
  57513. * @param indexBuffer defines the target index buffer
  57514. * @param indices defines the data to update
  57515. * @param offset defines the offset in the target index buffer where update should start
  57516. */
  57517. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57518. /**
  57519. * Updates a dynamic vertex buffer.
  57520. * @param vertexBuffer the vertex buffer to update
  57521. * @param vertices the data used to update the vertex buffer
  57522. * @param byteOffset the byte offset of the data (optional)
  57523. * @param byteLength the byte length of the data (optional)
  57524. */
  57525. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57526. /** @hidden */
  57527. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57528. /** @hidden */
  57529. _bindTexture(channel: number, texture: InternalTexture): void;
  57530. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57531. /**
  57532. * 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
  57533. */
  57534. releaseEffects(): void;
  57535. displayLoadingUI(): void;
  57536. hideLoadingUI(): void;
  57537. /** @hidden */
  57538. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57539. /** @hidden */
  57540. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57541. /** @hidden */
  57542. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57543. /** @hidden */
  57544. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57545. }
  57546. }
  57547. declare module "babylonjs/Instrumentation/timeToken" {
  57548. import { Nullable } from "babylonjs/types";
  57549. /**
  57550. * @hidden
  57551. **/
  57552. export class _TimeToken {
  57553. _startTimeQuery: Nullable<WebGLQuery>;
  57554. _endTimeQuery: Nullable<WebGLQuery>;
  57555. _timeElapsedQuery: Nullable<WebGLQuery>;
  57556. _timeElapsedQueryEnded: boolean;
  57557. }
  57558. }
  57559. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57560. import { Nullable, int } from "babylonjs/types";
  57561. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57562. /** @hidden */
  57563. export class _OcclusionDataStorage {
  57564. /** @hidden */
  57565. occlusionInternalRetryCounter: number;
  57566. /** @hidden */
  57567. isOcclusionQueryInProgress: boolean;
  57568. /** @hidden */
  57569. isOccluded: boolean;
  57570. /** @hidden */
  57571. occlusionRetryCount: number;
  57572. /** @hidden */
  57573. occlusionType: number;
  57574. /** @hidden */
  57575. occlusionQueryAlgorithmType: number;
  57576. }
  57577. module "babylonjs/Engines/engine" {
  57578. interface Engine {
  57579. /**
  57580. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  57581. * @return the new query
  57582. */
  57583. createQuery(): WebGLQuery;
  57584. /**
  57585. * Delete and release a webGL query
  57586. * @param query defines the query to delete
  57587. * @return the current engine
  57588. */
  57589. deleteQuery(query: WebGLQuery): Engine;
  57590. /**
  57591. * Check if a given query has resolved and got its value
  57592. * @param query defines the query to check
  57593. * @returns true if the query got its value
  57594. */
  57595. isQueryResultAvailable(query: WebGLQuery): boolean;
  57596. /**
  57597. * Gets the value of a given query
  57598. * @param query defines the query to check
  57599. * @returns the value of the query
  57600. */
  57601. getQueryResult(query: WebGLQuery): number;
  57602. /**
  57603. * Initiates an occlusion query
  57604. * @param algorithmType defines the algorithm to use
  57605. * @param query defines the query to use
  57606. * @returns the current engine
  57607. * @see https://doc.babylonjs.com/features/occlusionquery
  57608. */
  57609. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  57610. /**
  57611. * Ends an occlusion query
  57612. * @see https://doc.babylonjs.com/features/occlusionquery
  57613. * @param algorithmType defines the algorithm to use
  57614. * @returns the current engine
  57615. */
  57616. endOcclusionQuery(algorithmType: number): Engine;
  57617. /**
  57618. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  57619. * Please note that only one query can be issued at a time
  57620. * @returns a time token used to track the time span
  57621. */
  57622. startTimeQuery(): Nullable<_TimeToken>;
  57623. /**
  57624. * Ends a time query
  57625. * @param token defines the token used to measure the time span
  57626. * @returns the time spent (in ns)
  57627. */
  57628. endTimeQuery(token: _TimeToken): int;
  57629. /** @hidden */
  57630. _currentNonTimestampToken: Nullable<_TimeToken>;
  57631. /** @hidden */
  57632. _createTimeQuery(): WebGLQuery;
  57633. /** @hidden */
  57634. _deleteTimeQuery(query: WebGLQuery): void;
  57635. /** @hidden */
  57636. _getGlAlgorithmType(algorithmType: number): number;
  57637. /** @hidden */
  57638. _getTimeQueryResult(query: WebGLQuery): any;
  57639. /** @hidden */
  57640. _getTimeQueryAvailability(query: WebGLQuery): any;
  57641. }
  57642. }
  57643. module "babylonjs/Meshes/abstractMesh" {
  57644. interface AbstractMesh {
  57645. /**
  57646. * Backing filed
  57647. * @hidden
  57648. */
  57649. __occlusionDataStorage: _OcclusionDataStorage;
  57650. /**
  57651. * Access property
  57652. * @hidden
  57653. */
  57654. _occlusionDataStorage: _OcclusionDataStorage;
  57655. /**
  57656. * 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.
  57657. * The default value is -1 which means don't break the query and wait till the result
  57658. * @see https://doc.babylonjs.com/features/occlusionquery
  57659. */
  57660. occlusionRetryCount: number;
  57661. /**
  57662. * 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:
  57663. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  57664. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  57665. * * 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.
  57666. * @see https://doc.babylonjs.com/features/occlusionquery
  57667. */
  57668. occlusionType: number;
  57669. /**
  57670. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  57671. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  57672. * * 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.
  57673. * @see https://doc.babylonjs.com/features/occlusionquery
  57674. */
  57675. occlusionQueryAlgorithmType: number;
  57676. /**
  57677. * 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
  57678. * @see https://doc.babylonjs.com/features/occlusionquery
  57679. */
  57680. isOccluded: boolean;
  57681. /**
  57682. * Flag to check the progress status of the query
  57683. * @see https://doc.babylonjs.com/features/occlusionquery
  57684. */
  57685. isOcclusionQueryInProgress: boolean;
  57686. }
  57687. }
  57688. }
  57689. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  57690. import { Nullable } from "babylonjs/types";
  57691. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57692. /** @hidden */
  57693. export var _forceTransformFeedbackToBundle: boolean;
  57694. module "babylonjs/Engines/engine" {
  57695. interface Engine {
  57696. /**
  57697. * Creates a webGL transform feedback object
  57698. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  57699. * @returns the webGL transform feedback object
  57700. */
  57701. createTransformFeedback(): WebGLTransformFeedback;
  57702. /**
  57703. * Delete a webGL transform feedback object
  57704. * @param value defines the webGL transform feedback object to delete
  57705. */
  57706. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  57707. /**
  57708. * Bind a webGL transform feedback object to the webgl context
  57709. * @param value defines the webGL transform feedback object to bind
  57710. */
  57711. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  57712. /**
  57713. * Begins a transform feedback operation
  57714. * @param usePoints defines if points or triangles must be used
  57715. */
  57716. beginTransformFeedback(usePoints: boolean): void;
  57717. /**
  57718. * Ends a transform feedback operation
  57719. */
  57720. endTransformFeedback(): void;
  57721. /**
  57722. * Specify the varyings to use with transform feedback
  57723. * @param program defines the associated webGL program
  57724. * @param value defines the list of strings representing the varying names
  57725. */
  57726. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  57727. /**
  57728. * Bind a webGL buffer for a transform feedback operation
  57729. * @param value defines the webGL buffer to bind
  57730. */
  57731. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  57732. }
  57733. }
  57734. }
  57735. declare module "babylonjs/Engines/Extensions/engine.views" {
  57736. import { Camera } from "babylonjs/Cameras/camera";
  57737. import { Nullable } from "babylonjs/types";
  57738. /**
  57739. * Class used to define an additional view for the engine
  57740. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57741. */
  57742. export class EngineView {
  57743. /** Defines the canvas where to render the view */
  57744. target: HTMLCanvasElement;
  57745. /** Defines an optional camera used to render the view (will use active camera else) */
  57746. camera?: Camera;
  57747. }
  57748. module "babylonjs/Engines/engine" {
  57749. interface Engine {
  57750. /**
  57751. * Gets or sets the HTML element to use for attaching events
  57752. */
  57753. inputElement: Nullable<HTMLElement>;
  57754. /**
  57755. * Gets the current engine view
  57756. * @see https://doc.babylonjs.com/how_to/multi_canvases
  57757. */
  57758. activeView: Nullable<EngineView>;
  57759. /** Gets or sets the list of views */
  57760. views: EngineView[];
  57761. /**
  57762. * Register a new child canvas
  57763. * @param canvas defines the canvas to register
  57764. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  57765. * @returns the associated view
  57766. */
  57767. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  57768. /**
  57769. * Remove a registered child canvas
  57770. * @param canvas defines the canvas to remove
  57771. * @returns the current engine
  57772. */
  57773. unRegisterView(canvas: HTMLCanvasElement): Engine;
  57774. }
  57775. }
  57776. }
  57777. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  57778. import { Nullable } from "babylonjs/types";
  57779. module "babylonjs/Engines/engine" {
  57780. interface Engine {
  57781. /** @hidden */
  57782. _excludedCompressedTextures: string[];
  57783. /** @hidden */
  57784. _textureFormatInUse: string;
  57785. /**
  57786. * Gets the list of texture formats supported
  57787. */
  57788. readonly texturesSupported: Array<string>;
  57789. /**
  57790. * Gets the texture format in use
  57791. */
  57792. readonly textureFormatInUse: Nullable<string>;
  57793. /**
  57794. * Set the compressed texture extensions or file names to skip.
  57795. *
  57796. * @param skippedFiles defines the list of those texture files you want to skip
  57797. * Example: [".dds", ".env", "myfile.png"]
  57798. */
  57799. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  57800. /**
  57801. * Set the compressed texture format to use, based on the formats you have, and the formats
  57802. * supported by the hardware / browser.
  57803. *
  57804. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  57805. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  57806. * to API arguments needed to compressed textures. This puts the burden on the container
  57807. * generator to house the arcane code for determining these for current & future formats.
  57808. *
  57809. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57810. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57811. *
  57812. * Note: The result of this call is not taken into account when a texture is base64.
  57813. *
  57814. * @param formatsAvailable defines the list of those format families you have created
  57815. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  57816. *
  57817. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  57818. * @returns The extension selected.
  57819. */
  57820. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  57821. }
  57822. }
  57823. }
  57824. declare module "babylonjs/Engines/Extensions/index" {
  57825. export * from "babylonjs/Engines/Extensions/engine.alpha";
  57826. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  57827. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  57828. export * from "babylonjs/Engines/Extensions/engine.multiview";
  57829. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  57830. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57831. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  57832. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  57833. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  57834. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  57835. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57836. export * from "babylonjs/Engines/Extensions/engine.webVR";
  57837. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  57838. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  57839. export * from "babylonjs/Engines/Extensions/engine.views";
  57840. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  57841. import "babylonjs/Engines/Extensions/engine.textureSelector";
  57842. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  57843. }
  57844. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  57845. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57846. /** @hidden */
  57847. export var rgbdEncodePixelShader: {
  57848. name: string;
  57849. shader: string;
  57850. };
  57851. }
  57852. declare module "babylonjs/Misc/environmentTextureTools" {
  57853. import { Nullable } from "babylonjs/types";
  57854. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57855. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57856. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57857. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  57858. import "babylonjs/Engines/Extensions/engine.readTexture";
  57859. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57860. import "babylonjs/Shaders/rgbdEncode.fragment";
  57861. import "babylonjs/Shaders/rgbdDecode.fragment";
  57862. /**
  57863. * Raw texture data and descriptor sufficient for WebGL texture upload
  57864. */
  57865. export interface EnvironmentTextureInfo {
  57866. /**
  57867. * Version of the environment map
  57868. */
  57869. version: number;
  57870. /**
  57871. * Width of image
  57872. */
  57873. width: number;
  57874. /**
  57875. * Irradiance information stored in the file.
  57876. */
  57877. irradiance: any;
  57878. /**
  57879. * Specular information stored in the file.
  57880. */
  57881. specular: any;
  57882. }
  57883. /**
  57884. * Defines One Image in the file. It requires only the position in the file
  57885. * as well as the length.
  57886. */
  57887. interface BufferImageData {
  57888. /**
  57889. * Length of the image data.
  57890. */
  57891. length: number;
  57892. /**
  57893. * Position of the data from the null terminator delimiting the end of the JSON.
  57894. */
  57895. position: number;
  57896. }
  57897. /**
  57898. * Defines the specular data enclosed in the file.
  57899. * This corresponds to the version 1 of the data.
  57900. */
  57901. export interface EnvironmentTextureSpecularInfoV1 {
  57902. /**
  57903. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  57904. */
  57905. specularDataPosition?: number;
  57906. /**
  57907. * This contains all the images data needed to reconstruct the cubemap.
  57908. */
  57909. mipmaps: Array<BufferImageData>;
  57910. /**
  57911. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  57912. */
  57913. lodGenerationScale: number;
  57914. }
  57915. /**
  57916. * Sets of helpers addressing the serialization and deserialization of environment texture
  57917. * stored in a BabylonJS env file.
  57918. * Those files are usually stored as .env files.
  57919. */
  57920. export class EnvironmentTextureTools {
  57921. /**
  57922. * Magic number identifying the env file.
  57923. */
  57924. private static _MagicBytes;
  57925. /**
  57926. * Gets the environment info from an env file.
  57927. * @param data The array buffer containing the .env bytes.
  57928. * @returns the environment file info (the json header) if successfully parsed.
  57929. */
  57930. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  57931. /**
  57932. * Creates an environment texture from a loaded cube texture.
  57933. * @param texture defines the cube texture to convert in env file
  57934. * @return a promise containing the environment data if succesfull.
  57935. */
  57936. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  57937. /**
  57938. * Creates a JSON representation of the spherical data.
  57939. * @param texture defines the texture containing the polynomials
  57940. * @return the JSON representation of the spherical info
  57941. */
  57942. private static _CreateEnvTextureIrradiance;
  57943. /**
  57944. * Creates the ArrayBufferViews used for initializing environment texture image data.
  57945. * @param data the image data
  57946. * @param info parameters that determine what views will be created for accessing the underlying buffer
  57947. * @return the views described by info providing access to the underlying buffer
  57948. */
  57949. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  57950. /**
  57951. * Uploads the texture info contained in the env file to the GPU.
  57952. * @param texture defines the internal texture to upload to
  57953. * @param data defines the data to load
  57954. * @param info defines the texture info retrieved through the GetEnvInfo method
  57955. * @returns a promise
  57956. */
  57957. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  57958. private static _OnImageReadyAsync;
  57959. /**
  57960. * Uploads the levels of image data to the GPU.
  57961. * @param texture defines the internal texture to upload to
  57962. * @param imageData defines the array buffer views of image data [mipmap][face]
  57963. * @returns a promise
  57964. */
  57965. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  57966. /**
  57967. * Uploads spherical polynomials information to the texture.
  57968. * @param texture defines the texture we are trying to upload the information to
  57969. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  57970. */
  57971. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  57972. /** @hidden */
  57973. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57974. }
  57975. }
  57976. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  57977. /**
  57978. * Class used to inline functions in shader code
  57979. */
  57980. export class ShaderCodeInliner {
  57981. private static readonly _RegexpFindFunctionNameAndType;
  57982. private _sourceCode;
  57983. private _functionDescr;
  57984. private _numMaxIterations;
  57985. /** Gets or sets the token used to mark the functions to inline */
  57986. inlineToken: string;
  57987. /** Gets or sets the debug mode */
  57988. debug: boolean;
  57989. /** Gets the code after the inlining process */
  57990. get code(): string;
  57991. /**
  57992. * Initializes the inliner
  57993. * @param sourceCode shader code source to inline
  57994. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  57995. */
  57996. constructor(sourceCode: string, numMaxIterations?: number);
  57997. /**
  57998. * Start the processing of the shader code
  57999. */
  58000. processCode(): void;
  58001. private _collectFunctions;
  58002. private _processInlining;
  58003. private _extractBetweenMarkers;
  58004. private _skipWhitespaces;
  58005. private _removeComments;
  58006. private _replaceFunctionCallsByCode;
  58007. private _findBackward;
  58008. private _escapeRegExp;
  58009. private _replaceNames;
  58010. }
  58011. }
  58012. declare module "babylonjs/Engines/nativeEngine" {
  58013. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  58014. import { Engine } from "babylonjs/Engines/engine";
  58015. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58016. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58017. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58018. import { Effect } from "babylonjs/Materials/effect";
  58019. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58020. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  58021. import { IColor4Like } from "babylonjs/Maths/math.like";
  58022. import { Scene } from "babylonjs/scene";
  58023. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58024. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58025. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58026. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  58027. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  58028. /**
  58029. * Container for accessors for natively-stored mesh data buffers.
  58030. */
  58031. class NativeDataBuffer extends DataBuffer {
  58032. /**
  58033. * Accessor value used to identify/retrieve a natively-stored index buffer.
  58034. */
  58035. nativeIndexBuffer?: any;
  58036. /**
  58037. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  58038. */
  58039. nativeVertexBuffer?: any;
  58040. }
  58041. /** @hidden */
  58042. class NativeTexture extends InternalTexture {
  58043. getInternalTexture(): InternalTexture;
  58044. getViewCount(): number;
  58045. }
  58046. /** @hidden */
  58047. export class NativeEngine extends Engine {
  58048. private readonly _native;
  58049. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  58050. private readonly INVALID_HANDLE;
  58051. private _boundBuffersVertexArray;
  58052. private _currentDepthTest;
  58053. getHardwareScalingLevel(): number;
  58054. constructor();
  58055. dispose(): void;
  58056. /**
  58057. * Can be used to override the current requestAnimationFrame requester.
  58058. * @hidden
  58059. */
  58060. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  58061. /**
  58062. * Override default engine behavior.
  58063. * @param color
  58064. * @param backBuffer
  58065. * @param depth
  58066. * @param stencil
  58067. */
  58068. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  58069. /**
  58070. * Gets host document
  58071. * @returns the host document object
  58072. */
  58073. getHostDocument(): Nullable<Document>;
  58074. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58075. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58076. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58077. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58078. [key: string]: VertexBuffer;
  58079. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58080. bindBuffers(vertexBuffers: {
  58081. [key: string]: VertexBuffer;
  58082. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58083. recordVertexArrayObject(vertexBuffers: {
  58084. [key: string]: VertexBuffer;
  58085. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58086. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58087. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58088. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58089. /**
  58090. * Draw a list of indexed primitives
  58091. * @param fillMode defines the primitive to use
  58092. * @param indexStart defines the starting index
  58093. * @param indexCount defines the number of index to draw
  58094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58095. */
  58096. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58097. /**
  58098. * Draw a list of unindexed primitives
  58099. * @param fillMode defines the primitive to use
  58100. * @param verticesStart defines the index of first vertex to draw
  58101. * @param verticesCount defines the count of vertices to draw
  58102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58103. */
  58104. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58105. createPipelineContext(): IPipelineContext;
  58106. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58107. /** @hidden */
  58108. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58109. /** @hidden */
  58110. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58111. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58112. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58113. protected _setProgram(program: WebGLProgram): void;
  58114. _releaseEffect(effect: Effect): void;
  58115. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58116. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58117. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58118. bindSamplers(effect: Effect): void;
  58119. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58120. getRenderWidth(useScreen?: boolean): number;
  58121. getRenderHeight(useScreen?: boolean): number;
  58122. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58123. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58124. /**
  58125. * Set the z offset to apply to current rendering
  58126. * @param value defines the offset to apply
  58127. */
  58128. setZOffset(value: number): void;
  58129. /**
  58130. * Gets the current value of the zOffset
  58131. * @returns the current zOffset state
  58132. */
  58133. getZOffset(): number;
  58134. /**
  58135. * Enable or disable depth buffering
  58136. * @param enable defines the state to set
  58137. */
  58138. setDepthBuffer(enable: boolean): void;
  58139. /**
  58140. * Gets a boolean indicating if depth writing is enabled
  58141. * @returns the current depth writing state
  58142. */
  58143. getDepthWrite(): boolean;
  58144. setDepthFunctionToGreater(): void;
  58145. setDepthFunctionToGreaterOrEqual(): void;
  58146. setDepthFunctionToLess(): void;
  58147. setDepthFunctionToLessOrEqual(): void;
  58148. /**
  58149. * Enable or disable depth writing
  58150. * @param enable defines the state to set
  58151. */
  58152. setDepthWrite(enable: boolean): void;
  58153. /**
  58154. * Enable or disable color writing
  58155. * @param enable defines the state to set
  58156. */
  58157. setColorWrite(enable: boolean): void;
  58158. /**
  58159. * Gets a boolean indicating if color writing is enabled
  58160. * @returns the current color writing state
  58161. */
  58162. getColorWrite(): boolean;
  58163. /**
  58164. * Sets alpha constants used by some alpha blending modes
  58165. * @param r defines the red component
  58166. * @param g defines the green component
  58167. * @param b defines the blue component
  58168. * @param a defines the alpha component
  58169. */
  58170. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58171. /**
  58172. * Sets the current alpha mode
  58173. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58174. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58175. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58176. */
  58177. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58178. /**
  58179. * Gets the current alpha mode
  58180. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58181. * @returns the current alpha mode
  58182. */
  58183. getAlphaMode(): number;
  58184. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58185. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58186. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58187. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58188. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58189. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58190. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58191. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58192. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58193. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58194. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58195. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58196. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58197. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58198. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58199. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58200. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58201. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58202. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58203. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58204. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58205. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58206. wipeCaches(bruteForce?: boolean): void;
  58207. _createTexture(): WebGLTexture;
  58208. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58209. /**
  58210. * Update the content of a dynamic texture
  58211. * @param texture defines the texture to update
  58212. * @param canvas defines the canvas containing the source
  58213. * @param invertY defines if data must be stored with Y axis inverted
  58214. * @param premulAlpha defines if alpha is stored as premultiplied
  58215. * @param format defines the format of the data
  58216. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58217. */
  58218. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58219. /**
  58220. * Usually called from Texture.ts.
  58221. * Passed information to create a WebGLTexture
  58222. * @param url defines a value which contains one of the following:
  58223. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58224. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58225. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58226. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58227. * @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)
  58228. * @param scene needed for loading to the correct scene
  58229. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58230. * @param onLoad optional callback to be called upon successful completion
  58231. * @param onError optional callback to be called upon failure
  58232. * @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
  58233. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58234. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58235. * @param forcedExtension defines the extension to use to pick the right loader
  58236. * @param mimeType defines an optional mime type
  58237. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58238. */
  58239. 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;
  58240. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58241. _releaseFramebufferObjects(texture: InternalTexture): void;
  58242. /**
  58243. * Creates a cube texture
  58244. * @param rootUrl defines the url where the files to load is located
  58245. * @param scene defines the current scene
  58246. * @param files defines the list of files to load (1 per face)
  58247. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58248. * @param onLoad defines an optional callback raised when the texture is loaded
  58249. * @param onError defines an optional callback raised if there is an issue to load the texture
  58250. * @param format defines the format of the data
  58251. * @param forcedExtension defines the extension to use to pick the right loader
  58252. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58253. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58254. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58255. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58256. * @returns the cube texture as an InternalTexture
  58257. */
  58258. 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;
  58259. createRenderTargetTexture(size: number | {
  58260. width: number;
  58261. height: number;
  58262. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58263. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58264. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58265. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58266. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58267. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58268. /**
  58269. * Updates a dynamic vertex buffer.
  58270. * @param vertexBuffer the vertex buffer to update
  58271. * @param data the data used to update the vertex buffer
  58272. * @param byteOffset the byte offset of the data (optional)
  58273. * @param byteLength the byte length of the data (optional)
  58274. */
  58275. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58276. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58277. private _updateAnisotropicLevel;
  58278. private _getAddressMode;
  58279. /** @hidden */
  58280. _bindTexture(channel: number, texture: InternalTexture): void;
  58281. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58282. releaseEffects(): void;
  58283. /** @hidden */
  58284. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58285. /** @hidden */
  58286. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58287. /** @hidden */
  58288. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58289. /** @hidden */
  58290. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58291. private _getNativeSamplingMode;
  58292. private _getNativeTextureFormat;
  58293. private _getNativeAlphaMode;
  58294. private _getNativeAttribType;
  58295. }
  58296. }
  58297. declare module "babylonjs/Engines/index" {
  58298. export * from "babylonjs/Engines/constants";
  58299. export * from "babylonjs/Engines/engineCapabilities";
  58300. export * from "babylonjs/Engines/instancingAttributeInfo";
  58301. export * from "babylonjs/Engines/thinEngine";
  58302. export * from "babylonjs/Engines/engine";
  58303. export * from "babylonjs/Engines/engineStore";
  58304. export * from "babylonjs/Engines/nullEngine";
  58305. export * from "babylonjs/Engines/Extensions/index";
  58306. export * from "babylonjs/Engines/IPipelineContext";
  58307. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58308. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58309. export * from "babylonjs/Engines/nativeEngine";
  58310. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58311. export * from "babylonjs/Engines/performanceConfigurator";
  58312. }
  58313. declare module "babylonjs/Events/clipboardEvents" {
  58314. /**
  58315. * Gather the list of clipboard event types as constants.
  58316. */
  58317. export class ClipboardEventTypes {
  58318. /**
  58319. * The clipboard event is fired when a copy command is active (pressed).
  58320. */
  58321. static readonly COPY: number;
  58322. /**
  58323. * The clipboard event is fired when a cut command is active (pressed).
  58324. */
  58325. static readonly CUT: number;
  58326. /**
  58327. * The clipboard event is fired when a paste command is active (pressed).
  58328. */
  58329. static readonly PASTE: number;
  58330. }
  58331. /**
  58332. * This class is used to store clipboard related info for the onClipboardObservable event.
  58333. */
  58334. export class ClipboardInfo {
  58335. /**
  58336. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58337. */
  58338. type: number;
  58339. /**
  58340. * Defines the related dom event
  58341. */
  58342. event: ClipboardEvent;
  58343. /**
  58344. *Creates an instance of ClipboardInfo.
  58345. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58346. * @param event Defines the related dom event
  58347. */
  58348. constructor(
  58349. /**
  58350. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58351. */
  58352. type: number,
  58353. /**
  58354. * Defines the related dom event
  58355. */
  58356. event: ClipboardEvent);
  58357. /**
  58358. * Get the clipboard event's type from the keycode.
  58359. * @param keyCode Defines the keyCode for the current keyboard event.
  58360. * @return {number}
  58361. */
  58362. static GetTypeFromCharacter(keyCode: number): number;
  58363. }
  58364. }
  58365. declare module "babylonjs/Events/index" {
  58366. export * from "babylonjs/Events/keyboardEvents";
  58367. export * from "babylonjs/Events/pointerEvents";
  58368. export * from "babylonjs/Events/clipboardEvents";
  58369. }
  58370. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58371. import { Scene } from "babylonjs/scene";
  58372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58373. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58374. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58375. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58376. /**
  58377. * Google Daydream controller
  58378. */
  58379. export class DaydreamController extends WebVRController {
  58380. /**
  58381. * Base Url for the controller model.
  58382. */
  58383. static MODEL_BASE_URL: string;
  58384. /**
  58385. * File name for the controller model.
  58386. */
  58387. static MODEL_FILENAME: string;
  58388. /**
  58389. * Gamepad Id prefix used to identify Daydream Controller.
  58390. */
  58391. static readonly GAMEPAD_ID_PREFIX: string;
  58392. /**
  58393. * Creates a new DaydreamController from a gamepad
  58394. * @param vrGamepad the gamepad that the controller should be created from
  58395. */
  58396. constructor(vrGamepad: any);
  58397. /**
  58398. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58399. * @param scene scene in which to add meshes
  58400. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58401. */
  58402. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58403. /**
  58404. * Called once for each button that changed state since the last frame
  58405. * @param buttonIdx Which button index changed
  58406. * @param state New state of the button
  58407. * @param changes Which properties on the state changed since last frame
  58408. */
  58409. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58410. }
  58411. }
  58412. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58413. import { Scene } from "babylonjs/scene";
  58414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58415. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58416. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58417. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58418. /**
  58419. * Gear VR Controller
  58420. */
  58421. export class GearVRController extends WebVRController {
  58422. /**
  58423. * Base Url for the controller model.
  58424. */
  58425. static MODEL_BASE_URL: string;
  58426. /**
  58427. * File name for the controller model.
  58428. */
  58429. static MODEL_FILENAME: string;
  58430. /**
  58431. * Gamepad Id prefix used to identify this controller.
  58432. */
  58433. static readonly GAMEPAD_ID_PREFIX: string;
  58434. private readonly _buttonIndexToObservableNameMap;
  58435. /**
  58436. * Creates a new GearVRController from a gamepad
  58437. * @param vrGamepad the gamepad that the controller should be created from
  58438. */
  58439. constructor(vrGamepad: any);
  58440. /**
  58441. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58442. * @param scene scene in which to add meshes
  58443. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58444. */
  58445. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58446. /**
  58447. * Called once for each button that changed state since the last frame
  58448. * @param buttonIdx Which button index changed
  58449. * @param state New state of the button
  58450. * @param changes Which properties on the state changed since last frame
  58451. */
  58452. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58453. }
  58454. }
  58455. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58456. import { Scene } from "babylonjs/scene";
  58457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58458. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58459. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58460. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58461. /**
  58462. * Generic Controller
  58463. */
  58464. export class GenericController extends WebVRController {
  58465. /**
  58466. * Base Url for the controller model.
  58467. */
  58468. static readonly MODEL_BASE_URL: string;
  58469. /**
  58470. * File name for the controller model.
  58471. */
  58472. static readonly MODEL_FILENAME: string;
  58473. /**
  58474. * Creates a new GenericController from a gamepad
  58475. * @param vrGamepad the gamepad that the controller should be created from
  58476. */
  58477. constructor(vrGamepad: any);
  58478. /**
  58479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58480. * @param scene scene in which to add meshes
  58481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58482. */
  58483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58484. /**
  58485. * Called once for each button that changed state since the last frame
  58486. * @param buttonIdx Which button index changed
  58487. * @param state New state of the button
  58488. * @param changes Which properties on the state changed since last frame
  58489. */
  58490. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58491. }
  58492. }
  58493. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58494. import { Observable } from "babylonjs/Misc/observable";
  58495. import { Scene } from "babylonjs/scene";
  58496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58497. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58498. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58499. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58500. /**
  58501. * Oculus Touch Controller
  58502. */
  58503. export class OculusTouchController extends WebVRController {
  58504. /**
  58505. * Base Url for the controller model.
  58506. */
  58507. static MODEL_BASE_URL: string;
  58508. /**
  58509. * File name for the left controller model.
  58510. */
  58511. static MODEL_LEFT_FILENAME: string;
  58512. /**
  58513. * File name for the right controller model.
  58514. */
  58515. static MODEL_RIGHT_FILENAME: string;
  58516. /**
  58517. * Base Url for the Quest controller model.
  58518. */
  58519. static QUEST_MODEL_BASE_URL: string;
  58520. /**
  58521. * @hidden
  58522. * If the controllers are running on a device that needs the updated Quest controller models
  58523. */
  58524. static _IsQuest: boolean;
  58525. /**
  58526. * Fired when the secondary trigger on this controller is modified
  58527. */
  58528. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58529. /**
  58530. * Fired when the thumb rest on this controller is modified
  58531. */
  58532. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58533. /**
  58534. * Creates a new OculusTouchController from a gamepad
  58535. * @param vrGamepad the gamepad that the controller should be created from
  58536. */
  58537. constructor(vrGamepad: any);
  58538. /**
  58539. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58540. * @param scene scene in which to add meshes
  58541. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58542. */
  58543. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58544. /**
  58545. * Fired when the A button on this controller is modified
  58546. */
  58547. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58548. /**
  58549. * Fired when the B button on this controller is modified
  58550. */
  58551. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58552. /**
  58553. * Fired when the X button on this controller is modified
  58554. */
  58555. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58556. /**
  58557. * Fired when the Y button on this controller is modified
  58558. */
  58559. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58560. /**
  58561. * Called once for each button that changed state since the last frame
  58562. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58563. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58564. * 2) secondary trigger (same)
  58565. * 3) A (right) X (left), touch, pressed = value
  58566. * 4) B / Y
  58567. * 5) thumb rest
  58568. * @param buttonIdx Which button index changed
  58569. * @param state New state of the button
  58570. * @param changes Which properties on the state changed since last frame
  58571. */
  58572. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58573. }
  58574. }
  58575. declare module "babylonjs/Gamepads/Controllers/viveController" {
  58576. import { Scene } from "babylonjs/scene";
  58577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58578. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58579. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58580. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58581. import { Observable } from "babylonjs/Misc/observable";
  58582. /**
  58583. * Vive Controller
  58584. */
  58585. export class ViveController extends WebVRController {
  58586. /**
  58587. * Base Url for the controller model.
  58588. */
  58589. static MODEL_BASE_URL: string;
  58590. /**
  58591. * File name for the controller model.
  58592. */
  58593. static MODEL_FILENAME: string;
  58594. /**
  58595. * Creates a new ViveController from a gamepad
  58596. * @param vrGamepad the gamepad that the controller should be created from
  58597. */
  58598. constructor(vrGamepad: any);
  58599. /**
  58600. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58601. * @param scene scene in which to add meshes
  58602. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58603. */
  58604. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58605. /**
  58606. * Fired when the left button on this controller is modified
  58607. */
  58608. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58609. /**
  58610. * Fired when the right button on this controller is modified
  58611. */
  58612. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58613. /**
  58614. * Fired when the menu button on this controller is modified
  58615. */
  58616. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58617. /**
  58618. * Called once for each button that changed state since the last frame
  58619. * Vive mapping:
  58620. * 0: touchpad
  58621. * 1: trigger
  58622. * 2: left AND right buttons
  58623. * 3: menu button
  58624. * @param buttonIdx Which button index changed
  58625. * @param state New state of the button
  58626. * @param changes Which properties on the state changed since last frame
  58627. */
  58628. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58629. }
  58630. }
  58631. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  58632. import { Observable } from "babylonjs/Misc/observable";
  58633. import { Scene } from "babylonjs/scene";
  58634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58635. import { Ray } from "babylonjs/Culling/ray";
  58636. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58637. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58638. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58639. /**
  58640. * Defines the WindowsMotionController object that the state of the windows motion controller
  58641. */
  58642. export class WindowsMotionController extends WebVRController {
  58643. /**
  58644. * The base url used to load the left and right controller models
  58645. */
  58646. static MODEL_BASE_URL: string;
  58647. /**
  58648. * The name of the left controller model file
  58649. */
  58650. static MODEL_LEFT_FILENAME: string;
  58651. /**
  58652. * The name of the right controller model file
  58653. */
  58654. static MODEL_RIGHT_FILENAME: string;
  58655. /**
  58656. * The controller name prefix for this controller type
  58657. */
  58658. static readonly GAMEPAD_ID_PREFIX: string;
  58659. /**
  58660. * The controller id pattern for this controller type
  58661. */
  58662. private static readonly GAMEPAD_ID_PATTERN;
  58663. private _loadedMeshInfo;
  58664. protected readonly _mapping: {
  58665. buttons: string[];
  58666. buttonMeshNames: {
  58667. trigger: string;
  58668. menu: string;
  58669. grip: string;
  58670. thumbstick: string;
  58671. trackpad: string;
  58672. };
  58673. buttonObservableNames: {
  58674. trigger: string;
  58675. menu: string;
  58676. grip: string;
  58677. thumbstick: string;
  58678. trackpad: string;
  58679. };
  58680. axisMeshNames: string[];
  58681. pointingPoseMeshName: string;
  58682. };
  58683. /**
  58684. * Fired when the trackpad on this controller is clicked
  58685. */
  58686. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58687. /**
  58688. * Fired when the trackpad on this controller is modified
  58689. */
  58690. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58691. /**
  58692. * The current x and y values of this controller's trackpad
  58693. */
  58694. trackpad: StickValues;
  58695. /**
  58696. * Creates a new WindowsMotionController from a gamepad
  58697. * @param vrGamepad the gamepad that the controller should be created from
  58698. */
  58699. constructor(vrGamepad: any);
  58700. /**
  58701. * Fired when the trigger on this controller is modified
  58702. */
  58703. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58704. /**
  58705. * Fired when the menu button on this controller is modified
  58706. */
  58707. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58708. /**
  58709. * Fired when the grip button on this controller is modified
  58710. */
  58711. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58712. /**
  58713. * Fired when the thumbstick button on this controller is modified
  58714. */
  58715. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58716. /**
  58717. * Fired when the touchpad button on this controller is modified
  58718. */
  58719. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58720. /**
  58721. * Fired when the touchpad values on this controller are modified
  58722. */
  58723. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  58724. protected _updateTrackpad(): void;
  58725. /**
  58726. * Called once per frame by the engine.
  58727. */
  58728. update(): void;
  58729. /**
  58730. * Called once for each button that changed state since the last frame
  58731. * @param buttonIdx Which button index changed
  58732. * @param state New state of the button
  58733. * @param changes Which properties on the state changed since last frame
  58734. */
  58735. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58736. /**
  58737. * Moves the buttons on the controller mesh based on their current state
  58738. * @param buttonName the name of the button to move
  58739. * @param buttonValue the value of the button which determines the buttons new position
  58740. */
  58741. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  58742. /**
  58743. * Moves the axis on the controller mesh based on its current state
  58744. * @param axis the index of the axis
  58745. * @param axisValue the value of the axis which determines the meshes new position
  58746. * @hidden
  58747. */
  58748. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  58749. /**
  58750. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58751. * @param scene scene in which to add meshes
  58752. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58753. */
  58754. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  58755. /**
  58756. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  58757. * can be transformed by button presses and axes values, based on this._mapping.
  58758. *
  58759. * @param scene scene in which the meshes exist
  58760. * @param meshes list of meshes that make up the controller model to process
  58761. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  58762. */
  58763. private processModel;
  58764. private createMeshInfo;
  58765. /**
  58766. * Gets the ray of the controller in the direction the controller is pointing
  58767. * @param length the length the resulting ray should be
  58768. * @returns a ray in the direction the controller is pointing
  58769. */
  58770. getForwardRay(length?: number): Ray;
  58771. /**
  58772. * Disposes of the controller
  58773. */
  58774. dispose(): void;
  58775. }
  58776. /**
  58777. * This class represents a new windows motion controller in XR.
  58778. */
  58779. export class XRWindowsMotionController extends WindowsMotionController {
  58780. /**
  58781. * Changing the original WIndowsMotionController mapping to fir the new mapping
  58782. */
  58783. protected readonly _mapping: {
  58784. buttons: string[];
  58785. buttonMeshNames: {
  58786. trigger: string;
  58787. menu: string;
  58788. grip: string;
  58789. thumbstick: string;
  58790. trackpad: string;
  58791. };
  58792. buttonObservableNames: {
  58793. trigger: string;
  58794. menu: string;
  58795. grip: string;
  58796. thumbstick: string;
  58797. trackpad: string;
  58798. };
  58799. axisMeshNames: string[];
  58800. pointingPoseMeshName: string;
  58801. };
  58802. /**
  58803. * Construct a new XR-Based windows motion controller
  58804. *
  58805. * @param gamepadInfo the gamepad object from the browser
  58806. */
  58807. constructor(gamepadInfo: any);
  58808. /**
  58809. * holds the thumbstick values (X,Y)
  58810. */
  58811. thumbstickValues: StickValues;
  58812. /**
  58813. * Fired when the thumbstick on this controller is clicked
  58814. */
  58815. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  58816. /**
  58817. * Fired when the thumbstick on this controller is modified
  58818. */
  58819. onThumbstickValuesChangedObservable: Observable<StickValues>;
  58820. /**
  58821. * Fired when the touchpad button on this controller is modified
  58822. */
  58823. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  58824. /**
  58825. * Fired when the touchpad values on this controller are modified
  58826. */
  58827. onTrackpadValuesChangedObservable: Observable<StickValues>;
  58828. /**
  58829. * Fired when the thumbstick button on this controller is modified
  58830. * here to prevent breaking changes
  58831. */
  58832. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58833. /**
  58834. * updating the thumbstick(!) and not the trackpad.
  58835. * This is named this way due to the difference between WebVR and XR and to avoid
  58836. * changing the parent class.
  58837. */
  58838. protected _updateTrackpad(): void;
  58839. /**
  58840. * Disposes the class with joy
  58841. */
  58842. dispose(): void;
  58843. }
  58844. }
  58845. declare module "babylonjs/Gamepads/Controllers/index" {
  58846. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  58847. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  58848. export * from "babylonjs/Gamepads/Controllers/genericController";
  58849. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  58850. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58851. export * from "babylonjs/Gamepads/Controllers/viveController";
  58852. export * from "babylonjs/Gamepads/Controllers/webVRController";
  58853. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  58854. }
  58855. declare module "babylonjs/Gamepads/index" {
  58856. export * from "babylonjs/Gamepads/Controllers/index";
  58857. export * from "babylonjs/Gamepads/gamepad";
  58858. export * from "babylonjs/Gamepads/gamepadManager";
  58859. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  58860. export * from "babylonjs/Gamepads/xboxGamepad";
  58861. export * from "babylonjs/Gamepads/dualShockGamepad";
  58862. }
  58863. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  58864. import { Scene } from "babylonjs/scene";
  58865. import { Vector4 } from "babylonjs/Maths/math.vector";
  58866. import { Color4 } from "babylonjs/Maths/math.color";
  58867. import { Mesh } from "babylonjs/Meshes/mesh";
  58868. import { Nullable } from "babylonjs/types";
  58869. /**
  58870. * Class containing static functions to help procedurally build meshes
  58871. */
  58872. export class PolyhedronBuilder {
  58873. /**
  58874. * Creates a polyhedron mesh
  58875. * * 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
  58876. * * The parameter `size` (positive float, default 1) sets the polygon size
  58877. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58878. * * 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`
  58879. * * 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
  58880. * * 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)`)
  58881. * * 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
  58882. * * 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
  58883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58886. * @param name defines the name of the mesh
  58887. * @param options defines the options used to create the mesh
  58888. * @param scene defines the hosting scene
  58889. * @returns the polyhedron mesh
  58890. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58891. */
  58892. static CreatePolyhedron(name: string, options: {
  58893. type?: number;
  58894. size?: number;
  58895. sizeX?: number;
  58896. sizeY?: number;
  58897. sizeZ?: number;
  58898. custom?: any;
  58899. faceUV?: Vector4[];
  58900. faceColors?: Color4[];
  58901. flat?: boolean;
  58902. updatable?: boolean;
  58903. sideOrientation?: number;
  58904. frontUVs?: Vector4;
  58905. backUVs?: Vector4;
  58906. }, scene?: Nullable<Scene>): Mesh;
  58907. }
  58908. }
  58909. declare module "babylonjs/Gizmos/scaleGizmo" {
  58910. import { Observable } from "babylonjs/Misc/observable";
  58911. import { Nullable } from "babylonjs/types";
  58912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58913. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58914. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  58915. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58916. import { Node } from "babylonjs/node";
  58917. /**
  58918. * Gizmo that enables scaling a mesh along 3 axis
  58919. */
  58920. export class ScaleGizmo extends Gizmo {
  58921. /**
  58922. * Internal gizmo used for interactions on the x axis
  58923. */
  58924. xGizmo: AxisScaleGizmo;
  58925. /**
  58926. * Internal gizmo used for interactions on the y axis
  58927. */
  58928. yGizmo: AxisScaleGizmo;
  58929. /**
  58930. * Internal gizmo used for interactions on the z axis
  58931. */
  58932. zGizmo: AxisScaleGizmo;
  58933. /**
  58934. * Internal gizmo used to scale all axis equally
  58935. */
  58936. uniformScaleGizmo: AxisScaleGizmo;
  58937. private _meshAttached;
  58938. private _nodeAttached;
  58939. private _snapDistance;
  58940. private _uniformScalingMesh;
  58941. private _octahedron;
  58942. private _sensitivity;
  58943. /** Fires an event when any of it's sub gizmos are dragged */
  58944. onDragStartObservable: Observable<unknown>;
  58945. /** Fires an event when any of it's sub gizmos are released from dragging */
  58946. onDragEndObservable: Observable<unknown>;
  58947. get attachedMesh(): Nullable<AbstractMesh>;
  58948. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58949. get attachedNode(): Nullable<Node>;
  58950. set attachedNode(node: Nullable<Node>);
  58951. /**
  58952. * True when the mouse pointer is hovering a gizmo mesh
  58953. */
  58954. get isHovered(): boolean;
  58955. /**
  58956. * Creates a ScaleGizmo
  58957. * @param gizmoLayer The utility layer the gizmo will be added to
  58958. * @param thickness display gizmo axis thickness
  58959. */
  58960. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  58961. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58962. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58963. /**
  58964. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58965. */
  58966. set snapDistance(value: number);
  58967. get snapDistance(): number;
  58968. /**
  58969. * Ratio for the scale of the gizmo (Default: 1)
  58970. */
  58971. set scaleRatio(value: number);
  58972. get scaleRatio(): number;
  58973. /**
  58974. * Sensitivity factor for dragging (Default: 1)
  58975. */
  58976. set sensitivity(value: number);
  58977. get sensitivity(): number;
  58978. /**
  58979. * Disposes of the gizmo
  58980. */
  58981. dispose(): void;
  58982. }
  58983. }
  58984. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  58985. import { Observable } from "babylonjs/Misc/observable";
  58986. import { Nullable } from "babylonjs/types";
  58987. import { Vector3 } from "babylonjs/Maths/math.vector";
  58988. import { Node } from "babylonjs/node";
  58989. import { Mesh } from "babylonjs/Meshes/mesh";
  58990. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  58991. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  58992. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  58993. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  58994. import { Color3 } from "babylonjs/Maths/math.color";
  58995. /**
  58996. * Single axis scale gizmo
  58997. */
  58998. export class AxisScaleGizmo extends Gizmo {
  58999. /**
  59000. * Drag behavior responsible for the gizmos dragging interactions
  59001. */
  59002. dragBehavior: PointerDragBehavior;
  59003. private _pointerObserver;
  59004. /**
  59005. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59006. */
  59007. snapDistance: number;
  59008. /**
  59009. * Event that fires each time the gizmo snaps to a new location.
  59010. * * snapDistance is the the change in distance
  59011. */
  59012. onSnapObservable: Observable<{
  59013. snapDistance: number;
  59014. }>;
  59015. /**
  59016. * If the scaling operation should be done on all axis (default: false)
  59017. */
  59018. uniformScaling: boolean;
  59019. /**
  59020. * Custom sensitivity value for the drag strength
  59021. */
  59022. sensitivity: number;
  59023. private _isEnabled;
  59024. private _parent;
  59025. private _arrow;
  59026. private _coloredMaterial;
  59027. private _hoverMaterial;
  59028. /**
  59029. * Creates an AxisScaleGizmo
  59030. * @param gizmoLayer The utility layer the gizmo will be added to
  59031. * @param dragAxis The axis which the gizmo will be able to scale on
  59032. * @param color The color of the gizmo
  59033. * @param thickness display gizmo axis thickness
  59034. */
  59035. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59036. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59037. /**
  59038. * If the gizmo is enabled
  59039. */
  59040. set isEnabled(value: boolean);
  59041. get isEnabled(): boolean;
  59042. /**
  59043. * Disposes of the gizmo
  59044. */
  59045. dispose(): void;
  59046. /**
  59047. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59048. * @param mesh The mesh to replace the default mesh of the gizmo
  59049. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59050. */
  59051. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59052. }
  59053. }
  59054. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59055. import { Observable } from "babylonjs/Misc/observable";
  59056. import { Nullable } from "babylonjs/types";
  59057. import { Vector3 } from "babylonjs/Maths/math.vector";
  59058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59059. import { Mesh } from "babylonjs/Meshes/mesh";
  59060. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59061. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59062. import { Color3 } from "babylonjs/Maths/math.color";
  59063. import "babylonjs/Meshes/Builders/boxBuilder";
  59064. /**
  59065. * Bounding box gizmo
  59066. */
  59067. export class BoundingBoxGizmo extends Gizmo {
  59068. private _lineBoundingBox;
  59069. private _rotateSpheresParent;
  59070. private _scaleBoxesParent;
  59071. private _boundingDimensions;
  59072. private _renderObserver;
  59073. private _pointerObserver;
  59074. private _scaleDragSpeed;
  59075. private _tmpQuaternion;
  59076. private _tmpVector;
  59077. private _tmpRotationMatrix;
  59078. /**
  59079. * 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)
  59080. */
  59081. ignoreChildren: boolean;
  59082. /**
  59083. * 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)
  59084. */
  59085. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59086. /**
  59087. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59088. */
  59089. rotationSphereSize: number;
  59090. /**
  59091. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59092. */
  59093. scaleBoxSize: number;
  59094. /**
  59095. * 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)
  59096. */
  59097. fixedDragMeshScreenSize: boolean;
  59098. /**
  59099. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59100. */
  59101. fixedDragMeshScreenSizeDistanceFactor: number;
  59102. /**
  59103. * Fired when a rotation sphere or scale box is dragged
  59104. */
  59105. onDragStartObservable: Observable<{}>;
  59106. /**
  59107. * Fired when a scale box is dragged
  59108. */
  59109. onScaleBoxDragObservable: Observable<{}>;
  59110. /**
  59111. * Fired when a scale box drag is ended
  59112. */
  59113. onScaleBoxDragEndObservable: Observable<{}>;
  59114. /**
  59115. * Fired when a rotation sphere is dragged
  59116. */
  59117. onRotationSphereDragObservable: Observable<{}>;
  59118. /**
  59119. * Fired when a rotation sphere drag is ended
  59120. */
  59121. onRotationSphereDragEndObservable: Observable<{}>;
  59122. /**
  59123. * 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)
  59124. */
  59125. scalePivot: Nullable<Vector3>;
  59126. /**
  59127. * Mesh used as a pivot to rotate the attached node
  59128. */
  59129. private _anchorMesh;
  59130. private _existingMeshScale;
  59131. private _dragMesh;
  59132. private pointerDragBehavior;
  59133. private coloredMaterial;
  59134. private hoverColoredMaterial;
  59135. /**
  59136. * Sets the color of the bounding box gizmo
  59137. * @param color the color to set
  59138. */
  59139. setColor(color: Color3): void;
  59140. /**
  59141. * Creates an BoundingBoxGizmo
  59142. * @param gizmoLayer The utility layer the gizmo will be added to
  59143. * @param color The color of the gizmo
  59144. */
  59145. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59146. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59147. private _selectNode;
  59148. /**
  59149. * Updates the bounding box information for the Gizmo
  59150. */
  59151. updateBoundingBox(): void;
  59152. private _updateRotationSpheres;
  59153. private _updateScaleBoxes;
  59154. /**
  59155. * Enables rotation on the specified axis and disables rotation on the others
  59156. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59157. */
  59158. setEnabledRotationAxis(axis: string): void;
  59159. /**
  59160. * Enables/disables scaling
  59161. * @param enable if scaling should be enabled
  59162. * @param homogeneousScaling defines if scaling should only be homogeneous
  59163. */
  59164. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59165. private _updateDummy;
  59166. /**
  59167. * Enables a pointer drag behavior on the bounding box of the gizmo
  59168. */
  59169. enableDragBehavior(): void;
  59170. /**
  59171. * Disposes of the gizmo
  59172. */
  59173. dispose(): void;
  59174. /**
  59175. * 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)
  59176. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59177. * @returns the bounding box mesh with the passed in mesh as a child
  59178. */
  59179. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59180. /**
  59181. * CustomMeshes are not supported by this gizmo
  59182. * @param mesh The mesh to replace the default mesh of the gizmo
  59183. */
  59184. setCustomMesh(mesh: Mesh): void;
  59185. }
  59186. }
  59187. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59188. import { Observable } from "babylonjs/Misc/observable";
  59189. import { Nullable } from "babylonjs/types";
  59190. import { Vector3 } from "babylonjs/Maths/math.vector";
  59191. import { Color3 } from "babylonjs/Maths/math.color";
  59192. import { Node } from "babylonjs/node";
  59193. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59194. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59195. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59196. import "babylonjs/Meshes/Builders/linesBuilder";
  59197. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59198. /**
  59199. * Single plane rotation gizmo
  59200. */
  59201. export class PlaneRotationGizmo extends Gizmo {
  59202. /**
  59203. * Drag behavior responsible for the gizmos dragging interactions
  59204. */
  59205. dragBehavior: PointerDragBehavior;
  59206. private _pointerObserver;
  59207. /**
  59208. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59209. */
  59210. snapDistance: number;
  59211. /**
  59212. * Event that fires each time the gizmo snaps to a new location.
  59213. * * snapDistance is the the change in distance
  59214. */
  59215. onSnapObservable: Observable<{
  59216. snapDistance: number;
  59217. }>;
  59218. private _isEnabled;
  59219. private _parent;
  59220. /**
  59221. * Creates a PlaneRotationGizmo
  59222. * @param gizmoLayer The utility layer the gizmo will be added to
  59223. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59224. * @param color The color of the gizmo
  59225. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59226. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59227. * @param thickness display gizmo axis thickness
  59228. */
  59229. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59230. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59231. /**
  59232. * If the gizmo is enabled
  59233. */
  59234. set isEnabled(value: boolean);
  59235. get isEnabled(): boolean;
  59236. /**
  59237. * Disposes of the gizmo
  59238. */
  59239. dispose(): void;
  59240. }
  59241. }
  59242. declare module "babylonjs/Gizmos/rotationGizmo" {
  59243. import { Observable } from "babylonjs/Misc/observable";
  59244. import { Nullable } from "babylonjs/types";
  59245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59246. import { Mesh } from "babylonjs/Meshes/mesh";
  59247. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59248. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59249. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59250. import { Node } from "babylonjs/node";
  59251. /**
  59252. * Gizmo that enables rotating a mesh along 3 axis
  59253. */
  59254. export class RotationGizmo extends Gizmo {
  59255. /**
  59256. * Internal gizmo used for interactions on the x axis
  59257. */
  59258. xGizmo: PlaneRotationGizmo;
  59259. /**
  59260. * Internal gizmo used for interactions on the y axis
  59261. */
  59262. yGizmo: PlaneRotationGizmo;
  59263. /**
  59264. * Internal gizmo used for interactions on the z axis
  59265. */
  59266. zGizmo: PlaneRotationGizmo;
  59267. /** Fires an event when any of it's sub gizmos are dragged */
  59268. onDragStartObservable: Observable<unknown>;
  59269. /** Fires an event when any of it's sub gizmos are released from dragging */
  59270. onDragEndObservable: Observable<unknown>;
  59271. private _meshAttached;
  59272. private _nodeAttached;
  59273. get attachedMesh(): Nullable<AbstractMesh>;
  59274. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59275. get attachedNode(): Nullable<Node>;
  59276. set attachedNode(node: Nullable<Node>);
  59277. /**
  59278. * True when the mouse pointer is hovering a gizmo mesh
  59279. */
  59280. get isHovered(): boolean;
  59281. /**
  59282. * Creates a RotationGizmo
  59283. * @param gizmoLayer The utility layer the gizmo will be added to
  59284. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59285. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59286. * @param thickness display gizmo axis thickness
  59287. */
  59288. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59289. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59290. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59291. /**
  59292. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59293. */
  59294. set snapDistance(value: number);
  59295. get snapDistance(): number;
  59296. /**
  59297. * Ratio for the scale of the gizmo (Default: 1)
  59298. */
  59299. set scaleRatio(value: number);
  59300. get scaleRatio(): number;
  59301. /**
  59302. * Disposes of the gizmo
  59303. */
  59304. dispose(): void;
  59305. /**
  59306. * CustomMeshes are not supported by this gizmo
  59307. * @param mesh The mesh to replace the default mesh of the gizmo
  59308. */
  59309. setCustomMesh(mesh: Mesh): void;
  59310. }
  59311. }
  59312. declare module "babylonjs/Gizmos/gizmoManager" {
  59313. import { Observable } from "babylonjs/Misc/observable";
  59314. import { Nullable } from "babylonjs/types";
  59315. import { Scene, IDisposable } from "babylonjs/scene";
  59316. import { Node } from "babylonjs/node";
  59317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59318. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59319. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59320. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59321. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59322. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59323. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59324. /**
  59325. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59326. */
  59327. export class GizmoManager implements IDisposable {
  59328. private scene;
  59329. /**
  59330. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59331. */
  59332. gizmos: {
  59333. positionGizmo: Nullable<PositionGizmo>;
  59334. rotationGizmo: Nullable<RotationGizmo>;
  59335. scaleGizmo: Nullable<ScaleGizmo>;
  59336. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59337. };
  59338. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59339. clearGizmoOnEmptyPointerEvent: boolean;
  59340. /** Fires an event when the manager is attached to a mesh */
  59341. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59342. /** Fires an event when the manager is attached to a node */
  59343. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59344. private _gizmosEnabled;
  59345. private _pointerObserver;
  59346. private _attachedMesh;
  59347. private _attachedNode;
  59348. private _boundingBoxColor;
  59349. private _defaultUtilityLayer;
  59350. private _defaultKeepDepthUtilityLayer;
  59351. private _thickness;
  59352. /**
  59353. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59354. */
  59355. boundingBoxDragBehavior: SixDofDragBehavior;
  59356. /**
  59357. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59358. */
  59359. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59360. /**
  59361. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59362. */
  59363. attachableNodes: Nullable<Array<Node>>;
  59364. /**
  59365. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59366. */
  59367. usePointerToAttachGizmos: boolean;
  59368. /**
  59369. * Utility layer that the bounding box gizmo belongs to
  59370. */
  59371. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59372. /**
  59373. * Utility layer that all gizmos besides bounding box belong to
  59374. */
  59375. get utilityLayer(): UtilityLayerRenderer;
  59376. /**
  59377. * True when the mouse pointer is hovering a gizmo mesh
  59378. */
  59379. get isHovered(): boolean;
  59380. /**
  59381. * Instatiates a gizmo manager
  59382. * @param scene the scene to overlay the gizmos on top of
  59383. * @param thickness display gizmo axis thickness
  59384. */
  59385. constructor(scene: Scene, thickness?: number);
  59386. /**
  59387. * Attaches a set of gizmos to the specified mesh
  59388. * @param mesh The mesh the gizmo's should be attached to
  59389. */
  59390. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59391. /**
  59392. * Attaches a set of gizmos to the specified node
  59393. * @param node The node the gizmo's should be attached to
  59394. */
  59395. attachToNode(node: Nullable<Node>): void;
  59396. /**
  59397. * If the position gizmo is enabled
  59398. */
  59399. set positionGizmoEnabled(value: boolean);
  59400. get positionGizmoEnabled(): boolean;
  59401. /**
  59402. * If the rotation gizmo is enabled
  59403. */
  59404. set rotationGizmoEnabled(value: boolean);
  59405. get rotationGizmoEnabled(): boolean;
  59406. /**
  59407. * If the scale gizmo is enabled
  59408. */
  59409. set scaleGizmoEnabled(value: boolean);
  59410. get scaleGizmoEnabled(): boolean;
  59411. /**
  59412. * If the boundingBox gizmo is enabled
  59413. */
  59414. set boundingBoxGizmoEnabled(value: boolean);
  59415. get boundingBoxGizmoEnabled(): boolean;
  59416. /**
  59417. * Disposes of the gizmo manager
  59418. */
  59419. dispose(): void;
  59420. }
  59421. }
  59422. declare module "babylonjs/Lights/directionalLight" {
  59423. import { Camera } from "babylonjs/Cameras/camera";
  59424. import { Scene } from "babylonjs/scene";
  59425. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59427. import { Light } from "babylonjs/Lights/light";
  59428. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59429. import { Effect } from "babylonjs/Materials/effect";
  59430. /**
  59431. * A directional light is defined by a direction (what a surprise!).
  59432. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59433. * 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.
  59434. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59435. */
  59436. export class DirectionalLight extends ShadowLight {
  59437. private _shadowFrustumSize;
  59438. /**
  59439. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59440. */
  59441. get shadowFrustumSize(): number;
  59442. /**
  59443. * Specifies a fix frustum size for the shadow generation.
  59444. */
  59445. set shadowFrustumSize(value: number);
  59446. private _shadowOrthoScale;
  59447. /**
  59448. * Gets the shadow projection scale against the optimal computed one.
  59449. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59450. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59451. */
  59452. get shadowOrthoScale(): number;
  59453. /**
  59454. * Sets the shadow projection scale against the optimal computed one.
  59455. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59456. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59457. */
  59458. set shadowOrthoScale(value: number);
  59459. /**
  59460. * Automatically compute the projection matrix to best fit (including all the casters)
  59461. * on each frame.
  59462. */
  59463. autoUpdateExtends: boolean;
  59464. /**
  59465. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59466. * on each frame. autoUpdateExtends must be set to true for this to work
  59467. */
  59468. autoCalcShadowZBounds: boolean;
  59469. private _orthoLeft;
  59470. private _orthoRight;
  59471. private _orthoTop;
  59472. private _orthoBottom;
  59473. /**
  59474. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59475. * The directional light is emitted from everywhere in the given direction.
  59476. * It can cast shadows.
  59477. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59478. * @param name The friendly name of the light
  59479. * @param direction The direction of the light
  59480. * @param scene The scene the light belongs to
  59481. */
  59482. constructor(name: string, direction: Vector3, scene: Scene);
  59483. /**
  59484. * Returns the string "DirectionalLight".
  59485. * @return The class name
  59486. */
  59487. getClassName(): string;
  59488. /**
  59489. * Returns the integer 1.
  59490. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59491. */
  59492. getTypeID(): number;
  59493. /**
  59494. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59495. * Returns the DirectionalLight Shadow projection matrix.
  59496. */
  59497. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59498. /**
  59499. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59500. * Returns the DirectionalLight Shadow projection matrix.
  59501. */
  59502. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59503. /**
  59504. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59505. * Returns the DirectionalLight Shadow projection matrix.
  59506. */
  59507. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59508. protected _buildUniformLayout(): void;
  59509. /**
  59510. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59511. * @param effect The effect to update
  59512. * @param lightIndex The index of the light in the effect to update
  59513. * @returns The directional light
  59514. */
  59515. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59516. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59517. /**
  59518. * Gets the minZ used for shadow according to both the scene and the light.
  59519. *
  59520. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59521. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59522. * @param activeCamera The camera we are returning the min for
  59523. * @returns the depth min z
  59524. */
  59525. getDepthMinZ(activeCamera: Camera): number;
  59526. /**
  59527. * Gets the maxZ used for shadow according to both the scene and the light.
  59528. *
  59529. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59530. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59531. * @param activeCamera The camera we are returning the max for
  59532. * @returns the depth max z
  59533. */
  59534. getDepthMaxZ(activeCamera: Camera): number;
  59535. /**
  59536. * Prepares the list of defines specific to the light type.
  59537. * @param defines the list of defines
  59538. * @param lightIndex defines the index of the light for the effect
  59539. */
  59540. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59541. }
  59542. }
  59543. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59544. import { Mesh } from "babylonjs/Meshes/mesh";
  59545. /**
  59546. * Class containing static functions to help procedurally build meshes
  59547. */
  59548. export class HemisphereBuilder {
  59549. /**
  59550. * Creates a hemisphere mesh
  59551. * @param name defines the name of the mesh
  59552. * @param options defines the options used to create the mesh
  59553. * @param scene defines the hosting scene
  59554. * @returns the hemisphere mesh
  59555. */
  59556. static CreateHemisphere(name: string, options: {
  59557. segments?: number;
  59558. diameter?: number;
  59559. sideOrientation?: number;
  59560. }, scene: any): Mesh;
  59561. }
  59562. }
  59563. declare module "babylonjs/Lights/spotLight" {
  59564. import { Nullable } from "babylonjs/types";
  59565. import { Scene } from "babylonjs/scene";
  59566. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59568. import { Effect } from "babylonjs/Materials/effect";
  59569. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59570. import { Light } from "babylonjs/Lights/light";
  59571. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59572. /**
  59573. * A spot light is defined by a position, a direction, an angle, and an exponent.
  59574. * These values define a cone of light starting from the position, emitting toward the direction.
  59575. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  59576. * and the exponent defines the speed of the decay of the light with distance (reach).
  59577. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59578. */
  59579. export class SpotLight extends ShadowLight {
  59580. private _angle;
  59581. private _innerAngle;
  59582. private _cosHalfAngle;
  59583. private _lightAngleScale;
  59584. private _lightAngleOffset;
  59585. /**
  59586. * Gets the cone angle of the spot light in Radians.
  59587. */
  59588. get angle(): number;
  59589. /**
  59590. * Sets the cone angle of the spot light in Radians.
  59591. */
  59592. set angle(value: number);
  59593. /**
  59594. * Only used in gltf falloff mode, this defines the angle where
  59595. * the directional falloff will start before cutting at angle which could be seen
  59596. * as outer angle.
  59597. */
  59598. get innerAngle(): number;
  59599. /**
  59600. * Only used in gltf falloff mode, this defines the angle where
  59601. * the directional falloff will start before cutting at angle which could be seen
  59602. * as outer angle.
  59603. */
  59604. set innerAngle(value: number);
  59605. private _shadowAngleScale;
  59606. /**
  59607. * Allows scaling the angle of the light for shadow generation only.
  59608. */
  59609. get shadowAngleScale(): number;
  59610. /**
  59611. * Allows scaling the angle of the light for shadow generation only.
  59612. */
  59613. set shadowAngleScale(value: number);
  59614. /**
  59615. * The light decay speed with the distance from the emission spot.
  59616. */
  59617. exponent: number;
  59618. private _projectionTextureMatrix;
  59619. /**
  59620. * Allows reading the projecton texture
  59621. */
  59622. get projectionTextureMatrix(): Matrix;
  59623. protected _projectionTextureLightNear: number;
  59624. /**
  59625. * Gets the near clip of the Spotlight for texture projection.
  59626. */
  59627. get projectionTextureLightNear(): number;
  59628. /**
  59629. * Sets the near clip of the Spotlight for texture projection.
  59630. */
  59631. set projectionTextureLightNear(value: number);
  59632. protected _projectionTextureLightFar: number;
  59633. /**
  59634. * Gets the far clip of the Spotlight for texture projection.
  59635. */
  59636. get projectionTextureLightFar(): number;
  59637. /**
  59638. * Sets the far clip of the Spotlight for texture projection.
  59639. */
  59640. set projectionTextureLightFar(value: number);
  59641. protected _projectionTextureUpDirection: Vector3;
  59642. /**
  59643. * Gets the Up vector of the Spotlight for texture projection.
  59644. */
  59645. get projectionTextureUpDirection(): Vector3;
  59646. /**
  59647. * Sets the Up vector of the Spotlight for texture projection.
  59648. */
  59649. set projectionTextureUpDirection(value: Vector3);
  59650. private _projectionTexture;
  59651. /**
  59652. * Gets the projection texture of the light.
  59653. */
  59654. get projectionTexture(): Nullable<BaseTexture>;
  59655. /**
  59656. * Sets the projection texture of the light.
  59657. */
  59658. set projectionTexture(value: Nullable<BaseTexture>);
  59659. private _projectionTextureViewLightDirty;
  59660. private _projectionTextureProjectionLightDirty;
  59661. private _projectionTextureDirty;
  59662. private _projectionTextureViewTargetVector;
  59663. private _projectionTextureViewLightMatrix;
  59664. private _projectionTextureProjectionLightMatrix;
  59665. private _projectionTextureScalingMatrix;
  59666. /**
  59667. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  59668. * It can cast shadows.
  59669. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59670. * @param name The light friendly name
  59671. * @param position The position of the spot light in the scene
  59672. * @param direction The direction of the light in the scene
  59673. * @param angle The cone angle of the light in Radians
  59674. * @param exponent The light decay speed with the distance from the emission spot
  59675. * @param scene The scene the lights belongs to
  59676. */
  59677. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  59678. /**
  59679. * Returns the string "SpotLight".
  59680. * @returns the class name
  59681. */
  59682. getClassName(): string;
  59683. /**
  59684. * Returns the integer 2.
  59685. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59686. */
  59687. getTypeID(): number;
  59688. /**
  59689. * Overrides the direction setter to recompute the projection texture view light Matrix.
  59690. */
  59691. protected _setDirection(value: Vector3): void;
  59692. /**
  59693. * Overrides the position setter to recompute the projection texture view light Matrix.
  59694. */
  59695. protected _setPosition(value: Vector3): void;
  59696. /**
  59697. * 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.
  59698. * Returns the SpotLight.
  59699. */
  59700. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59701. protected _computeProjectionTextureViewLightMatrix(): void;
  59702. protected _computeProjectionTextureProjectionLightMatrix(): void;
  59703. /**
  59704. * Main function for light texture projection matrix computing.
  59705. */
  59706. protected _computeProjectionTextureMatrix(): void;
  59707. protected _buildUniformLayout(): void;
  59708. private _computeAngleValues;
  59709. /**
  59710. * Sets the passed Effect "effect" with the Light textures.
  59711. * @param effect The effect to update
  59712. * @param lightIndex The index of the light in the effect to update
  59713. * @returns The light
  59714. */
  59715. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  59716. /**
  59717. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  59718. * @param effect The effect to update
  59719. * @param lightIndex The index of the light in the effect to update
  59720. * @returns The spot light
  59721. */
  59722. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  59723. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59724. /**
  59725. * Disposes the light and the associated resources.
  59726. */
  59727. dispose(): void;
  59728. /**
  59729. * Prepares the list of defines specific to the light type.
  59730. * @param defines the list of defines
  59731. * @param lightIndex defines the index of the light for the effect
  59732. */
  59733. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59734. }
  59735. }
  59736. declare module "babylonjs/Gizmos/lightGizmo" {
  59737. import { Nullable } from "babylonjs/types";
  59738. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59739. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59740. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59741. import { Light } from "babylonjs/Lights/light";
  59742. import { Observable } from "babylonjs/Misc/observable";
  59743. /**
  59744. * Gizmo that enables viewing a light
  59745. */
  59746. export class LightGizmo extends Gizmo {
  59747. private _lightMesh;
  59748. private _material;
  59749. private _cachedPosition;
  59750. private _cachedForward;
  59751. private _attachedMeshParent;
  59752. private _pointerObserver;
  59753. /**
  59754. * Event that fires each time the gizmo is clicked
  59755. */
  59756. onClickedObservable: Observable<Light>;
  59757. /**
  59758. * Creates a LightGizmo
  59759. * @param gizmoLayer The utility layer the gizmo will be added to
  59760. */
  59761. constructor(gizmoLayer?: UtilityLayerRenderer);
  59762. private _light;
  59763. /**
  59764. * The light that the gizmo is attached to
  59765. */
  59766. set light(light: Nullable<Light>);
  59767. get light(): Nullable<Light>;
  59768. /**
  59769. * Gets the material used to render the light gizmo
  59770. */
  59771. get material(): StandardMaterial;
  59772. /**
  59773. * @hidden
  59774. * Updates the gizmo to match the attached mesh's position/rotation
  59775. */
  59776. protected _update(): void;
  59777. private static _Scale;
  59778. /**
  59779. * Creates the lines for a light mesh
  59780. */
  59781. private static _CreateLightLines;
  59782. /**
  59783. * Disposes of the light gizmo
  59784. */
  59785. dispose(): void;
  59786. private static _CreateHemisphericLightMesh;
  59787. private static _CreatePointLightMesh;
  59788. private static _CreateSpotLightMesh;
  59789. private static _CreateDirectionalLightMesh;
  59790. }
  59791. }
  59792. declare module "babylonjs/Gizmos/cameraGizmo" {
  59793. import { Nullable } from "babylonjs/types";
  59794. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59795. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59796. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59797. import { Camera } from "babylonjs/Cameras/camera";
  59798. import { Observable } from "babylonjs/Misc/observable";
  59799. /**
  59800. * Gizmo that enables viewing a camera
  59801. */
  59802. export class CameraGizmo extends Gizmo {
  59803. private _cameraMesh;
  59804. private _cameraLinesMesh;
  59805. private _material;
  59806. private _pointerObserver;
  59807. /**
  59808. * Event that fires each time the gizmo is clicked
  59809. */
  59810. onClickedObservable: Observable<Camera>;
  59811. /**
  59812. * Creates a CameraGizmo
  59813. * @param gizmoLayer The utility layer the gizmo will be added to
  59814. */
  59815. constructor(gizmoLayer?: UtilityLayerRenderer);
  59816. private _camera;
  59817. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  59818. get displayFrustum(): boolean;
  59819. set displayFrustum(value: boolean);
  59820. /**
  59821. * The camera that the gizmo is attached to
  59822. */
  59823. set camera(camera: Nullable<Camera>);
  59824. get camera(): Nullable<Camera>;
  59825. /**
  59826. * Gets the material used to render the camera gizmo
  59827. */
  59828. get material(): StandardMaterial;
  59829. /**
  59830. * @hidden
  59831. * Updates the gizmo to match the attached mesh's position/rotation
  59832. */
  59833. protected _update(): void;
  59834. private static _Scale;
  59835. private _invProjection;
  59836. /**
  59837. * Disposes of the camera gizmo
  59838. */
  59839. dispose(): void;
  59840. private static _CreateCameraMesh;
  59841. private static _CreateCameraFrustum;
  59842. }
  59843. }
  59844. declare module "babylonjs/Gizmos/index" {
  59845. export * from "babylonjs/Gizmos/axisDragGizmo";
  59846. export * from "babylonjs/Gizmos/axisScaleGizmo";
  59847. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  59848. export * from "babylonjs/Gizmos/gizmo";
  59849. export * from "babylonjs/Gizmos/gizmoManager";
  59850. export * from "babylonjs/Gizmos/planeRotationGizmo";
  59851. export * from "babylonjs/Gizmos/positionGizmo";
  59852. export * from "babylonjs/Gizmos/rotationGizmo";
  59853. export * from "babylonjs/Gizmos/scaleGizmo";
  59854. export * from "babylonjs/Gizmos/lightGizmo";
  59855. export * from "babylonjs/Gizmos/cameraGizmo";
  59856. export * from "babylonjs/Gizmos/planeDragGizmo";
  59857. }
  59858. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  59859. /** @hidden */
  59860. export var backgroundFragmentDeclaration: {
  59861. name: string;
  59862. shader: string;
  59863. };
  59864. }
  59865. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  59866. /** @hidden */
  59867. export var backgroundUboDeclaration: {
  59868. name: string;
  59869. shader: string;
  59870. };
  59871. }
  59872. declare module "babylonjs/Shaders/background.fragment" {
  59873. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  59874. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59875. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59876. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59877. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59878. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59879. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59880. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59881. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59882. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59883. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  59884. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59885. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59886. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59887. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  59888. /** @hidden */
  59889. export var backgroundPixelShader: {
  59890. name: string;
  59891. shader: string;
  59892. };
  59893. }
  59894. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  59895. /** @hidden */
  59896. export var backgroundVertexDeclaration: {
  59897. name: string;
  59898. shader: string;
  59899. };
  59900. }
  59901. declare module "babylonjs/Shaders/background.vertex" {
  59902. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  59903. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  59904. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59905. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59906. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59907. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59908. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59909. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59910. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59911. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59912. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59913. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59914. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59915. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59916. /** @hidden */
  59917. export var backgroundVertexShader: {
  59918. name: string;
  59919. shader: string;
  59920. };
  59921. }
  59922. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  59923. import { Nullable, int, float } from "babylonjs/types";
  59924. import { Scene } from "babylonjs/scene";
  59925. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59926. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59928. import { Mesh } from "babylonjs/Meshes/mesh";
  59929. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59930. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59931. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59932. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59933. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  59934. import { Color3 } from "babylonjs/Maths/math.color";
  59935. import "babylonjs/Shaders/background.fragment";
  59936. import "babylonjs/Shaders/background.vertex";
  59937. /**
  59938. * Background material used to create an efficient environement around your scene.
  59939. */
  59940. export class BackgroundMaterial extends PushMaterial {
  59941. /**
  59942. * Standard reflectance value at parallel view angle.
  59943. */
  59944. static StandardReflectance0: number;
  59945. /**
  59946. * Standard reflectance value at grazing angle.
  59947. */
  59948. static StandardReflectance90: number;
  59949. protected _primaryColor: Color3;
  59950. /**
  59951. * Key light Color (multiply against the environement texture)
  59952. */
  59953. primaryColor: Color3;
  59954. protected __perceptualColor: Nullable<Color3>;
  59955. /**
  59956. * Experimental Internal Use Only.
  59957. *
  59958. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  59959. * This acts as a helper to set the primary color to a more "human friendly" value.
  59960. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  59961. * output color as close as possible from the chosen value.
  59962. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  59963. * part of lighting setup.)
  59964. */
  59965. get _perceptualColor(): Nullable<Color3>;
  59966. set _perceptualColor(value: Nullable<Color3>);
  59967. protected _primaryColorShadowLevel: float;
  59968. /**
  59969. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  59970. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  59971. */
  59972. get primaryColorShadowLevel(): float;
  59973. set primaryColorShadowLevel(value: float);
  59974. protected _primaryColorHighlightLevel: float;
  59975. /**
  59976. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  59977. * The primary color is used at the level chosen to define what the white area would look.
  59978. */
  59979. get primaryColorHighlightLevel(): float;
  59980. set primaryColorHighlightLevel(value: float);
  59981. protected _reflectionTexture: Nullable<BaseTexture>;
  59982. /**
  59983. * Reflection Texture used in the material.
  59984. * Should be author in a specific way for the best result (refer to the documentation).
  59985. */
  59986. reflectionTexture: Nullable<BaseTexture>;
  59987. protected _reflectionBlur: float;
  59988. /**
  59989. * Reflection Texture level of blur.
  59990. *
  59991. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  59992. * texture twice.
  59993. */
  59994. reflectionBlur: float;
  59995. protected _diffuseTexture: Nullable<BaseTexture>;
  59996. /**
  59997. * Diffuse Texture used in the material.
  59998. * Should be author in a specific way for the best result (refer to the documentation).
  59999. */
  60000. diffuseTexture: Nullable<BaseTexture>;
  60001. protected _shadowLights: Nullable<IShadowLight[]>;
  60002. /**
  60003. * Specify the list of lights casting shadow on the material.
  60004. * All scene shadow lights will be included if null.
  60005. */
  60006. shadowLights: Nullable<IShadowLight[]>;
  60007. protected _shadowLevel: float;
  60008. /**
  60009. * Helps adjusting the shadow to a softer level if required.
  60010. * 0 means black shadows and 1 means no shadows.
  60011. */
  60012. shadowLevel: float;
  60013. protected _sceneCenter: Vector3;
  60014. /**
  60015. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60016. * It is usually zero but might be interesting to modify according to your setup.
  60017. */
  60018. sceneCenter: Vector3;
  60019. protected _opacityFresnel: boolean;
  60020. /**
  60021. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60022. * This helps ensuring a nice transition when the camera goes under the ground.
  60023. */
  60024. opacityFresnel: boolean;
  60025. protected _reflectionFresnel: boolean;
  60026. /**
  60027. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60028. * This helps adding a mirror texture on the ground.
  60029. */
  60030. reflectionFresnel: boolean;
  60031. protected _reflectionFalloffDistance: number;
  60032. /**
  60033. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60034. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60035. */
  60036. reflectionFalloffDistance: number;
  60037. protected _reflectionAmount: number;
  60038. /**
  60039. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60040. */
  60041. reflectionAmount: number;
  60042. protected _reflectionReflectance0: number;
  60043. /**
  60044. * This specifies the weight of the reflection at grazing angle.
  60045. */
  60046. reflectionReflectance0: number;
  60047. protected _reflectionReflectance90: number;
  60048. /**
  60049. * This specifies the weight of the reflection at a perpendicular point of view.
  60050. */
  60051. reflectionReflectance90: number;
  60052. /**
  60053. * Sets the reflection reflectance fresnel values according to the default standard
  60054. * empirically know to work well :-)
  60055. */
  60056. set reflectionStandardFresnelWeight(value: number);
  60057. protected _useRGBColor: boolean;
  60058. /**
  60059. * Helps to directly use the maps channels instead of their level.
  60060. */
  60061. useRGBColor: boolean;
  60062. protected _enableNoise: boolean;
  60063. /**
  60064. * This helps reducing the banding effect that could occur on the background.
  60065. */
  60066. enableNoise: boolean;
  60067. /**
  60068. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60069. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60070. * Recommended to be keep at 1.0 except for special cases.
  60071. */
  60072. get fovMultiplier(): number;
  60073. set fovMultiplier(value: number);
  60074. private _fovMultiplier;
  60075. /**
  60076. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60077. */
  60078. useEquirectangularFOV: boolean;
  60079. private _maxSimultaneousLights;
  60080. /**
  60081. * Number of Simultaneous lights allowed on the material.
  60082. */
  60083. maxSimultaneousLights: int;
  60084. private _shadowOnly;
  60085. /**
  60086. * Make the material only render shadows
  60087. */
  60088. shadowOnly: boolean;
  60089. /**
  60090. * Default configuration related to image processing available in the Background Material.
  60091. */
  60092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60093. /**
  60094. * Keep track of the image processing observer to allow dispose and replace.
  60095. */
  60096. private _imageProcessingObserver;
  60097. /**
  60098. * Attaches a new image processing configuration to the PBR Material.
  60099. * @param configuration (if null the scene configuration will be use)
  60100. */
  60101. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60102. /**
  60103. * Gets the image processing configuration used either in this material.
  60104. */
  60105. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60106. /**
  60107. * Sets the Default image processing configuration used either in the this material.
  60108. *
  60109. * If sets to null, the scene one is in use.
  60110. */
  60111. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60112. /**
  60113. * Gets wether the color curves effect is enabled.
  60114. */
  60115. get cameraColorCurvesEnabled(): boolean;
  60116. /**
  60117. * Sets wether the color curves effect is enabled.
  60118. */
  60119. set cameraColorCurvesEnabled(value: boolean);
  60120. /**
  60121. * Gets wether the color grading effect is enabled.
  60122. */
  60123. get cameraColorGradingEnabled(): boolean;
  60124. /**
  60125. * Gets wether the color grading effect is enabled.
  60126. */
  60127. set cameraColorGradingEnabled(value: boolean);
  60128. /**
  60129. * Gets wether tonemapping is enabled or not.
  60130. */
  60131. get cameraToneMappingEnabled(): boolean;
  60132. /**
  60133. * Sets wether tonemapping is enabled or not
  60134. */
  60135. set cameraToneMappingEnabled(value: boolean);
  60136. /**
  60137. * The camera exposure used on this material.
  60138. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60139. * This corresponds to a photographic exposure.
  60140. */
  60141. get cameraExposure(): float;
  60142. /**
  60143. * The camera exposure used on this material.
  60144. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60145. * This corresponds to a photographic exposure.
  60146. */
  60147. set cameraExposure(value: float);
  60148. /**
  60149. * Gets The camera contrast used on this material.
  60150. */
  60151. get cameraContrast(): float;
  60152. /**
  60153. * Sets The camera contrast used on this material.
  60154. */
  60155. set cameraContrast(value: float);
  60156. /**
  60157. * Gets the Color Grading 2D Lookup Texture.
  60158. */
  60159. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60160. /**
  60161. * Sets the Color Grading 2D Lookup Texture.
  60162. */
  60163. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60164. /**
  60165. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60166. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60167. * 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;
  60168. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60169. */
  60170. get cameraColorCurves(): Nullable<ColorCurves>;
  60171. /**
  60172. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60173. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60174. * 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;
  60175. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60176. */
  60177. set cameraColorCurves(value: Nullable<ColorCurves>);
  60178. /**
  60179. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60180. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60181. */
  60182. switchToBGR: boolean;
  60183. private _renderTargets;
  60184. private _reflectionControls;
  60185. private _white;
  60186. private _primaryShadowColor;
  60187. private _primaryHighlightColor;
  60188. /**
  60189. * Instantiates a Background Material in the given scene
  60190. * @param name The friendly name of the material
  60191. * @param scene The scene to add the material to
  60192. */
  60193. constructor(name: string, scene: Scene);
  60194. /**
  60195. * Gets a boolean indicating that current material needs to register RTT
  60196. */
  60197. get hasRenderTargetTextures(): boolean;
  60198. /**
  60199. * The entire material has been created in order to prevent overdraw.
  60200. * @returns false
  60201. */
  60202. needAlphaTesting(): boolean;
  60203. /**
  60204. * The entire material has been created in order to prevent overdraw.
  60205. * @returns true if blending is enable
  60206. */
  60207. needAlphaBlending(): boolean;
  60208. /**
  60209. * Checks wether the material is ready to be rendered for a given mesh.
  60210. * @param mesh The mesh to render
  60211. * @param subMesh The submesh to check against
  60212. * @param useInstances Specify wether or not the material is used with instances
  60213. * @returns true if all the dependencies are ready (Textures, Effects...)
  60214. */
  60215. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60216. /**
  60217. * Compute the primary color according to the chosen perceptual color.
  60218. */
  60219. private _computePrimaryColorFromPerceptualColor;
  60220. /**
  60221. * Compute the highlights and shadow colors according to their chosen levels.
  60222. */
  60223. private _computePrimaryColors;
  60224. /**
  60225. * Build the uniform buffer used in the material.
  60226. */
  60227. buildUniformLayout(): void;
  60228. /**
  60229. * Unbind the material.
  60230. */
  60231. unbind(): void;
  60232. /**
  60233. * Bind only the world matrix to the material.
  60234. * @param world The world matrix to bind.
  60235. */
  60236. bindOnlyWorldMatrix(world: Matrix): void;
  60237. /**
  60238. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60239. * @param world The world matrix to bind.
  60240. * @param subMesh The submesh to bind for.
  60241. */
  60242. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60243. /**
  60244. * Checks to see if a texture is used in the material.
  60245. * @param texture - Base texture to use.
  60246. * @returns - Boolean specifying if a texture is used in the material.
  60247. */
  60248. hasTexture(texture: BaseTexture): boolean;
  60249. /**
  60250. * Dispose the material.
  60251. * @param forceDisposeEffect Force disposal of the associated effect.
  60252. * @param forceDisposeTextures Force disposal of the associated textures.
  60253. */
  60254. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60255. /**
  60256. * Clones the material.
  60257. * @param name The cloned name.
  60258. * @returns The cloned material.
  60259. */
  60260. clone(name: string): BackgroundMaterial;
  60261. /**
  60262. * Serializes the current material to its JSON representation.
  60263. * @returns The JSON representation.
  60264. */
  60265. serialize(): any;
  60266. /**
  60267. * Gets the class name of the material
  60268. * @returns "BackgroundMaterial"
  60269. */
  60270. getClassName(): string;
  60271. /**
  60272. * Parse a JSON input to create back a background material.
  60273. * @param source The JSON data to parse
  60274. * @param scene The scene to create the parsed material in
  60275. * @param rootUrl The root url of the assets the material depends upon
  60276. * @returns the instantiated BackgroundMaterial.
  60277. */
  60278. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60279. }
  60280. }
  60281. declare module "babylonjs/Helpers/environmentHelper" {
  60282. import { Observable } from "babylonjs/Misc/observable";
  60283. import { Nullable } from "babylonjs/types";
  60284. import { Scene } from "babylonjs/scene";
  60285. import { Vector3 } from "babylonjs/Maths/math.vector";
  60286. import { Color3 } from "babylonjs/Maths/math.color";
  60287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60288. import { Mesh } from "babylonjs/Meshes/mesh";
  60289. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60290. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60291. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60292. import "babylonjs/Meshes/Builders/planeBuilder";
  60293. import "babylonjs/Meshes/Builders/boxBuilder";
  60294. /**
  60295. * Represents the different options available during the creation of
  60296. * a Environment helper.
  60297. *
  60298. * This can control the default ground, skybox and image processing setup of your scene.
  60299. */
  60300. export interface IEnvironmentHelperOptions {
  60301. /**
  60302. * Specifies whether or not to create a ground.
  60303. * True by default.
  60304. */
  60305. createGround: boolean;
  60306. /**
  60307. * Specifies the ground size.
  60308. * 15 by default.
  60309. */
  60310. groundSize: number;
  60311. /**
  60312. * The texture used on the ground for the main color.
  60313. * Comes from the BabylonJS CDN by default.
  60314. *
  60315. * Remarks: Can be either a texture or a url.
  60316. */
  60317. groundTexture: string | BaseTexture;
  60318. /**
  60319. * The color mixed in the ground texture by default.
  60320. * BabylonJS clearColor by default.
  60321. */
  60322. groundColor: Color3;
  60323. /**
  60324. * Specifies the ground opacity.
  60325. * 1 by default.
  60326. */
  60327. groundOpacity: number;
  60328. /**
  60329. * Enables the ground to receive shadows.
  60330. * True by default.
  60331. */
  60332. enableGroundShadow: boolean;
  60333. /**
  60334. * Helps preventing the shadow to be fully black on the ground.
  60335. * 0.5 by default.
  60336. */
  60337. groundShadowLevel: number;
  60338. /**
  60339. * Creates a mirror texture attach to the ground.
  60340. * false by default.
  60341. */
  60342. enableGroundMirror: boolean;
  60343. /**
  60344. * Specifies the ground mirror size ratio.
  60345. * 0.3 by default as the default kernel is 64.
  60346. */
  60347. groundMirrorSizeRatio: number;
  60348. /**
  60349. * Specifies the ground mirror blur kernel size.
  60350. * 64 by default.
  60351. */
  60352. groundMirrorBlurKernel: number;
  60353. /**
  60354. * Specifies the ground mirror visibility amount.
  60355. * 1 by default
  60356. */
  60357. groundMirrorAmount: number;
  60358. /**
  60359. * Specifies the ground mirror reflectance weight.
  60360. * This uses the standard weight of the background material to setup the fresnel effect
  60361. * of the mirror.
  60362. * 1 by default.
  60363. */
  60364. groundMirrorFresnelWeight: number;
  60365. /**
  60366. * Specifies the ground mirror Falloff distance.
  60367. * This can helps reducing the size of the reflection.
  60368. * 0 by Default.
  60369. */
  60370. groundMirrorFallOffDistance: number;
  60371. /**
  60372. * Specifies the ground mirror texture type.
  60373. * Unsigned Int by Default.
  60374. */
  60375. groundMirrorTextureType: number;
  60376. /**
  60377. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60378. * the shown objects.
  60379. */
  60380. groundYBias: number;
  60381. /**
  60382. * Specifies whether or not to create a skybox.
  60383. * True by default.
  60384. */
  60385. createSkybox: boolean;
  60386. /**
  60387. * Specifies the skybox size.
  60388. * 20 by default.
  60389. */
  60390. skyboxSize: number;
  60391. /**
  60392. * The texture used on the skybox for the main color.
  60393. * Comes from the BabylonJS CDN by default.
  60394. *
  60395. * Remarks: Can be either a texture or a url.
  60396. */
  60397. skyboxTexture: string | BaseTexture;
  60398. /**
  60399. * The color mixed in the skybox texture by default.
  60400. * BabylonJS clearColor by default.
  60401. */
  60402. skyboxColor: Color3;
  60403. /**
  60404. * The background rotation around the Y axis of the scene.
  60405. * This helps aligning the key lights of your scene with the background.
  60406. * 0 by default.
  60407. */
  60408. backgroundYRotation: number;
  60409. /**
  60410. * Compute automatically the size of the elements to best fit with the scene.
  60411. */
  60412. sizeAuto: boolean;
  60413. /**
  60414. * Default position of the rootMesh if autoSize is not true.
  60415. */
  60416. rootPosition: Vector3;
  60417. /**
  60418. * Sets up the image processing in the scene.
  60419. * true by default.
  60420. */
  60421. setupImageProcessing: boolean;
  60422. /**
  60423. * The texture used as your environment texture in the scene.
  60424. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60425. *
  60426. * Remarks: Can be either a texture or a url.
  60427. */
  60428. environmentTexture: string | BaseTexture;
  60429. /**
  60430. * The value of the exposure to apply to the scene.
  60431. * 0.6 by default if setupImageProcessing is true.
  60432. */
  60433. cameraExposure: number;
  60434. /**
  60435. * The value of the contrast to apply to the scene.
  60436. * 1.6 by default if setupImageProcessing is true.
  60437. */
  60438. cameraContrast: number;
  60439. /**
  60440. * Specifies whether or not tonemapping should be enabled in the scene.
  60441. * true by default if setupImageProcessing is true.
  60442. */
  60443. toneMappingEnabled: boolean;
  60444. }
  60445. /**
  60446. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60447. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60448. * It also helps with the default setup of your imageProcessing configuration.
  60449. */
  60450. export class EnvironmentHelper {
  60451. /**
  60452. * Default ground texture URL.
  60453. */
  60454. private static _groundTextureCDNUrl;
  60455. /**
  60456. * Default skybox texture URL.
  60457. */
  60458. private static _skyboxTextureCDNUrl;
  60459. /**
  60460. * Default environment texture URL.
  60461. */
  60462. private static _environmentTextureCDNUrl;
  60463. /**
  60464. * Creates the default options for the helper.
  60465. */
  60466. private static _getDefaultOptions;
  60467. private _rootMesh;
  60468. /**
  60469. * Gets the root mesh created by the helper.
  60470. */
  60471. get rootMesh(): Mesh;
  60472. private _skybox;
  60473. /**
  60474. * Gets the skybox created by the helper.
  60475. */
  60476. get skybox(): Nullable<Mesh>;
  60477. private _skyboxTexture;
  60478. /**
  60479. * Gets the skybox texture created by the helper.
  60480. */
  60481. get skyboxTexture(): Nullable<BaseTexture>;
  60482. private _skyboxMaterial;
  60483. /**
  60484. * Gets the skybox material created by the helper.
  60485. */
  60486. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60487. private _ground;
  60488. /**
  60489. * Gets the ground mesh created by the helper.
  60490. */
  60491. get ground(): Nullable<Mesh>;
  60492. private _groundTexture;
  60493. /**
  60494. * Gets the ground texture created by the helper.
  60495. */
  60496. get groundTexture(): Nullable<BaseTexture>;
  60497. private _groundMirror;
  60498. /**
  60499. * Gets the ground mirror created by the helper.
  60500. */
  60501. get groundMirror(): Nullable<MirrorTexture>;
  60502. /**
  60503. * Gets the ground mirror render list to helps pushing the meshes
  60504. * you wish in the ground reflection.
  60505. */
  60506. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60507. private _groundMaterial;
  60508. /**
  60509. * Gets the ground material created by the helper.
  60510. */
  60511. get groundMaterial(): Nullable<BackgroundMaterial>;
  60512. /**
  60513. * Stores the creation options.
  60514. */
  60515. private readonly _scene;
  60516. private _options;
  60517. /**
  60518. * This observable will be notified with any error during the creation of the environment,
  60519. * mainly texture creation errors.
  60520. */
  60521. onErrorObservable: Observable<{
  60522. message?: string;
  60523. exception?: any;
  60524. }>;
  60525. /**
  60526. * constructor
  60527. * @param options Defines the options we want to customize the helper
  60528. * @param scene The scene to add the material to
  60529. */
  60530. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60531. /**
  60532. * Updates the background according to the new options
  60533. * @param options
  60534. */
  60535. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60536. /**
  60537. * Sets the primary color of all the available elements.
  60538. * @param color the main color to affect to the ground and the background
  60539. */
  60540. setMainColor(color: Color3): void;
  60541. /**
  60542. * Setup the image processing according to the specified options.
  60543. */
  60544. private _setupImageProcessing;
  60545. /**
  60546. * Setup the environment texture according to the specified options.
  60547. */
  60548. private _setupEnvironmentTexture;
  60549. /**
  60550. * Setup the background according to the specified options.
  60551. */
  60552. private _setupBackground;
  60553. /**
  60554. * Get the scene sizes according to the setup.
  60555. */
  60556. private _getSceneSize;
  60557. /**
  60558. * Setup the ground according to the specified options.
  60559. */
  60560. private _setupGround;
  60561. /**
  60562. * Setup the ground material according to the specified options.
  60563. */
  60564. private _setupGroundMaterial;
  60565. /**
  60566. * Setup the ground diffuse texture according to the specified options.
  60567. */
  60568. private _setupGroundDiffuseTexture;
  60569. /**
  60570. * Setup the ground mirror texture according to the specified options.
  60571. */
  60572. private _setupGroundMirrorTexture;
  60573. /**
  60574. * Setup the ground to receive the mirror texture.
  60575. */
  60576. private _setupMirrorInGroundMaterial;
  60577. /**
  60578. * Setup the skybox according to the specified options.
  60579. */
  60580. private _setupSkybox;
  60581. /**
  60582. * Setup the skybox material according to the specified options.
  60583. */
  60584. private _setupSkyboxMaterial;
  60585. /**
  60586. * Setup the skybox reflection texture according to the specified options.
  60587. */
  60588. private _setupSkyboxReflectionTexture;
  60589. private _errorHandler;
  60590. /**
  60591. * Dispose all the elements created by the Helper.
  60592. */
  60593. dispose(): void;
  60594. }
  60595. }
  60596. declare module "babylonjs/Helpers/textureDome" {
  60597. import { Scene } from "babylonjs/scene";
  60598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60599. import { Mesh } from "babylonjs/Meshes/mesh";
  60600. import { Texture } from "babylonjs/Materials/Textures/texture";
  60601. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60602. import "babylonjs/Meshes/Builders/sphereBuilder";
  60603. import { Nullable } from "babylonjs/types";
  60604. import { Observable } from "babylonjs/Misc/observable";
  60605. /**
  60606. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  60607. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  60608. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60609. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60610. */
  60611. export abstract class TextureDome<T extends Texture> extends TransformNode {
  60612. protected onError: Nullable<(message?: string, exception?: any) => void>;
  60613. /**
  60614. * Define the source as a Monoscopic panoramic 360/180.
  60615. */
  60616. static readonly MODE_MONOSCOPIC: number;
  60617. /**
  60618. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  60619. */
  60620. static readonly MODE_TOPBOTTOM: number;
  60621. /**
  60622. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  60623. */
  60624. static readonly MODE_SIDEBYSIDE: number;
  60625. private _halfDome;
  60626. private _crossEye;
  60627. protected _useDirectMapping: boolean;
  60628. /**
  60629. * The texture being displayed on the sphere
  60630. */
  60631. protected _texture: T;
  60632. /**
  60633. * Gets the texture being displayed on the sphere
  60634. */
  60635. get texture(): T;
  60636. /**
  60637. * Sets the texture being displayed on the sphere
  60638. */
  60639. set texture(newTexture: T);
  60640. /**
  60641. * The skybox material
  60642. */
  60643. protected _material: BackgroundMaterial;
  60644. /**
  60645. * The surface used for the dome
  60646. */
  60647. protected _mesh: Mesh;
  60648. /**
  60649. * Gets the mesh used for the dome.
  60650. */
  60651. get mesh(): Mesh;
  60652. /**
  60653. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  60654. */
  60655. private _halfDomeMask;
  60656. /**
  60657. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60658. * Also see the options.resolution property.
  60659. */
  60660. get fovMultiplier(): number;
  60661. set fovMultiplier(value: number);
  60662. protected _textureMode: number;
  60663. /**
  60664. * Gets or set the current texture mode for the texture. It can be:
  60665. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60666. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60667. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60668. */
  60669. get textureMode(): number;
  60670. /**
  60671. * Sets the current texture mode for the texture. It can be:
  60672. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60673. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60674. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60675. */
  60676. set textureMode(value: number);
  60677. /**
  60678. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  60679. */
  60680. get halfDome(): boolean;
  60681. /**
  60682. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60683. */
  60684. set halfDome(enabled: boolean);
  60685. /**
  60686. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  60687. */
  60688. set crossEye(enabled: boolean);
  60689. /**
  60690. * Is it a cross-eye texture?
  60691. */
  60692. get crossEye(): boolean;
  60693. /**
  60694. * Oberserver used in Stereoscopic VR Mode.
  60695. */
  60696. private _onBeforeCameraRenderObserver;
  60697. /**
  60698. * Observable raised when an error occured while loading the 360 image
  60699. */
  60700. onLoadErrorObservable: Observable<string>;
  60701. /**
  60702. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  60703. * @param name Element's name, child elements will append suffixes for their own names.
  60704. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  60705. * @param options An object containing optional or exposed sub element properties
  60706. */
  60707. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  60708. resolution?: number;
  60709. clickToPlay?: boolean;
  60710. autoPlay?: boolean;
  60711. loop?: boolean;
  60712. size?: number;
  60713. poster?: string;
  60714. faceForward?: boolean;
  60715. useDirectMapping?: boolean;
  60716. halfDomeMode?: boolean;
  60717. crossEyeMode?: boolean;
  60718. generateMipMaps?: boolean;
  60719. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  60720. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  60721. protected _changeTextureMode(value: number): void;
  60722. /**
  60723. * Releases resources associated with this node.
  60724. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60725. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60726. */
  60727. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60728. }
  60729. }
  60730. declare module "babylonjs/Helpers/photoDome" {
  60731. import { Scene } from "babylonjs/scene";
  60732. import { Texture } from "babylonjs/Materials/Textures/texture";
  60733. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60734. /**
  60735. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  60736. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  60737. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  60738. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60739. */
  60740. export class PhotoDome extends TextureDome<Texture> {
  60741. /**
  60742. * Define the image as a Monoscopic panoramic 360 image.
  60743. */
  60744. static readonly MODE_MONOSCOPIC: number;
  60745. /**
  60746. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  60747. */
  60748. static readonly MODE_TOPBOTTOM: number;
  60749. /**
  60750. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  60751. */
  60752. static readonly MODE_SIDEBYSIDE: number;
  60753. /**
  60754. * Gets or sets the texture being displayed on the sphere
  60755. */
  60756. get photoTexture(): Texture;
  60757. /**
  60758. * sets the texture being displayed on the sphere
  60759. */
  60760. set photoTexture(value: Texture);
  60761. /**
  60762. * Gets the current video mode for the video. It can be:
  60763. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60764. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60765. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60766. */
  60767. get imageMode(): number;
  60768. /**
  60769. * Sets the current video mode for the video. It can be:
  60770. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  60771. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  60772. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  60773. */
  60774. set imageMode(value: number);
  60775. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  60776. }
  60777. }
  60778. declare module "babylonjs/Misc/dds" {
  60779. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60780. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60781. import { Nullable } from "babylonjs/types";
  60782. import { Scene } from "babylonjs/scene";
  60783. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60784. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60785. /**
  60786. * Direct draw surface info
  60787. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60788. */
  60789. export interface DDSInfo {
  60790. /**
  60791. * Width of the texture
  60792. */
  60793. width: number;
  60794. /**
  60795. * Width of the texture
  60796. */
  60797. height: number;
  60798. /**
  60799. * Number of Mipmaps for the texture
  60800. * @see https://en.wikipedia.org/wiki/Mipmap
  60801. */
  60802. mipmapCount: number;
  60803. /**
  60804. * If the textures format is a known fourCC format
  60805. * @see https://www.fourcc.org/
  60806. */
  60807. isFourCC: boolean;
  60808. /**
  60809. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60810. */
  60811. isRGB: boolean;
  60812. /**
  60813. * If the texture is a lumincance format
  60814. */
  60815. isLuminance: boolean;
  60816. /**
  60817. * If this is a cube texture
  60818. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60819. */
  60820. isCube: boolean;
  60821. /**
  60822. * If the texture is a compressed format eg. FOURCC_DXT1
  60823. */
  60824. isCompressed: boolean;
  60825. /**
  60826. * The dxgiFormat of the texture
  60827. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60828. */
  60829. dxgiFormat: number;
  60830. /**
  60831. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60832. */
  60833. textureType: number;
  60834. /**
  60835. * Sphericle polynomial created for the dds texture
  60836. */
  60837. sphericalPolynomial?: SphericalPolynomial;
  60838. }
  60839. /**
  60840. * Class used to provide DDS decompression tools
  60841. */
  60842. export class DDSTools {
  60843. /**
  60844. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60845. */
  60846. static StoreLODInAlphaChannel: boolean;
  60847. /**
  60848. * Gets DDS information from an array buffer
  60849. * @param data defines the array buffer view to read data from
  60850. * @returns the DDS information
  60851. */
  60852. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60853. private static _FloatView;
  60854. private static _Int32View;
  60855. private static _ToHalfFloat;
  60856. private static _FromHalfFloat;
  60857. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60858. private static _GetHalfFloatRGBAArrayBuffer;
  60859. private static _GetFloatRGBAArrayBuffer;
  60860. private static _GetFloatAsUIntRGBAArrayBuffer;
  60861. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60862. private static _GetRGBAArrayBuffer;
  60863. private static _ExtractLongWordOrder;
  60864. private static _GetRGBArrayBuffer;
  60865. private static _GetLuminanceArrayBuffer;
  60866. /**
  60867. * Uploads DDS Levels to a Babylon Texture
  60868. * @hidden
  60869. */
  60870. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60871. }
  60872. module "babylonjs/Engines/thinEngine" {
  60873. interface ThinEngine {
  60874. /**
  60875. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60876. * @param rootUrl defines the url where the file to load is located
  60877. * @param scene defines the current scene
  60878. * @param lodScale defines scale to apply to the mip map selection
  60879. * @param lodOffset defines offset to apply to the mip map selection
  60880. * @param onLoad defines an optional callback raised when the texture is loaded
  60881. * @param onError defines an optional callback raised if there is an issue to load the texture
  60882. * @param format defines the format of the data
  60883. * @param forcedExtension defines the extension to use to pick the right loader
  60884. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60885. * @returns the cube texture as an InternalTexture
  60886. */
  60887. 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;
  60888. }
  60889. }
  60890. }
  60891. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60892. import { Nullable } from "babylonjs/types";
  60893. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60894. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60895. /**
  60896. * Implementation of the DDS Texture Loader.
  60897. * @hidden
  60898. */
  60899. export class _DDSTextureLoader implements IInternalTextureLoader {
  60900. /**
  60901. * Defines wether the loader supports cascade loading the different faces.
  60902. */
  60903. readonly supportCascades: boolean;
  60904. /**
  60905. * This returns if the loader support the current file information.
  60906. * @param extension defines the file extension of the file being loaded
  60907. * @returns true if the loader can load the specified file
  60908. */
  60909. canLoad(extension: string): boolean;
  60910. /**
  60911. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60912. * @param data contains the texture data
  60913. * @param texture defines the BabylonJS internal texture
  60914. * @param createPolynomials will be true if polynomials have been requested
  60915. * @param onLoad defines the callback to trigger once the texture is ready
  60916. * @param onError defines the callback to trigger in case of error
  60917. */
  60918. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60919. /**
  60920. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60921. * @param data contains the texture data
  60922. * @param texture defines the BabylonJS internal texture
  60923. * @param callback defines the method to call once ready to upload
  60924. */
  60925. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60926. }
  60927. }
  60928. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60929. import { Nullable } from "babylonjs/types";
  60930. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60931. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60932. /**
  60933. * Implementation of the ENV Texture Loader.
  60934. * @hidden
  60935. */
  60936. export class _ENVTextureLoader implements IInternalTextureLoader {
  60937. /**
  60938. * Defines wether the loader supports cascade loading the different faces.
  60939. */
  60940. readonly supportCascades: boolean;
  60941. /**
  60942. * This returns if the loader support the current file information.
  60943. * @param extension defines the file extension of the file being loaded
  60944. * @returns true if the loader can load the specified file
  60945. */
  60946. canLoad(extension: string): boolean;
  60947. /**
  60948. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60949. * @param data contains the texture data
  60950. * @param texture defines the BabylonJS internal texture
  60951. * @param createPolynomials will be true if polynomials have been requested
  60952. * @param onLoad defines the callback to trigger once the texture is ready
  60953. * @param onError defines the callback to trigger in case of error
  60954. */
  60955. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60956. /**
  60957. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60958. * @param data contains the texture data
  60959. * @param texture defines the BabylonJS internal texture
  60960. * @param callback defines the method to call once ready to upload
  60961. */
  60962. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60963. }
  60964. }
  60965. declare module "babylonjs/Misc/khronosTextureContainer" {
  60966. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60967. /**
  60968. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60969. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60970. */
  60971. export class KhronosTextureContainer {
  60972. /** contents of the KTX container file */
  60973. data: ArrayBufferView;
  60974. private static HEADER_LEN;
  60975. private static COMPRESSED_2D;
  60976. private static COMPRESSED_3D;
  60977. private static TEX_2D;
  60978. private static TEX_3D;
  60979. /**
  60980. * Gets the openGL type
  60981. */
  60982. glType: number;
  60983. /**
  60984. * Gets the openGL type size
  60985. */
  60986. glTypeSize: number;
  60987. /**
  60988. * Gets the openGL format
  60989. */
  60990. glFormat: number;
  60991. /**
  60992. * Gets the openGL internal format
  60993. */
  60994. glInternalFormat: number;
  60995. /**
  60996. * Gets the base internal format
  60997. */
  60998. glBaseInternalFormat: number;
  60999. /**
  61000. * Gets image width in pixel
  61001. */
  61002. pixelWidth: number;
  61003. /**
  61004. * Gets image height in pixel
  61005. */
  61006. pixelHeight: number;
  61007. /**
  61008. * Gets image depth in pixels
  61009. */
  61010. pixelDepth: number;
  61011. /**
  61012. * Gets the number of array elements
  61013. */
  61014. numberOfArrayElements: number;
  61015. /**
  61016. * Gets the number of faces
  61017. */
  61018. numberOfFaces: number;
  61019. /**
  61020. * Gets the number of mipmap levels
  61021. */
  61022. numberOfMipmapLevels: number;
  61023. /**
  61024. * Gets the bytes of key value data
  61025. */
  61026. bytesOfKeyValueData: number;
  61027. /**
  61028. * Gets the load type
  61029. */
  61030. loadType: number;
  61031. /**
  61032. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61033. */
  61034. isInvalid: boolean;
  61035. /**
  61036. * Creates a new KhronosTextureContainer
  61037. * @param data contents of the KTX container file
  61038. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61039. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61040. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61041. */
  61042. constructor(
  61043. /** contents of the KTX container file */
  61044. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61045. /**
  61046. * Uploads KTX content to a Babylon Texture.
  61047. * It is assumed that the texture has already been created & is currently bound
  61048. * @hidden
  61049. */
  61050. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61051. private _upload2DCompressedLevels;
  61052. /**
  61053. * Checks if the given data starts with a KTX file identifier.
  61054. * @param data the data to check
  61055. * @returns true if the data is a KTX file or false otherwise
  61056. */
  61057. static IsValid(data: ArrayBufferView): boolean;
  61058. }
  61059. }
  61060. declare module "babylonjs/Misc/workerPool" {
  61061. import { IDisposable } from "babylonjs/scene";
  61062. /**
  61063. * Helper class to push actions to a pool of workers.
  61064. */
  61065. export class WorkerPool implements IDisposable {
  61066. private _workerInfos;
  61067. private _pendingActions;
  61068. /**
  61069. * Constructor
  61070. * @param workers Array of workers to use for actions
  61071. */
  61072. constructor(workers: Array<Worker>);
  61073. /**
  61074. * Terminates all workers and clears any pending actions.
  61075. */
  61076. dispose(): void;
  61077. /**
  61078. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61079. * pended until a worker has completed its action.
  61080. * @param action The action to perform. Call onComplete when the action is complete.
  61081. */
  61082. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61083. private _execute;
  61084. }
  61085. }
  61086. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61087. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61088. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61089. /**
  61090. * Class for loading KTX2 files
  61091. */
  61092. export class KhronosTextureContainer2 {
  61093. private static _WorkerPoolPromise?;
  61094. private static _Initialized;
  61095. private static _Ktx2Decoder;
  61096. /**
  61097. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61098. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61099. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61100. * Urls you can change:
  61101. * URLConfig.jsDecoderModule
  61102. * URLConfig.wasmUASTCToASTC
  61103. * URLConfig.wasmUASTCToBC7
  61104. * URLConfig.jsMSCTranscoder
  61105. * URLConfig.wasmMSCTranscoder
  61106. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61107. */
  61108. static URLConfig: {
  61109. jsDecoderModule: string;
  61110. wasmUASTCToASTC: null;
  61111. wasmUASTCToBC7: null;
  61112. jsMSCTranscoder: null;
  61113. wasmMSCTranscoder: null;
  61114. };
  61115. /**
  61116. * Default number of workers used to handle data decoding
  61117. */
  61118. static DefaultNumWorkers: number;
  61119. private static GetDefaultNumWorkers;
  61120. private _engine;
  61121. private static _CreateWorkerPool;
  61122. /**
  61123. * Constructor
  61124. * @param engine The engine to use
  61125. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61126. */
  61127. constructor(engine: ThinEngine, numWorkers?: number);
  61128. /** @hidden */
  61129. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  61130. /**
  61131. * Stop all async operations and release resources.
  61132. */
  61133. dispose(): void;
  61134. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  61135. /**
  61136. * Checks if the given data starts with a KTX2 file identifier.
  61137. * @param data the data to check
  61138. * @returns true if the data is a KTX2 file or false otherwise
  61139. */
  61140. static IsValid(data: ArrayBufferView): boolean;
  61141. }
  61142. }
  61143. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61144. import { Nullable } from "babylonjs/types";
  61145. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61146. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61147. /**
  61148. * Implementation of the KTX Texture Loader.
  61149. * @hidden
  61150. */
  61151. export class _KTXTextureLoader implements IInternalTextureLoader {
  61152. /**
  61153. * Defines wether the loader supports cascade loading the different faces.
  61154. */
  61155. readonly supportCascades: boolean;
  61156. /**
  61157. * This returns if the loader support the current file information.
  61158. * @param extension defines the file extension of the file being loaded
  61159. * @param mimeType defines the optional mime type of the file being loaded
  61160. * @returns true if the loader can load the specified file
  61161. */
  61162. canLoad(extension: string, mimeType?: string): boolean;
  61163. /**
  61164. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61165. * @param data contains the texture data
  61166. * @param texture defines the BabylonJS internal texture
  61167. * @param createPolynomials will be true if polynomials have been requested
  61168. * @param onLoad defines the callback to trigger once the texture is ready
  61169. * @param onError defines the callback to trigger in case of error
  61170. */
  61171. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61172. /**
  61173. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61174. * @param data contains the texture data
  61175. * @param texture defines the BabylonJS internal texture
  61176. * @param callback defines the method to call once ready to upload
  61177. */
  61178. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  61179. }
  61180. }
  61181. declare module "babylonjs/Helpers/sceneHelpers" {
  61182. import { Nullable } from "babylonjs/types";
  61183. import { Mesh } from "babylonjs/Meshes/mesh";
  61184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61185. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61186. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61187. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61188. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61189. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61190. import "babylonjs/Meshes/Builders/boxBuilder";
  61191. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61192. /** @hidden */
  61193. export var _forceSceneHelpersToBundle: boolean;
  61194. module "babylonjs/scene" {
  61195. interface Scene {
  61196. /**
  61197. * Creates a default light for the scene.
  61198. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61199. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61200. */
  61201. createDefaultLight(replace?: boolean): void;
  61202. /**
  61203. * Creates a default camera for the scene.
  61204. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61205. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61206. * @param replace has default false, when true replaces the active camera in the scene
  61207. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61208. */
  61209. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61210. /**
  61211. * Creates a default camera and a default light.
  61212. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61213. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61214. * @param replace has the default false, when true replaces the active camera/light in the scene
  61215. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61216. */
  61217. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61218. /**
  61219. * Creates a new sky box
  61220. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61221. * @param environmentTexture defines the texture to use as environment texture
  61222. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61223. * @param scale defines the overall scale of the skybox
  61224. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61225. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61226. * @returns a new mesh holding the sky box
  61227. */
  61228. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61229. /**
  61230. * Creates a new environment
  61231. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61232. * @param options defines the options you can use to configure the environment
  61233. * @returns the new EnvironmentHelper
  61234. */
  61235. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61236. /**
  61237. * Creates a new VREXperienceHelper
  61238. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61239. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61240. * @returns a new VREXperienceHelper
  61241. */
  61242. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61243. /**
  61244. * Creates a new WebXRDefaultExperience
  61245. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61246. * @param options experience options
  61247. * @returns a promise for a new WebXRDefaultExperience
  61248. */
  61249. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61250. }
  61251. }
  61252. }
  61253. declare module "babylonjs/Helpers/videoDome" {
  61254. import { Scene } from "babylonjs/scene";
  61255. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61256. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61257. /**
  61258. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61259. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61260. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61261. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61262. */
  61263. export class VideoDome extends TextureDome<VideoTexture> {
  61264. /**
  61265. * Define the video source as a Monoscopic panoramic 360 video.
  61266. */
  61267. static readonly MODE_MONOSCOPIC: number;
  61268. /**
  61269. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61270. */
  61271. static readonly MODE_TOPBOTTOM: number;
  61272. /**
  61273. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61274. */
  61275. static readonly MODE_SIDEBYSIDE: number;
  61276. /**
  61277. * Get the video texture associated with this video dome
  61278. */
  61279. get videoTexture(): VideoTexture;
  61280. /**
  61281. * Get the video mode of this dome
  61282. */
  61283. get videoMode(): number;
  61284. /**
  61285. * Set the video mode of this dome.
  61286. * @see textureMode
  61287. */
  61288. set videoMode(value: number);
  61289. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61290. }
  61291. }
  61292. declare module "babylonjs/Helpers/index" {
  61293. export * from "babylonjs/Helpers/environmentHelper";
  61294. export * from "babylonjs/Helpers/photoDome";
  61295. export * from "babylonjs/Helpers/sceneHelpers";
  61296. export * from "babylonjs/Helpers/videoDome";
  61297. }
  61298. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61299. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61300. import { IDisposable } from "babylonjs/scene";
  61301. import { Engine } from "babylonjs/Engines/engine";
  61302. /**
  61303. * This class can be used to get instrumentation data from a Babylon engine
  61304. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61305. */
  61306. export class EngineInstrumentation implements IDisposable {
  61307. /**
  61308. * Define the instrumented engine.
  61309. */
  61310. engine: Engine;
  61311. private _captureGPUFrameTime;
  61312. private _gpuFrameTimeToken;
  61313. private _gpuFrameTime;
  61314. private _captureShaderCompilationTime;
  61315. private _shaderCompilationTime;
  61316. private _onBeginFrameObserver;
  61317. private _onEndFrameObserver;
  61318. private _onBeforeShaderCompilationObserver;
  61319. private _onAfterShaderCompilationObserver;
  61320. /**
  61321. * Gets the perf counter used for GPU frame time
  61322. */
  61323. get gpuFrameTimeCounter(): PerfCounter;
  61324. /**
  61325. * Gets the GPU frame time capture status
  61326. */
  61327. get captureGPUFrameTime(): boolean;
  61328. /**
  61329. * Enable or disable the GPU frame time capture
  61330. */
  61331. set captureGPUFrameTime(value: boolean);
  61332. /**
  61333. * Gets the perf counter used for shader compilation time
  61334. */
  61335. get shaderCompilationTimeCounter(): PerfCounter;
  61336. /**
  61337. * Gets the shader compilation time capture status
  61338. */
  61339. get captureShaderCompilationTime(): boolean;
  61340. /**
  61341. * Enable or disable the shader compilation time capture
  61342. */
  61343. set captureShaderCompilationTime(value: boolean);
  61344. /**
  61345. * Instantiates a new engine instrumentation.
  61346. * This class can be used to get instrumentation data from a Babylon engine
  61347. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61348. * @param engine Defines the engine to instrument
  61349. */
  61350. constructor(
  61351. /**
  61352. * Define the instrumented engine.
  61353. */
  61354. engine: Engine);
  61355. /**
  61356. * Dispose and release associated resources.
  61357. */
  61358. dispose(): void;
  61359. }
  61360. }
  61361. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61362. import { Scene, IDisposable } from "babylonjs/scene";
  61363. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61364. /**
  61365. * This class can be used to get instrumentation data from a Babylon engine
  61366. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61367. */
  61368. export class SceneInstrumentation implements IDisposable {
  61369. /**
  61370. * Defines the scene to instrument
  61371. */
  61372. scene: Scene;
  61373. private _captureActiveMeshesEvaluationTime;
  61374. private _activeMeshesEvaluationTime;
  61375. private _captureRenderTargetsRenderTime;
  61376. private _renderTargetsRenderTime;
  61377. private _captureFrameTime;
  61378. private _frameTime;
  61379. private _captureRenderTime;
  61380. private _renderTime;
  61381. private _captureInterFrameTime;
  61382. private _interFrameTime;
  61383. private _captureParticlesRenderTime;
  61384. private _particlesRenderTime;
  61385. private _captureSpritesRenderTime;
  61386. private _spritesRenderTime;
  61387. private _capturePhysicsTime;
  61388. private _physicsTime;
  61389. private _captureAnimationsTime;
  61390. private _animationsTime;
  61391. private _captureCameraRenderTime;
  61392. private _cameraRenderTime;
  61393. private _onBeforeActiveMeshesEvaluationObserver;
  61394. private _onAfterActiveMeshesEvaluationObserver;
  61395. private _onBeforeRenderTargetsRenderObserver;
  61396. private _onAfterRenderTargetsRenderObserver;
  61397. private _onAfterRenderObserver;
  61398. private _onBeforeDrawPhaseObserver;
  61399. private _onAfterDrawPhaseObserver;
  61400. private _onBeforeAnimationsObserver;
  61401. private _onBeforeParticlesRenderingObserver;
  61402. private _onAfterParticlesRenderingObserver;
  61403. private _onBeforeSpritesRenderingObserver;
  61404. private _onAfterSpritesRenderingObserver;
  61405. private _onBeforePhysicsObserver;
  61406. private _onAfterPhysicsObserver;
  61407. private _onAfterAnimationsObserver;
  61408. private _onBeforeCameraRenderObserver;
  61409. private _onAfterCameraRenderObserver;
  61410. /**
  61411. * Gets the perf counter used for active meshes evaluation time
  61412. */
  61413. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61414. /**
  61415. * Gets the active meshes evaluation time capture status
  61416. */
  61417. get captureActiveMeshesEvaluationTime(): boolean;
  61418. /**
  61419. * Enable or disable the active meshes evaluation time capture
  61420. */
  61421. set captureActiveMeshesEvaluationTime(value: boolean);
  61422. /**
  61423. * Gets the perf counter used for render targets render time
  61424. */
  61425. get renderTargetsRenderTimeCounter(): PerfCounter;
  61426. /**
  61427. * Gets the render targets render time capture status
  61428. */
  61429. get captureRenderTargetsRenderTime(): boolean;
  61430. /**
  61431. * Enable or disable the render targets render time capture
  61432. */
  61433. set captureRenderTargetsRenderTime(value: boolean);
  61434. /**
  61435. * Gets the perf counter used for particles render time
  61436. */
  61437. get particlesRenderTimeCounter(): PerfCounter;
  61438. /**
  61439. * Gets the particles render time capture status
  61440. */
  61441. get captureParticlesRenderTime(): boolean;
  61442. /**
  61443. * Enable or disable the particles render time capture
  61444. */
  61445. set captureParticlesRenderTime(value: boolean);
  61446. /**
  61447. * Gets the perf counter used for sprites render time
  61448. */
  61449. get spritesRenderTimeCounter(): PerfCounter;
  61450. /**
  61451. * Gets the sprites render time capture status
  61452. */
  61453. get captureSpritesRenderTime(): boolean;
  61454. /**
  61455. * Enable or disable the sprites render time capture
  61456. */
  61457. set captureSpritesRenderTime(value: boolean);
  61458. /**
  61459. * Gets the perf counter used for physics time
  61460. */
  61461. get physicsTimeCounter(): PerfCounter;
  61462. /**
  61463. * Gets the physics time capture status
  61464. */
  61465. get capturePhysicsTime(): boolean;
  61466. /**
  61467. * Enable or disable the physics time capture
  61468. */
  61469. set capturePhysicsTime(value: boolean);
  61470. /**
  61471. * Gets the perf counter used for animations time
  61472. */
  61473. get animationsTimeCounter(): PerfCounter;
  61474. /**
  61475. * Gets the animations time capture status
  61476. */
  61477. get captureAnimationsTime(): boolean;
  61478. /**
  61479. * Enable or disable the animations time capture
  61480. */
  61481. set captureAnimationsTime(value: boolean);
  61482. /**
  61483. * Gets the perf counter used for frame time capture
  61484. */
  61485. get frameTimeCounter(): PerfCounter;
  61486. /**
  61487. * Gets the frame time capture status
  61488. */
  61489. get captureFrameTime(): boolean;
  61490. /**
  61491. * Enable or disable the frame time capture
  61492. */
  61493. set captureFrameTime(value: boolean);
  61494. /**
  61495. * Gets the perf counter used for inter-frames time capture
  61496. */
  61497. get interFrameTimeCounter(): PerfCounter;
  61498. /**
  61499. * Gets the inter-frames time capture status
  61500. */
  61501. get captureInterFrameTime(): boolean;
  61502. /**
  61503. * Enable or disable the inter-frames time capture
  61504. */
  61505. set captureInterFrameTime(value: boolean);
  61506. /**
  61507. * Gets the perf counter used for render time capture
  61508. */
  61509. get renderTimeCounter(): PerfCounter;
  61510. /**
  61511. * Gets the render time capture status
  61512. */
  61513. get captureRenderTime(): boolean;
  61514. /**
  61515. * Enable or disable the render time capture
  61516. */
  61517. set captureRenderTime(value: boolean);
  61518. /**
  61519. * Gets the perf counter used for camera render time capture
  61520. */
  61521. get cameraRenderTimeCounter(): PerfCounter;
  61522. /**
  61523. * Gets the camera render time capture status
  61524. */
  61525. get captureCameraRenderTime(): boolean;
  61526. /**
  61527. * Enable or disable the camera render time capture
  61528. */
  61529. set captureCameraRenderTime(value: boolean);
  61530. /**
  61531. * Gets the perf counter used for draw calls
  61532. */
  61533. get drawCallsCounter(): PerfCounter;
  61534. /**
  61535. * Instantiates a new scene instrumentation.
  61536. * This class can be used to get instrumentation data from a Babylon engine
  61537. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61538. * @param scene Defines the scene to instrument
  61539. */
  61540. constructor(
  61541. /**
  61542. * Defines the scene to instrument
  61543. */
  61544. scene: Scene);
  61545. /**
  61546. * Dispose and release associated resources.
  61547. */
  61548. dispose(): void;
  61549. }
  61550. }
  61551. declare module "babylonjs/Instrumentation/index" {
  61552. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61553. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61554. export * from "babylonjs/Instrumentation/timeToken";
  61555. }
  61556. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61557. /** @hidden */
  61558. export var glowMapGenerationPixelShader: {
  61559. name: string;
  61560. shader: string;
  61561. };
  61562. }
  61563. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61564. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61565. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61566. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61567. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61568. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61569. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61570. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61571. /** @hidden */
  61572. export var glowMapGenerationVertexShader: {
  61573. name: string;
  61574. shader: string;
  61575. };
  61576. }
  61577. declare module "babylonjs/Layers/effectLayer" {
  61578. import { Observable } from "babylonjs/Misc/observable";
  61579. import { Nullable } from "babylonjs/types";
  61580. import { Camera } from "babylonjs/Cameras/camera";
  61581. import { Scene } from "babylonjs/scene";
  61582. import { ISize } from "babylonjs/Maths/math.size";
  61583. import { Color4 } from "babylonjs/Maths/math.color";
  61584. import { Engine } from "babylonjs/Engines/engine";
  61585. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61587. import { Mesh } from "babylonjs/Meshes/mesh";
  61588. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61590. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61591. import { Effect } from "babylonjs/Materials/effect";
  61592. import { Material } from "babylonjs/Materials/material";
  61593. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61594. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61595. /**
  61596. * Effect layer options. This helps customizing the behaviour
  61597. * of the effect layer.
  61598. */
  61599. export interface IEffectLayerOptions {
  61600. /**
  61601. * Multiplication factor apply to the canvas size to compute the render target size
  61602. * used to generated the objects (the smaller the faster).
  61603. */
  61604. mainTextureRatio: number;
  61605. /**
  61606. * Enforces a fixed size texture to ensure effect stability across devices.
  61607. */
  61608. mainTextureFixedSize?: number;
  61609. /**
  61610. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61611. */
  61612. alphaBlendingMode: number;
  61613. /**
  61614. * The camera attached to the layer.
  61615. */
  61616. camera: Nullable<Camera>;
  61617. /**
  61618. * The rendering group to draw the layer in.
  61619. */
  61620. renderingGroupId: number;
  61621. }
  61622. /**
  61623. * The effect layer Helps adding post process effect blended with the main pass.
  61624. *
  61625. * This can be for instance use to generate glow or higlight effects on the scene.
  61626. *
  61627. * The effect layer class can not be used directly and is intented to inherited from to be
  61628. * customized per effects.
  61629. */
  61630. export abstract class EffectLayer {
  61631. private _vertexBuffers;
  61632. private _indexBuffer;
  61633. private _cachedDefines;
  61634. private _effectLayerMapGenerationEffect;
  61635. private _effectLayerOptions;
  61636. private _mergeEffect;
  61637. protected _scene: Scene;
  61638. protected _engine: Engine;
  61639. protected _maxSize: number;
  61640. protected _mainTextureDesiredSize: ISize;
  61641. protected _mainTexture: RenderTargetTexture;
  61642. protected _shouldRender: boolean;
  61643. protected _postProcesses: PostProcess[];
  61644. protected _textures: BaseTexture[];
  61645. protected _emissiveTextureAndColor: {
  61646. texture: Nullable<BaseTexture>;
  61647. color: Color4;
  61648. };
  61649. /**
  61650. * The name of the layer
  61651. */
  61652. name: string;
  61653. /**
  61654. * The clear color of the texture used to generate the glow map.
  61655. */
  61656. neutralColor: Color4;
  61657. /**
  61658. * Specifies whether the highlight layer is enabled or not.
  61659. */
  61660. isEnabled: boolean;
  61661. /**
  61662. * Gets the camera attached to the layer.
  61663. */
  61664. get camera(): Nullable<Camera>;
  61665. /**
  61666. * Gets the rendering group id the layer should render in.
  61667. */
  61668. get renderingGroupId(): number;
  61669. set renderingGroupId(renderingGroupId: number);
  61670. /**
  61671. * An event triggered when the effect layer has been disposed.
  61672. */
  61673. onDisposeObservable: Observable<EffectLayer>;
  61674. /**
  61675. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61676. */
  61677. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61678. /**
  61679. * An event triggered when the generated texture is being merged in the scene.
  61680. */
  61681. onBeforeComposeObservable: Observable<EffectLayer>;
  61682. /**
  61683. * An event triggered when the mesh is rendered into the effect render target.
  61684. */
  61685. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61686. /**
  61687. * An event triggered after the mesh has been rendered into the effect render target.
  61688. */
  61689. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61690. /**
  61691. * An event triggered when the generated texture has been merged in the scene.
  61692. */
  61693. onAfterComposeObservable: Observable<EffectLayer>;
  61694. /**
  61695. * An event triggered when the efffect layer changes its size.
  61696. */
  61697. onSizeChangedObservable: Observable<EffectLayer>;
  61698. /** @hidden */
  61699. static _SceneComponentInitialization: (scene: Scene) => void;
  61700. /**
  61701. * Instantiates a new effect Layer and references it in the scene.
  61702. * @param name The name of the layer
  61703. * @param scene The scene to use the layer in
  61704. */
  61705. constructor(
  61706. /** The Friendly of the effect in the scene */
  61707. name: string, scene: Scene);
  61708. /**
  61709. * Get the effect name of the layer.
  61710. * @return The effect name
  61711. */
  61712. abstract getEffectName(): string;
  61713. /**
  61714. * Checks for the readiness of the element composing the layer.
  61715. * @param subMesh the mesh to check for
  61716. * @param useInstances specify whether or not to use instances to render the mesh
  61717. * @return true if ready otherwise, false
  61718. */
  61719. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61720. /**
  61721. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61722. * @returns true if the effect requires stencil during the main canvas render pass.
  61723. */
  61724. abstract needStencil(): boolean;
  61725. /**
  61726. * Create the merge effect. This is the shader use to blit the information back
  61727. * to the main canvas at the end of the scene rendering.
  61728. * @returns The effect containing the shader used to merge the effect on the main canvas
  61729. */
  61730. protected abstract _createMergeEffect(): Effect;
  61731. /**
  61732. * Creates the render target textures and post processes used in the effect layer.
  61733. */
  61734. protected abstract _createTextureAndPostProcesses(): void;
  61735. /**
  61736. * Implementation specific of rendering the generating effect on the main canvas.
  61737. * @param effect The effect used to render through
  61738. */
  61739. protected abstract _internalRender(effect: Effect): void;
  61740. /**
  61741. * Sets the required values for both the emissive texture and and the main color.
  61742. */
  61743. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61744. /**
  61745. * Free any resources and references associated to a mesh.
  61746. * Internal use
  61747. * @param mesh The mesh to free.
  61748. */
  61749. abstract _disposeMesh(mesh: Mesh): void;
  61750. /**
  61751. * Serializes this layer (Glow or Highlight for example)
  61752. * @returns a serialized layer object
  61753. */
  61754. abstract serialize?(): any;
  61755. /**
  61756. * Initializes the effect layer with the required options.
  61757. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61758. */
  61759. protected _init(options: Partial<IEffectLayerOptions>): void;
  61760. /**
  61761. * Generates the index buffer of the full screen quad blending to the main canvas.
  61762. */
  61763. private _generateIndexBuffer;
  61764. /**
  61765. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61766. */
  61767. private _generateVertexBuffer;
  61768. /**
  61769. * Sets the main texture desired size which is the closest power of two
  61770. * of the engine canvas size.
  61771. */
  61772. private _setMainTextureSize;
  61773. /**
  61774. * Creates the main texture for the effect layer.
  61775. */
  61776. protected _createMainTexture(): void;
  61777. /**
  61778. * Adds specific effects defines.
  61779. * @param defines The defines to add specifics to.
  61780. */
  61781. protected _addCustomEffectDefines(defines: string[]): void;
  61782. /**
  61783. * Checks for the readiness of the element composing the layer.
  61784. * @param subMesh the mesh to check for
  61785. * @param useInstances specify whether or not to use instances to render the mesh
  61786. * @param emissiveTexture the associated emissive texture used to generate the glow
  61787. * @return true if ready otherwise, false
  61788. */
  61789. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61790. /**
  61791. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61792. */
  61793. render(): void;
  61794. /**
  61795. * Determine if a given mesh will be used in the current effect.
  61796. * @param mesh mesh to test
  61797. * @returns true if the mesh will be used
  61798. */
  61799. hasMesh(mesh: AbstractMesh): boolean;
  61800. /**
  61801. * Returns true if the layer contains information to display, otherwise false.
  61802. * @returns true if the glow layer should be rendered
  61803. */
  61804. shouldRender(): boolean;
  61805. /**
  61806. * Returns true if the mesh should render, otherwise false.
  61807. * @param mesh The mesh to render
  61808. * @returns true if it should render otherwise false
  61809. */
  61810. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61811. /**
  61812. * Returns true if the mesh can be rendered, otherwise false.
  61813. * @param mesh The mesh to render
  61814. * @param material The material used on the mesh
  61815. * @returns true if it can be rendered otherwise false
  61816. */
  61817. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61818. /**
  61819. * Returns true if the mesh should render, otherwise false.
  61820. * @param mesh The mesh to render
  61821. * @returns true if it should render otherwise false
  61822. */
  61823. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61824. /**
  61825. * Renders the submesh passed in parameter to the generation map.
  61826. */
  61827. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61828. /**
  61829. * Defines whether the current material of the mesh should be use to render the effect.
  61830. * @param mesh defines the current mesh to render
  61831. */
  61832. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61833. /**
  61834. * Rebuild the required buffers.
  61835. * @hidden Internal use only.
  61836. */
  61837. _rebuild(): void;
  61838. /**
  61839. * Dispose only the render target textures and post process.
  61840. */
  61841. private _disposeTextureAndPostProcesses;
  61842. /**
  61843. * Dispose the highlight layer and free resources.
  61844. */
  61845. dispose(): void;
  61846. /**
  61847. * Gets the class name of the effect layer
  61848. * @returns the string with the class name of the effect layer
  61849. */
  61850. getClassName(): string;
  61851. /**
  61852. * Creates an effect layer from parsed effect layer data
  61853. * @param parsedEffectLayer defines effect layer data
  61854. * @param scene defines the current scene
  61855. * @param rootUrl defines the root URL containing the effect layer information
  61856. * @returns a parsed effect Layer
  61857. */
  61858. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61859. }
  61860. }
  61861. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61862. import { Scene } from "babylonjs/scene";
  61863. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61864. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61865. import { AbstractScene } from "babylonjs/abstractScene";
  61866. module "babylonjs/abstractScene" {
  61867. interface AbstractScene {
  61868. /**
  61869. * The list of effect layers (highlights/glow) added to the scene
  61870. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61871. * @see https://doc.babylonjs.com/how_to/glow_layer
  61872. */
  61873. effectLayers: Array<EffectLayer>;
  61874. /**
  61875. * Removes the given effect layer from this scene.
  61876. * @param toRemove defines the effect layer to remove
  61877. * @returns the index of the removed effect layer
  61878. */
  61879. removeEffectLayer(toRemove: EffectLayer): number;
  61880. /**
  61881. * Adds the given effect layer to this scene
  61882. * @param newEffectLayer defines the effect layer to add
  61883. */
  61884. addEffectLayer(newEffectLayer: EffectLayer): void;
  61885. }
  61886. }
  61887. /**
  61888. * Defines the layer scene component responsible to manage any effect layers
  61889. * in a given scene.
  61890. */
  61891. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61892. /**
  61893. * The component name helpfull to identify the component in the list of scene components.
  61894. */
  61895. readonly name: string;
  61896. /**
  61897. * The scene the component belongs to.
  61898. */
  61899. scene: Scene;
  61900. private _engine;
  61901. private _renderEffects;
  61902. private _needStencil;
  61903. private _previousStencilState;
  61904. /**
  61905. * Creates a new instance of the component for the given scene
  61906. * @param scene Defines the scene to register the component in
  61907. */
  61908. constructor(scene: Scene);
  61909. /**
  61910. * Registers the component in a given scene
  61911. */
  61912. register(): void;
  61913. /**
  61914. * Rebuilds the elements related to this component in case of
  61915. * context lost for instance.
  61916. */
  61917. rebuild(): void;
  61918. /**
  61919. * Serializes the component data to the specified json object
  61920. * @param serializationObject The object to serialize to
  61921. */
  61922. serialize(serializationObject: any): void;
  61923. /**
  61924. * Adds all the elements from the container to the scene
  61925. * @param container the container holding the elements
  61926. */
  61927. addFromContainer(container: AbstractScene): void;
  61928. /**
  61929. * Removes all the elements in the container from the scene
  61930. * @param container contains the elements to remove
  61931. * @param dispose if the removed element should be disposed (default: false)
  61932. */
  61933. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61934. /**
  61935. * Disposes the component and the associated ressources.
  61936. */
  61937. dispose(): void;
  61938. private _isReadyForMesh;
  61939. private _renderMainTexture;
  61940. private _setStencil;
  61941. private _setStencilBack;
  61942. private _draw;
  61943. private _drawCamera;
  61944. private _drawRenderingGroup;
  61945. }
  61946. }
  61947. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61948. /** @hidden */
  61949. export var glowMapMergePixelShader: {
  61950. name: string;
  61951. shader: string;
  61952. };
  61953. }
  61954. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61955. /** @hidden */
  61956. export var glowMapMergeVertexShader: {
  61957. name: string;
  61958. shader: string;
  61959. };
  61960. }
  61961. declare module "babylonjs/Layers/glowLayer" {
  61962. import { Nullable } from "babylonjs/types";
  61963. import { Camera } from "babylonjs/Cameras/camera";
  61964. import { Scene } from "babylonjs/scene";
  61965. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61967. import { Mesh } from "babylonjs/Meshes/mesh";
  61968. import { Texture } from "babylonjs/Materials/Textures/texture";
  61969. import { Effect } from "babylonjs/Materials/effect";
  61970. import { Material } from "babylonjs/Materials/material";
  61971. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61972. import { Color4 } from "babylonjs/Maths/math.color";
  61973. import "babylonjs/Shaders/glowMapMerge.fragment";
  61974. import "babylonjs/Shaders/glowMapMerge.vertex";
  61975. import "babylonjs/Layers/effectLayerSceneComponent";
  61976. module "babylonjs/abstractScene" {
  61977. interface AbstractScene {
  61978. /**
  61979. * Return a the first highlight layer of the scene with a given name.
  61980. * @param name The name of the highlight layer to look for.
  61981. * @return The highlight layer if found otherwise null.
  61982. */
  61983. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61984. }
  61985. }
  61986. /**
  61987. * Glow layer options. This helps customizing the behaviour
  61988. * of the glow layer.
  61989. */
  61990. export interface IGlowLayerOptions {
  61991. /**
  61992. * Multiplication factor apply to the canvas size to compute the render target size
  61993. * used to generated the glowing objects (the smaller the faster).
  61994. */
  61995. mainTextureRatio: number;
  61996. /**
  61997. * Enforces a fixed size texture to ensure resize independant blur.
  61998. */
  61999. mainTextureFixedSize?: number;
  62000. /**
  62001. * How big is the kernel of the blur texture.
  62002. */
  62003. blurKernelSize: number;
  62004. /**
  62005. * The camera attached to the layer.
  62006. */
  62007. camera: Nullable<Camera>;
  62008. /**
  62009. * Enable MSAA by chosing the number of samples.
  62010. */
  62011. mainTextureSamples?: number;
  62012. /**
  62013. * The rendering group to draw the layer in.
  62014. */
  62015. renderingGroupId: number;
  62016. }
  62017. /**
  62018. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62019. *
  62020. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62021. *
  62022. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62023. */
  62024. export class GlowLayer extends EffectLayer {
  62025. /**
  62026. * Effect Name of the layer.
  62027. */
  62028. static readonly EffectName: string;
  62029. /**
  62030. * The default blur kernel size used for the glow.
  62031. */
  62032. static DefaultBlurKernelSize: number;
  62033. /**
  62034. * The default texture size ratio used for the glow.
  62035. */
  62036. static DefaultTextureRatio: number;
  62037. /**
  62038. * Sets the kernel size of the blur.
  62039. */
  62040. set blurKernelSize(value: number);
  62041. /**
  62042. * Gets the kernel size of the blur.
  62043. */
  62044. get blurKernelSize(): number;
  62045. /**
  62046. * Sets the glow intensity.
  62047. */
  62048. set intensity(value: number);
  62049. /**
  62050. * Gets the glow intensity.
  62051. */
  62052. get intensity(): number;
  62053. private _options;
  62054. private _intensity;
  62055. private _horizontalBlurPostprocess1;
  62056. private _verticalBlurPostprocess1;
  62057. private _horizontalBlurPostprocess2;
  62058. private _verticalBlurPostprocess2;
  62059. private _blurTexture1;
  62060. private _blurTexture2;
  62061. private _postProcesses1;
  62062. private _postProcesses2;
  62063. private _includedOnlyMeshes;
  62064. private _excludedMeshes;
  62065. private _meshesUsingTheirOwnMaterials;
  62066. /**
  62067. * Callback used to let the user override the color selection on a per mesh basis
  62068. */
  62069. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62070. /**
  62071. * Callback used to let the user override the texture selection on a per mesh basis
  62072. */
  62073. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62074. /**
  62075. * Instantiates a new glow Layer and references it to the scene.
  62076. * @param name The name of the layer
  62077. * @param scene The scene to use the layer in
  62078. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62079. */
  62080. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62081. /**
  62082. * Get the effect name of the layer.
  62083. * @return The effect name
  62084. */
  62085. getEffectName(): string;
  62086. /**
  62087. * Create the merge effect. This is the shader use to blit the information back
  62088. * to the main canvas at the end of the scene rendering.
  62089. */
  62090. protected _createMergeEffect(): Effect;
  62091. /**
  62092. * Creates the render target textures and post processes used in the glow layer.
  62093. */
  62094. protected _createTextureAndPostProcesses(): void;
  62095. /**
  62096. * Checks for the readiness of the element composing the layer.
  62097. * @param subMesh the mesh to check for
  62098. * @param useInstances specify wether or not to use instances to render the mesh
  62099. * @param emissiveTexture the associated emissive texture used to generate the glow
  62100. * @return true if ready otherwise, false
  62101. */
  62102. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62103. /**
  62104. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62105. */
  62106. needStencil(): boolean;
  62107. /**
  62108. * Returns true if the mesh can be rendered, otherwise false.
  62109. * @param mesh The mesh to render
  62110. * @param material The material used on the mesh
  62111. * @returns true if it can be rendered otherwise false
  62112. */
  62113. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62114. /**
  62115. * Implementation specific of rendering the generating effect on the main canvas.
  62116. * @param effect The effect used to render through
  62117. */
  62118. protected _internalRender(effect: Effect): void;
  62119. /**
  62120. * Sets the required values for both the emissive texture and and the main color.
  62121. */
  62122. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62123. /**
  62124. * Returns true if the mesh should render, otherwise false.
  62125. * @param mesh The mesh to render
  62126. * @returns true if it should render otherwise false
  62127. */
  62128. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62129. /**
  62130. * Adds specific effects defines.
  62131. * @param defines The defines to add specifics to.
  62132. */
  62133. protected _addCustomEffectDefines(defines: string[]): void;
  62134. /**
  62135. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62136. * @param mesh The mesh to exclude from the glow layer
  62137. */
  62138. addExcludedMesh(mesh: Mesh): void;
  62139. /**
  62140. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62141. * @param mesh The mesh to remove
  62142. */
  62143. removeExcludedMesh(mesh: Mesh): void;
  62144. /**
  62145. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62146. * @param mesh The mesh to include in the glow layer
  62147. */
  62148. addIncludedOnlyMesh(mesh: Mesh): void;
  62149. /**
  62150. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62151. * @param mesh The mesh to remove
  62152. */
  62153. removeIncludedOnlyMesh(mesh: Mesh): void;
  62154. /**
  62155. * Determine if a given mesh will be used in the glow layer
  62156. * @param mesh The mesh to test
  62157. * @returns true if the mesh will be highlighted by the current glow layer
  62158. */
  62159. hasMesh(mesh: AbstractMesh): boolean;
  62160. /**
  62161. * Defines whether the current material of the mesh should be use to render the effect.
  62162. * @param mesh defines the current mesh to render
  62163. */
  62164. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62165. /**
  62166. * Add a mesh to be rendered through its own material and not with emissive only.
  62167. * @param mesh The mesh for which we need to use its material
  62168. */
  62169. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62170. /**
  62171. * Remove a mesh from being rendered through its own material and not with emissive only.
  62172. * @param mesh The mesh for which we need to not use its material
  62173. */
  62174. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62175. /**
  62176. * Free any resources and references associated to a mesh.
  62177. * Internal use
  62178. * @param mesh The mesh to free.
  62179. * @hidden
  62180. */
  62181. _disposeMesh(mesh: Mesh): void;
  62182. /**
  62183. * Gets the class name of the effect layer
  62184. * @returns the string with the class name of the effect layer
  62185. */
  62186. getClassName(): string;
  62187. /**
  62188. * Serializes this glow layer
  62189. * @returns a serialized glow layer object
  62190. */
  62191. serialize(): any;
  62192. /**
  62193. * Creates a Glow Layer from parsed glow layer data
  62194. * @param parsedGlowLayer defines glow layer data
  62195. * @param scene defines the current scene
  62196. * @param rootUrl defines the root URL containing the glow layer information
  62197. * @returns a parsed Glow Layer
  62198. */
  62199. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62200. }
  62201. }
  62202. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62203. /** @hidden */
  62204. export var glowBlurPostProcessPixelShader: {
  62205. name: string;
  62206. shader: string;
  62207. };
  62208. }
  62209. declare module "babylonjs/Layers/highlightLayer" {
  62210. import { Observable } from "babylonjs/Misc/observable";
  62211. import { Nullable } from "babylonjs/types";
  62212. import { Camera } from "babylonjs/Cameras/camera";
  62213. import { Scene } from "babylonjs/scene";
  62214. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62216. import { Mesh } from "babylonjs/Meshes/mesh";
  62217. import { Effect } from "babylonjs/Materials/effect";
  62218. import { Material } from "babylonjs/Materials/material";
  62219. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62220. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62221. import "babylonjs/Shaders/glowMapMerge.fragment";
  62222. import "babylonjs/Shaders/glowMapMerge.vertex";
  62223. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62224. module "babylonjs/abstractScene" {
  62225. interface AbstractScene {
  62226. /**
  62227. * Return a the first highlight layer of the scene with a given name.
  62228. * @param name The name of the highlight layer to look for.
  62229. * @return The highlight layer if found otherwise null.
  62230. */
  62231. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62232. }
  62233. }
  62234. /**
  62235. * Highlight layer options. This helps customizing the behaviour
  62236. * of the highlight layer.
  62237. */
  62238. export interface IHighlightLayerOptions {
  62239. /**
  62240. * Multiplication factor apply to the canvas size to compute the render target size
  62241. * used to generated the glowing objects (the smaller the faster).
  62242. */
  62243. mainTextureRatio: number;
  62244. /**
  62245. * Enforces a fixed size texture to ensure resize independant blur.
  62246. */
  62247. mainTextureFixedSize?: number;
  62248. /**
  62249. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62250. * of the picture to blur (the smaller the faster).
  62251. */
  62252. blurTextureSizeRatio: number;
  62253. /**
  62254. * How big in texel of the blur texture is the vertical blur.
  62255. */
  62256. blurVerticalSize: number;
  62257. /**
  62258. * How big in texel of the blur texture is the horizontal blur.
  62259. */
  62260. blurHorizontalSize: number;
  62261. /**
  62262. * Alpha blending mode used to apply the blur. Default is combine.
  62263. */
  62264. alphaBlendingMode: number;
  62265. /**
  62266. * The camera attached to the layer.
  62267. */
  62268. camera: Nullable<Camera>;
  62269. /**
  62270. * Should we display highlight as a solid stroke?
  62271. */
  62272. isStroke?: boolean;
  62273. /**
  62274. * The rendering group to draw the layer in.
  62275. */
  62276. renderingGroupId: number;
  62277. }
  62278. /**
  62279. * The highlight layer Helps adding a glow effect around a mesh.
  62280. *
  62281. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62282. * glowy meshes to your scene.
  62283. *
  62284. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62285. */
  62286. export class HighlightLayer extends EffectLayer {
  62287. name: string;
  62288. /**
  62289. * Effect Name of the highlight layer.
  62290. */
  62291. static readonly EffectName: string;
  62292. /**
  62293. * The neutral color used during the preparation of the glow effect.
  62294. * This is black by default as the blend operation is a blend operation.
  62295. */
  62296. static NeutralColor: Color4;
  62297. /**
  62298. * Stencil value used for glowing meshes.
  62299. */
  62300. static GlowingMeshStencilReference: number;
  62301. /**
  62302. * Stencil value used for the other meshes in the scene.
  62303. */
  62304. static NormalMeshStencilReference: number;
  62305. /**
  62306. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62307. */
  62308. innerGlow: boolean;
  62309. /**
  62310. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62311. */
  62312. outerGlow: boolean;
  62313. /**
  62314. * Specifies the horizontal size of the blur.
  62315. */
  62316. set blurHorizontalSize(value: number);
  62317. /**
  62318. * Specifies the vertical size of the blur.
  62319. */
  62320. set blurVerticalSize(value: number);
  62321. /**
  62322. * Gets the horizontal size of the blur.
  62323. */
  62324. get blurHorizontalSize(): number;
  62325. /**
  62326. * Gets the vertical size of the blur.
  62327. */
  62328. get blurVerticalSize(): number;
  62329. /**
  62330. * An event triggered when the highlight layer is being blurred.
  62331. */
  62332. onBeforeBlurObservable: Observable<HighlightLayer>;
  62333. /**
  62334. * An event triggered when the highlight layer has been blurred.
  62335. */
  62336. onAfterBlurObservable: Observable<HighlightLayer>;
  62337. private _instanceGlowingMeshStencilReference;
  62338. private _options;
  62339. private _downSamplePostprocess;
  62340. private _horizontalBlurPostprocess;
  62341. private _verticalBlurPostprocess;
  62342. private _blurTexture;
  62343. private _meshes;
  62344. private _excludedMeshes;
  62345. /**
  62346. * Instantiates a new highlight Layer and references it to the scene..
  62347. * @param name The name of the layer
  62348. * @param scene The scene to use the layer in
  62349. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62350. */
  62351. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62352. /**
  62353. * Get the effect name of the layer.
  62354. * @return The effect name
  62355. */
  62356. getEffectName(): string;
  62357. /**
  62358. * Create the merge effect. This is the shader use to blit the information back
  62359. * to the main canvas at the end of the scene rendering.
  62360. */
  62361. protected _createMergeEffect(): Effect;
  62362. /**
  62363. * Creates the render target textures and post processes used in the highlight layer.
  62364. */
  62365. protected _createTextureAndPostProcesses(): void;
  62366. /**
  62367. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62368. */
  62369. needStencil(): boolean;
  62370. /**
  62371. * Checks for the readiness of the element composing the layer.
  62372. * @param subMesh the mesh to check for
  62373. * @param useInstances specify wether or not to use instances to render the mesh
  62374. * @param emissiveTexture the associated emissive texture used to generate the glow
  62375. * @return true if ready otherwise, false
  62376. */
  62377. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62378. /**
  62379. * Implementation specific of rendering the generating effect on the main canvas.
  62380. * @param effect The effect used to render through
  62381. */
  62382. protected _internalRender(effect: Effect): void;
  62383. /**
  62384. * Returns true if the layer contains information to display, otherwise false.
  62385. */
  62386. shouldRender(): boolean;
  62387. /**
  62388. * Returns true if the mesh should render, otherwise false.
  62389. * @param mesh The mesh to render
  62390. * @returns true if it should render otherwise false
  62391. */
  62392. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62393. /**
  62394. * Returns true if the mesh can be rendered, otherwise false.
  62395. * @param mesh The mesh to render
  62396. * @param material The material used on the mesh
  62397. * @returns true if it can be rendered otherwise false
  62398. */
  62399. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62400. /**
  62401. * Adds specific effects defines.
  62402. * @param defines The defines to add specifics to.
  62403. */
  62404. protected _addCustomEffectDefines(defines: string[]): void;
  62405. /**
  62406. * Sets the required values for both the emissive texture and and the main color.
  62407. */
  62408. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62409. /**
  62410. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62411. * @param mesh The mesh to exclude from the highlight layer
  62412. */
  62413. addExcludedMesh(mesh: Mesh): void;
  62414. /**
  62415. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62416. * @param mesh The mesh to highlight
  62417. */
  62418. removeExcludedMesh(mesh: Mesh): void;
  62419. /**
  62420. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62421. * @param mesh mesh to test
  62422. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62423. */
  62424. hasMesh(mesh: AbstractMesh): boolean;
  62425. /**
  62426. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62427. * @param mesh The mesh to highlight
  62428. * @param color The color of the highlight
  62429. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62430. */
  62431. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62432. /**
  62433. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62434. * @param mesh The mesh to highlight
  62435. */
  62436. removeMesh(mesh: Mesh): void;
  62437. /**
  62438. * Remove all the meshes currently referenced in the highlight layer
  62439. */
  62440. removeAllMeshes(): void;
  62441. /**
  62442. * Force the stencil to the normal expected value for none glowing parts
  62443. */
  62444. private _defaultStencilReference;
  62445. /**
  62446. * Free any resources and references associated to a mesh.
  62447. * Internal use
  62448. * @param mesh The mesh to free.
  62449. * @hidden
  62450. */
  62451. _disposeMesh(mesh: Mesh): void;
  62452. /**
  62453. * Dispose the highlight layer and free resources.
  62454. */
  62455. dispose(): void;
  62456. /**
  62457. * Gets the class name of the effect layer
  62458. * @returns the string with the class name of the effect layer
  62459. */
  62460. getClassName(): string;
  62461. /**
  62462. * Serializes this Highlight layer
  62463. * @returns a serialized Highlight layer object
  62464. */
  62465. serialize(): any;
  62466. /**
  62467. * Creates a Highlight layer from parsed Highlight layer data
  62468. * @param parsedHightlightLayer defines the Highlight layer data
  62469. * @param scene defines the current scene
  62470. * @param rootUrl defines the root URL containing the Highlight layer information
  62471. * @returns a parsed Highlight layer
  62472. */
  62473. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62474. }
  62475. }
  62476. declare module "babylonjs/Layers/layerSceneComponent" {
  62477. import { Scene } from "babylonjs/scene";
  62478. import { ISceneComponent } from "babylonjs/sceneComponent";
  62479. import { Layer } from "babylonjs/Layers/layer";
  62480. import { AbstractScene } from "babylonjs/abstractScene";
  62481. module "babylonjs/abstractScene" {
  62482. interface AbstractScene {
  62483. /**
  62484. * The list of layers (background and foreground) of the scene
  62485. */
  62486. layers: Array<Layer>;
  62487. }
  62488. }
  62489. /**
  62490. * Defines the layer scene component responsible to manage any layers
  62491. * in a given scene.
  62492. */
  62493. export class LayerSceneComponent implements ISceneComponent {
  62494. /**
  62495. * The component name helpfull to identify the component in the list of scene components.
  62496. */
  62497. readonly name: string;
  62498. /**
  62499. * The scene the component belongs to.
  62500. */
  62501. scene: Scene;
  62502. private _engine;
  62503. /**
  62504. * Creates a new instance of the component for the given scene
  62505. * @param scene Defines the scene to register the component in
  62506. */
  62507. constructor(scene: Scene);
  62508. /**
  62509. * Registers the component in a given scene
  62510. */
  62511. register(): void;
  62512. /**
  62513. * Rebuilds the elements related to this component in case of
  62514. * context lost for instance.
  62515. */
  62516. rebuild(): void;
  62517. /**
  62518. * Disposes the component and the associated ressources.
  62519. */
  62520. dispose(): void;
  62521. private _draw;
  62522. private _drawCameraPredicate;
  62523. private _drawCameraBackground;
  62524. private _drawCameraForeground;
  62525. private _drawRenderTargetPredicate;
  62526. private _drawRenderTargetBackground;
  62527. private _drawRenderTargetForeground;
  62528. /**
  62529. * Adds all the elements from the container to the scene
  62530. * @param container the container holding the elements
  62531. */
  62532. addFromContainer(container: AbstractScene): void;
  62533. /**
  62534. * Removes all the elements in the container from the scene
  62535. * @param container contains the elements to remove
  62536. * @param dispose if the removed element should be disposed (default: false)
  62537. */
  62538. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62539. }
  62540. }
  62541. declare module "babylonjs/Shaders/layer.fragment" {
  62542. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62543. /** @hidden */
  62544. export var layerPixelShader: {
  62545. name: string;
  62546. shader: string;
  62547. };
  62548. }
  62549. declare module "babylonjs/Shaders/layer.vertex" {
  62550. /** @hidden */
  62551. export var layerVertexShader: {
  62552. name: string;
  62553. shader: string;
  62554. };
  62555. }
  62556. declare module "babylonjs/Layers/layer" {
  62557. import { Observable } from "babylonjs/Misc/observable";
  62558. import { Nullable } from "babylonjs/types";
  62559. import { Scene } from "babylonjs/scene";
  62560. import { Vector2 } from "babylonjs/Maths/math.vector";
  62561. import { Color4 } from "babylonjs/Maths/math.color";
  62562. import { Texture } from "babylonjs/Materials/Textures/texture";
  62563. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62564. import "babylonjs/Shaders/layer.fragment";
  62565. import "babylonjs/Shaders/layer.vertex";
  62566. /**
  62567. * This represents a full screen 2d layer.
  62568. * This can be useful to display a picture in the background of your scene for instance.
  62569. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62570. */
  62571. export class Layer {
  62572. /**
  62573. * Define the name of the layer.
  62574. */
  62575. name: string;
  62576. /**
  62577. * Define the texture the layer should display.
  62578. */
  62579. texture: Nullable<Texture>;
  62580. /**
  62581. * Is the layer in background or foreground.
  62582. */
  62583. isBackground: boolean;
  62584. /**
  62585. * Define the color of the layer (instead of texture).
  62586. */
  62587. color: Color4;
  62588. /**
  62589. * Define the scale of the layer in order to zoom in out of the texture.
  62590. */
  62591. scale: Vector2;
  62592. /**
  62593. * Define an offset for the layer in order to shift the texture.
  62594. */
  62595. offset: Vector2;
  62596. /**
  62597. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62598. */
  62599. alphaBlendingMode: number;
  62600. /**
  62601. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62602. * Alpha test will not mix with the background color in case of transparency.
  62603. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62604. */
  62605. alphaTest: boolean;
  62606. /**
  62607. * Define a mask to restrict the layer to only some of the scene cameras.
  62608. */
  62609. layerMask: number;
  62610. /**
  62611. * Define the list of render target the layer is visible into.
  62612. */
  62613. renderTargetTextures: RenderTargetTexture[];
  62614. /**
  62615. * Define if the layer is only used in renderTarget or if it also
  62616. * renders in the main frame buffer of the canvas.
  62617. */
  62618. renderOnlyInRenderTargetTextures: boolean;
  62619. private _scene;
  62620. private _vertexBuffers;
  62621. private _indexBuffer;
  62622. private _effect;
  62623. private _previousDefines;
  62624. /**
  62625. * An event triggered when the layer is disposed.
  62626. */
  62627. onDisposeObservable: Observable<Layer>;
  62628. private _onDisposeObserver;
  62629. /**
  62630. * Back compatibility with callback before the onDisposeObservable existed.
  62631. * The set callback will be triggered when the layer has been disposed.
  62632. */
  62633. set onDispose(callback: () => void);
  62634. /**
  62635. * An event triggered before rendering the scene
  62636. */
  62637. onBeforeRenderObservable: Observable<Layer>;
  62638. private _onBeforeRenderObserver;
  62639. /**
  62640. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62641. * The set callback will be triggered just before rendering the layer.
  62642. */
  62643. set onBeforeRender(callback: () => void);
  62644. /**
  62645. * An event triggered after rendering the scene
  62646. */
  62647. onAfterRenderObservable: Observable<Layer>;
  62648. private _onAfterRenderObserver;
  62649. /**
  62650. * Back compatibility with callback before the onAfterRenderObservable existed.
  62651. * The set callback will be triggered just after rendering the layer.
  62652. */
  62653. set onAfterRender(callback: () => void);
  62654. /**
  62655. * Instantiates a new layer.
  62656. * This represents a full screen 2d layer.
  62657. * This can be useful to display a picture in the background of your scene for instance.
  62658. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62659. * @param name Define the name of the layer in the scene
  62660. * @param imgUrl Define the url of the texture to display in the layer
  62661. * @param scene Define the scene the layer belongs to
  62662. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62663. * @param color Defines a color for the layer
  62664. */
  62665. constructor(
  62666. /**
  62667. * Define the name of the layer.
  62668. */
  62669. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62670. private _createIndexBuffer;
  62671. /** @hidden */
  62672. _rebuild(): void;
  62673. /**
  62674. * Renders the layer in the scene.
  62675. */
  62676. render(): void;
  62677. /**
  62678. * Disposes and releases the associated ressources.
  62679. */
  62680. dispose(): void;
  62681. }
  62682. }
  62683. declare module "babylonjs/Layers/index" {
  62684. export * from "babylonjs/Layers/effectLayer";
  62685. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62686. export * from "babylonjs/Layers/glowLayer";
  62687. export * from "babylonjs/Layers/highlightLayer";
  62688. export * from "babylonjs/Layers/layer";
  62689. export * from "babylonjs/Layers/layerSceneComponent";
  62690. }
  62691. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62692. /** @hidden */
  62693. export var lensFlarePixelShader: {
  62694. name: string;
  62695. shader: string;
  62696. };
  62697. }
  62698. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62699. /** @hidden */
  62700. export var lensFlareVertexShader: {
  62701. name: string;
  62702. shader: string;
  62703. };
  62704. }
  62705. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62706. import { Scene } from "babylonjs/scene";
  62707. import { Vector3 } from "babylonjs/Maths/math.vector";
  62708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62709. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62710. import "babylonjs/Shaders/lensFlare.fragment";
  62711. import "babylonjs/Shaders/lensFlare.vertex";
  62712. import { Viewport } from "babylonjs/Maths/math.viewport";
  62713. /**
  62714. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62715. * It is usually composed of several `lensFlare`.
  62716. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62717. */
  62718. export class LensFlareSystem {
  62719. /**
  62720. * Define the name of the lens flare system
  62721. */
  62722. name: string;
  62723. /**
  62724. * List of lens flares used in this system.
  62725. */
  62726. lensFlares: LensFlare[];
  62727. /**
  62728. * Define a limit from the border the lens flare can be visible.
  62729. */
  62730. borderLimit: number;
  62731. /**
  62732. * Define a viewport border we do not want to see the lens flare in.
  62733. */
  62734. viewportBorder: number;
  62735. /**
  62736. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62737. */
  62738. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62739. /**
  62740. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62741. */
  62742. layerMask: number;
  62743. /**
  62744. * Define the id of the lens flare system in the scene.
  62745. * (equal to name by default)
  62746. */
  62747. id: string;
  62748. private _scene;
  62749. private _emitter;
  62750. private _vertexBuffers;
  62751. private _indexBuffer;
  62752. private _effect;
  62753. private _positionX;
  62754. private _positionY;
  62755. private _isEnabled;
  62756. /** @hidden */
  62757. static _SceneComponentInitialization: (scene: Scene) => void;
  62758. /**
  62759. * Instantiates a lens flare system.
  62760. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62761. * It is usually composed of several `lensFlare`.
  62762. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62763. * @param name Define the name of the lens flare system in the scene
  62764. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62765. * @param scene Define the scene the lens flare system belongs to
  62766. */
  62767. constructor(
  62768. /**
  62769. * Define the name of the lens flare system
  62770. */
  62771. name: string, emitter: any, scene: Scene);
  62772. /**
  62773. * Define if the lens flare system is enabled.
  62774. */
  62775. get isEnabled(): boolean;
  62776. set isEnabled(value: boolean);
  62777. /**
  62778. * Get the scene the effects belongs to.
  62779. * @returns the scene holding the lens flare system
  62780. */
  62781. getScene(): Scene;
  62782. /**
  62783. * Get the emitter of the lens flare system.
  62784. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62785. * @returns the emitter of the lens flare system
  62786. */
  62787. getEmitter(): any;
  62788. /**
  62789. * Set the emitter of the lens flare system.
  62790. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62791. * @param newEmitter Define the new emitter of the system
  62792. */
  62793. setEmitter(newEmitter: any): void;
  62794. /**
  62795. * Get the lens flare system emitter position.
  62796. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62797. * @returns the position
  62798. */
  62799. getEmitterPosition(): Vector3;
  62800. /**
  62801. * @hidden
  62802. */
  62803. computeEffectivePosition(globalViewport: Viewport): boolean;
  62804. /** @hidden */
  62805. _isVisible(): boolean;
  62806. /**
  62807. * @hidden
  62808. */
  62809. render(): boolean;
  62810. /**
  62811. * Dispose and release the lens flare with its associated resources.
  62812. */
  62813. dispose(): void;
  62814. /**
  62815. * Parse a lens flare system from a JSON repressentation
  62816. * @param parsedLensFlareSystem Define the JSON to parse
  62817. * @param scene Define the scene the parsed system should be instantiated in
  62818. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62819. * @returns the parsed system
  62820. */
  62821. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62822. /**
  62823. * Serialize the current Lens Flare System into a JSON representation.
  62824. * @returns the serialized JSON
  62825. */
  62826. serialize(): any;
  62827. }
  62828. }
  62829. declare module "babylonjs/LensFlares/lensFlare" {
  62830. import { Nullable } from "babylonjs/types";
  62831. import { Color3 } from "babylonjs/Maths/math.color";
  62832. import { Texture } from "babylonjs/Materials/Textures/texture";
  62833. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62834. /**
  62835. * This represents one of the lens effect in a `lensFlareSystem`.
  62836. * It controls one of the indiviual texture used in the effect.
  62837. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62838. */
  62839. export class LensFlare {
  62840. /**
  62841. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62842. */
  62843. size: number;
  62844. /**
  62845. * 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.
  62846. */
  62847. position: number;
  62848. /**
  62849. * Define the lens color.
  62850. */
  62851. color: Color3;
  62852. /**
  62853. * Define the lens texture.
  62854. */
  62855. texture: Nullable<Texture>;
  62856. /**
  62857. * Define the alpha mode to render this particular lens.
  62858. */
  62859. alphaMode: number;
  62860. private _system;
  62861. /**
  62862. * Creates a new Lens Flare.
  62863. * This represents one of the lens effect in a `lensFlareSystem`.
  62864. * It controls one of the indiviual texture used in the effect.
  62865. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62866. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62867. * @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.
  62868. * @param color Define the lens color
  62869. * @param imgUrl Define the lens texture url
  62870. * @param system Define the `lensFlareSystem` this flare is part of
  62871. * @returns The newly created Lens Flare
  62872. */
  62873. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62874. /**
  62875. * Instantiates a new Lens Flare.
  62876. * This represents one of the lens effect in a `lensFlareSystem`.
  62877. * It controls one of the indiviual texture used in the effect.
  62878. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62879. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62880. * @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.
  62881. * @param color Define the lens color
  62882. * @param imgUrl Define the lens texture url
  62883. * @param system Define the `lensFlareSystem` this flare is part of
  62884. */
  62885. constructor(
  62886. /**
  62887. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62888. */
  62889. size: number,
  62890. /**
  62891. * 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.
  62892. */
  62893. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62894. /**
  62895. * Dispose and release the lens flare with its associated resources.
  62896. */
  62897. dispose(): void;
  62898. }
  62899. }
  62900. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62901. import { Nullable } from "babylonjs/types";
  62902. import { Scene } from "babylonjs/scene";
  62903. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62904. import { AbstractScene } from "babylonjs/abstractScene";
  62905. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62906. module "babylonjs/abstractScene" {
  62907. interface AbstractScene {
  62908. /**
  62909. * The list of lens flare system added to the scene
  62910. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62911. */
  62912. lensFlareSystems: Array<LensFlareSystem>;
  62913. /**
  62914. * Removes the given lens flare system from this scene.
  62915. * @param toRemove The lens flare system to remove
  62916. * @returns The index of the removed lens flare system
  62917. */
  62918. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62919. /**
  62920. * Adds the given lens flare system to this scene
  62921. * @param newLensFlareSystem The lens flare system to add
  62922. */
  62923. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62924. /**
  62925. * Gets a lens flare system using its name
  62926. * @param name defines the name to look for
  62927. * @returns the lens flare system or null if not found
  62928. */
  62929. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62930. /**
  62931. * Gets a lens flare system using its id
  62932. * @param id defines the id to look for
  62933. * @returns the lens flare system or null if not found
  62934. */
  62935. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62936. }
  62937. }
  62938. /**
  62939. * Defines the lens flare scene component responsible to manage any lens flares
  62940. * in a given scene.
  62941. */
  62942. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62943. /**
  62944. * The component name helpfull to identify the component in the list of scene components.
  62945. */
  62946. readonly name: string;
  62947. /**
  62948. * The scene the component belongs to.
  62949. */
  62950. scene: Scene;
  62951. /**
  62952. * Creates a new instance of the component for the given scene
  62953. * @param scene Defines the scene to register the component in
  62954. */
  62955. constructor(scene: Scene);
  62956. /**
  62957. * Registers the component in a given scene
  62958. */
  62959. register(): void;
  62960. /**
  62961. * Rebuilds the elements related to this component in case of
  62962. * context lost for instance.
  62963. */
  62964. rebuild(): void;
  62965. /**
  62966. * Adds all the elements from the container to the scene
  62967. * @param container the container holding the elements
  62968. */
  62969. addFromContainer(container: AbstractScene): void;
  62970. /**
  62971. * Removes all the elements in the container from the scene
  62972. * @param container contains the elements to remove
  62973. * @param dispose if the removed element should be disposed (default: false)
  62974. */
  62975. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62976. /**
  62977. * Serializes the component data to the specified json object
  62978. * @param serializationObject The object to serialize to
  62979. */
  62980. serialize(serializationObject: any): void;
  62981. /**
  62982. * Disposes the component and the associated ressources.
  62983. */
  62984. dispose(): void;
  62985. private _draw;
  62986. }
  62987. }
  62988. declare module "babylonjs/LensFlares/index" {
  62989. export * from "babylonjs/LensFlares/lensFlare";
  62990. export * from "babylonjs/LensFlares/lensFlareSystem";
  62991. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62992. }
  62993. declare module "babylonjs/Shaders/depth.fragment" {
  62994. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62995. /** @hidden */
  62996. export var depthPixelShader: {
  62997. name: string;
  62998. shader: string;
  62999. };
  63000. }
  63001. declare module "babylonjs/Shaders/depth.vertex" {
  63002. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63003. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63004. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63005. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63006. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63007. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63008. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63009. /** @hidden */
  63010. export var depthVertexShader: {
  63011. name: string;
  63012. shader: string;
  63013. };
  63014. }
  63015. declare module "babylonjs/Rendering/depthRenderer" {
  63016. import { Nullable } from "babylonjs/types";
  63017. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63018. import { Scene } from "babylonjs/scene";
  63019. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63020. import { Camera } from "babylonjs/Cameras/camera";
  63021. import "babylonjs/Shaders/depth.fragment";
  63022. import "babylonjs/Shaders/depth.vertex";
  63023. /**
  63024. * This represents a depth renderer in Babylon.
  63025. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63026. */
  63027. export class DepthRenderer {
  63028. private _scene;
  63029. private _depthMap;
  63030. private _effect;
  63031. private readonly _storeNonLinearDepth;
  63032. private readonly _clearColor;
  63033. /** Get if the depth renderer is using packed depth or not */
  63034. readonly isPacked: boolean;
  63035. private _cachedDefines;
  63036. private _camera;
  63037. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63038. enabled: boolean;
  63039. /**
  63040. * Specifiess that the depth renderer will only be used within
  63041. * the camera it is created for.
  63042. * This can help forcing its rendering during the camera processing.
  63043. */
  63044. useOnlyInActiveCamera: boolean;
  63045. /** @hidden */
  63046. static _SceneComponentInitialization: (scene: Scene) => void;
  63047. /**
  63048. * Instantiates a depth renderer
  63049. * @param scene The scene the renderer belongs to
  63050. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63051. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63052. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63053. */
  63054. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63055. /**
  63056. * Creates the depth rendering effect and checks if the effect is ready.
  63057. * @param subMesh The submesh to be used to render the depth map of
  63058. * @param useInstances If multiple world instances should be used
  63059. * @returns if the depth renderer is ready to render the depth map
  63060. */
  63061. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63062. /**
  63063. * Gets the texture which the depth map will be written to.
  63064. * @returns The depth map texture
  63065. */
  63066. getDepthMap(): RenderTargetTexture;
  63067. /**
  63068. * Disposes of the depth renderer.
  63069. */
  63070. dispose(): void;
  63071. }
  63072. }
  63073. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63074. /** @hidden */
  63075. export var minmaxReduxPixelShader: {
  63076. name: string;
  63077. shader: string;
  63078. };
  63079. }
  63080. declare module "babylonjs/Misc/minMaxReducer" {
  63081. import { Nullable } from "babylonjs/types";
  63082. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63083. import { Camera } from "babylonjs/Cameras/camera";
  63084. import { Observer } from "babylonjs/Misc/observable";
  63085. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63086. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63087. import { Observable } from "babylonjs/Misc/observable";
  63088. import "babylonjs/Shaders/minmaxRedux.fragment";
  63089. /**
  63090. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63091. * and maximum values from all values of the texture.
  63092. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63093. * The source values are read from the red channel of the texture.
  63094. */
  63095. export class MinMaxReducer {
  63096. /**
  63097. * Observable triggered when the computation has been performed
  63098. */
  63099. onAfterReductionPerformed: Observable<{
  63100. min: number;
  63101. max: number;
  63102. }>;
  63103. protected _camera: Camera;
  63104. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63105. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63106. protected _postProcessManager: PostProcessManager;
  63107. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63108. protected _forceFullscreenViewport: boolean;
  63109. /**
  63110. * Creates a min/max reducer
  63111. * @param camera The camera to use for the post processes
  63112. */
  63113. constructor(camera: Camera);
  63114. /**
  63115. * Gets the texture used to read the values from.
  63116. */
  63117. get sourceTexture(): Nullable<RenderTargetTexture>;
  63118. /**
  63119. * Sets the source texture to read the values from.
  63120. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63121. * because in such textures '1' value must not be taken into account to compute the maximum
  63122. * as this value is used to clear the texture.
  63123. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63124. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63125. * @param depthRedux Indicates if the texture is a depth texture or not
  63126. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63127. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63128. */
  63129. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63130. /**
  63131. * Defines the refresh rate of the computation.
  63132. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63133. */
  63134. get refreshRate(): number;
  63135. set refreshRate(value: number);
  63136. protected _activated: boolean;
  63137. /**
  63138. * Gets the activation status of the reducer
  63139. */
  63140. get activated(): boolean;
  63141. /**
  63142. * Activates the reduction computation.
  63143. * When activated, the observers registered in onAfterReductionPerformed are
  63144. * called after the compuation is performed
  63145. */
  63146. activate(): void;
  63147. /**
  63148. * Deactivates the reduction computation.
  63149. */
  63150. deactivate(): void;
  63151. /**
  63152. * Disposes the min/max reducer
  63153. * @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.
  63154. */
  63155. dispose(disposeAll?: boolean): void;
  63156. }
  63157. }
  63158. declare module "babylonjs/Misc/depthReducer" {
  63159. import { Nullable } from "babylonjs/types";
  63160. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63161. import { Camera } from "babylonjs/Cameras/camera";
  63162. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63163. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63164. /**
  63165. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63166. */
  63167. export class DepthReducer extends MinMaxReducer {
  63168. private _depthRenderer;
  63169. private _depthRendererId;
  63170. /**
  63171. * Gets the depth renderer used for the computation.
  63172. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63173. */
  63174. get depthRenderer(): Nullable<DepthRenderer>;
  63175. /**
  63176. * Creates a depth reducer
  63177. * @param camera The camera used to render the depth texture
  63178. */
  63179. constructor(camera: Camera);
  63180. /**
  63181. * Sets the depth renderer to use to generate the depth map
  63182. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63183. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63184. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63185. */
  63186. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63187. /** @hidden */
  63188. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63189. /**
  63190. * Activates the reduction computation.
  63191. * When activated, the observers registered in onAfterReductionPerformed are
  63192. * called after the compuation is performed
  63193. */
  63194. activate(): void;
  63195. /**
  63196. * Deactivates the reduction computation.
  63197. */
  63198. deactivate(): void;
  63199. /**
  63200. * Disposes the depth reducer
  63201. * @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.
  63202. */
  63203. dispose(disposeAll?: boolean): void;
  63204. }
  63205. }
  63206. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63207. import { Nullable } from "babylonjs/types";
  63208. import { Scene } from "babylonjs/scene";
  63209. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63210. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63212. import { Effect } from "babylonjs/Materials/effect";
  63213. import "babylonjs/Shaders/shadowMap.fragment";
  63214. import "babylonjs/Shaders/shadowMap.vertex";
  63215. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63216. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63217. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63218. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63219. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63220. /**
  63221. * A CSM implementation allowing casting shadows on large scenes.
  63222. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63223. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63224. */
  63225. export class CascadedShadowGenerator extends ShadowGenerator {
  63226. private static readonly frustumCornersNDCSpace;
  63227. /**
  63228. * Name of the CSM class
  63229. */
  63230. static CLASSNAME: string;
  63231. /**
  63232. * Defines the default number of cascades used by the CSM.
  63233. */
  63234. static readonly DEFAULT_CASCADES_COUNT: number;
  63235. /**
  63236. * Defines the minimum number of cascades used by the CSM.
  63237. */
  63238. static readonly MIN_CASCADES_COUNT: number;
  63239. /**
  63240. * Defines the maximum number of cascades used by the CSM.
  63241. */
  63242. static readonly MAX_CASCADES_COUNT: number;
  63243. protected _validateFilter(filter: number): number;
  63244. /**
  63245. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63246. */
  63247. penumbraDarkness: number;
  63248. private _numCascades;
  63249. /**
  63250. * Gets or set the number of cascades used by the CSM.
  63251. */
  63252. get numCascades(): number;
  63253. set numCascades(value: number);
  63254. /**
  63255. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63256. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63257. */
  63258. stabilizeCascades: boolean;
  63259. private _freezeShadowCastersBoundingInfo;
  63260. private _freezeShadowCastersBoundingInfoObservable;
  63261. /**
  63262. * Enables or disables the shadow casters bounding info computation.
  63263. * If your shadow casters don't move, you can disable this feature.
  63264. * If it is enabled, the bounding box computation is done every frame.
  63265. */
  63266. get freezeShadowCastersBoundingInfo(): boolean;
  63267. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63268. private _scbiMin;
  63269. private _scbiMax;
  63270. protected _computeShadowCastersBoundingInfo(): void;
  63271. protected _shadowCastersBoundingInfo: BoundingInfo;
  63272. /**
  63273. * Gets or sets the shadow casters bounding info.
  63274. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63275. * so that the system won't overwrite the bounds you provide
  63276. */
  63277. get shadowCastersBoundingInfo(): BoundingInfo;
  63278. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63279. protected _breaksAreDirty: boolean;
  63280. protected _minDistance: number;
  63281. protected _maxDistance: number;
  63282. /**
  63283. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63284. *
  63285. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63286. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63287. * @param min minimal distance for the breaks (default to 0.)
  63288. * @param max maximal distance for the breaks (default to 1.)
  63289. */
  63290. setMinMaxDistance(min: number, max: number): void;
  63291. /** Gets the minimal distance used in the cascade break computation */
  63292. get minDistance(): number;
  63293. /** Gets the maximal distance used in the cascade break computation */
  63294. get maxDistance(): number;
  63295. /**
  63296. * Gets the class name of that object
  63297. * @returns "CascadedShadowGenerator"
  63298. */
  63299. getClassName(): string;
  63300. private _cascadeMinExtents;
  63301. private _cascadeMaxExtents;
  63302. /**
  63303. * Gets a cascade minimum extents
  63304. * @param cascadeIndex index of the cascade
  63305. * @returns the minimum cascade extents
  63306. */
  63307. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63308. /**
  63309. * Gets a cascade maximum extents
  63310. * @param cascadeIndex index of the cascade
  63311. * @returns the maximum cascade extents
  63312. */
  63313. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63314. private _cascades;
  63315. private _currentLayer;
  63316. private _viewSpaceFrustumsZ;
  63317. private _viewMatrices;
  63318. private _projectionMatrices;
  63319. private _transformMatrices;
  63320. private _transformMatricesAsArray;
  63321. private _frustumLengths;
  63322. private _lightSizeUVCorrection;
  63323. private _depthCorrection;
  63324. private _frustumCornersWorldSpace;
  63325. private _frustumCenter;
  63326. private _shadowCameraPos;
  63327. private _shadowMaxZ;
  63328. /**
  63329. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63330. * It defaults to camera.maxZ
  63331. */
  63332. get shadowMaxZ(): number;
  63333. /**
  63334. * Sets the shadow max z distance.
  63335. */
  63336. set shadowMaxZ(value: number);
  63337. protected _debug: boolean;
  63338. /**
  63339. * Gets or sets the debug flag.
  63340. * When enabled, the cascades are materialized by different colors on the screen.
  63341. */
  63342. get debug(): boolean;
  63343. set debug(dbg: boolean);
  63344. private _depthClamp;
  63345. /**
  63346. * Gets or sets the depth clamping value.
  63347. *
  63348. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63349. * to account for the shadow casters far away.
  63350. *
  63351. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63352. */
  63353. get depthClamp(): boolean;
  63354. set depthClamp(value: boolean);
  63355. private _cascadeBlendPercentage;
  63356. /**
  63357. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63358. * It defaults to 0.1 (10% blending).
  63359. */
  63360. get cascadeBlendPercentage(): number;
  63361. set cascadeBlendPercentage(value: number);
  63362. private _lambda;
  63363. /**
  63364. * Gets or set the lambda parameter.
  63365. * This parameter is used to split the camera frustum and create the cascades.
  63366. * 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.
  63367. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63368. */
  63369. get lambda(): number;
  63370. set lambda(value: number);
  63371. /**
  63372. * Gets the view matrix corresponding to a given cascade
  63373. * @param cascadeNum cascade to retrieve the view matrix from
  63374. * @returns the cascade view matrix
  63375. */
  63376. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63377. /**
  63378. * Gets the projection matrix corresponding to a given cascade
  63379. * @param cascadeNum cascade to retrieve the projection matrix from
  63380. * @returns the cascade projection matrix
  63381. */
  63382. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63383. /**
  63384. * Gets the transformation matrix corresponding to a given cascade
  63385. * @param cascadeNum cascade to retrieve the transformation matrix from
  63386. * @returns the cascade transformation matrix
  63387. */
  63388. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63389. private _depthRenderer;
  63390. /**
  63391. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63392. *
  63393. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63394. *
  63395. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63396. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63397. * @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
  63398. */
  63399. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63400. private _depthReducer;
  63401. private _autoCalcDepthBounds;
  63402. /**
  63403. * Gets or sets the autoCalcDepthBounds property.
  63404. *
  63405. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63406. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63407. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63408. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63409. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63410. */
  63411. get autoCalcDepthBounds(): boolean;
  63412. set autoCalcDepthBounds(value: boolean);
  63413. /**
  63414. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63415. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63416. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63417. * for setting the refresh rate on the renderer yourself!
  63418. */
  63419. get autoCalcDepthBoundsRefreshRate(): number;
  63420. set autoCalcDepthBoundsRefreshRate(value: number);
  63421. /**
  63422. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63423. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63424. * you change the camera near/far planes!
  63425. */
  63426. splitFrustum(): void;
  63427. private _splitFrustum;
  63428. private _computeMatrices;
  63429. private _computeFrustumInWorldSpace;
  63430. private _computeCascadeFrustum;
  63431. /**
  63432. * Support test.
  63433. */
  63434. static get IsSupported(): boolean;
  63435. /** @hidden */
  63436. static _SceneComponentInitialization: (scene: Scene) => void;
  63437. /**
  63438. * Creates a Cascaded Shadow Generator object.
  63439. * A ShadowGenerator is the required tool to use the shadows.
  63440. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63441. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63442. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63443. * @param light The directional light object generating the shadows.
  63444. * @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.
  63445. */
  63446. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63447. protected _initializeGenerator(): void;
  63448. protected _createTargetRenderTexture(): void;
  63449. protected _initializeShadowMap(): void;
  63450. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63451. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63452. /**
  63453. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63454. * @param defines Defines of the material we want to update
  63455. * @param lightIndex Index of the light in the enabled light list of the material
  63456. */
  63457. prepareDefines(defines: any, lightIndex: number): void;
  63458. /**
  63459. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63460. * defined in the generator but impacting the effect).
  63461. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63462. * @param effect The effect we are binfing the information for
  63463. */
  63464. bindShadowLight(lightIndex: string, effect: Effect): void;
  63465. /**
  63466. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63467. * (eq to view projection * shadow projection matrices)
  63468. * @returns The transform matrix used to create the shadow map
  63469. */
  63470. getTransformMatrix(): Matrix;
  63471. /**
  63472. * Disposes the ShadowGenerator.
  63473. * Returns nothing.
  63474. */
  63475. dispose(): void;
  63476. /**
  63477. * Serializes the shadow generator setup to a json object.
  63478. * @returns The serialized JSON object
  63479. */
  63480. serialize(): any;
  63481. /**
  63482. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63483. * @param parsedShadowGenerator The JSON object to parse
  63484. * @param scene The scene to create the shadow map for
  63485. * @returns The parsed shadow generator
  63486. */
  63487. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63488. }
  63489. }
  63490. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63491. import { Scene } from "babylonjs/scene";
  63492. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63493. import { AbstractScene } from "babylonjs/abstractScene";
  63494. /**
  63495. * Defines the shadow generator component responsible to manage any shadow generators
  63496. * in a given scene.
  63497. */
  63498. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63499. /**
  63500. * The component name helpfull to identify the component in the list of scene components.
  63501. */
  63502. readonly name: string;
  63503. /**
  63504. * The scene the component belongs to.
  63505. */
  63506. scene: Scene;
  63507. /**
  63508. * Creates a new instance of the component for the given scene
  63509. * @param scene Defines the scene to register the component in
  63510. */
  63511. constructor(scene: Scene);
  63512. /**
  63513. * Registers the component in a given scene
  63514. */
  63515. register(): void;
  63516. /**
  63517. * Rebuilds the elements related to this component in case of
  63518. * context lost for instance.
  63519. */
  63520. rebuild(): void;
  63521. /**
  63522. * Serializes the component data to the specified json object
  63523. * @param serializationObject The object to serialize to
  63524. */
  63525. serialize(serializationObject: any): void;
  63526. /**
  63527. * Adds all the elements from the container to the scene
  63528. * @param container the container holding the elements
  63529. */
  63530. addFromContainer(container: AbstractScene): void;
  63531. /**
  63532. * Removes all the elements in the container from the scene
  63533. * @param container contains the elements to remove
  63534. * @param dispose if the removed element should be disposed (default: false)
  63535. */
  63536. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63537. /**
  63538. * Rebuilds the elements related to this component in case of
  63539. * context lost for instance.
  63540. */
  63541. dispose(): void;
  63542. private _gatherRenderTargets;
  63543. }
  63544. }
  63545. declare module "babylonjs/Lights/Shadows/index" {
  63546. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63547. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63548. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63549. }
  63550. declare module "babylonjs/Lights/pointLight" {
  63551. import { Scene } from "babylonjs/scene";
  63552. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63554. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63555. import { Effect } from "babylonjs/Materials/effect";
  63556. /**
  63557. * A point light is a light defined by an unique point in world space.
  63558. * The light is emitted in every direction from this point.
  63559. * A good example of a point light is a standard light bulb.
  63560. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63561. */
  63562. export class PointLight extends ShadowLight {
  63563. private _shadowAngle;
  63564. /**
  63565. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63566. * This specifies what angle the shadow will use to be created.
  63567. *
  63568. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63569. */
  63570. get shadowAngle(): number;
  63571. /**
  63572. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63573. * This specifies what angle the shadow will use to be created.
  63574. *
  63575. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63576. */
  63577. set shadowAngle(value: number);
  63578. /**
  63579. * Gets the direction if it has been set.
  63580. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63581. */
  63582. get direction(): Vector3;
  63583. /**
  63584. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63585. */
  63586. set direction(value: Vector3);
  63587. /**
  63588. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63589. * A PointLight emits the light in every direction.
  63590. * It can cast shadows.
  63591. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63592. * ```javascript
  63593. * var pointLight = new PointLight("pl", camera.position, scene);
  63594. * ```
  63595. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63596. * @param name The light friendly name
  63597. * @param position The position of the point light in the scene
  63598. * @param scene The scene the lights belongs to
  63599. */
  63600. constructor(name: string, position: Vector3, scene: Scene);
  63601. /**
  63602. * Returns the string "PointLight"
  63603. * @returns the class name
  63604. */
  63605. getClassName(): string;
  63606. /**
  63607. * Returns the integer 0.
  63608. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63609. */
  63610. getTypeID(): number;
  63611. /**
  63612. * Specifies wether or not the shadowmap should be a cube texture.
  63613. * @returns true if the shadowmap needs to be a cube texture.
  63614. */
  63615. needCube(): boolean;
  63616. /**
  63617. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63618. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63619. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63620. */
  63621. getShadowDirection(faceIndex?: number): Vector3;
  63622. /**
  63623. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63624. * - fov = PI / 2
  63625. * - aspect ratio : 1.0
  63626. * - z-near and far equal to the active camera minZ and maxZ.
  63627. * Returns the PointLight.
  63628. */
  63629. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63630. protected _buildUniformLayout(): void;
  63631. /**
  63632. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63633. * @param effect The effect to update
  63634. * @param lightIndex The index of the light in the effect to update
  63635. * @returns The point light
  63636. */
  63637. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63638. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63639. /**
  63640. * Prepares the list of defines specific to the light type.
  63641. * @param defines the list of defines
  63642. * @param lightIndex defines the index of the light for the effect
  63643. */
  63644. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63645. }
  63646. }
  63647. declare module "babylonjs/Lights/index" {
  63648. export * from "babylonjs/Lights/light";
  63649. export * from "babylonjs/Lights/shadowLight";
  63650. export * from "babylonjs/Lights/Shadows/index";
  63651. export * from "babylonjs/Lights/directionalLight";
  63652. export * from "babylonjs/Lights/hemisphericLight";
  63653. export * from "babylonjs/Lights/pointLight";
  63654. export * from "babylonjs/Lights/spotLight";
  63655. }
  63656. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63657. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63658. /**
  63659. * Header information of HDR texture files.
  63660. */
  63661. export interface HDRInfo {
  63662. /**
  63663. * The height of the texture in pixels.
  63664. */
  63665. height: number;
  63666. /**
  63667. * The width of the texture in pixels.
  63668. */
  63669. width: number;
  63670. /**
  63671. * The index of the beginning of the data in the binary file.
  63672. */
  63673. dataPosition: number;
  63674. }
  63675. /**
  63676. * This groups tools to convert HDR texture to native colors array.
  63677. */
  63678. export class HDRTools {
  63679. private static Ldexp;
  63680. private static Rgbe2float;
  63681. private static readStringLine;
  63682. /**
  63683. * Reads header information from an RGBE texture stored in a native array.
  63684. * More information on this format are available here:
  63685. * https://en.wikipedia.org/wiki/RGBE_image_format
  63686. *
  63687. * @param uint8array The binary file stored in native array.
  63688. * @return The header information.
  63689. */
  63690. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63691. /**
  63692. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63693. * This RGBE texture needs to store the information as a panorama.
  63694. *
  63695. * More information on this format are available here:
  63696. * https://en.wikipedia.org/wiki/RGBE_image_format
  63697. *
  63698. * @param buffer The binary file stored in an array buffer.
  63699. * @param size The expected size of the extracted cubemap.
  63700. * @return The Cube Map information.
  63701. */
  63702. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63703. /**
  63704. * Returns the pixels data extracted from an RGBE texture.
  63705. * This pixels will be stored left to right up to down in the R G B order in one array.
  63706. *
  63707. * More information on this format are available here:
  63708. * https://en.wikipedia.org/wiki/RGBE_image_format
  63709. *
  63710. * @param uint8array The binary file stored in an array buffer.
  63711. * @param hdrInfo The header information of the file.
  63712. * @return The pixels data in RGB right to left up to down order.
  63713. */
  63714. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63715. private static RGBE_ReadPixels_RLE;
  63716. private static RGBE_ReadPixels_NOT_RLE;
  63717. }
  63718. }
  63719. declare module "babylonjs/Materials/effectRenderer" {
  63720. import { Nullable } from "babylonjs/types";
  63721. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63722. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63723. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63724. import { Viewport } from "babylonjs/Maths/math.viewport";
  63725. import { Observable } from "babylonjs/Misc/observable";
  63726. import { Effect } from "babylonjs/Materials/effect";
  63727. import "babylonjs/Shaders/postprocess.vertex";
  63728. /**
  63729. * Effect Render Options
  63730. */
  63731. export interface IEffectRendererOptions {
  63732. /**
  63733. * Defines the vertices positions.
  63734. */
  63735. positions?: number[];
  63736. /**
  63737. * Defines the indices.
  63738. */
  63739. indices?: number[];
  63740. }
  63741. /**
  63742. * Helper class to render one or more effects.
  63743. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63744. */
  63745. export class EffectRenderer {
  63746. private engine;
  63747. private static _DefaultOptions;
  63748. private _vertexBuffers;
  63749. private _indexBuffer;
  63750. private _fullscreenViewport;
  63751. /**
  63752. * Creates an effect renderer
  63753. * @param engine the engine to use for rendering
  63754. * @param options defines the options of the effect renderer
  63755. */
  63756. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63757. /**
  63758. * Sets the current viewport in normalized coordinates 0-1
  63759. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63760. */
  63761. setViewport(viewport?: Viewport): void;
  63762. /**
  63763. * Binds the embedded attributes buffer to the effect.
  63764. * @param effect Defines the effect to bind the attributes for
  63765. */
  63766. bindBuffers(effect: Effect): void;
  63767. /**
  63768. * Sets the current effect wrapper to use during draw.
  63769. * The effect needs to be ready before calling this api.
  63770. * This also sets the default full screen position attribute.
  63771. * @param effectWrapper Defines the effect to draw with
  63772. */
  63773. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63774. /**
  63775. * Restores engine states
  63776. */
  63777. restoreStates(): void;
  63778. /**
  63779. * Draws a full screen quad.
  63780. */
  63781. draw(): void;
  63782. private isRenderTargetTexture;
  63783. /**
  63784. * renders one or more effects to a specified texture
  63785. * @param effectWrapper the effect to renderer
  63786. * @param outputTexture texture to draw to, if null it will render to the screen.
  63787. */
  63788. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63789. /**
  63790. * Disposes of the effect renderer
  63791. */
  63792. dispose(): void;
  63793. }
  63794. /**
  63795. * Options to create an EffectWrapper
  63796. */
  63797. interface EffectWrapperCreationOptions {
  63798. /**
  63799. * Engine to use to create the effect
  63800. */
  63801. engine: ThinEngine;
  63802. /**
  63803. * Fragment shader for the effect
  63804. */
  63805. fragmentShader: string;
  63806. /**
  63807. * Use the shader store instead of direct source code
  63808. */
  63809. useShaderStore?: boolean;
  63810. /**
  63811. * Vertex shader for the effect
  63812. */
  63813. vertexShader?: string;
  63814. /**
  63815. * Attributes to use in the shader
  63816. */
  63817. attributeNames?: Array<string>;
  63818. /**
  63819. * Uniforms to use in the shader
  63820. */
  63821. uniformNames?: Array<string>;
  63822. /**
  63823. * Texture sampler names to use in the shader
  63824. */
  63825. samplerNames?: Array<string>;
  63826. /**
  63827. * Defines to use in the shader
  63828. */
  63829. defines?: Array<string>;
  63830. /**
  63831. * Callback when effect is compiled
  63832. */
  63833. onCompiled?: Nullable<(effect: Effect) => void>;
  63834. /**
  63835. * The friendly name of the effect displayed in Spector.
  63836. */
  63837. name?: string;
  63838. }
  63839. /**
  63840. * Wraps an effect to be used for rendering
  63841. */
  63842. export class EffectWrapper {
  63843. /**
  63844. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63845. */
  63846. onApplyObservable: Observable<{}>;
  63847. /**
  63848. * The underlying effect
  63849. */
  63850. effect: Effect;
  63851. /**
  63852. * Creates an effect to be renderer
  63853. * @param creationOptions options to create the effect
  63854. */
  63855. constructor(creationOptions: EffectWrapperCreationOptions);
  63856. /**
  63857. * Disposes of the effect wrapper
  63858. */
  63859. dispose(): void;
  63860. }
  63861. }
  63862. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63863. /** @hidden */
  63864. export var hdrFilteringVertexShader: {
  63865. name: string;
  63866. shader: string;
  63867. };
  63868. }
  63869. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63870. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63871. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63872. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63873. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63874. /** @hidden */
  63875. export var hdrFilteringPixelShader: {
  63876. name: string;
  63877. shader: string;
  63878. };
  63879. }
  63880. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63882. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63883. import { Nullable } from "babylonjs/types";
  63884. import "babylonjs/Shaders/hdrFiltering.vertex";
  63885. import "babylonjs/Shaders/hdrFiltering.fragment";
  63886. /**
  63887. * Options for texture filtering
  63888. */
  63889. interface IHDRFilteringOptions {
  63890. /**
  63891. * Scales pixel intensity for the input HDR map.
  63892. */
  63893. hdrScale?: number;
  63894. /**
  63895. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63896. */
  63897. quality?: number;
  63898. }
  63899. /**
  63900. * Filters HDR maps to get correct renderings of PBR reflections
  63901. */
  63902. export class HDRFiltering {
  63903. private _engine;
  63904. private _effectRenderer;
  63905. private _effectWrapper;
  63906. private _lodGenerationOffset;
  63907. private _lodGenerationScale;
  63908. /**
  63909. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63910. * you care about baking speed.
  63911. */
  63912. quality: number;
  63913. /**
  63914. * Scales pixel intensity for the input HDR map.
  63915. */
  63916. hdrScale: number;
  63917. /**
  63918. * Instantiates HDR filter for reflection maps
  63919. *
  63920. * @param engine Thin engine
  63921. * @param options Options
  63922. */
  63923. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63924. private _createRenderTarget;
  63925. private _prefilterInternal;
  63926. private _createEffect;
  63927. /**
  63928. * Get a value indicating if the filter is ready to be used
  63929. * @param texture Texture to filter
  63930. * @returns true if the filter is ready
  63931. */
  63932. isReady(texture: BaseTexture): boolean;
  63933. /**
  63934. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63935. * Prefiltering will be invoked at the end of next rendering pass.
  63936. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63937. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63938. * @param texture Texture to filter
  63939. * @param onFinished Callback when filtering is done
  63940. * @return Promise called when prefiltering is done
  63941. */
  63942. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63943. }
  63944. }
  63945. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63946. import { Nullable } from "babylonjs/types";
  63947. import { Scene } from "babylonjs/scene";
  63948. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63950. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63951. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63952. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63953. /**
  63954. * This represents a texture coming from an HDR input.
  63955. *
  63956. * The only supported format is currently panorama picture stored in RGBE format.
  63957. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63958. */
  63959. export class HDRCubeTexture extends BaseTexture {
  63960. private static _facesMapping;
  63961. private _generateHarmonics;
  63962. private _noMipmap;
  63963. private _prefilterOnLoad;
  63964. private _textureMatrix;
  63965. private _size;
  63966. private _onLoad;
  63967. private _onError;
  63968. /**
  63969. * The texture URL.
  63970. */
  63971. url: string;
  63972. protected _isBlocking: boolean;
  63973. /**
  63974. * Sets wether or not the texture is blocking during loading.
  63975. */
  63976. set isBlocking(value: boolean);
  63977. /**
  63978. * Gets wether or not the texture is blocking during loading.
  63979. */
  63980. get isBlocking(): boolean;
  63981. protected _rotationY: number;
  63982. /**
  63983. * Sets texture matrix rotation angle around Y axis in radians.
  63984. */
  63985. set rotationY(value: number);
  63986. /**
  63987. * Gets texture matrix rotation angle around Y axis radians.
  63988. */
  63989. get rotationY(): number;
  63990. /**
  63991. * Gets or sets the center of the bounding box associated with the cube texture
  63992. * It must define where the camera used to render the texture was set
  63993. */
  63994. boundingBoxPosition: Vector3;
  63995. private _boundingBoxSize;
  63996. /**
  63997. * Gets or sets the size of the bounding box associated with the cube texture
  63998. * When defined, the cubemap will switch to local mode
  63999. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64000. * @example https://www.babylonjs-playground.com/#RNASML
  64001. */
  64002. set boundingBoxSize(value: Vector3);
  64003. get boundingBoxSize(): Vector3;
  64004. /**
  64005. * Instantiates an HDRTexture from the following parameters.
  64006. *
  64007. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64008. * @param sceneOrEngine The scene or engine the texture will be used in
  64009. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64010. * @param noMipmap Forces to not generate the mipmap if true
  64011. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64012. * @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)
  64013. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64014. */
  64015. 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>);
  64016. /**
  64017. * Get the current class name of the texture useful for serialization or dynamic coding.
  64018. * @returns "HDRCubeTexture"
  64019. */
  64020. getClassName(): string;
  64021. /**
  64022. * Occurs when the file is raw .hdr file.
  64023. */
  64024. private loadTexture;
  64025. clone(): HDRCubeTexture;
  64026. delayLoad(): void;
  64027. /**
  64028. * Get the texture reflection matrix used to rotate/transform the reflection.
  64029. * @returns the reflection matrix
  64030. */
  64031. getReflectionTextureMatrix(): Matrix;
  64032. /**
  64033. * Set the texture reflection matrix used to rotate/transform the reflection.
  64034. * @param value Define the reflection matrix to set
  64035. */
  64036. setReflectionTextureMatrix(value: Matrix): void;
  64037. /**
  64038. * Parses a JSON representation of an HDR Texture in order to create the texture
  64039. * @param parsedTexture Define the JSON representation
  64040. * @param scene Define the scene the texture should be created in
  64041. * @param rootUrl Define the root url in case we need to load relative dependencies
  64042. * @returns the newly created texture after parsing
  64043. */
  64044. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64045. serialize(): any;
  64046. }
  64047. }
  64048. declare module "babylonjs/Physics/physicsEngine" {
  64049. import { Nullable } from "babylonjs/types";
  64050. import { Vector3 } from "babylonjs/Maths/math.vector";
  64051. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64052. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64053. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64054. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64055. /**
  64056. * Class used to control physics engine
  64057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64058. */
  64059. export class PhysicsEngine implements IPhysicsEngine {
  64060. private _physicsPlugin;
  64061. /**
  64062. * Global value used to control the smallest number supported by the simulation
  64063. */
  64064. static Epsilon: number;
  64065. private _impostors;
  64066. private _joints;
  64067. private _subTimeStep;
  64068. /**
  64069. * Gets the gravity vector used by the simulation
  64070. */
  64071. gravity: Vector3;
  64072. /**
  64073. * Factory used to create the default physics plugin.
  64074. * @returns The default physics plugin
  64075. */
  64076. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64077. /**
  64078. * Creates a new Physics Engine
  64079. * @param gravity defines the gravity vector used by the simulation
  64080. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64081. */
  64082. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64083. /**
  64084. * Sets the gravity vector used by the simulation
  64085. * @param gravity defines the gravity vector to use
  64086. */
  64087. setGravity(gravity: Vector3): void;
  64088. /**
  64089. * Set the time step of the physics engine.
  64090. * Default is 1/60.
  64091. * To slow it down, enter 1/600 for example.
  64092. * To speed it up, 1/30
  64093. * @param newTimeStep defines the new timestep to apply to this world.
  64094. */
  64095. setTimeStep(newTimeStep?: number): void;
  64096. /**
  64097. * Get the time step of the physics engine.
  64098. * @returns the current time step
  64099. */
  64100. getTimeStep(): number;
  64101. /**
  64102. * Set the sub time step of the physics engine.
  64103. * Default is 0 meaning there is no sub steps
  64104. * To increase physics resolution precision, set a small value (like 1 ms)
  64105. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64106. */
  64107. setSubTimeStep(subTimeStep?: number): void;
  64108. /**
  64109. * Get the sub time step of the physics engine.
  64110. * @returns the current sub time step
  64111. */
  64112. getSubTimeStep(): number;
  64113. /**
  64114. * Release all resources
  64115. */
  64116. dispose(): void;
  64117. /**
  64118. * Gets the name of the current physics plugin
  64119. * @returns the name of the plugin
  64120. */
  64121. getPhysicsPluginName(): string;
  64122. /**
  64123. * Adding a new impostor for the impostor tracking.
  64124. * This will be done by the impostor itself.
  64125. * @param impostor the impostor to add
  64126. */
  64127. addImpostor(impostor: PhysicsImpostor): void;
  64128. /**
  64129. * Remove an impostor from the engine.
  64130. * This impostor and its mesh will not longer be updated by the physics engine.
  64131. * @param impostor the impostor to remove
  64132. */
  64133. removeImpostor(impostor: PhysicsImpostor): void;
  64134. /**
  64135. * Add a joint to the physics engine
  64136. * @param mainImpostor defines the main impostor to which the joint is added.
  64137. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64138. * @param joint defines the joint that will connect both impostors.
  64139. */
  64140. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64141. /**
  64142. * Removes a joint from the simulation
  64143. * @param mainImpostor defines the impostor used with the joint
  64144. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64145. * @param joint defines the joint to remove
  64146. */
  64147. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64148. /**
  64149. * Called by the scene. No need to call it.
  64150. * @param delta defines the timespam between frames
  64151. */
  64152. _step(delta: number): void;
  64153. /**
  64154. * Gets the current plugin used to run the simulation
  64155. * @returns current plugin
  64156. */
  64157. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64158. /**
  64159. * Gets the list of physic impostors
  64160. * @returns an array of PhysicsImpostor
  64161. */
  64162. getImpostors(): Array<PhysicsImpostor>;
  64163. /**
  64164. * Gets the impostor for a physics enabled object
  64165. * @param object defines the object impersonated by the impostor
  64166. * @returns the PhysicsImpostor or null if not found
  64167. */
  64168. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64169. /**
  64170. * Gets the impostor for a physics body object
  64171. * @param body defines physics body used by the impostor
  64172. * @returns the PhysicsImpostor or null if not found
  64173. */
  64174. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64175. /**
  64176. * Does a raycast in the physics world
  64177. * @param from when should the ray start?
  64178. * @param to when should the ray end?
  64179. * @returns PhysicsRaycastResult
  64180. */
  64181. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64182. }
  64183. }
  64184. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64185. import { Nullable } from "babylonjs/types";
  64186. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64188. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64189. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64190. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64191. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64192. /** @hidden */
  64193. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64194. private _useDeltaForWorldStep;
  64195. world: any;
  64196. name: string;
  64197. private _physicsMaterials;
  64198. private _fixedTimeStep;
  64199. private _cannonRaycastResult;
  64200. private _raycastResult;
  64201. private _physicsBodysToRemoveAfterStep;
  64202. private _firstFrame;
  64203. BJSCANNON: any;
  64204. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64205. setGravity(gravity: Vector3): void;
  64206. setTimeStep(timeStep: number): void;
  64207. getTimeStep(): number;
  64208. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64209. private _removeMarkedPhysicsBodiesFromWorld;
  64210. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64211. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64212. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64213. private _processChildMeshes;
  64214. removePhysicsBody(impostor: PhysicsImpostor): void;
  64215. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64216. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64217. private _addMaterial;
  64218. private _checkWithEpsilon;
  64219. private _createShape;
  64220. private _createHeightmap;
  64221. private _minus90X;
  64222. private _plus90X;
  64223. private _tmpPosition;
  64224. private _tmpDeltaPosition;
  64225. private _tmpUnityRotation;
  64226. private _updatePhysicsBodyTransformation;
  64227. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64228. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64229. isSupported(): boolean;
  64230. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64231. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64232. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64233. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64234. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64235. getBodyMass(impostor: PhysicsImpostor): number;
  64236. getBodyFriction(impostor: PhysicsImpostor): number;
  64237. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64238. getBodyRestitution(impostor: PhysicsImpostor): number;
  64239. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64240. sleepBody(impostor: PhysicsImpostor): void;
  64241. wakeUpBody(impostor: PhysicsImpostor): void;
  64242. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64243. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64244. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64245. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64246. getRadius(impostor: PhysicsImpostor): number;
  64247. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64248. dispose(): void;
  64249. private _extendNamespace;
  64250. /**
  64251. * Does a raycast in the physics world
  64252. * @param from when should the ray start?
  64253. * @param to when should the ray end?
  64254. * @returns PhysicsRaycastResult
  64255. */
  64256. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64257. }
  64258. }
  64259. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64260. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64261. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64262. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64264. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64265. import { Nullable } from "babylonjs/types";
  64266. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64267. /** @hidden */
  64268. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64269. private _useDeltaForWorldStep;
  64270. world: any;
  64271. name: string;
  64272. BJSOIMO: any;
  64273. private _raycastResult;
  64274. private _fixedTimeStep;
  64275. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64276. setGravity(gravity: Vector3): void;
  64277. setTimeStep(timeStep: number): void;
  64278. getTimeStep(): number;
  64279. private _tmpImpostorsArray;
  64280. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64281. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64282. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64283. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64284. private _tmpPositionVector;
  64285. removePhysicsBody(impostor: PhysicsImpostor): void;
  64286. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64287. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64288. isSupported(): boolean;
  64289. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64290. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64291. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64292. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64293. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64294. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64295. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64296. getBodyMass(impostor: PhysicsImpostor): number;
  64297. getBodyFriction(impostor: PhysicsImpostor): number;
  64298. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64299. getBodyRestitution(impostor: PhysicsImpostor): number;
  64300. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64301. sleepBody(impostor: PhysicsImpostor): void;
  64302. wakeUpBody(impostor: PhysicsImpostor): void;
  64303. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64304. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64305. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64306. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64307. getRadius(impostor: PhysicsImpostor): number;
  64308. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64309. dispose(): void;
  64310. /**
  64311. * Does a raycast in the physics world
  64312. * @param from when should the ray start?
  64313. * @param to when should the ray end?
  64314. * @returns PhysicsRaycastResult
  64315. */
  64316. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64317. }
  64318. }
  64319. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64320. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64321. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64322. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64323. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64324. import { Nullable } from "babylonjs/types";
  64325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64326. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64327. /**
  64328. * AmmoJS Physics plugin
  64329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64330. * @see https://github.com/kripken/ammo.js/
  64331. */
  64332. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64333. private _useDeltaForWorldStep;
  64334. /**
  64335. * Reference to the Ammo library
  64336. */
  64337. bjsAMMO: any;
  64338. /**
  64339. * Created ammoJS world which physics bodies are added to
  64340. */
  64341. world: any;
  64342. /**
  64343. * Name of the plugin
  64344. */
  64345. name: string;
  64346. private _timeStep;
  64347. private _fixedTimeStep;
  64348. private _maxSteps;
  64349. private _tmpQuaternion;
  64350. private _tmpAmmoTransform;
  64351. private _tmpAmmoQuaternion;
  64352. private _tmpAmmoConcreteContactResultCallback;
  64353. private _collisionConfiguration;
  64354. private _dispatcher;
  64355. private _overlappingPairCache;
  64356. private _solver;
  64357. private _softBodySolver;
  64358. private _tmpAmmoVectorA;
  64359. private _tmpAmmoVectorB;
  64360. private _tmpAmmoVectorC;
  64361. private _tmpAmmoVectorD;
  64362. private _tmpContactCallbackResult;
  64363. private _tmpAmmoVectorRCA;
  64364. private _tmpAmmoVectorRCB;
  64365. private _raycastResult;
  64366. private static readonly DISABLE_COLLISION_FLAG;
  64367. private static readonly KINEMATIC_FLAG;
  64368. private static readonly DISABLE_DEACTIVATION_FLAG;
  64369. /**
  64370. * Initializes the ammoJS plugin
  64371. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64372. * @param ammoInjection can be used to inject your own ammo reference
  64373. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64374. */
  64375. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64376. /**
  64377. * Sets the gravity of the physics world (m/(s^2))
  64378. * @param gravity Gravity to set
  64379. */
  64380. setGravity(gravity: Vector3): void;
  64381. /**
  64382. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64383. * @param timeStep timestep to use in seconds
  64384. */
  64385. setTimeStep(timeStep: number): void;
  64386. /**
  64387. * 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)
  64388. * @param fixedTimeStep fixedTimeStep to use in seconds
  64389. */
  64390. setFixedTimeStep(fixedTimeStep: number): void;
  64391. /**
  64392. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64393. * @param maxSteps the maximum number of steps by the physics engine per frame
  64394. */
  64395. setMaxSteps(maxSteps: number): void;
  64396. /**
  64397. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64398. * @returns the current timestep in seconds
  64399. */
  64400. getTimeStep(): number;
  64401. /**
  64402. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64403. */
  64404. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64405. private _isImpostorInContact;
  64406. private _isImpostorPairInContact;
  64407. private _stepSimulation;
  64408. /**
  64409. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64410. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64411. * After the step the babylon meshes are set to the position of the physics imposters
  64412. * @param delta amount of time to step forward
  64413. * @param impostors array of imposters to update before/after the step
  64414. */
  64415. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64416. /**
  64417. * Update babylon mesh to match physics world object
  64418. * @param impostor imposter to match
  64419. */
  64420. private _afterSoftStep;
  64421. /**
  64422. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64423. * @param impostor imposter to match
  64424. */
  64425. private _ropeStep;
  64426. /**
  64427. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64428. * @param impostor imposter to match
  64429. */
  64430. private _softbodyOrClothStep;
  64431. private _tmpMatrix;
  64432. /**
  64433. * Applies an impulse on the imposter
  64434. * @param impostor imposter to apply impulse to
  64435. * @param force amount of force to be applied to the imposter
  64436. * @param contactPoint the location to apply the impulse on the imposter
  64437. */
  64438. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64439. /**
  64440. * Applies a force on the imposter
  64441. * @param impostor imposter to apply force
  64442. * @param force amount of force to be applied to the imposter
  64443. * @param contactPoint the location to apply the force on the imposter
  64444. */
  64445. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64446. /**
  64447. * Creates a physics body using the plugin
  64448. * @param impostor the imposter to create the physics body on
  64449. */
  64450. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64451. /**
  64452. * Removes the physics body from the imposter and disposes of the body's memory
  64453. * @param impostor imposter to remove the physics body from
  64454. */
  64455. removePhysicsBody(impostor: PhysicsImpostor): void;
  64456. /**
  64457. * Generates a joint
  64458. * @param impostorJoint the imposter joint to create the joint with
  64459. */
  64460. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64461. /**
  64462. * Removes a joint
  64463. * @param impostorJoint the imposter joint to remove the joint from
  64464. */
  64465. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64466. private _addMeshVerts;
  64467. /**
  64468. * Initialise the soft body vertices to match its object's (mesh) vertices
  64469. * Softbody vertices (nodes) are in world space and to match this
  64470. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64471. * @param impostor to create the softbody for
  64472. */
  64473. private _softVertexData;
  64474. /**
  64475. * Create an impostor's soft body
  64476. * @param impostor to create the softbody for
  64477. */
  64478. private _createSoftbody;
  64479. /**
  64480. * Create cloth for an impostor
  64481. * @param impostor to create the softbody for
  64482. */
  64483. private _createCloth;
  64484. /**
  64485. * Create rope for an impostor
  64486. * @param impostor to create the softbody for
  64487. */
  64488. private _createRope;
  64489. /**
  64490. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64491. * @param impostor to create the custom physics shape for
  64492. */
  64493. private _createCustom;
  64494. private _addHullVerts;
  64495. private _createShape;
  64496. /**
  64497. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64498. * @param impostor imposter containing the physics body and babylon object
  64499. */
  64500. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64501. /**
  64502. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64503. * @param impostor imposter containing the physics body and babylon object
  64504. * @param newPosition new position
  64505. * @param newRotation new rotation
  64506. */
  64507. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64508. /**
  64509. * If this plugin is supported
  64510. * @returns true if its supported
  64511. */
  64512. isSupported(): boolean;
  64513. /**
  64514. * Sets the linear velocity of the physics body
  64515. * @param impostor imposter to set the velocity on
  64516. * @param velocity velocity to set
  64517. */
  64518. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64519. /**
  64520. * Sets the angular velocity of the physics body
  64521. * @param impostor imposter to set the velocity on
  64522. * @param velocity velocity to set
  64523. */
  64524. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64525. /**
  64526. * gets the linear velocity
  64527. * @param impostor imposter to get linear velocity from
  64528. * @returns linear velocity
  64529. */
  64530. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64531. /**
  64532. * gets the angular velocity
  64533. * @param impostor imposter to get angular velocity from
  64534. * @returns angular velocity
  64535. */
  64536. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64537. /**
  64538. * Sets the mass of physics body
  64539. * @param impostor imposter to set the mass on
  64540. * @param mass mass to set
  64541. */
  64542. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64543. /**
  64544. * Gets the mass of the physics body
  64545. * @param impostor imposter to get the mass from
  64546. * @returns mass
  64547. */
  64548. getBodyMass(impostor: PhysicsImpostor): number;
  64549. /**
  64550. * Gets friction of the impostor
  64551. * @param impostor impostor to get friction from
  64552. * @returns friction value
  64553. */
  64554. getBodyFriction(impostor: PhysicsImpostor): number;
  64555. /**
  64556. * Sets friction of the impostor
  64557. * @param impostor impostor to set friction on
  64558. * @param friction friction value
  64559. */
  64560. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64561. /**
  64562. * Gets restitution of the impostor
  64563. * @param impostor impostor to get restitution from
  64564. * @returns restitution value
  64565. */
  64566. getBodyRestitution(impostor: PhysicsImpostor): number;
  64567. /**
  64568. * Sets resitution of the impostor
  64569. * @param impostor impostor to set resitution on
  64570. * @param restitution resitution value
  64571. */
  64572. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64573. /**
  64574. * Gets pressure inside the impostor
  64575. * @param impostor impostor to get pressure from
  64576. * @returns pressure value
  64577. */
  64578. getBodyPressure(impostor: PhysicsImpostor): number;
  64579. /**
  64580. * Sets pressure inside a soft body impostor
  64581. * Cloth and rope must remain 0 pressure
  64582. * @param impostor impostor to set pressure on
  64583. * @param pressure pressure value
  64584. */
  64585. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64586. /**
  64587. * Gets stiffness of the impostor
  64588. * @param impostor impostor to get stiffness from
  64589. * @returns pressure value
  64590. */
  64591. getBodyStiffness(impostor: PhysicsImpostor): number;
  64592. /**
  64593. * Sets stiffness of the impostor
  64594. * @param impostor impostor to set stiffness on
  64595. * @param stiffness stiffness value from 0 to 1
  64596. */
  64597. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64598. /**
  64599. * Gets velocityIterations of the impostor
  64600. * @param impostor impostor to get velocity iterations from
  64601. * @returns velocityIterations value
  64602. */
  64603. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64604. /**
  64605. * Sets velocityIterations of the impostor
  64606. * @param impostor impostor to set velocity iterations on
  64607. * @param velocityIterations velocityIterations value
  64608. */
  64609. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64610. /**
  64611. * Gets positionIterations of the impostor
  64612. * @param impostor impostor to get position iterations from
  64613. * @returns positionIterations value
  64614. */
  64615. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64616. /**
  64617. * Sets positionIterations of the impostor
  64618. * @param impostor impostor to set position on
  64619. * @param positionIterations positionIterations value
  64620. */
  64621. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64622. /**
  64623. * Append an anchor to a cloth object
  64624. * @param impostor is the cloth impostor to add anchor to
  64625. * @param otherImpostor is the rigid impostor to anchor to
  64626. * @param width ratio across width from 0 to 1
  64627. * @param height ratio up height from 0 to 1
  64628. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64629. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64630. */
  64631. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64632. /**
  64633. * Append an hook to a rope object
  64634. * @param impostor is the rope impostor to add hook to
  64635. * @param otherImpostor is the rigid impostor to hook to
  64636. * @param length ratio along the rope from 0 to 1
  64637. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64638. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64639. */
  64640. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64641. /**
  64642. * Sleeps the physics body and stops it from being active
  64643. * @param impostor impostor to sleep
  64644. */
  64645. sleepBody(impostor: PhysicsImpostor): void;
  64646. /**
  64647. * Activates the physics body
  64648. * @param impostor impostor to activate
  64649. */
  64650. wakeUpBody(impostor: PhysicsImpostor): void;
  64651. /**
  64652. * Updates the distance parameters of the joint
  64653. * @param joint joint to update
  64654. * @param maxDistance maximum distance of the joint
  64655. * @param minDistance minimum distance of the joint
  64656. */
  64657. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64658. /**
  64659. * Sets a motor on the joint
  64660. * @param joint joint to set motor on
  64661. * @param speed speed of the motor
  64662. * @param maxForce maximum force of the motor
  64663. * @param motorIndex index of the motor
  64664. */
  64665. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64666. /**
  64667. * Sets the motors limit
  64668. * @param joint joint to set limit on
  64669. * @param upperLimit upper limit
  64670. * @param lowerLimit lower limit
  64671. */
  64672. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64673. /**
  64674. * Syncs the position and rotation of a mesh with the impostor
  64675. * @param mesh mesh to sync
  64676. * @param impostor impostor to update the mesh with
  64677. */
  64678. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64679. /**
  64680. * Gets the radius of the impostor
  64681. * @param impostor impostor to get radius from
  64682. * @returns the radius
  64683. */
  64684. getRadius(impostor: PhysicsImpostor): number;
  64685. /**
  64686. * Gets the box size of the impostor
  64687. * @param impostor impostor to get box size from
  64688. * @param result the resulting box size
  64689. */
  64690. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64691. /**
  64692. * Disposes of the impostor
  64693. */
  64694. dispose(): void;
  64695. /**
  64696. * Does a raycast in the physics world
  64697. * @param from when should the ray start?
  64698. * @param to when should the ray end?
  64699. * @returns PhysicsRaycastResult
  64700. */
  64701. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64702. }
  64703. }
  64704. declare module "babylonjs/Probes/reflectionProbe" {
  64705. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64706. import { Vector3 } from "babylonjs/Maths/math.vector";
  64707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64708. import { Nullable } from "babylonjs/types";
  64709. import { Scene } from "babylonjs/scene";
  64710. module "babylonjs/abstractScene" {
  64711. interface AbstractScene {
  64712. /**
  64713. * The list of reflection probes added to the scene
  64714. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64715. */
  64716. reflectionProbes: Array<ReflectionProbe>;
  64717. /**
  64718. * Removes the given reflection probe from this scene.
  64719. * @param toRemove The reflection probe to remove
  64720. * @returns The index of the removed reflection probe
  64721. */
  64722. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64723. /**
  64724. * Adds the given reflection probe to this scene.
  64725. * @param newReflectionProbe The reflection probe to add
  64726. */
  64727. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64728. }
  64729. }
  64730. /**
  64731. * Class used to generate realtime reflection / refraction cube textures
  64732. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64733. */
  64734. export class ReflectionProbe {
  64735. /** defines the name of the probe */
  64736. name: string;
  64737. private _scene;
  64738. private _renderTargetTexture;
  64739. private _projectionMatrix;
  64740. private _viewMatrix;
  64741. private _target;
  64742. private _add;
  64743. private _attachedMesh;
  64744. private _invertYAxis;
  64745. /** Gets or sets probe position (center of the cube map) */
  64746. position: Vector3;
  64747. /**
  64748. * Creates a new reflection probe
  64749. * @param name defines the name of the probe
  64750. * @param size defines the texture resolution (for each face)
  64751. * @param scene defines the hosting scene
  64752. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64753. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64754. */
  64755. constructor(
  64756. /** defines the name of the probe */
  64757. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64758. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64759. get samples(): number;
  64760. set samples(value: number);
  64761. /** Gets or sets the refresh rate to use (on every frame by default) */
  64762. get refreshRate(): number;
  64763. set refreshRate(value: number);
  64764. /**
  64765. * Gets the hosting scene
  64766. * @returns a Scene
  64767. */
  64768. getScene(): Scene;
  64769. /** Gets the internal CubeTexture used to render to */
  64770. get cubeTexture(): RenderTargetTexture;
  64771. /** Gets the list of meshes to render */
  64772. get renderList(): Nullable<AbstractMesh[]>;
  64773. /**
  64774. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64775. * @param mesh defines the mesh to attach to
  64776. */
  64777. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64778. /**
  64779. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64780. * @param renderingGroupId The rendering group id corresponding to its index
  64781. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64782. */
  64783. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64784. /**
  64785. * Clean all associated resources
  64786. */
  64787. dispose(): void;
  64788. /**
  64789. * Converts the reflection probe information to a readable string for debug purpose.
  64790. * @param fullDetails Supports for multiple levels of logging within scene loading
  64791. * @returns the human readable reflection probe info
  64792. */
  64793. toString(fullDetails?: boolean): string;
  64794. /**
  64795. * Get the class name of the relfection probe.
  64796. * @returns "ReflectionProbe"
  64797. */
  64798. getClassName(): string;
  64799. /**
  64800. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64801. * @returns The JSON representation of the texture
  64802. */
  64803. serialize(): any;
  64804. /**
  64805. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64806. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64807. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64808. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64809. * @returns The parsed reflection probe if successful
  64810. */
  64811. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64812. }
  64813. }
  64814. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64815. /** @hidden */
  64816. export var _BabylonLoaderRegistered: boolean;
  64817. /**
  64818. * Helps setting up some configuration for the babylon file loader.
  64819. */
  64820. export class BabylonFileLoaderConfiguration {
  64821. /**
  64822. * The loader does not allow injecting custom physix engine into the plugins.
  64823. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64824. * So you could set this variable to your engine import to make it work.
  64825. */
  64826. static LoaderInjectedPhysicsEngine: any;
  64827. }
  64828. }
  64829. declare module "babylonjs/Loading/Plugins/index" {
  64830. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64831. }
  64832. declare module "babylonjs/Loading/index" {
  64833. export * from "babylonjs/Loading/loadingScreen";
  64834. export * from "babylonjs/Loading/Plugins/index";
  64835. export * from "babylonjs/Loading/sceneLoader";
  64836. export * from "babylonjs/Loading/sceneLoaderFlags";
  64837. }
  64838. declare module "babylonjs/Materials/Background/index" {
  64839. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64840. }
  64841. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64842. import { Scene } from "babylonjs/scene";
  64843. import { Color3 } from "babylonjs/Maths/math.color";
  64844. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64846. /**
  64847. * The Physically based simple base material of BJS.
  64848. *
  64849. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64850. * It is used as the base class for both the specGloss and metalRough conventions.
  64851. */
  64852. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64853. /**
  64854. * Number of Simultaneous lights allowed on the material.
  64855. */
  64856. maxSimultaneousLights: number;
  64857. /**
  64858. * If sets to true, disables all the lights affecting the material.
  64859. */
  64860. disableLighting: boolean;
  64861. /**
  64862. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64863. */
  64864. environmentTexture: BaseTexture;
  64865. /**
  64866. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64867. */
  64868. invertNormalMapX: boolean;
  64869. /**
  64870. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64871. */
  64872. invertNormalMapY: boolean;
  64873. /**
  64874. * Normal map used in the model.
  64875. */
  64876. normalTexture: BaseTexture;
  64877. /**
  64878. * Emissivie color used to self-illuminate the model.
  64879. */
  64880. emissiveColor: Color3;
  64881. /**
  64882. * Emissivie texture used to self-illuminate the model.
  64883. */
  64884. emissiveTexture: BaseTexture;
  64885. /**
  64886. * Occlusion Channel Strenght.
  64887. */
  64888. occlusionStrength: number;
  64889. /**
  64890. * Occlusion Texture of the material (adding extra occlusion effects).
  64891. */
  64892. occlusionTexture: BaseTexture;
  64893. /**
  64894. * Defines the alpha limits in alpha test mode.
  64895. */
  64896. alphaCutOff: number;
  64897. /**
  64898. * Gets the current double sided mode.
  64899. */
  64900. get doubleSided(): boolean;
  64901. /**
  64902. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64903. */
  64904. set doubleSided(value: boolean);
  64905. /**
  64906. * Stores the pre-calculated light information of a mesh in a texture.
  64907. */
  64908. lightmapTexture: BaseTexture;
  64909. /**
  64910. * If true, the light map contains occlusion information instead of lighting info.
  64911. */
  64912. useLightmapAsShadowmap: boolean;
  64913. /**
  64914. * Instantiates a new PBRMaterial instance.
  64915. *
  64916. * @param name The material name
  64917. * @param scene The scene the material will be use in.
  64918. */
  64919. constructor(name: string, scene: Scene);
  64920. getClassName(): string;
  64921. }
  64922. }
  64923. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64924. import { Scene } from "babylonjs/scene";
  64925. import { Color3 } from "babylonjs/Maths/math.color";
  64926. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64927. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64928. /**
  64929. * The PBR material of BJS following the metal roughness convention.
  64930. *
  64931. * This fits to the PBR convention in the GLTF definition:
  64932. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64933. */
  64934. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64935. /**
  64936. * The base color has two different interpretations depending on the value of metalness.
  64937. * When the material is a metal, the base color is the specific measured reflectance value
  64938. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64939. * of the material.
  64940. */
  64941. baseColor: Color3;
  64942. /**
  64943. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64944. * well as opacity information in the alpha channel.
  64945. */
  64946. baseTexture: BaseTexture;
  64947. /**
  64948. * Specifies the metallic scalar value of the material.
  64949. * Can also be used to scale the metalness values of the metallic texture.
  64950. */
  64951. metallic: number;
  64952. /**
  64953. * Specifies the roughness scalar value of the material.
  64954. * Can also be used to scale the roughness values of the metallic texture.
  64955. */
  64956. roughness: number;
  64957. /**
  64958. * Texture containing both the metallic value in the B channel and the
  64959. * roughness value in the G channel to keep better precision.
  64960. */
  64961. metallicRoughnessTexture: BaseTexture;
  64962. /**
  64963. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64964. *
  64965. * @param name The material name
  64966. * @param scene The scene the material will be use in.
  64967. */
  64968. constructor(name: string, scene: Scene);
  64969. /**
  64970. * Return the currrent class name of the material.
  64971. */
  64972. getClassName(): string;
  64973. /**
  64974. * Makes a duplicate of the current material.
  64975. * @param name - name to use for the new material.
  64976. */
  64977. clone(name: string): PBRMetallicRoughnessMaterial;
  64978. /**
  64979. * Serialize the material to a parsable JSON object.
  64980. */
  64981. serialize(): any;
  64982. /**
  64983. * Parses a JSON object correponding to the serialize function.
  64984. */
  64985. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64986. }
  64987. }
  64988. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64989. import { Scene } from "babylonjs/scene";
  64990. import { Color3 } from "babylonjs/Maths/math.color";
  64991. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64992. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64993. /**
  64994. * The PBR material of BJS following the specular glossiness convention.
  64995. *
  64996. * This fits to the PBR convention in the GLTF definition:
  64997. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64998. */
  64999. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65000. /**
  65001. * Specifies the diffuse color of the material.
  65002. */
  65003. diffuseColor: Color3;
  65004. /**
  65005. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65006. * channel.
  65007. */
  65008. diffuseTexture: BaseTexture;
  65009. /**
  65010. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65011. */
  65012. specularColor: Color3;
  65013. /**
  65014. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65015. */
  65016. glossiness: number;
  65017. /**
  65018. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65019. */
  65020. specularGlossinessTexture: BaseTexture;
  65021. /**
  65022. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65023. *
  65024. * @param name The material name
  65025. * @param scene The scene the material will be use in.
  65026. */
  65027. constructor(name: string, scene: Scene);
  65028. /**
  65029. * Return the currrent class name of the material.
  65030. */
  65031. getClassName(): string;
  65032. /**
  65033. * Makes a duplicate of the current material.
  65034. * @param name - name to use for the new material.
  65035. */
  65036. clone(name: string): PBRSpecularGlossinessMaterial;
  65037. /**
  65038. * Serialize the material to a parsable JSON object.
  65039. */
  65040. serialize(): any;
  65041. /**
  65042. * Parses a JSON object correponding to the serialize function.
  65043. */
  65044. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65045. }
  65046. }
  65047. declare module "babylonjs/Materials/PBR/index" {
  65048. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65049. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65050. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65051. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65052. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65053. }
  65054. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65055. import { Nullable } from "babylonjs/types";
  65056. import { Scene } from "babylonjs/scene";
  65057. import { Matrix } from "babylonjs/Maths/math.vector";
  65058. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65059. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65060. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65061. /**
  65062. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65063. * It can help converting any input color in a desired output one. This can then be used to create effects
  65064. * from sepia, black and white to sixties or futuristic rendering...
  65065. *
  65066. * The only supported format is currently 3dl.
  65067. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65068. */
  65069. export class ColorGradingTexture extends BaseTexture {
  65070. /**
  65071. * The texture URL.
  65072. */
  65073. url: string;
  65074. /**
  65075. * Empty line regex stored for GC.
  65076. */
  65077. private static _noneEmptyLineRegex;
  65078. private _textureMatrix;
  65079. private _onLoad;
  65080. /**
  65081. * Instantiates a ColorGradingTexture from the following parameters.
  65082. *
  65083. * @param url The location of the color gradind data (currently only supporting 3dl)
  65084. * @param sceneOrEngine The scene or engine the texture will be used in
  65085. * @param onLoad defines a callback triggered when the texture has been loaded
  65086. */
  65087. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65088. /**
  65089. * Fires the onload event from the constructor if requested.
  65090. */
  65091. private _triggerOnLoad;
  65092. /**
  65093. * Returns the texture matrix used in most of the material.
  65094. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65095. */
  65096. getTextureMatrix(): Matrix;
  65097. /**
  65098. * Occurs when the file being loaded is a .3dl LUT file.
  65099. */
  65100. private load3dlTexture;
  65101. /**
  65102. * Starts the loading process of the texture.
  65103. */
  65104. private loadTexture;
  65105. /**
  65106. * Clones the color gradind texture.
  65107. */
  65108. clone(): ColorGradingTexture;
  65109. /**
  65110. * Called during delayed load for textures.
  65111. */
  65112. delayLoad(): void;
  65113. /**
  65114. * Parses a color grading texture serialized by Babylon.
  65115. * @param parsedTexture The texture information being parsedTexture
  65116. * @param scene The scene to load the texture in
  65117. * @param rootUrl The root url of the data assets to load
  65118. * @return A color gradind texture
  65119. */
  65120. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65121. /**
  65122. * Serializes the LUT texture to json format.
  65123. */
  65124. serialize(): any;
  65125. }
  65126. }
  65127. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65129. import { Scene } from "babylonjs/scene";
  65130. import { Nullable } from "babylonjs/types";
  65131. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65132. /**
  65133. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65134. */
  65135. export class EquiRectangularCubeTexture extends BaseTexture {
  65136. /** The six faces of the cube. */
  65137. private static _FacesMapping;
  65138. private _noMipmap;
  65139. private _onLoad;
  65140. private _onError;
  65141. /** The size of the cubemap. */
  65142. private _size;
  65143. /** The buffer of the image. */
  65144. private _buffer;
  65145. /** The width of the input image. */
  65146. private _width;
  65147. /** The height of the input image. */
  65148. private _height;
  65149. /** The URL to the image. */
  65150. url: string;
  65151. /**
  65152. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65153. * @param url The location of the image
  65154. * @param scene The scene the texture will be used in
  65155. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65156. * @param noMipmap Forces to not generate the mipmap if true
  65157. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65158. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65159. * @param onLoad — defines a callback called when texture is loaded
  65160. * @param onError — defines a callback called if there is an error
  65161. */
  65162. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65163. /**
  65164. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65165. */
  65166. private loadImage;
  65167. /**
  65168. * Convert the image buffer into a cubemap and create a CubeTexture.
  65169. */
  65170. private loadTexture;
  65171. /**
  65172. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65173. * @param buffer The ArrayBuffer that should be converted.
  65174. * @returns The buffer as Float32Array.
  65175. */
  65176. private getFloat32ArrayFromArrayBuffer;
  65177. /**
  65178. * Get the current class name of the texture useful for serialization or dynamic coding.
  65179. * @returns "EquiRectangularCubeTexture"
  65180. */
  65181. getClassName(): string;
  65182. /**
  65183. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65184. * @returns A clone of the current EquiRectangularCubeTexture.
  65185. */
  65186. clone(): EquiRectangularCubeTexture;
  65187. }
  65188. }
  65189. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65190. import { Nullable } from "babylonjs/types";
  65191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65192. import { Matrix } from "babylonjs/Maths/math.vector";
  65193. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65194. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65195. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65196. import { Scene } from "babylonjs/scene";
  65197. /**
  65198. * Defines the options related to the creation of an HtmlElementTexture
  65199. */
  65200. export interface IHtmlElementTextureOptions {
  65201. /**
  65202. * Defines wether mip maps should be created or not.
  65203. */
  65204. generateMipMaps?: boolean;
  65205. /**
  65206. * Defines the sampling mode of the texture.
  65207. */
  65208. samplingMode?: number;
  65209. /**
  65210. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65211. */
  65212. engine: Nullable<ThinEngine>;
  65213. /**
  65214. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65215. */
  65216. scene: Nullable<Scene>;
  65217. }
  65218. /**
  65219. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65220. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65221. * is automatically managed.
  65222. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65223. * in your application.
  65224. *
  65225. * As the update is not automatic, you need to call them manually.
  65226. */
  65227. export class HtmlElementTexture extends BaseTexture {
  65228. /**
  65229. * The texture URL.
  65230. */
  65231. element: HTMLVideoElement | HTMLCanvasElement;
  65232. private static readonly DefaultOptions;
  65233. private _textureMatrix;
  65234. private _isVideo;
  65235. private _generateMipMaps;
  65236. private _samplingMode;
  65237. /**
  65238. * Instantiates a HtmlElementTexture from the following parameters.
  65239. *
  65240. * @param name Defines the name of the texture
  65241. * @param element Defines the video or canvas the texture is filled with
  65242. * @param options Defines the other none mandatory texture creation options
  65243. */
  65244. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65245. private _createInternalTexture;
  65246. /**
  65247. * Returns the texture matrix used in most of the material.
  65248. */
  65249. getTextureMatrix(): Matrix;
  65250. /**
  65251. * Updates the content of the texture.
  65252. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65253. */
  65254. update(invertY?: Nullable<boolean>): void;
  65255. }
  65256. }
  65257. declare module "babylonjs/Misc/tga" {
  65258. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65259. /**
  65260. * Based on jsTGALoader - Javascript loader for TGA file
  65261. * By Vincent Thibault
  65262. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65263. */
  65264. export class TGATools {
  65265. private static _TYPE_INDEXED;
  65266. private static _TYPE_RGB;
  65267. private static _TYPE_GREY;
  65268. private static _TYPE_RLE_INDEXED;
  65269. private static _TYPE_RLE_RGB;
  65270. private static _TYPE_RLE_GREY;
  65271. private static _ORIGIN_MASK;
  65272. private static _ORIGIN_SHIFT;
  65273. private static _ORIGIN_BL;
  65274. private static _ORIGIN_BR;
  65275. private static _ORIGIN_UL;
  65276. private static _ORIGIN_UR;
  65277. /**
  65278. * Gets the header of a TGA file
  65279. * @param data defines the TGA data
  65280. * @returns the header
  65281. */
  65282. static GetTGAHeader(data: Uint8Array): any;
  65283. /**
  65284. * Uploads TGA content to a Babylon Texture
  65285. * @hidden
  65286. */
  65287. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65288. /** @hidden */
  65289. 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;
  65290. /** @hidden */
  65291. 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;
  65292. /** @hidden */
  65293. 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;
  65294. /** @hidden */
  65295. 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;
  65296. /** @hidden */
  65297. 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;
  65298. /** @hidden */
  65299. 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;
  65300. }
  65301. }
  65302. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65303. import { Nullable } from "babylonjs/types";
  65304. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65305. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65306. /**
  65307. * Implementation of the TGA Texture Loader.
  65308. * @hidden
  65309. */
  65310. export class _TGATextureLoader implements IInternalTextureLoader {
  65311. /**
  65312. * Defines wether the loader supports cascade loading the different faces.
  65313. */
  65314. readonly supportCascades: boolean;
  65315. /**
  65316. * This returns if the loader support the current file information.
  65317. * @param extension defines the file extension of the file being loaded
  65318. * @returns true if the loader can load the specified file
  65319. */
  65320. canLoad(extension: string): boolean;
  65321. /**
  65322. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65323. * @param data contains the texture data
  65324. * @param texture defines the BabylonJS internal texture
  65325. * @param createPolynomials will be true if polynomials have been requested
  65326. * @param onLoad defines the callback to trigger once the texture is ready
  65327. * @param onError defines the callback to trigger in case of error
  65328. */
  65329. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65330. /**
  65331. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65332. * @param data contains the texture data
  65333. * @param texture defines the BabylonJS internal texture
  65334. * @param callback defines the method to call once ready to upload
  65335. */
  65336. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65337. }
  65338. }
  65339. declare module "babylonjs/Misc/basis" {
  65340. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65341. /**
  65342. * Info about the .basis files
  65343. */
  65344. class BasisFileInfo {
  65345. /**
  65346. * If the file has alpha
  65347. */
  65348. hasAlpha: boolean;
  65349. /**
  65350. * Info about each image of the basis file
  65351. */
  65352. images: Array<{
  65353. levels: Array<{
  65354. width: number;
  65355. height: number;
  65356. transcodedPixels: ArrayBufferView;
  65357. }>;
  65358. }>;
  65359. }
  65360. /**
  65361. * Result of transcoding a basis file
  65362. */
  65363. class TranscodeResult {
  65364. /**
  65365. * Info about the .basis file
  65366. */
  65367. fileInfo: BasisFileInfo;
  65368. /**
  65369. * Format to use when loading the file
  65370. */
  65371. format: number;
  65372. }
  65373. /**
  65374. * Configuration options for the Basis transcoder
  65375. */
  65376. export class BasisTranscodeConfiguration {
  65377. /**
  65378. * Supported compression formats used to determine the supported output format of the transcoder
  65379. */
  65380. supportedCompressionFormats?: {
  65381. /**
  65382. * etc1 compression format
  65383. */
  65384. etc1?: boolean;
  65385. /**
  65386. * s3tc compression format
  65387. */
  65388. s3tc?: boolean;
  65389. /**
  65390. * pvrtc compression format
  65391. */
  65392. pvrtc?: boolean;
  65393. /**
  65394. * etc2 compression format
  65395. */
  65396. etc2?: boolean;
  65397. };
  65398. /**
  65399. * If mipmap levels should be loaded for transcoded images (Default: true)
  65400. */
  65401. loadMipmapLevels?: boolean;
  65402. /**
  65403. * Index of a single image to load (Default: all images)
  65404. */
  65405. loadSingleImage?: number;
  65406. }
  65407. /**
  65408. * Used to load .Basis files
  65409. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65410. */
  65411. export class BasisTools {
  65412. private static _IgnoreSupportedFormats;
  65413. /**
  65414. * URL to use when loading the basis transcoder
  65415. */
  65416. static JSModuleURL: string;
  65417. /**
  65418. * URL to use when loading the wasm module for the transcoder
  65419. */
  65420. static WasmModuleURL: string;
  65421. /**
  65422. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65423. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65424. * @returns internal format corresponding to the Basis format
  65425. */
  65426. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65427. private static _WorkerPromise;
  65428. private static _Worker;
  65429. private static _actionId;
  65430. private static _CreateWorkerAsync;
  65431. /**
  65432. * Transcodes a loaded image file to compressed pixel data
  65433. * @param data image data to transcode
  65434. * @param config configuration options for the transcoding
  65435. * @returns a promise resulting in the transcoded image
  65436. */
  65437. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65438. /**
  65439. * Loads a texture from the transcode result
  65440. * @param texture texture load to
  65441. * @param transcodeResult the result of transcoding the basis file to load from
  65442. */
  65443. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65444. }
  65445. }
  65446. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65447. import { Nullable } from "babylonjs/types";
  65448. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65449. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65450. /**
  65451. * Loader for .basis file format
  65452. */
  65453. export class _BasisTextureLoader implements IInternalTextureLoader {
  65454. /**
  65455. * Defines whether the loader supports cascade loading the different faces.
  65456. */
  65457. readonly supportCascades: boolean;
  65458. /**
  65459. * This returns if the loader support the current file information.
  65460. * @param extension defines the file extension of the file being loaded
  65461. * @returns true if the loader can load the specified file
  65462. */
  65463. canLoad(extension: string): boolean;
  65464. /**
  65465. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65466. * @param data contains the texture data
  65467. * @param texture defines the BabylonJS internal texture
  65468. * @param createPolynomials will be true if polynomials have been requested
  65469. * @param onLoad defines the callback to trigger once the texture is ready
  65470. * @param onError defines the callback to trigger in case of error
  65471. */
  65472. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65473. /**
  65474. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65475. * @param data contains the texture data
  65476. * @param texture defines the BabylonJS internal texture
  65477. * @param callback defines the method to call once ready to upload
  65478. */
  65479. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65480. }
  65481. }
  65482. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65483. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65484. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65485. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65486. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65487. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65488. }
  65489. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65490. import { Vector2 } from "babylonjs/Maths/math.vector";
  65491. /**
  65492. * Defines the basic options interface of a TexturePacker Frame
  65493. */
  65494. export interface ITexturePackerFrame {
  65495. /**
  65496. * The frame ID
  65497. */
  65498. id: number;
  65499. /**
  65500. * The frames Scale
  65501. */
  65502. scale: Vector2;
  65503. /**
  65504. * The Frames offset
  65505. */
  65506. offset: Vector2;
  65507. }
  65508. /**
  65509. * This is a support class for frame Data on texture packer sets.
  65510. */
  65511. export class TexturePackerFrame implements ITexturePackerFrame {
  65512. /**
  65513. * The frame ID
  65514. */
  65515. id: number;
  65516. /**
  65517. * The frames Scale
  65518. */
  65519. scale: Vector2;
  65520. /**
  65521. * The Frames offset
  65522. */
  65523. offset: Vector2;
  65524. /**
  65525. * Initializes a texture package frame.
  65526. * @param id The numerical frame identifier
  65527. * @param scale Scalar Vector2 for UV frame
  65528. * @param offset Vector2 for the frame position in UV units.
  65529. * @returns TexturePackerFrame
  65530. */
  65531. constructor(id: number, scale: Vector2, offset: Vector2);
  65532. }
  65533. }
  65534. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65536. import { Scene } from "babylonjs/scene";
  65537. import { Nullable } from "babylonjs/types";
  65538. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65539. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65540. /**
  65541. * Defines the basic options interface of a TexturePacker
  65542. */
  65543. export interface ITexturePackerOptions {
  65544. /**
  65545. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65546. */
  65547. map?: string[];
  65548. /**
  65549. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65550. */
  65551. uvsIn?: string;
  65552. /**
  65553. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65554. */
  65555. uvsOut?: string;
  65556. /**
  65557. * number representing the layout style. Defaults to LAYOUT_STRIP
  65558. */
  65559. layout?: number;
  65560. /**
  65561. * number of columns if using custom column count layout(2). This defaults to 4.
  65562. */
  65563. colnum?: number;
  65564. /**
  65565. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65566. */
  65567. updateInputMeshes?: boolean;
  65568. /**
  65569. * boolean flag to dispose all the source textures. Defaults to true.
  65570. */
  65571. disposeSources?: boolean;
  65572. /**
  65573. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65574. */
  65575. fillBlanks?: boolean;
  65576. /**
  65577. * string value representing the context fill style color. Defaults to 'black'.
  65578. */
  65579. customFillColor?: string;
  65580. /**
  65581. * Width and Height Value of each Frame in the TexturePacker Sets
  65582. */
  65583. frameSize?: number;
  65584. /**
  65585. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65586. */
  65587. paddingRatio?: number;
  65588. /**
  65589. * Number that declares the fill method for the padding gutter.
  65590. */
  65591. paddingMode?: number;
  65592. /**
  65593. * If in SUBUV_COLOR padding mode what color to use.
  65594. */
  65595. paddingColor?: Color3 | Color4;
  65596. }
  65597. /**
  65598. * Defines the basic interface of a TexturePacker JSON File
  65599. */
  65600. export interface ITexturePackerJSON {
  65601. /**
  65602. * The frame ID
  65603. */
  65604. name: string;
  65605. /**
  65606. * The base64 channel data
  65607. */
  65608. sets: any;
  65609. /**
  65610. * The options of the Packer
  65611. */
  65612. options: ITexturePackerOptions;
  65613. /**
  65614. * The frame data of the Packer
  65615. */
  65616. frames: Array<number>;
  65617. }
  65618. /**
  65619. * This is a support class that generates a series of packed texture sets.
  65620. * @see https://doc.babylonjs.com/babylon101/materials
  65621. */
  65622. export class TexturePacker {
  65623. /** Packer Layout Constant 0 */
  65624. static readonly LAYOUT_STRIP: number;
  65625. /** Packer Layout Constant 1 */
  65626. static readonly LAYOUT_POWER2: number;
  65627. /** Packer Layout Constant 2 */
  65628. static readonly LAYOUT_COLNUM: number;
  65629. /** Packer Layout Constant 0 */
  65630. static readonly SUBUV_WRAP: number;
  65631. /** Packer Layout Constant 1 */
  65632. static readonly SUBUV_EXTEND: number;
  65633. /** Packer Layout Constant 2 */
  65634. static readonly SUBUV_COLOR: number;
  65635. /** The Name of the Texture Package */
  65636. name: string;
  65637. /** The scene scope of the TexturePacker */
  65638. scene: Scene;
  65639. /** The Meshes to target */
  65640. meshes: AbstractMesh[];
  65641. /** Arguments passed with the Constructor */
  65642. options: ITexturePackerOptions;
  65643. /** The promise that is started upon initialization */
  65644. promise: Nullable<Promise<TexturePacker | string>>;
  65645. /** The Container object for the channel sets that are generated */
  65646. sets: object;
  65647. /** The Container array for the frames that are generated */
  65648. frames: TexturePackerFrame[];
  65649. /** The expected number of textures the system is parsing. */
  65650. private _expecting;
  65651. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65652. private _paddingValue;
  65653. /**
  65654. * Initializes a texture package series from an array of meshes or a single mesh.
  65655. * @param name The name of the package
  65656. * @param meshes The target meshes to compose the package from
  65657. * @param options The arguments that texture packer should follow while building.
  65658. * @param scene The scene which the textures are scoped to.
  65659. * @returns TexturePacker
  65660. */
  65661. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65662. /**
  65663. * Starts the package process
  65664. * @param resolve The promises resolution function
  65665. * @returns TexturePacker
  65666. */
  65667. private _createFrames;
  65668. /**
  65669. * Calculates the Size of the Channel Sets
  65670. * @returns Vector2
  65671. */
  65672. private _calculateSize;
  65673. /**
  65674. * Calculates the UV data for the frames.
  65675. * @param baseSize the base frameSize
  65676. * @param padding the base frame padding
  65677. * @param dtSize size of the Dynamic Texture for that channel
  65678. * @param dtUnits is 1/dtSize
  65679. * @param update flag to update the input meshes
  65680. */
  65681. private _calculateMeshUVFrames;
  65682. /**
  65683. * Calculates the frames Offset.
  65684. * @param index of the frame
  65685. * @returns Vector2
  65686. */
  65687. private _getFrameOffset;
  65688. /**
  65689. * Updates a Mesh to the frame data
  65690. * @param mesh that is the target
  65691. * @param frameID or the frame index
  65692. */
  65693. private _updateMeshUV;
  65694. /**
  65695. * Updates a Meshes materials to use the texture packer channels
  65696. * @param m is the mesh to target
  65697. * @param force all channels on the packer to be set.
  65698. */
  65699. private _updateTextureReferences;
  65700. /**
  65701. * Public method to set a Mesh to a frame
  65702. * @param m that is the target
  65703. * @param frameID or the frame index
  65704. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65705. */
  65706. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65707. /**
  65708. * Starts the async promise to compile the texture packer.
  65709. * @returns Promise<void>
  65710. */
  65711. processAsync(): Promise<void>;
  65712. /**
  65713. * Disposes all textures associated with this packer
  65714. */
  65715. dispose(): void;
  65716. /**
  65717. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65718. * @param imageType is the image type to use.
  65719. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65720. */
  65721. download(imageType?: string, quality?: number): void;
  65722. /**
  65723. * Public method to load a texturePacker JSON file.
  65724. * @param data of the JSON file in string format.
  65725. */
  65726. updateFromJSON(data: string): void;
  65727. }
  65728. }
  65729. declare module "babylonjs/Materials/Textures/Packer/index" {
  65730. export * from "babylonjs/Materials/Textures/Packer/packer";
  65731. export * from "babylonjs/Materials/Textures/Packer/frame";
  65732. }
  65733. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65734. import { Scene } from "babylonjs/scene";
  65735. import { Texture } from "babylonjs/Materials/Textures/texture";
  65736. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65737. /**
  65738. * 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.
  65739. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65740. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65741. */
  65742. export class CustomProceduralTexture extends ProceduralTexture {
  65743. private _animate;
  65744. private _time;
  65745. private _config;
  65746. private _texturePath;
  65747. /**
  65748. * Instantiates a new Custom Procedural Texture.
  65749. * 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.
  65750. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65751. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65752. * @param name Define the name of the texture
  65753. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65754. * @param size Define the size of the texture to create
  65755. * @param scene Define the scene the texture belongs to
  65756. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65757. * @param generateMipMaps Define if the texture should creates mip maps or not
  65758. */
  65759. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65760. private _loadJson;
  65761. /**
  65762. * Is the texture ready to be used ? (rendered at least once)
  65763. * @returns true if ready, otherwise, false.
  65764. */
  65765. isReady(): boolean;
  65766. /**
  65767. * Render the texture to its associated render target.
  65768. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65769. */
  65770. render(useCameraPostProcess?: boolean): void;
  65771. /**
  65772. * Update the list of dependant textures samplers in the shader.
  65773. */
  65774. updateTextures(): void;
  65775. /**
  65776. * Update the uniform values of the procedural texture in the shader.
  65777. */
  65778. updateShaderUniforms(): void;
  65779. /**
  65780. * Define if the texture animates or not.
  65781. */
  65782. get animate(): boolean;
  65783. set animate(value: boolean);
  65784. }
  65785. }
  65786. declare module "babylonjs/Shaders/noise.fragment" {
  65787. /** @hidden */
  65788. export var noisePixelShader: {
  65789. name: string;
  65790. shader: string;
  65791. };
  65792. }
  65793. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65794. import { Nullable } from "babylonjs/types";
  65795. import { Scene } from "babylonjs/scene";
  65796. import { Texture } from "babylonjs/Materials/Textures/texture";
  65797. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65798. import "babylonjs/Shaders/noise.fragment";
  65799. /**
  65800. * Class used to generate noise procedural textures
  65801. */
  65802. export class NoiseProceduralTexture extends ProceduralTexture {
  65803. /** Gets or sets the start time (default is 0) */
  65804. time: number;
  65805. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65806. brightness: number;
  65807. /** Defines the number of octaves to process */
  65808. octaves: number;
  65809. /** Defines the level of persistence (0.8 by default) */
  65810. persistence: number;
  65811. /** Gets or sets animation speed factor (default is 1) */
  65812. animationSpeedFactor: number;
  65813. /**
  65814. * Creates a new NoiseProceduralTexture
  65815. * @param name defines the name fo the texture
  65816. * @param size defines the size of the texture (default is 256)
  65817. * @param scene defines the hosting scene
  65818. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65819. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65820. */
  65821. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65822. private _updateShaderUniforms;
  65823. protected _getDefines(): string;
  65824. /** Generate the current state of the procedural texture */
  65825. render(useCameraPostProcess?: boolean): void;
  65826. /**
  65827. * Serializes this noise procedural texture
  65828. * @returns a serialized noise procedural texture object
  65829. */
  65830. serialize(): any;
  65831. /**
  65832. * Clone the texture.
  65833. * @returns the cloned texture
  65834. */
  65835. clone(): NoiseProceduralTexture;
  65836. /**
  65837. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65838. * @param parsedTexture defines parsed texture data
  65839. * @param scene defines the current scene
  65840. * @param rootUrl defines the root URL containing noise procedural texture information
  65841. * @returns a parsed NoiseProceduralTexture
  65842. */
  65843. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65844. }
  65845. }
  65846. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65847. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65848. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65849. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65850. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65851. }
  65852. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65853. import { Nullable } from "babylonjs/types";
  65854. import { Scene } from "babylonjs/scene";
  65855. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65856. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65857. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65858. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65859. /**
  65860. * Raw cube texture where the raw buffers are passed in
  65861. */
  65862. export class RawCubeTexture extends CubeTexture {
  65863. /**
  65864. * Creates a cube texture where the raw buffers are passed in.
  65865. * @param scene defines the scene the texture is attached to
  65866. * @param data defines the array of data to use to create each face
  65867. * @param size defines the size of the textures
  65868. * @param format defines the format of the data
  65869. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65870. * @param generateMipMaps defines if the engine should generate the mip levels
  65871. * @param invertY defines if data must be stored with Y axis inverted
  65872. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65873. * @param compression defines the compression used (null by default)
  65874. */
  65875. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65876. /**
  65877. * Updates the raw cube texture.
  65878. * @param data defines the data to store
  65879. * @param format defines the data format
  65880. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65881. * @param invertY defines if data must be stored with Y axis inverted
  65882. * @param compression defines the compression used (null by default)
  65883. * @param level defines which level of the texture to update
  65884. */
  65885. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65886. /**
  65887. * Updates a raw cube texture with RGBD encoded data.
  65888. * @param data defines the array of data [mipmap][face] to use to create each face
  65889. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65890. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65891. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65892. * @returns a promsie that resolves when the operation is complete
  65893. */
  65894. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65895. /**
  65896. * Clones the raw cube texture.
  65897. * @return a new cube texture
  65898. */
  65899. clone(): CubeTexture;
  65900. /** @hidden */
  65901. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65902. }
  65903. }
  65904. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65905. import { Scene } from "babylonjs/scene";
  65906. import { Texture } from "babylonjs/Materials/Textures/texture";
  65907. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65908. /**
  65909. * Class used to store 2D array textures containing user data
  65910. */
  65911. export class RawTexture2DArray extends Texture {
  65912. /** Gets or sets the texture format to use */
  65913. format: number;
  65914. /**
  65915. * Create a new RawTexture2DArray
  65916. * @param data defines the data of the texture
  65917. * @param width defines the width of the texture
  65918. * @param height defines the height of the texture
  65919. * @param depth defines the number of layers of the texture
  65920. * @param format defines the texture format to use
  65921. * @param scene defines the hosting scene
  65922. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65923. * @param invertY defines if texture must be stored with Y axis inverted
  65924. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65925. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65926. */
  65927. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65928. /** Gets or sets the texture format to use */
  65929. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65930. /**
  65931. * Update the texture with new data
  65932. * @param data defines the data to store in the texture
  65933. */
  65934. update(data: ArrayBufferView): void;
  65935. }
  65936. }
  65937. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65938. import { Scene } from "babylonjs/scene";
  65939. import { Texture } from "babylonjs/Materials/Textures/texture";
  65940. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65941. /**
  65942. * Class used to store 3D textures containing user data
  65943. */
  65944. export class RawTexture3D extends Texture {
  65945. /** Gets or sets the texture format to use */
  65946. format: number;
  65947. /**
  65948. * Create a new RawTexture3D
  65949. * @param data defines the data of the texture
  65950. * @param width defines the width of the texture
  65951. * @param height defines the height of the texture
  65952. * @param depth defines the depth of the texture
  65953. * @param format defines the texture format to use
  65954. * @param scene defines the hosting scene
  65955. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65956. * @param invertY defines if texture must be stored with Y axis inverted
  65957. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65958. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65959. */
  65960. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65961. /** Gets or sets the texture format to use */
  65962. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65963. /**
  65964. * Update the texture with new data
  65965. * @param data defines the data to store in the texture
  65966. */
  65967. update(data: ArrayBufferView): void;
  65968. }
  65969. }
  65970. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65971. import { Scene } from "babylonjs/scene";
  65972. import { Plane } from "babylonjs/Maths/math.plane";
  65973. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65974. /**
  65975. * Creates a refraction texture used by refraction channel of the standard material.
  65976. * It is like a mirror but to see through a material.
  65977. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65978. */
  65979. export class RefractionTexture extends RenderTargetTexture {
  65980. /**
  65981. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65982. * 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.
  65983. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65984. */
  65985. refractionPlane: Plane;
  65986. /**
  65987. * Define how deep under the surface we should see.
  65988. */
  65989. depth: number;
  65990. /**
  65991. * Creates a refraction texture used by refraction channel of the standard material.
  65992. * It is like a mirror but to see through a material.
  65993. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65994. * @param name Define the texture name
  65995. * @param size Define the size of the underlying texture
  65996. * @param scene Define the scene the refraction belongs to
  65997. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65998. */
  65999. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66000. /**
  66001. * Clone the refraction texture.
  66002. * @returns the cloned texture
  66003. */
  66004. clone(): RefractionTexture;
  66005. /**
  66006. * Serialize the texture to a JSON representation you could use in Parse later on
  66007. * @returns the serialized JSON representation
  66008. */
  66009. serialize(): any;
  66010. }
  66011. }
  66012. declare module "babylonjs/Materials/Textures/index" {
  66013. export * from "babylonjs/Materials/Textures/baseTexture";
  66014. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66015. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66016. export * from "babylonjs/Materials/Textures/cubeTexture";
  66017. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66018. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66019. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66020. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66021. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66022. export * from "babylonjs/Materials/Textures/internalTexture";
  66023. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66024. export * from "babylonjs/Materials/Textures/Loaders/index";
  66025. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66026. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66027. export * from "babylonjs/Materials/Textures/Packer/index";
  66028. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66029. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66030. export * from "babylonjs/Materials/Textures/rawTexture";
  66031. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66032. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66033. export * from "babylonjs/Materials/Textures/refractionTexture";
  66034. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66035. export * from "babylonjs/Materials/Textures/texture";
  66036. export * from "babylonjs/Materials/Textures/videoTexture";
  66037. }
  66038. declare module "babylonjs/Materials/Node/Enums/index" {
  66039. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66040. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66041. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66042. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66043. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66044. }
  66045. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66049. import { Mesh } from "babylonjs/Meshes/mesh";
  66050. import { Effect } from "babylonjs/Materials/effect";
  66051. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66052. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66053. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66054. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66055. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66056. /**
  66057. * Block used to add support for vertex skinning (bones)
  66058. */
  66059. export class BonesBlock extends NodeMaterialBlock {
  66060. /**
  66061. * Creates a new BonesBlock
  66062. * @param name defines the block name
  66063. */
  66064. constructor(name: string);
  66065. /**
  66066. * Initialize the block and prepare the context for build
  66067. * @param state defines the state that will be used for the build
  66068. */
  66069. initialize(state: NodeMaterialBuildState): void;
  66070. /**
  66071. * Gets the current class name
  66072. * @returns the class name
  66073. */
  66074. getClassName(): string;
  66075. /**
  66076. * Gets the matrix indices input component
  66077. */
  66078. get matricesIndices(): NodeMaterialConnectionPoint;
  66079. /**
  66080. * Gets the matrix weights input component
  66081. */
  66082. get matricesWeights(): NodeMaterialConnectionPoint;
  66083. /**
  66084. * Gets the extra matrix indices input component
  66085. */
  66086. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66087. /**
  66088. * Gets the extra matrix weights input component
  66089. */
  66090. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66091. /**
  66092. * Gets the world input component
  66093. */
  66094. get world(): NodeMaterialConnectionPoint;
  66095. /**
  66096. * Gets the output component
  66097. */
  66098. get output(): NodeMaterialConnectionPoint;
  66099. autoConfigure(material: NodeMaterial): void;
  66100. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66102. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66103. protected _buildBlock(state: NodeMaterialBuildState): this;
  66104. }
  66105. }
  66106. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66107. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66111. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66112. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66113. /**
  66114. * Block used to add support for instances
  66115. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66116. */
  66117. export class InstancesBlock extends NodeMaterialBlock {
  66118. /**
  66119. * Creates a new InstancesBlock
  66120. * @param name defines the block name
  66121. */
  66122. constructor(name: string);
  66123. /**
  66124. * Gets the current class name
  66125. * @returns the class name
  66126. */
  66127. getClassName(): string;
  66128. /**
  66129. * Gets the first world row input component
  66130. */
  66131. get world0(): NodeMaterialConnectionPoint;
  66132. /**
  66133. * Gets the second world row input component
  66134. */
  66135. get world1(): NodeMaterialConnectionPoint;
  66136. /**
  66137. * Gets the third world row input component
  66138. */
  66139. get world2(): NodeMaterialConnectionPoint;
  66140. /**
  66141. * Gets the forth world row input component
  66142. */
  66143. get world3(): NodeMaterialConnectionPoint;
  66144. /**
  66145. * Gets the world input component
  66146. */
  66147. get world(): NodeMaterialConnectionPoint;
  66148. /**
  66149. * Gets the output component
  66150. */
  66151. get output(): NodeMaterialConnectionPoint;
  66152. /**
  66153. * Gets the isntanceID component
  66154. */
  66155. get instanceID(): NodeMaterialConnectionPoint;
  66156. autoConfigure(material: NodeMaterial): void;
  66157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66158. protected _buildBlock(state: NodeMaterialBuildState): this;
  66159. }
  66160. }
  66161. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66166. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66167. import { Effect } from "babylonjs/Materials/effect";
  66168. import { Mesh } from "babylonjs/Meshes/mesh";
  66169. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66170. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66171. /**
  66172. * Block used to add morph targets support to vertex shader
  66173. */
  66174. export class MorphTargetsBlock extends NodeMaterialBlock {
  66175. private _repeatableContentAnchor;
  66176. /**
  66177. * Create a new MorphTargetsBlock
  66178. * @param name defines the block name
  66179. */
  66180. constructor(name: string);
  66181. /**
  66182. * Gets the current class name
  66183. * @returns the class name
  66184. */
  66185. getClassName(): string;
  66186. /**
  66187. * Gets the position input component
  66188. */
  66189. get position(): NodeMaterialConnectionPoint;
  66190. /**
  66191. * Gets the normal input component
  66192. */
  66193. get normal(): NodeMaterialConnectionPoint;
  66194. /**
  66195. * Gets the tangent input component
  66196. */
  66197. get tangent(): NodeMaterialConnectionPoint;
  66198. /**
  66199. * Gets the tangent input component
  66200. */
  66201. get uv(): NodeMaterialConnectionPoint;
  66202. /**
  66203. * Gets the position output component
  66204. */
  66205. get positionOutput(): NodeMaterialConnectionPoint;
  66206. /**
  66207. * Gets the normal output component
  66208. */
  66209. get normalOutput(): NodeMaterialConnectionPoint;
  66210. /**
  66211. * Gets the tangent output component
  66212. */
  66213. get tangentOutput(): NodeMaterialConnectionPoint;
  66214. /**
  66215. * Gets the tangent output component
  66216. */
  66217. get uvOutput(): NodeMaterialConnectionPoint;
  66218. initialize(state: NodeMaterialBuildState): void;
  66219. autoConfigure(material: NodeMaterial): void;
  66220. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66221. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66222. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66223. protected _buildBlock(state: NodeMaterialBuildState): this;
  66224. }
  66225. }
  66226. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  66227. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66228. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66229. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66230. import { Nullable } from "babylonjs/types";
  66231. import { Scene } from "babylonjs/scene";
  66232. import { Effect } from "babylonjs/Materials/effect";
  66233. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66234. import { Mesh } from "babylonjs/Meshes/mesh";
  66235. import { Light } from "babylonjs/Lights/light";
  66236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66237. /**
  66238. * Block used to get data information from a light
  66239. */
  66240. export class LightInformationBlock extends NodeMaterialBlock {
  66241. private _lightDataUniformName;
  66242. private _lightColorUniformName;
  66243. private _lightTypeDefineName;
  66244. /**
  66245. * Gets or sets the light associated with this block
  66246. */
  66247. light: Nullable<Light>;
  66248. /**
  66249. * Creates a new LightInformationBlock
  66250. * @param name defines the block name
  66251. */
  66252. constructor(name: string);
  66253. /**
  66254. * Gets the current class name
  66255. * @returns the class name
  66256. */
  66257. getClassName(): string;
  66258. /**
  66259. * Gets the world position input component
  66260. */
  66261. get worldPosition(): NodeMaterialConnectionPoint;
  66262. /**
  66263. * Gets the direction output component
  66264. */
  66265. get direction(): NodeMaterialConnectionPoint;
  66266. /**
  66267. * Gets the direction output component
  66268. */
  66269. get color(): NodeMaterialConnectionPoint;
  66270. /**
  66271. * Gets the direction output component
  66272. */
  66273. get intensity(): NodeMaterialConnectionPoint;
  66274. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66275. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66276. protected _buildBlock(state: NodeMaterialBuildState): this;
  66277. serialize(): any;
  66278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66279. }
  66280. }
  66281. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66282. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66283. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66284. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66285. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66286. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66287. }
  66288. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  66289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66290. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66291. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66293. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66294. import { Effect } from "babylonjs/Materials/effect";
  66295. import { Mesh } from "babylonjs/Meshes/mesh";
  66296. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66297. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66298. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66299. /**
  66300. * Block used to add image processing support to fragment shader
  66301. */
  66302. export class ImageProcessingBlock extends NodeMaterialBlock {
  66303. /**
  66304. * Create a new ImageProcessingBlock
  66305. * @param name defines the block name
  66306. */
  66307. constructor(name: string);
  66308. /**
  66309. * Gets the current class name
  66310. * @returns the class name
  66311. */
  66312. getClassName(): string;
  66313. /**
  66314. * Gets the color input component
  66315. */
  66316. get color(): NodeMaterialConnectionPoint;
  66317. /**
  66318. * Gets the output component
  66319. */
  66320. get output(): NodeMaterialConnectionPoint;
  66321. /**
  66322. * Initialize the block and prepare the context for build
  66323. * @param state defines the state that will be used for the build
  66324. */
  66325. initialize(state: NodeMaterialBuildState): void;
  66326. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66327. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66329. protected _buildBlock(state: NodeMaterialBuildState): this;
  66330. }
  66331. }
  66332. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66333. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66334. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66335. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66336. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66338. import { Effect } from "babylonjs/Materials/effect";
  66339. import { Mesh } from "babylonjs/Meshes/mesh";
  66340. import { Scene } from "babylonjs/scene";
  66341. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66342. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66343. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66344. /**
  66345. * Block used to pertub normals based on a normal map
  66346. */
  66347. export class PerturbNormalBlock extends NodeMaterialBlock {
  66348. private _tangentSpaceParameterName;
  66349. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66350. invertX: boolean;
  66351. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66352. invertY: boolean;
  66353. /**
  66354. * Create a new PerturbNormalBlock
  66355. * @param name defines the block name
  66356. */
  66357. constructor(name: string);
  66358. /**
  66359. * Gets the current class name
  66360. * @returns the class name
  66361. */
  66362. getClassName(): string;
  66363. /**
  66364. * Gets the world position input component
  66365. */
  66366. get worldPosition(): NodeMaterialConnectionPoint;
  66367. /**
  66368. * Gets the world normal input component
  66369. */
  66370. get worldNormal(): NodeMaterialConnectionPoint;
  66371. /**
  66372. * Gets the world tangent input component
  66373. */
  66374. get worldTangent(): NodeMaterialConnectionPoint;
  66375. /**
  66376. * Gets the uv input component
  66377. */
  66378. get uv(): NodeMaterialConnectionPoint;
  66379. /**
  66380. * Gets the normal map color input component
  66381. */
  66382. get normalMapColor(): NodeMaterialConnectionPoint;
  66383. /**
  66384. * Gets the strength input component
  66385. */
  66386. get strength(): NodeMaterialConnectionPoint;
  66387. /**
  66388. * Gets the output component
  66389. */
  66390. get output(): NodeMaterialConnectionPoint;
  66391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66392. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66393. autoConfigure(material: NodeMaterial): void;
  66394. protected _buildBlock(state: NodeMaterialBuildState): this;
  66395. protected _dumpPropertiesCode(): string;
  66396. serialize(): any;
  66397. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66398. }
  66399. }
  66400. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66404. /**
  66405. * Block used to discard a pixel if a value is smaller than a cutoff
  66406. */
  66407. export class DiscardBlock extends NodeMaterialBlock {
  66408. /**
  66409. * Create a new DiscardBlock
  66410. * @param name defines the block name
  66411. */
  66412. constructor(name: string);
  66413. /**
  66414. * Gets the current class name
  66415. * @returns the class name
  66416. */
  66417. getClassName(): string;
  66418. /**
  66419. * Gets the color input component
  66420. */
  66421. get value(): NodeMaterialConnectionPoint;
  66422. /**
  66423. * Gets the cutoff input component
  66424. */
  66425. get cutoff(): NodeMaterialConnectionPoint;
  66426. protected _buildBlock(state: NodeMaterialBuildState): this;
  66427. }
  66428. }
  66429. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66430. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66431. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66432. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66433. /**
  66434. * Block used to test if the fragment shader is front facing
  66435. */
  66436. export class FrontFacingBlock extends NodeMaterialBlock {
  66437. /**
  66438. * Creates a new FrontFacingBlock
  66439. * @param name defines the block name
  66440. */
  66441. constructor(name: string);
  66442. /**
  66443. * Gets the current class name
  66444. * @returns the class name
  66445. */
  66446. getClassName(): string;
  66447. /**
  66448. * Gets the output component
  66449. */
  66450. get output(): NodeMaterialConnectionPoint;
  66451. protected _buildBlock(state: NodeMaterialBuildState): this;
  66452. }
  66453. }
  66454. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66456. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66458. /**
  66459. * Block used to get the derivative value on x and y of a given input
  66460. */
  66461. export class DerivativeBlock extends NodeMaterialBlock {
  66462. /**
  66463. * Create a new DerivativeBlock
  66464. * @param name defines the block name
  66465. */
  66466. constructor(name: string);
  66467. /**
  66468. * Gets the current class name
  66469. * @returns the class name
  66470. */
  66471. getClassName(): string;
  66472. /**
  66473. * Gets the input component
  66474. */
  66475. get input(): NodeMaterialConnectionPoint;
  66476. /**
  66477. * Gets the derivative output on x
  66478. */
  66479. get dx(): NodeMaterialConnectionPoint;
  66480. /**
  66481. * Gets the derivative output on y
  66482. */
  66483. get dy(): NodeMaterialConnectionPoint;
  66484. protected _buildBlock(state: NodeMaterialBuildState): this;
  66485. }
  66486. }
  66487. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66491. /**
  66492. * Block used to make gl_FragCoord available
  66493. */
  66494. export class FragCoordBlock extends NodeMaterialBlock {
  66495. /**
  66496. * Creates a new FragCoordBlock
  66497. * @param name defines the block name
  66498. */
  66499. constructor(name: string);
  66500. /**
  66501. * Gets the current class name
  66502. * @returns the class name
  66503. */
  66504. getClassName(): string;
  66505. /**
  66506. * Gets the xy component
  66507. */
  66508. get xy(): NodeMaterialConnectionPoint;
  66509. /**
  66510. * Gets the xyz component
  66511. */
  66512. get xyz(): NodeMaterialConnectionPoint;
  66513. /**
  66514. * Gets the xyzw component
  66515. */
  66516. get xyzw(): NodeMaterialConnectionPoint;
  66517. /**
  66518. * Gets the x component
  66519. */
  66520. get x(): NodeMaterialConnectionPoint;
  66521. /**
  66522. * Gets the y component
  66523. */
  66524. get y(): NodeMaterialConnectionPoint;
  66525. /**
  66526. * Gets the z component
  66527. */
  66528. get z(): NodeMaterialConnectionPoint;
  66529. /**
  66530. * Gets the w component
  66531. */
  66532. get output(): NodeMaterialConnectionPoint;
  66533. protected writeOutputs(state: NodeMaterialBuildState): string;
  66534. protected _buildBlock(state: NodeMaterialBuildState): this;
  66535. }
  66536. }
  66537. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66541. import { Effect } from "babylonjs/Materials/effect";
  66542. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66543. import { Mesh } from "babylonjs/Meshes/mesh";
  66544. /**
  66545. * Block used to get the screen sizes
  66546. */
  66547. export class ScreenSizeBlock extends NodeMaterialBlock {
  66548. private _varName;
  66549. private _scene;
  66550. /**
  66551. * Creates a new ScreenSizeBlock
  66552. * @param name defines the block name
  66553. */
  66554. constructor(name: string);
  66555. /**
  66556. * Gets the current class name
  66557. * @returns the class name
  66558. */
  66559. getClassName(): string;
  66560. /**
  66561. * Gets the xy component
  66562. */
  66563. get xy(): NodeMaterialConnectionPoint;
  66564. /**
  66565. * Gets the x component
  66566. */
  66567. get x(): NodeMaterialConnectionPoint;
  66568. /**
  66569. * Gets the y component
  66570. */
  66571. get y(): NodeMaterialConnectionPoint;
  66572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66573. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66574. protected _buildBlock(state: NodeMaterialBuildState): this;
  66575. }
  66576. }
  66577. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66578. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66579. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66580. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66581. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66582. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66583. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66584. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66585. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66586. }
  66587. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66590. import { Mesh } from "babylonjs/Meshes/mesh";
  66591. import { Effect } from "babylonjs/Materials/effect";
  66592. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66594. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66595. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66596. /**
  66597. * Block used to add support for scene fog
  66598. */
  66599. export class FogBlock extends NodeMaterialBlock {
  66600. private _fogDistanceName;
  66601. private _fogParameters;
  66602. /**
  66603. * Create a new FogBlock
  66604. * @param name defines the block name
  66605. */
  66606. constructor(name: string);
  66607. /**
  66608. * Gets the current class name
  66609. * @returns the class name
  66610. */
  66611. getClassName(): string;
  66612. /**
  66613. * Gets the world position input component
  66614. */
  66615. get worldPosition(): NodeMaterialConnectionPoint;
  66616. /**
  66617. * Gets the view input component
  66618. */
  66619. get view(): NodeMaterialConnectionPoint;
  66620. /**
  66621. * Gets the color input component
  66622. */
  66623. get input(): NodeMaterialConnectionPoint;
  66624. /**
  66625. * Gets the fog color input component
  66626. */
  66627. get fogColor(): NodeMaterialConnectionPoint;
  66628. /**
  66629. * Gets the output component
  66630. */
  66631. get output(): NodeMaterialConnectionPoint;
  66632. autoConfigure(material: NodeMaterial): void;
  66633. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66634. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66635. protected _buildBlock(state: NodeMaterialBuildState): this;
  66636. }
  66637. }
  66638. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66643. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66644. import { Effect } from "babylonjs/Materials/effect";
  66645. import { Mesh } from "babylonjs/Meshes/mesh";
  66646. import { Light } from "babylonjs/Lights/light";
  66647. import { Nullable } from "babylonjs/types";
  66648. import { Scene } from "babylonjs/scene";
  66649. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66650. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66651. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66652. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66653. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66654. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66655. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66656. /**
  66657. * Block used to add light in the fragment shader
  66658. */
  66659. export class LightBlock extends NodeMaterialBlock {
  66660. private _lightId;
  66661. /**
  66662. * Gets or sets the light associated with this block
  66663. */
  66664. light: Nullable<Light>;
  66665. /**
  66666. * Create a new LightBlock
  66667. * @param name defines the block name
  66668. */
  66669. constructor(name: string);
  66670. /**
  66671. * Gets the current class name
  66672. * @returns the class name
  66673. */
  66674. getClassName(): string;
  66675. /**
  66676. * Gets the world position input component
  66677. */
  66678. get worldPosition(): NodeMaterialConnectionPoint;
  66679. /**
  66680. * Gets the world normal input component
  66681. */
  66682. get worldNormal(): NodeMaterialConnectionPoint;
  66683. /**
  66684. * Gets the camera (or eye) position component
  66685. */
  66686. get cameraPosition(): NodeMaterialConnectionPoint;
  66687. /**
  66688. * Gets the glossiness component
  66689. */
  66690. get glossiness(): NodeMaterialConnectionPoint;
  66691. /**
  66692. * Gets the glossinness power component
  66693. */
  66694. get glossPower(): NodeMaterialConnectionPoint;
  66695. /**
  66696. * Gets the diffuse color component
  66697. */
  66698. get diffuseColor(): NodeMaterialConnectionPoint;
  66699. /**
  66700. * Gets the specular color component
  66701. */
  66702. get specularColor(): NodeMaterialConnectionPoint;
  66703. /**
  66704. * Gets the diffuse output component
  66705. */
  66706. get diffuseOutput(): NodeMaterialConnectionPoint;
  66707. /**
  66708. * Gets the specular output component
  66709. */
  66710. get specularOutput(): NodeMaterialConnectionPoint;
  66711. /**
  66712. * Gets the shadow output component
  66713. */
  66714. get shadow(): NodeMaterialConnectionPoint;
  66715. autoConfigure(material: NodeMaterial): void;
  66716. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66717. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66718. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66719. private _injectVertexCode;
  66720. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66721. serialize(): any;
  66722. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66723. }
  66724. }
  66725. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66728. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66729. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66730. /**
  66731. * Block used to read a reflection texture from a sampler
  66732. */
  66733. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66734. /**
  66735. * Create a new ReflectionTextureBlock
  66736. * @param name defines the block name
  66737. */
  66738. constructor(name: string);
  66739. /**
  66740. * Gets the current class name
  66741. * @returns the class name
  66742. */
  66743. getClassName(): string;
  66744. /**
  66745. * Gets the world position input component
  66746. */
  66747. get position(): NodeMaterialConnectionPoint;
  66748. /**
  66749. * Gets the world position input component
  66750. */
  66751. get worldPosition(): NodeMaterialConnectionPoint;
  66752. /**
  66753. * Gets the world normal input component
  66754. */
  66755. get worldNormal(): NodeMaterialConnectionPoint;
  66756. /**
  66757. * Gets the world input component
  66758. */
  66759. get world(): NodeMaterialConnectionPoint;
  66760. /**
  66761. * Gets the camera (or eye) position component
  66762. */
  66763. get cameraPosition(): NodeMaterialConnectionPoint;
  66764. /**
  66765. * Gets the view input component
  66766. */
  66767. get view(): NodeMaterialConnectionPoint;
  66768. /**
  66769. * Gets the rgb output component
  66770. */
  66771. get rgb(): NodeMaterialConnectionPoint;
  66772. /**
  66773. * Gets the rgba output component
  66774. */
  66775. get rgba(): NodeMaterialConnectionPoint;
  66776. /**
  66777. * Gets the r output component
  66778. */
  66779. get r(): NodeMaterialConnectionPoint;
  66780. /**
  66781. * Gets the g output component
  66782. */
  66783. get g(): NodeMaterialConnectionPoint;
  66784. /**
  66785. * Gets the b output component
  66786. */
  66787. get b(): NodeMaterialConnectionPoint;
  66788. /**
  66789. * Gets the a output component
  66790. */
  66791. get a(): NodeMaterialConnectionPoint;
  66792. autoConfigure(material: NodeMaterial): void;
  66793. protected _buildBlock(state: NodeMaterialBuildState): this;
  66794. }
  66795. }
  66796. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66797. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66798. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66799. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66800. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66801. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66802. }
  66803. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66804. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66805. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66806. }
  66807. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66811. /**
  66812. * Block used to add 2 vectors
  66813. */
  66814. export class AddBlock extends NodeMaterialBlock {
  66815. /**
  66816. * Creates a new AddBlock
  66817. * @param name defines the block name
  66818. */
  66819. constructor(name: string);
  66820. /**
  66821. * Gets the current class name
  66822. * @returns the class name
  66823. */
  66824. getClassName(): string;
  66825. /**
  66826. * Gets the left operand input component
  66827. */
  66828. get left(): NodeMaterialConnectionPoint;
  66829. /**
  66830. * Gets the right operand input component
  66831. */
  66832. get right(): NodeMaterialConnectionPoint;
  66833. /**
  66834. * Gets the output component
  66835. */
  66836. get output(): NodeMaterialConnectionPoint;
  66837. protected _buildBlock(state: NodeMaterialBuildState): this;
  66838. }
  66839. }
  66840. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66844. /**
  66845. * Block used to scale a vector by a float
  66846. */
  66847. export class ScaleBlock extends NodeMaterialBlock {
  66848. /**
  66849. * Creates a new ScaleBlock
  66850. * @param name defines the block name
  66851. */
  66852. constructor(name: string);
  66853. /**
  66854. * Gets the current class name
  66855. * @returns the class name
  66856. */
  66857. getClassName(): string;
  66858. /**
  66859. * Gets the input component
  66860. */
  66861. get input(): NodeMaterialConnectionPoint;
  66862. /**
  66863. * Gets the factor input component
  66864. */
  66865. get factor(): NodeMaterialConnectionPoint;
  66866. /**
  66867. * Gets the output component
  66868. */
  66869. get output(): NodeMaterialConnectionPoint;
  66870. protected _buildBlock(state: NodeMaterialBuildState): this;
  66871. }
  66872. }
  66873. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66877. import { Scene } from "babylonjs/scene";
  66878. /**
  66879. * Block used to clamp a float
  66880. */
  66881. export class ClampBlock extends NodeMaterialBlock {
  66882. /** Gets or sets the minimum range */
  66883. minimum: number;
  66884. /** Gets or sets the maximum range */
  66885. maximum: number;
  66886. /**
  66887. * Creates a new ClampBlock
  66888. * @param name defines the block name
  66889. */
  66890. constructor(name: string);
  66891. /**
  66892. * Gets the current class name
  66893. * @returns the class name
  66894. */
  66895. getClassName(): string;
  66896. /**
  66897. * Gets the value input component
  66898. */
  66899. get value(): NodeMaterialConnectionPoint;
  66900. /**
  66901. * Gets the output component
  66902. */
  66903. get output(): NodeMaterialConnectionPoint;
  66904. protected _buildBlock(state: NodeMaterialBuildState): this;
  66905. protected _dumpPropertiesCode(): string;
  66906. serialize(): any;
  66907. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66908. }
  66909. }
  66910. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66914. /**
  66915. * Block used to apply a cross product between 2 vectors
  66916. */
  66917. export class CrossBlock extends NodeMaterialBlock {
  66918. /**
  66919. * Creates a new CrossBlock
  66920. * @param name defines the block name
  66921. */
  66922. constructor(name: string);
  66923. /**
  66924. * Gets the current class name
  66925. * @returns the class name
  66926. */
  66927. getClassName(): string;
  66928. /**
  66929. * Gets the left operand input component
  66930. */
  66931. get left(): NodeMaterialConnectionPoint;
  66932. /**
  66933. * Gets the right operand input component
  66934. */
  66935. get right(): NodeMaterialConnectionPoint;
  66936. /**
  66937. * Gets the output component
  66938. */
  66939. get output(): NodeMaterialConnectionPoint;
  66940. protected _buildBlock(state: NodeMaterialBuildState): this;
  66941. }
  66942. }
  66943. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66945. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66947. /**
  66948. * Block used to apply a dot product between 2 vectors
  66949. */
  66950. export class DotBlock extends NodeMaterialBlock {
  66951. /**
  66952. * Creates a new DotBlock
  66953. * @param name defines the block name
  66954. */
  66955. constructor(name: string);
  66956. /**
  66957. * Gets the current class name
  66958. * @returns the class name
  66959. */
  66960. getClassName(): string;
  66961. /**
  66962. * Gets the left operand input component
  66963. */
  66964. get left(): NodeMaterialConnectionPoint;
  66965. /**
  66966. * Gets the right operand input component
  66967. */
  66968. get right(): NodeMaterialConnectionPoint;
  66969. /**
  66970. * Gets the output component
  66971. */
  66972. get output(): NodeMaterialConnectionPoint;
  66973. protected _buildBlock(state: NodeMaterialBuildState): this;
  66974. }
  66975. }
  66976. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66977. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66978. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66979. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66980. /**
  66981. * Block used to normalize a vector
  66982. */
  66983. export class NormalizeBlock extends NodeMaterialBlock {
  66984. /**
  66985. * Creates a new NormalizeBlock
  66986. * @param name defines the block name
  66987. */
  66988. constructor(name: string);
  66989. /**
  66990. * Gets the current class name
  66991. * @returns the class name
  66992. */
  66993. getClassName(): string;
  66994. /**
  66995. * Gets the input component
  66996. */
  66997. get input(): NodeMaterialConnectionPoint;
  66998. /**
  66999. * Gets the output component
  67000. */
  67001. get output(): NodeMaterialConnectionPoint;
  67002. protected _buildBlock(state: NodeMaterialBuildState): this;
  67003. }
  67004. }
  67005. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67006. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67007. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67009. /**
  67010. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67011. */
  67012. export class ColorMergerBlock extends NodeMaterialBlock {
  67013. /**
  67014. * Create a new ColorMergerBlock
  67015. * @param name defines the block name
  67016. */
  67017. constructor(name: string);
  67018. /**
  67019. * Gets the current class name
  67020. * @returns the class name
  67021. */
  67022. getClassName(): string;
  67023. /**
  67024. * Gets the rgb component (input)
  67025. */
  67026. get rgbIn(): NodeMaterialConnectionPoint;
  67027. /**
  67028. * Gets the r component (input)
  67029. */
  67030. get r(): NodeMaterialConnectionPoint;
  67031. /**
  67032. * Gets the g component (input)
  67033. */
  67034. get g(): NodeMaterialConnectionPoint;
  67035. /**
  67036. * Gets the b component (input)
  67037. */
  67038. get b(): NodeMaterialConnectionPoint;
  67039. /**
  67040. * Gets the a component (input)
  67041. */
  67042. get a(): NodeMaterialConnectionPoint;
  67043. /**
  67044. * Gets the rgba component (output)
  67045. */
  67046. get rgba(): NodeMaterialConnectionPoint;
  67047. /**
  67048. * Gets the rgb component (output)
  67049. */
  67050. get rgbOut(): NodeMaterialConnectionPoint;
  67051. /**
  67052. * Gets the rgb component (output)
  67053. * @deprecated Please use rgbOut instead.
  67054. */
  67055. get rgb(): NodeMaterialConnectionPoint;
  67056. protected _buildBlock(state: NodeMaterialBuildState): this;
  67057. }
  67058. }
  67059. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67062. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67063. /**
  67064. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67065. */
  67066. export class VectorSplitterBlock extends NodeMaterialBlock {
  67067. /**
  67068. * Create a new VectorSplitterBlock
  67069. * @param name defines the block name
  67070. */
  67071. constructor(name: string);
  67072. /**
  67073. * Gets the current class name
  67074. * @returns the class name
  67075. */
  67076. getClassName(): string;
  67077. /**
  67078. * Gets the xyzw component (input)
  67079. */
  67080. get xyzw(): NodeMaterialConnectionPoint;
  67081. /**
  67082. * Gets the xyz component (input)
  67083. */
  67084. get xyzIn(): NodeMaterialConnectionPoint;
  67085. /**
  67086. * Gets the xy component (input)
  67087. */
  67088. get xyIn(): NodeMaterialConnectionPoint;
  67089. /**
  67090. * Gets the xyz component (output)
  67091. */
  67092. get xyzOut(): NodeMaterialConnectionPoint;
  67093. /**
  67094. * Gets the xy component (output)
  67095. */
  67096. get xyOut(): NodeMaterialConnectionPoint;
  67097. /**
  67098. * Gets the x component (output)
  67099. */
  67100. get x(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the y component (output)
  67103. */
  67104. get y(): NodeMaterialConnectionPoint;
  67105. /**
  67106. * Gets the z component (output)
  67107. */
  67108. get z(): NodeMaterialConnectionPoint;
  67109. /**
  67110. * Gets the w component (output)
  67111. */
  67112. get w(): NodeMaterialConnectionPoint;
  67113. protected _inputRename(name: string): string;
  67114. protected _outputRename(name: string): string;
  67115. protected _buildBlock(state: NodeMaterialBuildState): this;
  67116. }
  67117. }
  67118. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67122. /**
  67123. * Block used to lerp between 2 values
  67124. */
  67125. export class LerpBlock extends NodeMaterialBlock {
  67126. /**
  67127. * Creates a new LerpBlock
  67128. * @param name defines the block name
  67129. */
  67130. constructor(name: string);
  67131. /**
  67132. * Gets the current class name
  67133. * @returns the class name
  67134. */
  67135. getClassName(): string;
  67136. /**
  67137. * Gets the left operand input component
  67138. */
  67139. get left(): NodeMaterialConnectionPoint;
  67140. /**
  67141. * Gets the right operand input component
  67142. */
  67143. get right(): NodeMaterialConnectionPoint;
  67144. /**
  67145. * Gets the gradient operand input component
  67146. */
  67147. get gradient(): NodeMaterialConnectionPoint;
  67148. /**
  67149. * Gets the output component
  67150. */
  67151. get output(): NodeMaterialConnectionPoint;
  67152. protected _buildBlock(state: NodeMaterialBuildState): this;
  67153. }
  67154. }
  67155. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67157. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67159. /**
  67160. * Block used to divide 2 vectors
  67161. */
  67162. export class DivideBlock extends NodeMaterialBlock {
  67163. /**
  67164. * Creates a new DivideBlock
  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 left operand input component
  67175. */
  67176. get left(): NodeMaterialConnectionPoint;
  67177. /**
  67178. * Gets the right operand input component
  67179. */
  67180. get right(): 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/subtractBlock" {
  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. /**
  67193. * Block used to subtract 2 vectors
  67194. */
  67195. export class SubtractBlock extends NodeMaterialBlock {
  67196. /**
  67197. * Creates a new SubtractBlock
  67198. * @param name defines the block name
  67199. */
  67200. constructor(name: string);
  67201. /**
  67202. * Gets the current class name
  67203. * @returns the class name
  67204. */
  67205. getClassName(): string;
  67206. /**
  67207. * Gets the left operand input component
  67208. */
  67209. get left(): NodeMaterialConnectionPoint;
  67210. /**
  67211. * Gets the right operand input component
  67212. */
  67213. get right(): NodeMaterialConnectionPoint;
  67214. /**
  67215. * Gets the output component
  67216. */
  67217. get output(): NodeMaterialConnectionPoint;
  67218. protected _buildBlock(state: NodeMaterialBuildState): this;
  67219. }
  67220. }
  67221. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  67222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67225. /**
  67226. * Block used to step a value
  67227. */
  67228. export class StepBlock extends NodeMaterialBlock {
  67229. /**
  67230. * Creates a new StepBlock
  67231. * @param name defines the block name
  67232. */
  67233. constructor(name: string);
  67234. /**
  67235. * Gets the current class name
  67236. * @returns the class name
  67237. */
  67238. getClassName(): string;
  67239. /**
  67240. * Gets the value operand input component
  67241. */
  67242. get value(): NodeMaterialConnectionPoint;
  67243. /**
  67244. * Gets the edge operand input component
  67245. */
  67246. get edge(): NodeMaterialConnectionPoint;
  67247. /**
  67248. * Gets the output component
  67249. */
  67250. get output(): NodeMaterialConnectionPoint;
  67251. protected _buildBlock(state: NodeMaterialBuildState): this;
  67252. }
  67253. }
  67254. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67258. /**
  67259. * Block used to get the opposite (1 - x) of a value
  67260. */
  67261. export class OneMinusBlock extends NodeMaterialBlock {
  67262. /**
  67263. * Creates a new OneMinusBlock
  67264. * @param name defines the block name
  67265. */
  67266. constructor(name: string);
  67267. /**
  67268. * Gets the current class name
  67269. * @returns the class name
  67270. */
  67271. getClassName(): string;
  67272. /**
  67273. * Gets the input component
  67274. */
  67275. get input(): NodeMaterialConnectionPoint;
  67276. /**
  67277. * Gets the output component
  67278. */
  67279. get output(): NodeMaterialConnectionPoint;
  67280. protected _buildBlock(state: NodeMaterialBuildState): this;
  67281. }
  67282. }
  67283. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67287. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67288. /**
  67289. * Block used to get the view direction
  67290. */
  67291. export class ViewDirectionBlock extends NodeMaterialBlock {
  67292. /**
  67293. * Creates a new ViewDirectionBlock
  67294. * @param name defines the block name
  67295. */
  67296. constructor(name: string);
  67297. /**
  67298. * Gets the current class name
  67299. * @returns the class name
  67300. */
  67301. getClassName(): string;
  67302. /**
  67303. * Gets the world position component
  67304. */
  67305. get worldPosition(): NodeMaterialConnectionPoint;
  67306. /**
  67307. * Gets the camera position component
  67308. */
  67309. get cameraPosition(): NodeMaterialConnectionPoint;
  67310. /**
  67311. * Gets the output component
  67312. */
  67313. get output(): NodeMaterialConnectionPoint;
  67314. autoConfigure(material: NodeMaterial): void;
  67315. protected _buildBlock(state: NodeMaterialBuildState): this;
  67316. }
  67317. }
  67318. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67319. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67320. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67322. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67323. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67324. /**
  67325. * Block used to compute fresnel value
  67326. */
  67327. export class FresnelBlock extends NodeMaterialBlock {
  67328. /**
  67329. * Create a new FresnelBlock
  67330. * @param name defines the block name
  67331. */
  67332. constructor(name: string);
  67333. /**
  67334. * Gets the current class name
  67335. * @returns the class name
  67336. */
  67337. getClassName(): string;
  67338. /**
  67339. * Gets the world normal input component
  67340. */
  67341. get worldNormal(): NodeMaterialConnectionPoint;
  67342. /**
  67343. * Gets the view direction input component
  67344. */
  67345. get viewDirection(): NodeMaterialConnectionPoint;
  67346. /**
  67347. * Gets the bias input component
  67348. */
  67349. get bias(): NodeMaterialConnectionPoint;
  67350. /**
  67351. * Gets the camera (or eye) position component
  67352. */
  67353. get power(): NodeMaterialConnectionPoint;
  67354. /**
  67355. * Gets the fresnel output component
  67356. */
  67357. get fresnel(): NodeMaterialConnectionPoint;
  67358. autoConfigure(material: NodeMaterial): void;
  67359. protected _buildBlock(state: NodeMaterialBuildState): this;
  67360. }
  67361. }
  67362. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67363. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67364. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67365. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67366. /**
  67367. * Block used to get the max of 2 values
  67368. */
  67369. export class MaxBlock extends NodeMaterialBlock {
  67370. /**
  67371. * Creates a new MaxBlock
  67372. * @param name defines the block name
  67373. */
  67374. constructor(name: string);
  67375. /**
  67376. * Gets the current class name
  67377. * @returns the class name
  67378. */
  67379. getClassName(): string;
  67380. /**
  67381. * Gets the left operand input component
  67382. */
  67383. get left(): NodeMaterialConnectionPoint;
  67384. /**
  67385. * Gets the right operand input component
  67386. */
  67387. get right(): NodeMaterialConnectionPoint;
  67388. /**
  67389. * Gets the output component
  67390. */
  67391. get output(): NodeMaterialConnectionPoint;
  67392. protected _buildBlock(state: NodeMaterialBuildState): this;
  67393. }
  67394. }
  67395. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67396. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67397. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67398. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67399. /**
  67400. * Block used to get the min of 2 values
  67401. */
  67402. export class MinBlock extends NodeMaterialBlock {
  67403. /**
  67404. * Creates a new MinBlock
  67405. * @param name defines the block name
  67406. */
  67407. constructor(name: string);
  67408. /**
  67409. * Gets the current class name
  67410. * @returns the class name
  67411. */
  67412. getClassName(): string;
  67413. /**
  67414. * Gets the left operand input component
  67415. */
  67416. get left(): NodeMaterialConnectionPoint;
  67417. /**
  67418. * Gets the right operand input component
  67419. */
  67420. get right(): NodeMaterialConnectionPoint;
  67421. /**
  67422. * Gets the output component
  67423. */
  67424. get output(): NodeMaterialConnectionPoint;
  67425. protected _buildBlock(state: NodeMaterialBuildState): this;
  67426. }
  67427. }
  67428. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67432. /**
  67433. * Block used to get the distance between 2 values
  67434. */
  67435. export class DistanceBlock extends NodeMaterialBlock {
  67436. /**
  67437. * Creates a new DistanceBlock
  67438. * @param name defines the block name
  67439. */
  67440. constructor(name: string);
  67441. /**
  67442. * Gets the current class name
  67443. * @returns the class name
  67444. */
  67445. getClassName(): string;
  67446. /**
  67447. * Gets the left operand input component
  67448. */
  67449. get left(): NodeMaterialConnectionPoint;
  67450. /**
  67451. * Gets the right operand input component
  67452. */
  67453. get right(): NodeMaterialConnectionPoint;
  67454. /**
  67455. * Gets the output component
  67456. */
  67457. get output(): NodeMaterialConnectionPoint;
  67458. protected _buildBlock(state: NodeMaterialBuildState): this;
  67459. }
  67460. }
  67461. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67465. /**
  67466. * Block used to get the length of a vector
  67467. */
  67468. export class LengthBlock extends NodeMaterialBlock {
  67469. /**
  67470. * Creates a new LengthBlock
  67471. * @param name defines the block name
  67472. */
  67473. constructor(name: string);
  67474. /**
  67475. * Gets the current class name
  67476. * @returns the class name
  67477. */
  67478. getClassName(): string;
  67479. /**
  67480. * Gets the value input component
  67481. */
  67482. get value(): NodeMaterialConnectionPoint;
  67483. /**
  67484. * Gets the output component
  67485. */
  67486. get output(): NodeMaterialConnectionPoint;
  67487. protected _buildBlock(state: NodeMaterialBuildState): this;
  67488. }
  67489. }
  67490. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  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 negative version of a value (i.e. x * -1)
  67496. */
  67497. export class NegateBlock extends NodeMaterialBlock {
  67498. /**
  67499. * Creates a new NegateBlock
  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 value input component
  67510. */
  67511. get value(): NodeMaterialConnectionPoint;
  67512. /**
  67513. * Gets the output component
  67514. */
  67515. get output(): NodeMaterialConnectionPoint;
  67516. protected _buildBlock(state: NodeMaterialBuildState): this;
  67517. }
  67518. }
  67519. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67523. /**
  67524. * Block used to get the value of the first parameter raised to the power of the second
  67525. */
  67526. export class PowBlock extends NodeMaterialBlock {
  67527. /**
  67528. * Creates a new PowBlock
  67529. * @param name defines the block name
  67530. */
  67531. constructor(name: string);
  67532. /**
  67533. * Gets the current class name
  67534. * @returns the class name
  67535. */
  67536. getClassName(): string;
  67537. /**
  67538. * Gets the value operand input component
  67539. */
  67540. get value(): NodeMaterialConnectionPoint;
  67541. /**
  67542. * Gets the power operand input component
  67543. */
  67544. get power(): NodeMaterialConnectionPoint;
  67545. /**
  67546. * Gets the output component
  67547. */
  67548. get output(): NodeMaterialConnectionPoint;
  67549. protected _buildBlock(state: NodeMaterialBuildState): this;
  67550. }
  67551. }
  67552. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67556. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67557. /**
  67558. * Block used to get a random number
  67559. */
  67560. export class RandomNumberBlock extends NodeMaterialBlock {
  67561. /**
  67562. * Creates a new RandomNumberBlock
  67563. * @param name defines the block name
  67564. */
  67565. constructor(name: string);
  67566. /**
  67567. * Gets the current class name
  67568. * @returns the class name
  67569. */
  67570. getClassName(): string;
  67571. /**
  67572. * Gets the seed input component
  67573. */
  67574. get seed(): NodeMaterialConnectionPoint;
  67575. /**
  67576. * Gets the output component
  67577. */
  67578. get output(): NodeMaterialConnectionPoint;
  67579. protected _buildBlock(state: NodeMaterialBuildState): this;
  67580. }
  67581. }
  67582. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67586. /**
  67587. * Block used to compute arc tangent of 2 values
  67588. */
  67589. export class ArcTan2Block extends NodeMaterialBlock {
  67590. /**
  67591. * Creates a new ArcTan2Block
  67592. * @param name defines the block name
  67593. */
  67594. constructor(name: string);
  67595. /**
  67596. * Gets the current class name
  67597. * @returns the class name
  67598. */
  67599. getClassName(): string;
  67600. /**
  67601. * Gets the x operand input component
  67602. */
  67603. get x(): NodeMaterialConnectionPoint;
  67604. /**
  67605. * Gets the y operand input component
  67606. */
  67607. get y(): NodeMaterialConnectionPoint;
  67608. /**
  67609. * Gets the output component
  67610. */
  67611. get output(): NodeMaterialConnectionPoint;
  67612. protected _buildBlock(state: NodeMaterialBuildState): this;
  67613. }
  67614. }
  67615. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67617. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67619. /**
  67620. * Block used to smooth step a value
  67621. */
  67622. export class SmoothStepBlock extends NodeMaterialBlock {
  67623. /**
  67624. * Creates a new SmoothStepBlock
  67625. * @param name defines the block name
  67626. */
  67627. constructor(name: string);
  67628. /**
  67629. * Gets the current class name
  67630. * @returns the class name
  67631. */
  67632. getClassName(): string;
  67633. /**
  67634. * Gets the value operand input component
  67635. */
  67636. get value(): NodeMaterialConnectionPoint;
  67637. /**
  67638. * Gets the first edge operand input component
  67639. */
  67640. get edge0(): NodeMaterialConnectionPoint;
  67641. /**
  67642. * Gets the second edge operand input component
  67643. */
  67644. get edge1(): NodeMaterialConnectionPoint;
  67645. /**
  67646. * Gets the output component
  67647. */
  67648. get output(): NodeMaterialConnectionPoint;
  67649. protected _buildBlock(state: NodeMaterialBuildState): this;
  67650. }
  67651. }
  67652. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67656. /**
  67657. * Block used to get the reciprocal (1 / x) of a value
  67658. */
  67659. export class ReciprocalBlock extends NodeMaterialBlock {
  67660. /**
  67661. * Creates a new ReciprocalBlock
  67662. * @param name defines the block name
  67663. */
  67664. constructor(name: string);
  67665. /**
  67666. * Gets the current class name
  67667. * @returns the class name
  67668. */
  67669. getClassName(): string;
  67670. /**
  67671. * Gets the input component
  67672. */
  67673. get input(): NodeMaterialConnectionPoint;
  67674. /**
  67675. * Gets the output component
  67676. */
  67677. get output(): NodeMaterialConnectionPoint;
  67678. protected _buildBlock(state: NodeMaterialBuildState): this;
  67679. }
  67680. }
  67681. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67682. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67683. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67684. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67685. /**
  67686. * Block used to replace a color by another one
  67687. */
  67688. export class ReplaceColorBlock extends NodeMaterialBlock {
  67689. /**
  67690. * Creates a new ReplaceColorBlock
  67691. * @param name defines the block name
  67692. */
  67693. constructor(name: string);
  67694. /**
  67695. * Gets the current class name
  67696. * @returns the class name
  67697. */
  67698. getClassName(): string;
  67699. /**
  67700. * Gets the value input component
  67701. */
  67702. get value(): NodeMaterialConnectionPoint;
  67703. /**
  67704. * Gets the reference input component
  67705. */
  67706. get reference(): NodeMaterialConnectionPoint;
  67707. /**
  67708. * Gets the distance input component
  67709. */
  67710. get distance(): NodeMaterialConnectionPoint;
  67711. /**
  67712. * Gets the replacement input component
  67713. */
  67714. get replacement(): NodeMaterialConnectionPoint;
  67715. /**
  67716. * Gets the output component
  67717. */
  67718. get output(): NodeMaterialConnectionPoint;
  67719. protected _buildBlock(state: NodeMaterialBuildState): this;
  67720. }
  67721. }
  67722. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67726. /**
  67727. * Block used to posterize a value
  67728. * @see https://en.wikipedia.org/wiki/Posterization
  67729. */
  67730. export class PosterizeBlock extends NodeMaterialBlock {
  67731. /**
  67732. * Creates a new PosterizeBlock
  67733. * @param name defines the block name
  67734. */
  67735. constructor(name: string);
  67736. /**
  67737. * Gets the current class name
  67738. * @returns the class name
  67739. */
  67740. getClassName(): string;
  67741. /**
  67742. * Gets the value input component
  67743. */
  67744. get value(): NodeMaterialConnectionPoint;
  67745. /**
  67746. * Gets the steps input component
  67747. */
  67748. get steps(): NodeMaterialConnectionPoint;
  67749. /**
  67750. * Gets the output component
  67751. */
  67752. get output(): NodeMaterialConnectionPoint;
  67753. protected _buildBlock(state: NodeMaterialBuildState): this;
  67754. }
  67755. }
  67756. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67760. import { Scene } from "babylonjs/scene";
  67761. /**
  67762. * Operations supported by the Wave block
  67763. */
  67764. export enum WaveBlockKind {
  67765. /** SawTooth */
  67766. SawTooth = 0,
  67767. /** Square */
  67768. Square = 1,
  67769. /** Triangle */
  67770. Triangle = 2
  67771. }
  67772. /**
  67773. * Block used to apply wave operation to floats
  67774. */
  67775. export class WaveBlock extends NodeMaterialBlock {
  67776. /**
  67777. * Gets or sets the kibnd of wave to be applied by the block
  67778. */
  67779. kind: WaveBlockKind;
  67780. /**
  67781. * Creates a new WaveBlock
  67782. * @param name defines the block name
  67783. */
  67784. constructor(name: string);
  67785. /**
  67786. * Gets the current class name
  67787. * @returns the class name
  67788. */
  67789. getClassName(): string;
  67790. /**
  67791. * Gets the input component
  67792. */
  67793. get input(): NodeMaterialConnectionPoint;
  67794. /**
  67795. * Gets the output component
  67796. */
  67797. get output(): NodeMaterialConnectionPoint;
  67798. protected _buildBlock(state: NodeMaterialBuildState): this;
  67799. serialize(): any;
  67800. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67801. }
  67802. }
  67803. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67806. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67807. import { Color3 } from "babylonjs/Maths/math.color";
  67808. import { Scene } from "babylonjs/scene";
  67809. import { Observable } from "babylonjs/Misc/observable";
  67810. /**
  67811. * Class used to store a color step for the GradientBlock
  67812. */
  67813. export class GradientBlockColorStep {
  67814. private _step;
  67815. /**
  67816. * Gets value indicating which step this color is associated with (between 0 and 1)
  67817. */
  67818. get step(): number;
  67819. /**
  67820. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67821. */
  67822. set step(val: number);
  67823. private _color;
  67824. /**
  67825. * Gets the color associated with this step
  67826. */
  67827. get color(): Color3;
  67828. /**
  67829. * Sets the color associated with this step
  67830. */
  67831. set color(val: Color3);
  67832. /**
  67833. * Creates a new GradientBlockColorStep
  67834. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67835. * @param color defines the color associated with this step
  67836. */
  67837. constructor(step: number, color: Color3);
  67838. }
  67839. /**
  67840. * Block used to return a color from a gradient based on an input value between 0 and 1
  67841. */
  67842. export class GradientBlock extends NodeMaterialBlock {
  67843. /**
  67844. * Gets or sets the list of color steps
  67845. */
  67846. colorSteps: GradientBlockColorStep[];
  67847. /** Gets an observable raised when the value is changed */
  67848. onValueChangedObservable: Observable<GradientBlock>;
  67849. /** calls observable when the value is changed*/
  67850. colorStepsUpdated(): void;
  67851. /**
  67852. * Creates a new GradientBlock
  67853. * @param name defines the block name
  67854. */
  67855. constructor(name: string);
  67856. /**
  67857. * Gets the current class name
  67858. * @returns the class name
  67859. */
  67860. getClassName(): string;
  67861. /**
  67862. * Gets the gradient input component
  67863. */
  67864. get gradient(): NodeMaterialConnectionPoint;
  67865. /**
  67866. * Gets the output component
  67867. */
  67868. get output(): NodeMaterialConnectionPoint;
  67869. private _writeColorConstant;
  67870. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67871. serialize(): any;
  67872. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67873. protected _dumpPropertiesCode(): string;
  67874. }
  67875. }
  67876. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67877. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67878. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67879. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67880. /**
  67881. * Block used to normalize lerp between 2 values
  67882. */
  67883. export class NLerpBlock extends NodeMaterialBlock {
  67884. /**
  67885. * Creates a new NLerpBlock
  67886. * @param name defines the block name
  67887. */
  67888. constructor(name: string);
  67889. /**
  67890. * Gets the current class name
  67891. * @returns the class name
  67892. */
  67893. getClassName(): string;
  67894. /**
  67895. * Gets the left operand input component
  67896. */
  67897. get left(): NodeMaterialConnectionPoint;
  67898. /**
  67899. * Gets the right operand input component
  67900. */
  67901. get right(): NodeMaterialConnectionPoint;
  67902. /**
  67903. * Gets the gradient operand input component
  67904. */
  67905. get gradient(): NodeMaterialConnectionPoint;
  67906. /**
  67907. * Gets the output component
  67908. */
  67909. get output(): NodeMaterialConnectionPoint;
  67910. protected _buildBlock(state: NodeMaterialBuildState): this;
  67911. }
  67912. }
  67913. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67917. import { Scene } from "babylonjs/scene";
  67918. /**
  67919. * block used to Generate a Worley Noise 3D Noise Pattern
  67920. */
  67921. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67922. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67923. manhattanDistance: boolean;
  67924. /**
  67925. * Creates a new WorleyNoise3DBlock
  67926. * @param name defines the block name
  67927. */
  67928. constructor(name: string);
  67929. /**
  67930. * Gets the current class name
  67931. * @returns the class name
  67932. */
  67933. getClassName(): string;
  67934. /**
  67935. * Gets the seed input component
  67936. */
  67937. get seed(): NodeMaterialConnectionPoint;
  67938. /**
  67939. * Gets the jitter input component
  67940. */
  67941. get jitter(): NodeMaterialConnectionPoint;
  67942. /**
  67943. * Gets the output component
  67944. */
  67945. get output(): NodeMaterialConnectionPoint;
  67946. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67947. /**
  67948. * Exposes the properties to the UI?
  67949. */
  67950. protected _dumpPropertiesCode(): string;
  67951. /**
  67952. * Exposes the properties to the Seralize?
  67953. */
  67954. serialize(): any;
  67955. /**
  67956. * Exposes the properties to the deseralize?
  67957. */
  67958. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67959. }
  67960. }
  67961. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67963. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67964. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67965. /**
  67966. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67967. */
  67968. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67969. /**
  67970. * Creates a new SimplexPerlin3DBlock
  67971. * @param name defines the block name
  67972. */
  67973. constructor(name: string);
  67974. /**
  67975. * Gets the current class name
  67976. * @returns the class name
  67977. */
  67978. getClassName(): string;
  67979. /**
  67980. * Gets the seed operand input component
  67981. */
  67982. get seed(): NodeMaterialConnectionPoint;
  67983. /**
  67984. * Gets the output component
  67985. */
  67986. get output(): NodeMaterialConnectionPoint;
  67987. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67988. }
  67989. }
  67990. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67994. /**
  67995. * Block used to blend normals
  67996. */
  67997. export class NormalBlendBlock extends NodeMaterialBlock {
  67998. /**
  67999. * Creates a new NormalBlendBlock
  68000. * @param name defines the block name
  68001. */
  68002. constructor(name: string);
  68003. /**
  68004. * Gets the current class name
  68005. * @returns the class name
  68006. */
  68007. getClassName(): string;
  68008. /**
  68009. * Gets the first input component
  68010. */
  68011. get normalMap0(): NodeMaterialConnectionPoint;
  68012. /**
  68013. * Gets the second input component
  68014. */
  68015. get normalMap1(): NodeMaterialConnectionPoint;
  68016. /**
  68017. * Gets the output component
  68018. */
  68019. get output(): NodeMaterialConnectionPoint;
  68020. protected _buildBlock(state: NodeMaterialBuildState): this;
  68021. }
  68022. }
  68023. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68027. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68028. /**
  68029. * Block used to rotate a 2d vector by a given angle
  68030. */
  68031. export class Rotate2dBlock extends NodeMaterialBlock {
  68032. /**
  68033. * Creates a new Rotate2dBlock
  68034. * @param name defines the block name
  68035. */
  68036. constructor(name: string);
  68037. /**
  68038. * Gets the current class name
  68039. * @returns the class name
  68040. */
  68041. getClassName(): string;
  68042. /**
  68043. * Gets the input vector
  68044. */
  68045. get input(): NodeMaterialConnectionPoint;
  68046. /**
  68047. * Gets the input angle
  68048. */
  68049. get angle(): NodeMaterialConnectionPoint;
  68050. /**
  68051. * Gets the output component
  68052. */
  68053. get output(): NodeMaterialConnectionPoint;
  68054. autoConfigure(material: NodeMaterial): void;
  68055. protected _buildBlock(state: NodeMaterialBuildState): this;
  68056. }
  68057. }
  68058. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68061. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68062. /**
  68063. * Block used to get the reflected vector from a direction and a normal
  68064. */
  68065. export class ReflectBlock extends NodeMaterialBlock {
  68066. /**
  68067. * Creates a new ReflectBlock
  68068. * @param name defines the block name
  68069. */
  68070. constructor(name: string);
  68071. /**
  68072. * Gets the current class name
  68073. * @returns the class name
  68074. */
  68075. getClassName(): string;
  68076. /**
  68077. * Gets the incident component
  68078. */
  68079. get incident(): NodeMaterialConnectionPoint;
  68080. /**
  68081. * Gets the normal component
  68082. */
  68083. get normal(): NodeMaterialConnectionPoint;
  68084. /**
  68085. * Gets the output component
  68086. */
  68087. get output(): NodeMaterialConnectionPoint;
  68088. protected _buildBlock(state: NodeMaterialBuildState): this;
  68089. }
  68090. }
  68091. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68092. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68095. /**
  68096. * Block used to get the refracted vector from a direction and a normal
  68097. */
  68098. export class RefractBlock extends NodeMaterialBlock {
  68099. /**
  68100. * Creates a new RefractBlock
  68101. * @param name defines the block name
  68102. */
  68103. constructor(name: string);
  68104. /**
  68105. * Gets the current class name
  68106. * @returns the class name
  68107. */
  68108. getClassName(): string;
  68109. /**
  68110. * Gets the incident component
  68111. */
  68112. get incident(): NodeMaterialConnectionPoint;
  68113. /**
  68114. * Gets the normal component
  68115. */
  68116. get normal(): NodeMaterialConnectionPoint;
  68117. /**
  68118. * Gets the index of refraction component
  68119. */
  68120. get ior(): NodeMaterialConnectionPoint;
  68121. /**
  68122. * Gets the output component
  68123. */
  68124. get output(): NodeMaterialConnectionPoint;
  68125. protected _buildBlock(state: NodeMaterialBuildState): this;
  68126. }
  68127. }
  68128. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68132. /**
  68133. * Block used to desaturate a color
  68134. */
  68135. export class DesaturateBlock extends NodeMaterialBlock {
  68136. /**
  68137. * Creates a new DesaturateBlock
  68138. * @param name defines the block name
  68139. */
  68140. constructor(name: string);
  68141. /**
  68142. * Gets the current class name
  68143. * @returns the class name
  68144. */
  68145. getClassName(): string;
  68146. /**
  68147. * Gets the color operand input component
  68148. */
  68149. get color(): NodeMaterialConnectionPoint;
  68150. /**
  68151. * Gets the level operand input component
  68152. */
  68153. get level(): NodeMaterialConnectionPoint;
  68154. /**
  68155. * Gets the output component
  68156. */
  68157. get output(): NodeMaterialConnectionPoint;
  68158. protected _buildBlock(state: NodeMaterialBuildState): this;
  68159. }
  68160. }
  68161. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68165. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68166. import { Nullable } from "babylonjs/types";
  68167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68168. import { Scene } from "babylonjs/scene";
  68169. /**
  68170. * Block used to implement the ambient occlusion module of the PBR material
  68171. */
  68172. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68173. /**
  68174. * Create a new AmbientOcclusionBlock
  68175. * @param name defines the block name
  68176. */
  68177. constructor(name: string);
  68178. /**
  68179. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68180. */
  68181. useAmbientInGrayScale: boolean;
  68182. /**
  68183. * Initialize the block and prepare the context for build
  68184. * @param state defines the state that will be used for the build
  68185. */
  68186. initialize(state: NodeMaterialBuildState): void;
  68187. /**
  68188. * Gets the current class name
  68189. * @returns the class name
  68190. */
  68191. getClassName(): string;
  68192. /**
  68193. * Gets the texture input component
  68194. */
  68195. get texture(): NodeMaterialConnectionPoint;
  68196. /**
  68197. * Gets the texture intensity component
  68198. */
  68199. get intensity(): NodeMaterialConnectionPoint;
  68200. /**
  68201. * Gets the direct light intensity input component
  68202. */
  68203. get directLightIntensity(): NodeMaterialConnectionPoint;
  68204. /**
  68205. * Gets the ambient occlusion object output component
  68206. */
  68207. get ambientOcc(): NodeMaterialConnectionPoint;
  68208. /**
  68209. * Gets the main code of the block (fragment side)
  68210. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68211. * @returns the shader code
  68212. */
  68213. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68214. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68215. protected _buildBlock(state: NodeMaterialBuildState): this;
  68216. protected _dumpPropertiesCode(): string;
  68217. serialize(): any;
  68218. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68219. }
  68220. }
  68221. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68222. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68224. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68225. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68227. import { Nullable } from "babylonjs/types";
  68228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68229. import { Mesh } from "babylonjs/Meshes/mesh";
  68230. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68231. import { Effect } from "babylonjs/Materials/effect";
  68232. import { Scene } from "babylonjs/scene";
  68233. /**
  68234. * Block used to implement the reflection module of the PBR material
  68235. */
  68236. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68237. /** @hidden */
  68238. _defineLODReflectionAlpha: string;
  68239. /** @hidden */
  68240. _defineLinearSpecularReflection: string;
  68241. private _vEnvironmentIrradianceName;
  68242. /** @hidden */
  68243. _vReflectionMicrosurfaceInfosName: string;
  68244. /** @hidden */
  68245. _vReflectionInfosName: string;
  68246. /** @hidden */
  68247. _vReflectionFilteringInfoName: string;
  68248. private _scene;
  68249. /**
  68250. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68251. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68252. * It's less burden on the user side in the editor part.
  68253. */
  68254. /** @hidden */
  68255. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68256. /** @hidden */
  68257. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68258. /** @hidden */
  68259. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68260. /**
  68261. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68262. * diffuse part of the IBL.
  68263. */
  68264. useSphericalHarmonics: boolean;
  68265. /**
  68266. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68267. */
  68268. forceIrradianceInFragment: boolean;
  68269. /**
  68270. * Create a new ReflectionBlock
  68271. * @param name defines the block name
  68272. */
  68273. constructor(name: string);
  68274. /**
  68275. * Gets the current class name
  68276. * @returns the class name
  68277. */
  68278. getClassName(): string;
  68279. /**
  68280. * Gets the position input component
  68281. */
  68282. get position(): NodeMaterialConnectionPoint;
  68283. /**
  68284. * Gets the world position input component
  68285. */
  68286. get worldPosition(): NodeMaterialConnectionPoint;
  68287. /**
  68288. * Gets the world normal input component
  68289. */
  68290. get worldNormal(): NodeMaterialConnectionPoint;
  68291. /**
  68292. * Gets the world input component
  68293. */
  68294. get world(): NodeMaterialConnectionPoint;
  68295. /**
  68296. * Gets the camera (or eye) position component
  68297. */
  68298. get cameraPosition(): NodeMaterialConnectionPoint;
  68299. /**
  68300. * Gets the view input component
  68301. */
  68302. get view(): NodeMaterialConnectionPoint;
  68303. /**
  68304. * Gets the color input component
  68305. */
  68306. get color(): NodeMaterialConnectionPoint;
  68307. /**
  68308. * Gets the reflection object output component
  68309. */
  68310. get reflection(): NodeMaterialConnectionPoint;
  68311. /**
  68312. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68313. */
  68314. get hasTexture(): boolean;
  68315. /**
  68316. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68317. */
  68318. get reflectionColor(): string;
  68319. protected _getTexture(): Nullable<BaseTexture>;
  68320. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68321. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68322. /**
  68323. * Gets the code to inject in the vertex shader
  68324. * @param state current state of the node material building
  68325. * @returns the shader code
  68326. */
  68327. handleVertexSide(state: NodeMaterialBuildState): string;
  68328. /**
  68329. * Gets the main code of the block (fragment side)
  68330. * @param state current state of the node material building
  68331. * @param normalVarName name of the existing variable corresponding to the normal
  68332. * @returns the shader code
  68333. */
  68334. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68335. protected _buildBlock(state: NodeMaterialBuildState): this;
  68336. protected _dumpPropertiesCode(): string;
  68337. serialize(): any;
  68338. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68339. }
  68340. }
  68341. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68345. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68347. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68348. import { Scene } from "babylonjs/scene";
  68349. import { Nullable } from "babylonjs/types";
  68350. /**
  68351. * Block used to implement the sheen module of the PBR material
  68352. */
  68353. export class SheenBlock extends NodeMaterialBlock {
  68354. /**
  68355. * Create a new SheenBlock
  68356. * @param name defines the block name
  68357. */
  68358. constructor(name: string);
  68359. /**
  68360. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68361. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68362. * making it easier to setup and tweak the effect
  68363. */
  68364. albedoScaling: boolean;
  68365. /**
  68366. * Defines if the sheen is linked to the sheen color.
  68367. */
  68368. linkSheenWithAlbedo: boolean;
  68369. /**
  68370. * Initialize the block and prepare the context for build
  68371. * @param state defines the state that will be used for the build
  68372. */
  68373. initialize(state: NodeMaterialBuildState): void;
  68374. /**
  68375. * Gets the current class name
  68376. * @returns the class name
  68377. */
  68378. getClassName(): string;
  68379. /**
  68380. * Gets the intensity input component
  68381. */
  68382. get intensity(): NodeMaterialConnectionPoint;
  68383. /**
  68384. * Gets the color input component
  68385. */
  68386. get color(): NodeMaterialConnectionPoint;
  68387. /**
  68388. * Gets the roughness input component
  68389. */
  68390. get roughness(): NodeMaterialConnectionPoint;
  68391. /**
  68392. * Gets the sheen object output component
  68393. */
  68394. get sheen(): NodeMaterialConnectionPoint;
  68395. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68396. /**
  68397. * Gets the main code of the block (fragment side)
  68398. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68399. * @returns the shader code
  68400. */
  68401. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68402. protected _buildBlock(state: NodeMaterialBuildState): this;
  68403. protected _dumpPropertiesCode(): string;
  68404. serialize(): any;
  68405. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68406. }
  68407. }
  68408. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68409. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68410. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68414. import { Scene } from "babylonjs/scene";
  68415. import { Nullable } from "babylonjs/types";
  68416. import { Mesh } from "babylonjs/Meshes/mesh";
  68417. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68418. import { Effect } from "babylonjs/Materials/effect";
  68419. /**
  68420. * Block used to implement the reflectivity module of the PBR material
  68421. */
  68422. export class ReflectivityBlock extends NodeMaterialBlock {
  68423. private _metallicReflectanceColor;
  68424. private _metallicF0Factor;
  68425. /** @hidden */
  68426. _vMetallicReflectanceFactorsName: string;
  68427. /**
  68428. * The property below is set by the main PBR block prior to calling methods of this class.
  68429. */
  68430. /** @hidden */
  68431. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68432. /**
  68433. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68434. */
  68435. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68436. /**
  68437. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68438. */
  68439. useMetallnessFromMetallicTextureBlue: boolean;
  68440. /**
  68441. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68442. */
  68443. useRoughnessFromMetallicTextureAlpha: boolean;
  68444. /**
  68445. * Specifies if the metallic texture contains the roughness information in its green channel.
  68446. */
  68447. useRoughnessFromMetallicTextureGreen: boolean;
  68448. /**
  68449. * Create a new ReflectivityBlock
  68450. * @param name defines the block name
  68451. */
  68452. constructor(name: string);
  68453. /**
  68454. * Initialize the block and prepare the context for build
  68455. * @param state defines the state that will be used for the build
  68456. */
  68457. initialize(state: NodeMaterialBuildState): void;
  68458. /**
  68459. * Gets the current class name
  68460. * @returns the class name
  68461. */
  68462. getClassName(): string;
  68463. /**
  68464. * Gets the metallic input component
  68465. */
  68466. get metallic(): NodeMaterialConnectionPoint;
  68467. /**
  68468. * Gets the roughness input component
  68469. */
  68470. get roughness(): NodeMaterialConnectionPoint;
  68471. /**
  68472. * Gets the texture input component
  68473. */
  68474. get texture(): NodeMaterialConnectionPoint;
  68475. /**
  68476. * Gets the reflectivity object output component
  68477. */
  68478. get reflectivity(): NodeMaterialConnectionPoint;
  68479. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68480. /**
  68481. * Gets the main code of the block (fragment side)
  68482. * @param state current state of the node material building
  68483. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68484. * @returns the shader code
  68485. */
  68486. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68487. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68488. protected _buildBlock(state: NodeMaterialBuildState): this;
  68489. protected _dumpPropertiesCode(): string;
  68490. serialize(): any;
  68491. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68492. }
  68493. }
  68494. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68495. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68500. /**
  68501. * Block used to implement the anisotropy module of the PBR material
  68502. */
  68503. export class AnisotropyBlock extends NodeMaterialBlock {
  68504. /**
  68505. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68506. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68507. * It's less burden on the user side in the editor part.
  68508. */
  68509. /** @hidden */
  68510. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68511. /** @hidden */
  68512. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68513. /**
  68514. * Create a new AnisotropyBlock
  68515. * @param name defines the block name
  68516. */
  68517. constructor(name: string);
  68518. /**
  68519. * Initialize the block and prepare the context for build
  68520. * @param state defines the state that will be used for the build
  68521. */
  68522. initialize(state: NodeMaterialBuildState): void;
  68523. /**
  68524. * Gets the current class name
  68525. * @returns the class name
  68526. */
  68527. getClassName(): string;
  68528. /**
  68529. * Gets the intensity input component
  68530. */
  68531. get intensity(): NodeMaterialConnectionPoint;
  68532. /**
  68533. * Gets the direction input component
  68534. */
  68535. get direction(): NodeMaterialConnectionPoint;
  68536. /**
  68537. * Gets the texture input component
  68538. */
  68539. get texture(): NodeMaterialConnectionPoint;
  68540. /**
  68541. * Gets the uv input component
  68542. */
  68543. get uv(): NodeMaterialConnectionPoint;
  68544. /**
  68545. * Gets the worldTangent input component
  68546. */
  68547. get worldTangent(): NodeMaterialConnectionPoint;
  68548. /**
  68549. * Gets the anisotropy object output component
  68550. */
  68551. get anisotropy(): NodeMaterialConnectionPoint;
  68552. private _generateTBNSpace;
  68553. /**
  68554. * Gets the main code of the block (fragment side)
  68555. * @param state current state of the node material building
  68556. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68557. * @returns the shader code
  68558. */
  68559. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68560. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68561. protected _buildBlock(state: NodeMaterialBuildState): this;
  68562. }
  68563. }
  68564. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68566. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68568. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68570. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68571. import { Nullable } from "babylonjs/types";
  68572. import { Mesh } from "babylonjs/Meshes/mesh";
  68573. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68574. import { Effect } from "babylonjs/Materials/effect";
  68575. /**
  68576. * Block used to implement the clear coat module of the PBR material
  68577. */
  68578. export class ClearCoatBlock extends NodeMaterialBlock {
  68579. private _scene;
  68580. /**
  68581. * Create a new ClearCoatBlock
  68582. * @param name defines the block name
  68583. */
  68584. constructor(name: string);
  68585. /**
  68586. * Initialize the block and prepare the context for build
  68587. * @param state defines the state that will be used for the build
  68588. */
  68589. initialize(state: NodeMaterialBuildState): void;
  68590. /**
  68591. * Gets the current class name
  68592. * @returns the class name
  68593. */
  68594. getClassName(): string;
  68595. /**
  68596. * Gets the intensity input component
  68597. */
  68598. get intensity(): NodeMaterialConnectionPoint;
  68599. /**
  68600. * Gets the roughness input component
  68601. */
  68602. get roughness(): NodeMaterialConnectionPoint;
  68603. /**
  68604. * Gets the ior input component
  68605. */
  68606. get ior(): NodeMaterialConnectionPoint;
  68607. /**
  68608. * Gets the texture input component
  68609. */
  68610. get texture(): NodeMaterialConnectionPoint;
  68611. /**
  68612. * Gets the bump texture input component
  68613. */
  68614. get bumpTexture(): NodeMaterialConnectionPoint;
  68615. /**
  68616. * Gets the uv input component
  68617. */
  68618. get uv(): NodeMaterialConnectionPoint;
  68619. /**
  68620. * Gets the tint color input component
  68621. */
  68622. get tintColor(): NodeMaterialConnectionPoint;
  68623. /**
  68624. * Gets the tint "at distance" input component
  68625. */
  68626. get tintAtDistance(): NodeMaterialConnectionPoint;
  68627. /**
  68628. * Gets the tint thickness input component
  68629. */
  68630. get tintThickness(): NodeMaterialConnectionPoint;
  68631. /**
  68632. * Gets the world tangent input component
  68633. */
  68634. get worldTangent(): NodeMaterialConnectionPoint;
  68635. /**
  68636. * Gets the clear coat object output component
  68637. */
  68638. get clearcoat(): NodeMaterialConnectionPoint;
  68639. autoConfigure(material: NodeMaterial): void;
  68640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68642. private _generateTBNSpace;
  68643. /**
  68644. * Gets the main code of the block (fragment side)
  68645. * @param state current state of the node material building
  68646. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68647. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68648. * @param worldPosVarName name of the variable holding the world position
  68649. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68650. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68651. * @param worldNormalVarName name of the variable holding the world normal
  68652. * @returns the shader code
  68653. */
  68654. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68655. protected _buildBlock(state: NodeMaterialBuildState): this;
  68656. }
  68657. }
  68658. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68662. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68664. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68665. import { Nullable } from "babylonjs/types";
  68666. /**
  68667. * Block used to implement the sub surface module of the PBR material
  68668. */
  68669. export class SubSurfaceBlock extends NodeMaterialBlock {
  68670. /**
  68671. * Create a new SubSurfaceBlock
  68672. * @param name defines the block name
  68673. */
  68674. constructor(name: string);
  68675. /**
  68676. * Stores the intensity of the different subsurface effects in the thickness texture.
  68677. * * the green channel is the translucency intensity.
  68678. * * the blue channel is the scattering intensity.
  68679. * * the alpha channel is the refraction intensity.
  68680. */
  68681. useMaskFromThicknessTexture: boolean;
  68682. /**
  68683. * Initialize the block and prepare the context for build
  68684. * @param state defines the state that will be used for the build
  68685. */
  68686. initialize(state: NodeMaterialBuildState): void;
  68687. /**
  68688. * Gets the current class name
  68689. * @returns the class name
  68690. */
  68691. getClassName(): string;
  68692. /**
  68693. * Gets the min thickness input component
  68694. */
  68695. get minThickness(): NodeMaterialConnectionPoint;
  68696. /**
  68697. * Gets the max thickness input component
  68698. */
  68699. get maxThickness(): NodeMaterialConnectionPoint;
  68700. /**
  68701. * Gets the thickness texture component
  68702. */
  68703. get thicknessTexture(): NodeMaterialConnectionPoint;
  68704. /**
  68705. * Gets the tint color input component
  68706. */
  68707. get tintColor(): NodeMaterialConnectionPoint;
  68708. /**
  68709. * Gets the translucency intensity input component
  68710. */
  68711. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68712. /**
  68713. * Gets the translucency diffusion distance input component
  68714. */
  68715. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68716. /**
  68717. * Gets the refraction object parameters
  68718. */
  68719. get refraction(): NodeMaterialConnectionPoint;
  68720. /**
  68721. * Gets the sub surface object output component
  68722. */
  68723. get subsurface(): NodeMaterialConnectionPoint;
  68724. autoConfigure(material: NodeMaterial): void;
  68725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68726. /**
  68727. * Gets the main code of the block (fragment side)
  68728. * @param state current state of the node material building
  68729. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68730. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68731. * @param worldPosVarName name of the variable holding the world position
  68732. * @returns the shader code
  68733. */
  68734. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68735. protected _buildBlock(state: NodeMaterialBuildState): this;
  68736. }
  68737. }
  68738. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68740. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68741. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68742. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68743. import { Light } from "babylonjs/Lights/light";
  68744. import { Nullable } from "babylonjs/types";
  68745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68746. import { Effect } from "babylonjs/Materials/effect";
  68747. import { Mesh } from "babylonjs/Meshes/mesh";
  68748. import { Scene } from "babylonjs/scene";
  68749. /**
  68750. * Block used to implement the PBR metallic/roughness model
  68751. */
  68752. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68753. /**
  68754. * Gets or sets the light associated with this block
  68755. */
  68756. light: Nullable<Light>;
  68757. private _lightId;
  68758. private _scene;
  68759. private _environmentBRDFTexture;
  68760. private _environmentBrdfSamplerName;
  68761. private _vNormalWName;
  68762. private _invertNormalName;
  68763. /**
  68764. * Create a new ReflectionBlock
  68765. * @param name defines the block name
  68766. */
  68767. constructor(name: string);
  68768. /**
  68769. * Intensity of the direct lights e.g. the four lights available in your scene.
  68770. * This impacts both the direct diffuse and specular highlights.
  68771. */
  68772. directIntensity: number;
  68773. /**
  68774. * Intensity of the environment e.g. how much the environment will light the object
  68775. * either through harmonics for rough material or through the refelction for shiny ones.
  68776. */
  68777. environmentIntensity: number;
  68778. /**
  68779. * This is a special control allowing the reduction of the specular highlights coming from the
  68780. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68781. */
  68782. specularIntensity: number;
  68783. /**
  68784. * Defines the falloff type used in this material.
  68785. * It by default is Physical.
  68786. */
  68787. lightFalloff: number;
  68788. /**
  68789. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68790. */
  68791. useAlphaFromAlbedoTexture: boolean;
  68792. /**
  68793. * Specifies that alpha test should be used
  68794. */
  68795. useAlphaTest: boolean;
  68796. /**
  68797. * Defines the alpha limits in alpha test mode.
  68798. */
  68799. alphaTestCutoff: number;
  68800. /**
  68801. * Specifies that alpha blending should be used
  68802. */
  68803. useAlphaBlending: boolean;
  68804. /**
  68805. * Defines if the alpha value should be determined via the rgb values.
  68806. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68807. */
  68808. opacityRGB: boolean;
  68809. /**
  68810. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68811. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68812. */
  68813. useRadianceOverAlpha: boolean;
  68814. /**
  68815. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68816. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68817. */
  68818. useSpecularOverAlpha: boolean;
  68819. /**
  68820. * Enables specular anti aliasing in the PBR shader.
  68821. * It will both interacts on the Geometry for analytical and IBL lighting.
  68822. * It also prefilter the roughness map based on the bump values.
  68823. */
  68824. enableSpecularAntiAliasing: boolean;
  68825. /**
  68826. * Enables realtime filtering on the texture.
  68827. */
  68828. realTimeFiltering: boolean;
  68829. /**
  68830. * Quality switch for realtime filtering
  68831. */
  68832. realTimeFilteringQuality: number;
  68833. /**
  68834. * Defines if the material uses energy conservation.
  68835. */
  68836. useEnergyConservation: boolean;
  68837. /**
  68838. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68839. * too much the area relying on ambient texture to define their ambient occlusion.
  68840. */
  68841. useRadianceOcclusion: boolean;
  68842. /**
  68843. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68844. * makes the reflect vector face the model (under horizon).
  68845. */
  68846. useHorizonOcclusion: boolean;
  68847. /**
  68848. * If set to true, no lighting calculations will be applied.
  68849. */
  68850. unlit: boolean;
  68851. /**
  68852. * Force normal to face away from face.
  68853. */
  68854. forceNormalForward: boolean;
  68855. /**
  68856. * Defines the material debug mode.
  68857. * It helps seeing only some components of the material while troubleshooting.
  68858. */
  68859. debugMode: number;
  68860. /**
  68861. * Specify from where on screen the debug mode should start.
  68862. * The value goes from -1 (full screen) to 1 (not visible)
  68863. * It helps with side by side comparison against the final render
  68864. * This defaults to 0
  68865. */
  68866. debugLimit: number;
  68867. /**
  68868. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68869. * You can use the factor to better multiply the final value.
  68870. */
  68871. debugFactor: number;
  68872. /**
  68873. * Initialize the block and prepare the context for build
  68874. * @param state defines the state that will be used for the build
  68875. */
  68876. initialize(state: NodeMaterialBuildState): void;
  68877. /**
  68878. * Gets the current class name
  68879. * @returns the class name
  68880. */
  68881. getClassName(): string;
  68882. /**
  68883. * Gets the world position input component
  68884. */
  68885. get worldPosition(): NodeMaterialConnectionPoint;
  68886. /**
  68887. * Gets the world normal input component
  68888. */
  68889. get worldNormal(): NodeMaterialConnectionPoint;
  68890. /**
  68891. * Gets the perturbed normal input component
  68892. */
  68893. get perturbedNormal(): NodeMaterialConnectionPoint;
  68894. /**
  68895. * Gets the camera position input component
  68896. */
  68897. get cameraPosition(): NodeMaterialConnectionPoint;
  68898. /**
  68899. * Gets the base color input component
  68900. */
  68901. get baseColor(): NodeMaterialConnectionPoint;
  68902. /**
  68903. * Gets the opacity texture input component
  68904. */
  68905. get opacityTexture(): NodeMaterialConnectionPoint;
  68906. /**
  68907. * Gets the ambient color input component
  68908. */
  68909. get ambientColor(): NodeMaterialConnectionPoint;
  68910. /**
  68911. * Gets the reflectivity object parameters
  68912. */
  68913. get reflectivity(): NodeMaterialConnectionPoint;
  68914. /**
  68915. * Gets the ambient occlusion object parameters
  68916. */
  68917. get ambientOcc(): NodeMaterialConnectionPoint;
  68918. /**
  68919. * Gets the reflection object parameters
  68920. */
  68921. get reflection(): NodeMaterialConnectionPoint;
  68922. /**
  68923. * Gets the sheen object parameters
  68924. */
  68925. get sheen(): NodeMaterialConnectionPoint;
  68926. /**
  68927. * Gets the clear coat object parameters
  68928. */
  68929. get clearcoat(): NodeMaterialConnectionPoint;
  68930. /**
  68931. * Gets the sub surface object parameters
  68932. */
  68933. get subsurface(): NodeMaterialConnectionPoint;
  68934. /**
  68935. * Gets the anisotropy object parameters
  68936. */
  68937. get anisotropy(): NodeMaterialConnectionPoint;
  68938. /**
  68939. * Gets the ambient output component
  68940. */
  68941. get ambient(): NodeMaterialConnectionPoint;
  68942. /**
  68943. * Gets the diffuse output component
  68944. */
  68945. get diffuse(): NodeMaterialConnectionPoint;
  68946. /**
  68947. * Gets the specular output component
  68948. */
  68949. get specular(): NodeMaterialConnectionPoint;
  68950. /**
  68951. * Gets the sheen output component
  68952. */
  68953. get sheenDir(): NodeMaterialConnectionPoint;
  68954. /**
  68955. * Gets the clear coat output component
  68956. */
  68957. get clearcoatDir(): NodeMaterialConnectionPoint;
  68958. /**
  68959. * Gets the indirect diffuse output component
  68960. */
  68961. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68962. /**
  68963. * Gets the indirect specular output component
  68964. */
  68965. get specularIndirect(): NodeMaterialConnectionPoint;
  68966. /**
  68967. * Gets the indirect sheen output component
  68968. */
  68969. get sheenIndirect(): NodeMaterialConnectionPoint;
  68970. /**
  68971. * Gets the indirect clear coat output component
  68972. */
  68973. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68974. /**
  68975. * Gets the refraction output component
  68976. */
  68977. get refraction(): NodeMaterialConnectionPoint;
  68978. /**
  68979. * Gets the global lighting output component
  68980. */
  68981. get lighting(): NodeMaterialConnectionPoint;
  68982. /**
  68983. * Gets the shadow output component
  68984. */
  68985. get shadow(): NodeMaterialConnectionPoint;
  68986. /**
  68987. * Gets the alpha output component
  68988. */
  68989. get alpha(): NodeMaterialConnectionPoint;
  68990. autoConfigure(material: NodeMaterial): void;
  68991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68992. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68993. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68994. private _injectVertexCode;
  68995. /**
  68996. * Gets the code corresponding to the albedo/opacity module
  68997. * @returns the shader code
  68998. */
  68999. getAlbedoOpacityCode(): string;
  69000. protected _buildBlock(state: NodeMaterialBuildState): this;
  69001. protected _dumpPropertiesCode(): string;
  69002. serialize(): any;
  69003. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69004. }
  69005. }
  69006. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69007. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69008. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69009. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  69010. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  69011. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69012. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69013. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69014. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69015. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69016. }
  69017. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69018. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69019. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69020. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69021. }
  69022. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69024. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69025. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69026. /**
  69027. * Block used to compute value of one parameter modulo another
  69028. */
  69029. export class ModBlock extends NodeMaterialBlock {
  69030. /**
  69031. * Creates a new ModBlock
  69032. * @param name defines the block name
  69033. */
  69034. constructor(name: string);
  69035. /**
  69036. * Gets the current class name
  69037. * @returns the class name
  69038. */
  69039. getClassName(): string;
  69040. /**
  69041. * Gets the left operand input component
  69042. */
  69043. get left(): NodeMaterialConnectionPoint;
  69044. /**
  69045. * Gets the right operand input component
  69046. */
  69047. get right(): NodeMaterialConnectionPoint;
  69048. /**
  69049. * Gets the output component
  69050. */
  69051. get output(): NodeMaterialConnectionPoint;
  69052. protected _buildBlock(state: NodeMaterialBuildState): this;
  69053. }
  69054. }
  69055. declare module "babylonjs/Materials/Node/Blocks/index" {
  69056. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69057. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69058. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69059. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69060. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69061. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69062. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69063. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69064. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69065. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69066. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69067. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69068. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69069. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69070. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69071. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69072. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69073. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69074. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69075. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69076. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69077. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69078. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69079. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69080. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69081. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69082. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69083. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69084. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69085. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69086. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69087. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69088. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69089. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69090. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69091. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69092. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69093. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69094. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69095. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69096. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69097. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69098. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69099. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69100. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69101. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69102. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69103. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69104. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69105. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69106. }
  69107. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69108. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69109. }
  69110. declare module "babylonjs/Materials/Node/index" {
  69111. export * from "babylonjs/Materials/Node/Enums/index";
  69112. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69113. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69114. export * from "babylonjs/Materials/Node/nodeMaterial";
  69115. export * from "babylonjs/Materials/Node/Blocks/index";
  69116. export * from "babylonjs/Materials/Node/Optimizers/index";
  69117. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69118. }
  69119. declare module "babylonjs/Materials/index" {
  69120. export * from "babylonjs/Materials/Background/index";
  69121. export * from "babylonjs/Materials/colorCurves";
  69122. export * from "babylonjs/Materials/iEffectFallbacks";
  69123. export * from "babylonjs/Materials/effectFallbacks";
  69124. export * from "babylonjs/Materials/effect";
  69125. export * from "babylonjs/Materials/fresnelParameters";
  69126. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69127. export * from "babylonjs/Materials/material";
  69128. export * from "babylonjs/Materials/materialDefines";
  69129. export * from "babylonjs/Materials/thinMaterialHelper";
  69130. export * from "babylonjs/Materials/materialHelper";
  69131. export * from "babylonjs/Materials/multiMaterial";
  69132. export * from "babylonjs/Materials/PBR/index";
  69133. export * from "babylonjs/Materials/pushMaterial";
  69134. export * from "babylonjs/Materials/shaderMaterial";
  69135. export * from "babylonjs/Materials/standardMaterial";
  69136. export * from "babylonjs/Materials/Textures/index";
  69137. export * from "babylonjs/Materials/uniformBuffer";
  69138. export * from "babylonjs/Materials/materialFlags";
  69139. export * from "babylonjs/Materials/Node/index";
  69140. export * from "babylonjs/Materials/effectRenderer";
  69141. export * from "babylonjs/Materials/shadowDepthWrapper";
  69142. }
  69143. declare module "babylonjs/Maths/index" {
  69144. export * from "babylonjs/Maths/math.scalar";
  69145. export * from "babylonjs/Maths/math";
  69146. export * from "babylonjs/Maths/sphericalPolynomial";
  69147. }
  69148. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69149. import { IDisposable } from "babylonjs/scene";
  69150. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69151. /**
  69152. * Configuration for Draco compression
  69153. */
  69154. export interface IDracoCompressionConfiguration {
  69155. /**
  69156. * Configuration for the decoder.
  69157. */
  69158. decoder: {
  69159. /**
  69160. * The url to the WebAssembly module.
  69161. */
  69162. wasmUrl?: string;
  69163. /**
  69164. * The url to the WebAssembly binary.
  69165. */
  69166. wasmBinaryUrl?: string;
  69167. /**
  69168. * The url to the fallback JavaScript module.
  69169. */
  69170. fallbackUrl?: string;
  69171. };
  69172. }
  69173. /**
  69174. * Draco compression (https://google.github.io/draco/)
  69175. *
  69176. * This class wraps the Draco module.
  69177. *
  69178. * **Encoder**
  69179. *
  69180. * The encoder is not currently implemented.
  69181. *
  69182. * **Decoder**
  69183. *
  69184. * 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.
  69185. *
  69186. * To update the configuration, use the following code:
  69187. * ```javascript
  69188. * DracoCompression.Configuration = {
  69189. * decoder: {
  69190. * wasmUrl: "<url to the WebAssembly library>",
  69191. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69192. * fallbackUrl: "<url to the fallback JavaScript library>",
  69193. * }
  69194. * };
  69195. * ```
  69196. *
  69197. * 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.
  69198. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69199. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69200. *
  69201. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69202. * ```javascript
  69203. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69204. * ```
  69205. *
  69206. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69207. */
  69208. export class DracoCompression implements IDisposable {
  69209. private _workerPoolPromise?;
  69210. private _decoderModulePromise?;
  69211. /**
  69212. * The configuration. Defaults to the following urls:
  69213. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69214. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69215. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69216. */
  69217. static Configuration: IDracoCompressionConfiguration;
  69218. /**
  69219. * Returns true if the decoder configuration is available.
  69220. */
  69221. static get DecoderAvailable(): boolean;
  69222. /**
  69223. * Default number of workers to create when creating the draco compression object.
  69224. */
  69225. static DefaultNumWorkers: number;
  69226. private static GetDefaultNumWorkers;
  69227. private static _Default;
  69228. /**
  69229. * Default instance for the draco compression object.
  69230. */
  69231. static get Default(): DracoCompression;
  69232. /**
  69233. * Constructor
  69234. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69235. */
  69236. constructor(numWorkers?: number);
  69237. /**
  69238. * Stop all async operations and release resources.
  69239. */
  69240. dispose(): void;
  69241. /**
  69242. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69243. * @returns a promise that resolves when ready
  69244. */
  69245. whenReadyAsync(): Promise<void>;
  69246. /**
  69247. * Decode Draco compressed mesh data to vertex data.
  69248. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69249. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69250. * @returns A promise that resolves with the decoded vertex data
  69251. */
  69252. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69253. [kind: string]: number;
  69254. }): Promise<VertexData>;
  69255. }
  69256. }
  69257. declare module "babylonjs/Meshes/Compression/index" {
  69258. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69259. }
  69260. declare module "babylonjs/Meshes/csg" {
  69261. import { Nullable } from "babylonjs/types";
  69262. import { Scene } from "babylonjs/scene";
  69263. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69264. import { Mesh } from "babylonjs/Meshes/mesh";
  69265. import { Material } from "babylonjs/Materials/material";
  69266. /**
  69267. * Class for building Constructive Solid Geometry
  69268. */
  69269. export class CSG {
  69270. private polygons;
  69271. /**
  69272. * The world matrix
  69273. */
  69274. matrix: Matrix;
  69275. /**
  69276. * Stores the position
  69277. */
  69278. position: Vector3;
  69279. /**
  69280. * Stores the rotation
  69281. */
  69282. rotation: Vector3;
  69283. /**
  69284. * Stores the rotation quaternion
  69285. */
  69286. rotationQuaternion: Nullable<Quaternion>;
  69287. /**
  69288. * Stores the scaling vector
  69289. */
  69290. scaling: Vector3;
  69291. /**
  69292. * Convert the Mesh to CSG
  69293. * @param mesh The Mesh to convert to CSG
  69294. * @returns A new CSG from the Mesh
  69295. */
  69296. static FromMesh(mesh: Mesh): CSG;
  69297. /**
  69298. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69299. * @param polygons Polygons used to construct a CSG solid
  69300. */
  69301. private static FromPolygons;
  69302. /**
  69303. * Clones, or makes a deep copy, of the CSG
  69304. * @returns A new CSG
  69305. */
  69306. clone(): CSG;
  69307. /**
  69308. * Unions this CSG with another CSG
  69309. * @param csg The CSG to union against this CSG
  69310. * @returns The unioned CSG
  69311. */
  69312. union(csg: CSG): CSG;
  69313. /**
  69314. * Unions this CSG with another CSG in place
  69315. * @param csg The CSG to union against this CSG
  69316. */
  69317. unionInPlace(csg: CSG): void;
  69318. /**
  69319. * Subtracts this CSG with another CSG
  69320. * @param csg The CSG to subtract against this CSG
  69321. * @returns A new CSG
  69322. */
  69323. subtract(csg: CSG): CSG;
  69324. /**
  69325. * Subtracts this CSG with another CSG in place
  69326. * @param csg The CSG to subtact against this CSG
  69327. */
  69328. subtractInPlace(csg: CSG): void;
  69329. /**
  69330. * Intersect this CSG with another CSG
  69331. * @param csg The CSG to intersect against this CSG
  69332. * @returns A new CSG
  69333. */
  69334. intersect(csg: CSG): CSG;
  69335. /**
  69336. * Intersects this CSG with another CSG in place
  69337. * @param csg The CSG to intersect against this CSG
  69338. */
  69339. intersectInPlace(csg: CSG): void;
  69340. /**
  69341. * Return a new CSG solid with solid and empty space switched. This solid is
  69342. * not modified.
  69343. * @returns A new CSG solid with solid and empty space switched
  69344. */
  69345. inverse(): CSG;
  69346. /**
  69347. * Inverses the CSG in place
  69348. */
  69349. inverseInPlace(): void;
  69350. /**
  69351. * This is used to keep meshes transformations so they can be restored
  69352. * when we build back a Babylon Mesh
  69353. * NB : All CSG operations are performed in world coordinates
  69354. * @param csg The CSG to copy the transform attributes from
  69355. * @returns This CSG
  69356. */
  69357. copyTransformAttributes(csg: CSG): CSG;
  69358. /**
  69359. * Build Raw mesh from CSG
  69360. * Coordinates here are in world space
  69361. * @param name The name of the mesh geometry
  69362. * @param scene The Scene
  69363. * @param keepSubMeshes Specifies if the submeshes should be kept
  69364. * @returns A new Mesh
  69365. */
  69366. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69367. /**
  69368. * Build Mesh from CSG taking material and transforms into account
  69369. * @param name The name of the Mesh
  69370. * @param material The material of the Mesh
  69371. * @param scene The Scene
  69372. * @param keepSubMeshes Specifies if submeshes should be kept
  69373. * @returns The new Mesh
  69374. */
  69375. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69376. }
  69377. }
  69378. declare module "babylonjs/Meshes/trailMesh" {
  69379. import { Mesh } from "babylonjs/Meshes/mesh";
  69380. import { Scene } from "babylonjs/scene";
  69381. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69382. /**
  69383. * Class used to create a trail following a mesh
  69384. */
  69385. export class TrailMesh extends Mesh {
  69386. private _generator;
  69387. private _autoStart;
  69388. private _running;
  69389. private _diameter;
  69390. private _length;
  69391. private _sectionPolygonPointsCount;
  69392. private _sectionVectors;
  69393. private _sectionNormalVectors;
  69394. private _beforeRenderObserver;
  69395. /**
  69396. * @constructor
  69397. * @param name The value used by scene.getMeshByName() to do a lookup.
  69398. * @param generator The mesh or transform node to generate a trail.
  69399. * @param scene The scene to add this mesh to.
  69400. * @param diameter Diameter of trailing mesh. Default is 1.
  69401. * @param length Length of trailing mesh. Default is 60.
  69402. * @param autoStart Automatically start trailing mesh. Default true.
  69403. */
  69404. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69405. /**
  69406. * "TrailMesh"
  69407. * @returns "TrailMesh"
  69408. */
  69409. getClassName(): string;
  69410. private _createMesh;
  69411. /**
  69412. * Start trailing mesh.
  69413. */
  69414. start(): void;
  69415. /**
  69416. * Stop trailing mesh.
  69417. */
  69418. stop(): void;
  69419. /**
  69420. * Update trailing mesh geometry.
  69421. */
  69422. update(): void;
  69423. /**
  69424. * Returns a new TrailMesh object.
  69425. * @param name is a string, the name given to the new mesh
  69426. * @param newGenerator use new generator object for cloned trail mesh
  69427. * @returns a new mesh
  69428. */
  69429. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69430. /**
  69431. * Serializes this trail mesh
  69432. * @param serializationObject object to write serialization to
  69433. */
  69434. serialize(serializationObject: any): void;
  69435. /**
  69436. * Parses a serialized trail mesh
  69437. * @param parsedMesh the serialized mesh
  69438. * @param scene the scene to create the trail mesh in
  69439. * @returns the created trail mesh
  69440. */
  69441. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69442. }
  69443. }
  69444. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69445. import { Nullable } from "babylonjs/types";
  69446. import { Scene } from "babylonjs/scene";
  69447. import { Vector4 } from "babylonjs/Maths/math.vector";
  69448. import { Color4 } from "babylonjs/Maths/math.color";
  69449. import { Mesh } from "babylonjs/Meshes/mesh";
  69450. /**
  69451. * Class containing static functions to help procedurally build meshes
  69452. */
  69453. export class TiledBoxBuilder {
  69454. /**
  69455. * Creates a box mesh
  69456. * 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)
  69457. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69461. * @param name defines the name of the mesh
  69462. * @param options defines the options used to create the mesh
  69463. * @param scene defines the hosting scene
  69464. * @returns the box mesh
  69465. */
  69466. static CreateTiledBox(name: string, options: {
  69467. pattern?: number;
  69468. width?: number;
  69469. height?: number;
  69470. depth?: number;
  69471. tileSize?: number;
  69472. tileWidth?: number;
  69473. tileHeight?: number;
  69474. alignHorizontal?: number;
  69475. alignVertical?: number;
  69476. faceUV?: Vector4[];
  69477. faceColors?: Color4[];
  69478. sideOrientation?: number;
  69479. updatable?: boolean;
  69480. }, scene?: Nullable<Scene>): Mesh;
  69481. }
  69482. }
  69483. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69484. import { Vector4 } from "babylonjs/Maths/math.vector";
  69485. import { Mesh } from "babylonjs/Meshes/mesh";
  69486. /**
  69487. * Class containing static functions to help procedurally build meshes
  69488. */
  69489. export class TorusKnotBuilder {
  69490. /**
  69491. * Creates a torus knot mesh
  69492. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69493. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69494. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69495. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69499. * @param name defines the name of the mesh
  69500. * @param options defines the options used to create the mesh
  69501. * @param scene defines the hosting scene
  69502. * @returns the torus knot mesh
  69503. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69504. */
  69505. static CreateTorusKnot(name: string, options: {
  69506. radius?: number;
  69507. tube?: number;
  69508. radialSegments?: number;
  69509. tubularSegments?: number;
  69510. p?: number;
  69511. q?: number;
  69512. updatable?: boolean;
  69513. sideOrientation?: number;
  69514. frontUVs?: Vector4;
  69515. backUVs?: Vector4;
  69516. }, scene: any): Mesh;
  69517. }
  69518. }
  69519. declare module "babylonjs/Meshes/polygonMesh" {
  69520. import { Scene } from "babylonjs/scene";
  69521. import { Vector2 } from "babylonjs/Maths/math.vector";
  69522. import { Mesh } from "babylonjs/Meshes/mesh";
  69523. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69524. import { Path2 } from "babylonjs/Maths/math.path";
  69525. /**
  69526. * Polygon
  69527. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69528. */
  69529. export class Polygon {
  69530. /**
  69531. * Creates a rectangle
  69532. * @param xmin bottom X coord
  69533. * @param ymin bottom Y coord
  69534. * @param xmax top X coord
  69535. * @param ymax top Y coord
  69536. * @returns points that make the resulting rectation
  69537. */
  69538. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69539. /**
  69540. * Creates a circle
  69541. * @param radius radius of circle
  69542. * @param cx scale in x
  69543. * @param cy scale in y
  69544. * @param numberOfSides number of sides that make up the circle
  69545. * @returns points that make the resulting circle
  69546. */
  69547. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69548. /**
  69549. * Creates a polygon from input string
  69550. * @param input Input polygon data
  69551. * @returns the parsed points
  69552. */
  69553. static Parse(input: string): Vector2[];
  69554. /**
  69555. * Starts building a polygon from x and y coordinates
  69556. * @param x x coordinate
  69557. * @param y y coordinate
  69558. * @returns the started path2
  69559. */
  69560. static StartingAt(x: number, y: number): Path2;
  69561. }
  69562. /**
  69563. * Builds a polygon
  69564. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69565. */
  69566. export class PolygonMeshBuilder {
  69567. private _points;
  69568. private _outlinepoints;
  69569. private _holes;
  69570. private _name;
  69571. private _scene;
  69572. private _epoints;
  69573. private _eholes;
  69574. private _addToepoint;
  69575. /**
  69576. * Babylon reference to the earcut plugin.
  69577. */
  69578. bjsEarcut: any;
  69579. /**
  69580. * Creates a PolygonMeshBuilder
  69581. * @param name name of the builder
  69582. * @param contours Path of the polygon
  69583. * @param scene scene to add to when creating the mesh
  69584. * @param earcutInjection can be used to inject your own earcut reference
  69585. */
  69586. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69587. /**
  69588. * Adds a whole within the polygon
  69589. * @param hole Array of points defining the hole
  69590. * @returns this
  69591. */
  69592. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69593. /**
  69594. * Creates the polygon
  69595. * @param updatable If the mesh should be updatable
  69596. * @param depth The depth of the mesh created
  69597. * @returns the created mesh
  69598. */
  69599. build(updatable?: boolean, depth?: number): Mesh;
  69600. /**
  69601. * Creates the polygon
  69602. * @param depth The depth of the mesh created
  69603. * @returns the created VertexData
  69604. */
  69605. buildVertexData(depth?: number): VertexData;
  69606. /**
  69607. * Adds a side to the polygon
  69608. * @param positions points that make the polygon
  69609. * @param normals normals of the polygon
  69610. * @param uvs uvs of the polygon
  69611. * @param indices indices of the polygon
  69612. * @param bounds bounds of the polygon
  69613. * @param points points of the polygon
  69614. * @param depth depth of the polygon
  69615. * @param flip flip of the polygon
  69616. */
  69617. private addSide;
  69618. }
  69619. }
  69620. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69621. import { Scene } from "babylonjs/scene";
  69622. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69623. import { Color4 } from "babylonjs/Maths/math.color";
  69624. import { Mesh } from "babylonjs/Meshes/mesh";
  69625. import { Nullable } from "babylonjs/types";
  69626. /**
  69627. * Class containing static functions to help procedurally build meshes
  69628. */
  69629. export class PolygonBuilder {
  69630. /**
  69631. * Creates a polygon mesh
  69632. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69633. * * 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
  69634. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69637. * * Remember you can only change the shape positions, not their number when updating a polygon
  69638. * @param name defines the name of the mesh
  69639. * @param options defines the options used to create the mesh
  69640. * @param scene defines the hosting scene
  69641. * @param earcutInjection can be used to inject your own earcut reference
  69642. * @returns the polygon mesh
  69643. */
  69644. static CreatePolygon(name: string, options: {
  69645. shape: Vector3[];
  69646. holes?: Vector3[][];
  69647. depth?: number;
  69648. faceUV?: Vector4[];
  69649. faceColors?: Color4[];
  69650. updatable?: boolean;
  69651. sideOrientation?: number;
  69652. frontUVs?: Vector4;
  69653. backUVs?: Vector4;
  69654. wrap?: boolean;
  69655. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69656. /**
  69657. * Creates an extruded polygon mesh, with depth in the Y direction.
  69658. * * 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)
  69659. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69660. * @param name defines the name of the mesh
  69661. * @param options defines the options used to create the mesh
  69662. * @param scene defines the hosting scene
  69663. * @param earcutInjection can be used to inject your own earcut reference
  69664. * @returns the polygon mesh
  69665. */
  69666. static ExtrudePolygon(name: string, options: {
  69667. shape: Vector3[];
  69668. holes?: Vector3[][];
  69669. depth?: number;
  69670. faceUV?: Vector4[];
  69671. faceColors?: Color4[];
  69672. updatable?: boolean;
  69673. sideOrientation?: number;
  69674. frontUVs?: Vector4;
  69675. backUVs?: Vector4;
  69676. wrap?: boolean;
  69677. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69678. }
  69679. }
  69680. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69681. import { Scene } from "babylonjs/scene";
  69682. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69683. import { Mesh } from "babylonjs/Meshes/mesh";
  69684. import { Nullable } from "babylonjs/types";
  69685. /**
  69686. * Class containing static functions to help procedurally build meshes
  69687. */
  69688. export class LatheBuilder {
  69689. /**
  69690. * Creates lathe mesh.
  69691. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69692. * * 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
  69693. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69694. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69695. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69696. * * 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
  69697. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69698. * * 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
  69699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69701. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69703. * @param name defines the name of the mesh
  69704. * @param options defines the options used to create the mesh
  69705. * @param scene defines the hosting scene
  69706. * @returns the lathe mesh
  69707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69708. */
  69709. static CreateLathe(name: string, options: {
  69710. shape: Vector3[];
  69711. radius?: number;
  69712. tessellation?: number;
  69713. clip?: number;
  69714. arc?: number;
  69715. closed?: boolean;
  69716. updatable?: boolean;
  69717. sideOrientation?: number;
  69718. frontUVs?: Vector4;
  69719. backUVs?: Vector4;
  69720. cap?: number;
  69721. invertUV?: boolean;
  69722. }, scene?: Nullable<Scene>): Mesh;
  69723. }
  69724. }
  69725. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69726. import { Nullable } from "babylonjs/types";
  69727. import { Scene } from "babylonjs/scene";
  69728. import { Vector4 } from "babylonjs/Maths/math.vector";
  69729. import { Mesh } from "babylonjs/Meshes/mesh";
  69730. /**
  69731. * Class containing static functions to help procedurally build meshes
  69732. */
  69733. export class TiledPlaneBuilder {
  69734. /**
  69735. * Creates a tiled plane mesh
  69736. * * The parameter `pattern` will, depending on value, do nothing or
  69737. * * * flip (reflect about central vertical) alternate tiles across and up
  69738. * * * flip every tile on alternate rows
  69739. * * * rotate (180 degs) alternate tiles across and up
  69740. * * * rotate every tile on alternate rows
  69741. * * * flip and rotate alternate tiles across and up
  69742. * * * flip and rotate every tile on alternate rows
  69743. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69744. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69746. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69747. * * 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)
  69748. * * 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)
  69749. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69750. * @param name defines the name of the mesh
  69751. * @param options defines the options used to create the mesh
  69752. * @param scene defines the hosting scene
  69753. * @returns the box mesh
  69754. */
  69755. static CreateTiledPlane(name: string, options: {
  69756. pattern?: number;
  69757. tileSize?: number;
  69758. tileWidth?: number;
  69759. tileHeight?: number;
  69760. size?: number;
  69761. width?: number;
  69762. height?: number;
  69763. alignHorizontal?: number;
  69764. alignVertical?: number;
  69765. sideOrientation?: number;
  69766. frontUVs?: Vector4;
  69767. backUVs?: Vector4;
  69768. updatable?: boolean;
  69769. }, scene?: Nullable<Scene>): Mesh;
  69770. }
  69771. }
  69772. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69773. import { Nullable } from "babylonjs/types";
  69774. import { Scene } from "babylonjs/scene";
  69775. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69776. import { Mesh } from "babylonjs/Meshes/mesh";
  69777. /**
  69778. * Class containing static functions to help procedurally build meshes
  69779. */
  69780. export class TubeBuilder {
  69781. /**
  69782. * Creates a tube mesh.
  69783. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69784. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69785. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69786. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69787. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69788. * * 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)
  69789. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69790. * * 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
  69791. * * 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
  69792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69793. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69794. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69796. * @param name defines the name of the mesh
  69797. * @param options defines the options used to create the mesh
  69798. * @param scene defines the hosting scene
  69799. * @returns the tube mesh
  69800. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69801. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69802. */
  69803. static CreateTube(name: string, options: {
  69804. path: Vector3[];
  69805. radius?: number;
  69806. tessellation?: number;
  69807. radiusFunction?: {
  69808. (i: number, distance: number): number;
  69809. };
  69810. cap?: number;
  69811. arc?: number;
  69812. updatable?: boolean;
  69813. sideOrientation?: number;
  69814. frontUVs?: Vector4;
  69815. backUVs?: Vector4;
  69816. instance?: Mesh;
  69817. invertUV?: boolean;
  69818. }, scene?: Nullable<Scene>): Mesh;
  69819. }
  69820. }
  69821. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69822. import { Scene } from "babylonjs/scene";
  69823. import { Vector4 } from "babylonjs/Maths/math.vector";
  69824. import { Mesh } from "babylonjs/Meshes/mesh";
  69825. import { Nullable } from "babylonjs/types";
  69826. /**
  69827. * Class containing static functions to help procedurally build meshes
  69828. */
  69829. export class IcoSphereBuilder {
  69830. /**
  69831. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69832. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69833. * * 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`)
  69834. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69835. * * 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
  69836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 icosahedron mesh
  69843. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69844. */
  69845. static CreateIcoSphere(name: string, options: {
  69846. radius?: number;
  69847. radiusX?: number;
  69848. radiusY?: number;
  69849. radiusZ?: number;
  69850. flat?: boolean;
  69851. subdivisions?: number;
  69852. sideOrientation?: number;
  69853. frontUVs?: Vector4;
  69854. backUVs?: Vector4;
  69855. updatable?: boolean;
  69856. }, scene?: Nullable<Scene>): Mesh;
  69857. }
  69858. }
  69859. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69860. import { Vector3 } from "babylonjs/Maths/math.vector";
  69861. import { Mesh } from "babylonjs/Meshes/mesh";
  69862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69863. /**
  69864. * Class containing static functions to help procedurally build meshes
  69865. */
  69866. export class DecalBuilder {
  69867. /**
  69868. * Creates a decal mesh.
  69869. * 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
  69870. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69871. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69872. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69873. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69874. * @param name defines the name of the mesh
  69875. * @param sourceMesh defines the mesh where the decal must be applied
  69876. * @param options defines the options used to create the mesh
  69877. * @param scene defines the hosting scene
  69878. * @returns the decal mesh
  69879. * @see https://doc.babylonjs.com/how_to/decals
  69880. */
  69881. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69882. position?: Vector3;
  69883. normal?: Vector3;
  69884. size?: Vector3;
  69885. angle?: number;
  69886. }): Mesh;
  69887. }
  69888. }
  69889. declare module "babylonjs/Meshes/meshBuilder" {
  69890. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69891. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69892. import { Nullable } from "babylonjs/types";
  69893. import { Scene } from "babylonjs/scene";
  69894. import { Mesh } from "babylonjs/Meshes/mesh";
  69895. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69896. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69898. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69899. import { Plane } from "babylonjs/Maths/math.plane";
  69900. /**
  69901. * Class containing static functions to help procedurally build meshes
  69902. */
  69903. export class MeshBuilder {
  69904. /**
  69905. * Creates a box mesh
  69906. * * The parameter `size` sets the size (float) of each box side (default 1)
  69907. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69908. * * 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)
  69909. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69913. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69914. * @param name defines the name of the mesh
  69915. * @param options defines the options used to create the mesh
  69916. * @param scene defines the hosting scene
  69917. * @returns the box mesh
  69918. */
  69919. static CreateBox(name: string, options: {
  69920. size?: number;
  69921. width?: number;
  69922. height?: number;
  69923. depth?: number;
  69924. faceUV?: Vector4[];
  69925. faceColors?: Color4[];
  69926. sideOrientation?: number;
  69927. frontUVs?: Vector4;
  69928. backUVs?: Vector4;
  69929. wrap?: boolean;
  69930. topBaseAt?: number;
  69931. bottomBaseAt?: number;
  69932. updatable?: boolean;
  69933. }, scene?: Nullable<Scene>): Mesh;
  69934. /**
  69935. * Creates a tiled box mesh
  69936. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69938. * @param name defines the name of the mesh
  69939. * @param options defines the options used to create the mesh
  69940. * @param scene defines the hosting scene
  69941. * @returns the tiled box mesh
  69942. */
  69943. static CreateTiledBox(name: string, options: {
  69944. pattern?: number;
  69945. size?: number;
  69946. width?: number;
  69947. height?: number;
  69948. depth: number;
  69949. tileSize?: number;
  69950. tileWidth?: number;
  69951. tileHeight?: number;
  69952. faceUV?: Vector4[];
  69953. faceColors?: Color4[];
  69954. alignHorizontal?: number;
  69955. alignVertical?: number;
  69956. sideOrientation?: number;
  69957. updatable?: boolean;
  69958. }, scene?: Nullable<Scene>): Mesh;
  69959. /**
  69960. * Creates a sphere mesh
  69961. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69962. * * 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`)
  69963. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69964. * * 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
  69965. * * 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)
  69966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69969. * @param name defines the name of the mesh
  69970. * @param options defines the options used to create the mesh
  69971. * @param scene defines the hosting scene
  69972. * @returns the sphere mesh
  69973. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69974. */
  69975. static CreateSphere(name: string, options: {
  69976. segments?: number;
  69977. diameter?: number;
  69978. diameterX?: number;
  69979. diameterY?: number;
  69980. diameterZ?: number;
  69981. arc?: number;
  69982. slice?: number;
  69983. sideOrientation?: number;
  69984. frontUVs?: Vector4;
  69985. backUVs?: Vector4;
  69986. updatable?: boolean;
  69987. }, scene?: Nullable<Scene>): Mesh;
  69988. /**
  69989. * Creates a plane polygonal mesh. By default, this is a disc
  69990. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69991. * * 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
  69992. * * 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
  69993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69996. * @param name defines the name of the mesh
  69997. * @param options defines the options used to create the mesh
  69998. * @param scene defines the hosting scene
  69999. * @returns the plane polygonal mesh
  70000. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70001. */
  70002. static CreateDisc(name: string, options: {
  70003. radius?: number;
  70004. tessellation?: number;
  70005. arc?: number;
  70006. updatable?: boolean;
  70007. sideOrientation?: number;
  70008. frontUVs?: Vector4;
  70009. backUVs?: Vector4;
  70010. }, scene?: Nullable<Scene>): Mesh;
  70011. /**
  70012. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70013. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70014. * * 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`)
  70015. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70016. * * 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
  70017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70020. * @param name defines the name of the mesh
  70021. * @param options defines the options used to create the mesh
  70022. * @param scene defines the hosting scene
  70023. * @returns the icosahedron mesh
  70024. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70025. */
  70026. static CreateIcoSphere(name: string, options: {
  70027. radius?: number;
  70028. radiusX?: number;
  70029. radiusY?: number;
  70030. radiusZ?: number;
  70031. flat?: boolean;
  70032. subdivisions?: number;
  70033. sideOrientation?: number;
  70034. frontUVs?: Vector4;
  70035. backUVs?: Vector4;
  70036. updatable?: boolean;
  70037. }, scene?: Nullable<Scene>): Mesh;
  70038. /**
  70039. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70040. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70041. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70042. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70043. * * 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
  70044. * * 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
  70045. * * 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
  70046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70048. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70049. * * 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
  70050. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70051. * * 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
  70052. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70054. * @param name defines the name of the mesh
  70055. * @param options defines the options used to create the mesh
  70056. * @param scene defines the hosting scene
  70057. * @returns the ribbon mesh
  70058. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70059. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70060. */
  70061. static CreateRibbon(name: string, options: {
  70062. pathArray: Vector3[][];
  70063. closeArray?: boolean;
  70064. closePath?: boolean;
  70065. offset?: number;
  70066. updatable?: boolean;
  70067. sideOrientation?: number;
  70068. frontUVs?: Vector4;
  70069. backUVs?: Vector4;
  70070. instance?: Mesh;
  70071. invertUV?: boolean;
  70072. uvs?: Vector2[];
  70073. colors?: Color4[];
  70074. }, scene?: Nullable<Scene>): Mesh;
  70075. /**
  70076. * Creates a cylinder or a cone mesh
  70077. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70078. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70079. * * 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.
  70080. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70081. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70082. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70083. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70084. * * 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).
  70085. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70086. * * 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).
  70087. * * 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
  70088. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70089. * * 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
  70090. * * 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.
  70091. * * If `enclose` is false, a ring surface is one element.
  70092. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70093. * * 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
  70094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70097. * @param name defines the name of the mesh
  70098. * @param options defines the options used to create the mesh
  70099. * @param scene defines the hosting scene
  70100. * @returns the cylinder mesh
  70101. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70102. */
  70103. static CreateCylinder(name: string, options: {
  70104. height?: number;
  70105. diameterTop?: number;
  70106. diameterBottom?: number;
  70107. diameter?: number;
  70108. tessellation?: number;
  70109. subdivisions?: number;
  70110. arc?: number;
  70111. faceColors?: Color4[];
  70112. faceUV?: Vector4[];
  70113. updatable?: boolean;
  70114. hasRings?: boolean;
  70115. enclose?: boolean;
  70116. cap?: number;
  70117. sideOrientation?: number;
  70118. frontUVs?: Vector4;
  70119. backUVs?: Vector4;
  70120. }, scene?: Nullable<Scene>): Mesh;
  70121. /**
  70122. * Creates a torus mesh
  70123. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70124. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70125. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70129. * @param name defines the name of the mesh
  70130. * @param options defines the options used to create the mesh
  70131. * @param scene defines the hosting scene
  70132. * @returns the torus mesh
  70133. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70134. */
  70135. static CreateTorus(name: string, options: {
  70136. diameter?: number;
  70137. thickness?: number;
  70138. tessellation?: number;
  70139. updatable?: boolean;
  70140. sideOrientation?: number;
  70141. frontUVs?: Vector4;
  70142. backUVs?: Vector4;
  70143. }, scene?: Nullable<Scene>): Mesh;
  70144. /**
  70145. * Creates a torus knot mesh
  70146. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70147. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70148. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70149. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70153. * @param name defines the name of the mesh
  70154. * @param options defines the options used to create the mesh
  70155. * @param scene defines the hosting scene
  70156. * @returns the torus knot mesh
  70157. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70158. */
  70159. static CreateTorusKnot(name: string, options: {
  70160. radius?: number;
  70161. tube?: number;
  70162. radialSegments?: number;
  70163. tubularSegments?: number;
  70164. p?: number;
  70165. q?: number;
  70166. updatable?: boolean;
  70167. sideOrientation?: number;
  70168. frontUVs?: Vector4;
  70169. backUVs?: Vector4;
  70170. }, scene?: Nullable<Scene>): Mesh;
  70171. /**
  70172. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70173. * * 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
  70174. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70175. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70176. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70177. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70178. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70179. * * 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
  70180. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70183. * @param name defines the name of the new line system
  70184. * @param options defines the options used to create the line system
  70185. * @param scene defines the hosting scene
  70186. * @returns a new line system mesh
  70187. */
  70188. static CreateLineSystem(name: string, options: {
  70189. lines: Vector3[][];
  70190. updatable?: boolean;
  70191. instance?: Nullable<LinesMesh>;
  70192. colors?: Nullable<Color4[][]>;
  70193. useVertexAlpha?: boolean;
  70194. }, scene: Nullable<Scene>): LinesMesh;
  70195. /**
  70196. * Creates a line mesh
  70197. * 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
  70198. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70199. * * The parameter `points` is an array successive Vector3
  70200. * * 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
  70201. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70202. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70203. * * When updating an instance, remember that only point positions can change, not the number of points
  70204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70206. * @param name defines the name of the new line system
  70207. * @param options defines the options used to create the line system
  70208. * @param scene defines the hosting scene
  70209. * @returns a new line mesh
  70210. */
  70211. static CreateLines(name: string, options: {
  70212. points: Vector3[];
  70213. updatable?: boolean;
  70214. instance?: Nullable<LinesMesh>;
  70215. colors?: Color4[];
  70216. useVertexAlpha?: boolean;
  70217. }, scene?: Nullable<Scene>): LinesMesh;
  70218. /**
  70219. * Creates a dashed line mesh
  70220. * * 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
  70221. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70222. * * The parameter `points` is an array successive Vector3
  70223. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70224. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70225. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70226. * * 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
  70227. * * When updating an instance, remember that only point positions can change, not the number of points
  70228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70229. * @param name defines the name of the mesh
  70230. * @param options defines the options used to create the mesh
  70231. * @param scene defines the hosting scene
  70232. * @returns the dashed line mesh
  70233. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70234. */
  70235. static CreateDashedLines(name: string, options: {
  70236. points: Vector3[];
  70237. dashSize?: number;
  70238. gapSize?: number;
  70239. dashNb?: number;
  70240. updatable?: boolean;
  70241. instance?: LinesMesh;
  70242. }, scene?: Nullable<Scene>): LinesMesh;
  70243. /**
  70244. * 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.
  70245. * * 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.
  70246. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70247. * * 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.
  70248. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70249. * * 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
  70250. * * 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
  70251. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70254. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70256. * @param name defines the name of the mesh
  70257. * @param options defines the options used to create the mesh
  70258. * @param scene defines the hosting scene
  70259. * @returns the extruded shape mesh
  70260. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70261. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70262. */
  70263. static ExtrudeShape(name: string, options: {
  70264. shape: Vector3[];
  70265. path: Vector3[];
  70266. scale?: number;
  70267. rotation?: number;
  70268. cap?: number;
  70269. updatable?: boolean;
  70270. sideOrientation?: number;
  70271. frontUVs?: Vector4;
  70272. backUVs?: Vector4;
  70273. instance?: Mesh;
  70274. invertUV?: boolean;
  70275. }, scene?: Nullable<Scene>): Mesh;
  70276. /**
  70277. * Creates an custom extruded shape mesh.
  70278. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70279. * * 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.
  70280. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70281. * * 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
  70282. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70283. * * 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
  70284. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70285. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70286. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70287. * * 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
  70288. * * 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
  70289. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70292. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70294. * @param name defines the name of the mesh
  70295. * @param options defines the options used to create the mesh
  70296. * @param scene defines the hosting scene
  70297. * @returns the custom extruded shape mesh
  70298. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70299. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70301. */
  70302. static ExtrudeShapeCustom(name: string, options: {
  70303. shape: Vector3[];
  70304. path: Vector3[];
  70305. scaleFunction?: any;
  70306. rotationFunction?: any;
  70307. ribbonCloseArray?: boolean;
  70308. ribbonClosePath?: boolean;
  70309. cap?: number;
  70310. updatable?: boolean;
  70311. sideOrientation?: number;
  70312. frontUVs?: Vector4;
  70313. backUVs?: Vector4;
  70314. instance?: Mesh;
  70315. invertUV?: boolean;
  70316. }, scene?: Nullable<Scene>): Mesh;
  70317. /**
  70318. * Creates lathe mesh.
  70319. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70320. * * 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
  70321. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70322. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70323. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70324. * * 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
  70325. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70326. * * 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
  70327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70329. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70331. * @param name defines the name of the mesh
  70332. * @param options defines the options used to create the mesh
  70333. * @param scene defines the hosting scene
  70334. * @returns the lathe mesh
  70335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70336. */
  70337. static CreateLathe(name: string, options: {
  70338. shape: Vector3[];
  70339. radius?: number;
  70340. tessellation?: number;
  70341. clip?: number;
  70342. arc?: number;
  70343. closed?: boolean;
  70344. updatable?: boolean;
  70345. sideOrientation?: number;
  70346. frontUVs?: Vector4;
  70347. backUVs?: Vector4;
  70348. cap?: number;
  70349. invertUV?: boolean;
  70350. }, scene?: Nullable<Scene>): Mesh;
  70351. /**
  70352. * Creates a tiled plane mesh
  70353. * * You can set a limited pattern arrangement with the tiles
  70354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70357. * @param name defines the name of the mesh
  70358. * @param options defines the options used to create the mesh
  70359. * @param scene defines the hosting scene
  70360. * @returns the plane mesh
  70361. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70362. */
  70363. static CreateTiledPlane(name: string, options: {
  70364. pattern?: number;
  70365. tileSize?: number;
  70366. tileWidth?: number;
  70367. tileHeight?: number;
  70368. size?: number;
  70369. width?: number;
  70370. height?: number;
  70371. alignHorizontal?: number;
  70372. alignVertical?: number;
  70373. sideOrientation?: number;
  70374. frontUVs?: Vector4;
  70375. backUVs?: Vector4;
  70376. updatable?: boolean;
  70377. }, scene?: Nullable<Scene>): Mesh;
  70378. /**
  70379. * Creates a plane mesh
  70380. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70381. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70382. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70386. * @param name defines the name of the mesh
  70387. * @param options defines the options used to create the mesh
  70388. * @param scene defines the hosting scene
  70389. * @returns the plane mesh
  70390. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70391. */
  70392. static CreatePlane(name: string, options: {
  70393. size?: number;
  70394. width?: number;
  70395. height?: number;
  70396. sideOrientation?: number;
  70397. frontUVs?: Vector4;
  70398. backUVs?: Vector4;
  70399. updatable?: boolean;
  70400. sourcePlane?: Plane;
  70401. }, scene?: Nullable<Scene>): Mesh;
  70402. /**
  70403. * Creates a ground mesh
  70404. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70405. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70407. * @param name defines the name of the mesh
  70408. * @param options defines the options used to create the mesh
  70409. * @param scene defines the hosting scene
  70410. * @returns the ground mesh
  70411. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70412. */
  70413. static CreateGround(name: string, options: {
  70414. width?: number;
  70415. height?: number;
  70416. subdivisions?: number;
  70417. subdivisionsX?: number;
  70418. subdivisionsY?: number;
  70419. updatable?: boolean;
  70420. }, scene?: Nullable<Scene>): Mesh;
  70421. /**
  70422. * Creates a tiled ground mesh
  70423. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70424. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70425. * * 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
  70426. * * 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
  70427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70428. * @param name defines the name of the mesh
  70429. * @param options defines the options used to create the mesh
  70430. * @param scene defines the hosting scene
  70431. * @returns the tiled ground mesh
  70432. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70433. */
  70434. static CreateTiledGround(name: string, options: {
  70435. xmin: number;
  70436. zmin: number;
  70437. xmax: number;
  70438. zmax: number;
  70439. subdivisions?: {
  70440. w: number;
  70441. h: number;
  70442. };
  70443. precision?: {
  70444. w: number;
  70445. h: number;
  70446. };
  70447. updatable?: boolean;
  70448. }, scene?: Nullable<Scene>): Mesh;
  70449. /**
  70450. * Creates a ground mesh from a height map
  70451. * * The parameter `url` sets the URL of the height map image resource.
  70452. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70453. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70454. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70455. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70456. * * 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.
  70457. * * 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).
  70458. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70460. * @param name defines the name of the mesh
  70461. * @param url defines the url to the height map
  70462. * @param options defines the options used to create the mesh
  70463. * @param scene defines the hosting scene
  70464. * @returns the ground mesh
  70465. * @see https://doc.babylonjs.com/babylon101/height_map
  70466. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70467. */
  70468. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70469. width?: number;
  70470. height?: number;
  70471. subdivisions?: number;
  70472. minHeight?: number;
  70473. maxHeight?: number;
  70474. colorFilter?: Color3;
  70475. alphaFilter?: number;
  70476. updatable?: boolean;
  70477. onReady?: (mesh: GroundMesh) => void;
  70478. }, scene?: Nullable<Scene>): GroundMesh;
  70479. /**
  70480. * Creates a polygon mesh
  70481. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70482. * * 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
  70483. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70486. * * Remember you can only change the shape positions, not their number when updating a polygon
  70487. * @param name defines the name of the mesh
  70488. * @param options defines the options used to create the mesh
  70489. * @param scene defines the hosting scene
  70490. * @param earcutInjection can be used to inject your own earcut reference
  70491. * @returns the polygon mesh
  70492. */
  70493. static CreatePolygon(name: string, options: {
  70494. shape: Vector3[];
  70495. holes?: Vector3[][];
  70496. depth?: number;
  70497. faceUV?: Vector4[];
  70498. faceColors?: Color4[];
  70499. updatable?: boolean;
  70500. sideOrientation?: number;
  70501. frontUVs?: Vector4;
  70502. backUVs?: Vector4;
  70503. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70504. /**
  70505. * Creates an extruded polygon mesh, with depth in the Y direction.
  70506. * * 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)
  70507. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70508. * @param name defines the name of the mesh
  70509. * @param options defines the options used to create the mesh
  70510. * @param scene defines the hosting scene
  70511. * @param earcutInjection can be used to inject your own earcut reference
  70512. * @returns the polygon mesh
  70513. */
  70514. static ExtrudePolygon(name: string, options: {
  70515. shape: Vector3[];
  70516. holes?: Vector3[][];
  70517. depth?: number;
  70518. faceUV?: Vector4[];
  70519. faceColors?: Color4[];
  70520. updatable?: boolean;
  70521. sideOrientation?: number;
  70522. frontUVs?: Vector4;
  70523. backUVs?: Vector4;
  70524. wrap?: boolean;
  70525. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70526. /**
  70527. * Creates a tube mesh.
  70528. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70529. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70530. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70531. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70532. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70533. * * 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)
  70534. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70535. * * 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
  70536. * * 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
  70537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70541. * @param name defines the name of the mesh
  70542. * @param options defines the options used to create the mesh
  70543. * @param scene defines the hosting scene
  70544. * @returns the tube mesh
  70545. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70546. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70547. */
  70548. static CreateTube(name: string, options: {
  70549. path: Vector3[];
  70550. radius?: number;
  70551. tessellation?: number;
  70552. radiusFunction?: {
  70553. (i: number, distance: number): number;
  70554. };
  70555. cap?: number;
  70556. arc?: number;
  70557. updatable?: boolean;
  70558. sideOrientation?: number;
  70559. frontUVs?: Vector4;
  70560. backUVs?: Vector4;
  70561. instance?: Mesh;
  70562. invertUV?: boolean;
  70563. }, scene?: Nullable<Scene>): Mesh;
  70564. /**
  70565. * Creates a polyhedron mesh
  70566. * * 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
  70567. * * The parameter `size` (positive float, default 1) sets the polygon size
  70568. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70569. * * 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`
  70570. * * 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
  70571. * * 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)`)
  70572. * * 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
  70573. * * 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
  70574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70577. * @param name defines the name of the mesh
  70578. * @param options defines the options used to create the mesh
  70579. * @param scene defines the hosting scene
  70580. * @returns the polyhedron mesh
  70581. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70582. */
  70583. static CreatePolyhedron(name: string, options: {
  70584. type?: number;
  70585. size?: number;
  70586. sizeX?: number;
  70587. sizeY?: number;
  70588. sizeZ?: number;
  70589. custom?: any;
  70590. faceUV?: Vector4[];
  70591. faceColors?: Color4[];
  70592. flat?: boolean;
  70593. updatable?: boolean;
  70594. sideOrientation?: number;
  70595. frontUVs?: Vector4;
  70596. backUVs?: Vector4;
  70597. }, scene?: Nullable<Scene>): Mesh;
  70598. /**
  70599. * Creates a decal mesh.
  70600. * 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
  70601. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70602. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70603. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70604. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70605. * @param name defines the name of the mesh
  70606. * @param sourceMesh defines the mesh where the decal must be applied
  70607. * @param options defines the options used to create the mesh
  70608. * @param scene defines the hosting scene
  70609. * @returns the decal mesh
  70610. * @see https://doc.babylonjs.com/how_to/decals
  70611. */
  70612. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70613. position?: Vector3;
  70614. normal?: Vector3;
  70615. size?: Vector3;
  70616. angle?: number;
  70617. }): Mesh;
  70618. /**
  70619. * Creates a Capsule Mesh
  70620. * @param name defines the name of the mesh.
  70621. * @param options the constructors options used to shape the mesh.
  70622. * @param scene defines the scene the mesh is scoped to.
  70623. * @returns the capsule mesh
  70624. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70625. */
  70626. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70627. }
  70628. }
  70629. declare module "babylonjs/Meshes/meshSimplification" {
  70630. import { Mesh } from "babylonjs/Meshes/mesh";
  70631. /**
  70632. * A simplifier interface for future simplification implementations
  70633. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70634. */
  70635. export interface ISimplifier {
  70636. /**
  70637. * Simplification of a given mesh according to the given settings.
  70638. * Since this requires computation, it is assumed that the function runs async.
  70639. * @param settings The settings of the simplification, including quality and distance
  70640. * @param successCallback A callback that will be called after the mesh was simplified.
  70641. * @param errorCallback in case of an error, this callback will be called. optional.
  70642. */
  70643. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70644. }
  70645. /**
  70646. * Expected simplification settings.
  70647. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70648. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70649. */
  70650. export interface ISimplificationSettings {
  70651. /**
  70652. * Gets or sets the expected quality
  70653. */
  70654. quality: number;
  70655. /**
  70656. * Gets or sets the distance when this optimized version should be used
  70657. */
  70658. distance: number;
  70659. /**
  70660. * Gets an already optimized mesh
  70661. */
  70662. optimizeMesh?: boolean;
  70663. }
  70664. /**
  70665. * Class used to specify simplification options
  70666. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70667. */
  70668. export class SimplificationSettings implements ISimplificationSettings {
  70669. /** expected quality */
  70670. quality: number;
  70671. /** distance when this optimized version should be used */
  70672. distance: number;
  70673. /** already optimized mesh */
  70674. optimizeMesh?: boolean | undefined;
  70675. /**
  70676. * Creates a SimplificationSettings
  70677. * @param quality expected quality
  70678. * @param distance distance when this optimized version should be used
  70679. * @param optimizeMesh already optimized mesh
  70680. */
  70681. constructor(
  70682. /** expected quality */
  70683. quality: number,
  70684. /** distance when this optimized version should be used */
  70685. distance: number,
  70686. /** already optimized mesh */
  70687. optimizeMesh?: boolean | undefined);
  70688. }
  70689. /**
  70690. * Interface used to define a simplification task
  70691. */
  70692. export interface ISimplificationTask {
  70693. /**
  70694. * Array of settings
  70695. */
  70696. settings: Array<ISimplificationSettings>;
  70697. /**
  70698. * Simplification type
  70699. */
  70700. simplificationType: SimplificationType;
  70701. /**
  70702. * Mesh to simplify
  70703. */
  70704. mesh: Mesh;
  70705. /**
  70706. * Callback called on success
  70707. */
  70708. successCallback?: () => void;
  70709. /**
  70710. * Defines if parallel processing can be used
  70711. */
  70712. parallelProcessing: boolean;
  70713. }
  70714. /**
  70715. * Queue used to order the simplification tasks
  70716. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70717. */
  70718. export class SimplificationQueue {
  70719. private _simplificationArray;
  70720. /**
  70721. * Gets a boolean indicating that the process is still running
  70722. */
  70723. running: boolean;
  70724. /**
  70725. * Creates a new queue
  70726. */
  70727. constructor();
  70728. /**
  70729. * Adds a new simplification task
  70730. * @param task defines a task to add
  70731. */
  70732. addTask(task: ISimplificationTask): void;
  70733. /**
  70734. * Execute next task
  70735. */
  70736. executeNext(): void;
  70737. /**
  70738. * Execute a simplification task
  70739. * @param task defines the task to run
  70740. */
  70741. runSimplification(task: ISimplificationTask): void;
  70742. private getSimplifier;
  70743. }
  70744. /**
  70745. * The implemented types of simplification
  70746. * At the moment only Quadratic Error Decimation is implemented
  70747. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70748. */
  70749. export enum SimplificationType {
  70750. /** Quadratic error decimation */
  70751. QUADRATIC = 0
  70752. }
  70753. /**
  70754. * An implementation of the Quadratic Error simplification algorithm.
  70755. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70756. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70757. * @author RaananW
  70758. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70759. */
  70760. export class QuadraticErrorSimplification implements ISimplifier {
  70761. private _mesh;
  70762. private triangles;
  70763. private vertices;
  70764. private references;
  70765. private _reconstructedMesh;
  70766. /** Gets or sets the number pf sync interations */
  70767. syncIterations: number;
  70768. /** Gets or sets the aggressiveness of the simplifier */
  70769. aggressiveness: number;
  70770. /** Gets or sets the number of allowed iterations for decimation */
  70771. decimationIterations: number;
  70772. /** Gets or sets the espilon to use for bounding box computation */
  70773. boundingBoxEpsilon: number;
  70774. /**
  70775. * Creates a new QuadraticErrorSimplification
  70776. * @param _mesh defines the target mesh
  70777. */
  70778. constructor(_mesh: Mesh);
  70779. /**
  70780. * Simplification of a given mesh according to the given settings.
  70781. * Since this requires computation, it is assumed that the function runs async.
  70782. * @param settings The settings of the simplification, including quality and distance
  70783. * @param successCallback A callback that will be called after the mesh was simplified.
  70784. */
  70785. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70786. private runDecimation;
  70787. private initWithMesh;
  70788. private init;
  70789. private reconstructMesh;
  70790. private initDecimatedMesh;
  70791. private isFlipped;
  70792. private updateTriangles;
  70793. private identifyBorder;
  70794. private updateMesh;
  70795. private vertexError;
  70796. private calculateError;
  70797. }
  70798. }
  70799. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70800. import { Scene } from "babylonjs/scene";
  70801. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70802. import { ISceneComponent } from "babylonjs/sceneComponent";
  70803. module "babylonjs/scene" {
  70804. interface Scene {
  70805. /** @hidden (Backing field) */
  70806. _simplificationQueue: SimplificationQueue;
  70807. /**
  70808. * Gets or sets the simplification queue attached to the scene
  70809. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70810. */
  70811. simplificationQueue: SimplificationQueue;
  70812. }
  70813. }
  70814. module "babylonjs/Meshes/mesh" {
  70815. interface Mesh {
  70816. /**
  70817. * Simplify the mesh according to the given array of settings.
  70818. * Function will return immediately and will simplify async
  70819. * @param settings a collection of simplification settings
  70820. * @param parallelProcessing should all levels calculate parallel or one after the other
  70821. * @param simplificationType the type of simplification to run
  70822. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70823. * @returns the current mesh
  70824. */
  70825. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70826. }
  70827. }
  70828. /**
  70829. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70830. * created in a scene
  70831. */
  70832. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70833. /**
  70834. * The component name helpfull to identify the component in the list of scene components.
  70835. */
  70836. readonly name: string;
  70837. /**
  70838. * The scene the component belongs to.
  70839. */
  70840. scene: Scene;
  70841. /**
  70842. * Creates a new instance of the component for the given scene
  70843. * @param scene Defines the scene to register the component in
  70844. */
  70845. constructor(scene: Scene);
  70846. /**
  70847. * Registers the component in a given scene
  70848. */
  70849. register(): void;
  70850. /**
  70851. * Rebuilds the elements related to this component in case of
  70852. * context lost for instance.
  70853. */
  70854. rebuild(): void;
  70855. /**
  70856. * Disposes the component and the associated ressources
  70857. */
  70858. dispose(): void;
  70859. private _beforeCameraUpdate;
  70860. }
  70861. }
  70862. declare module "babylonjs/Meshes/Builders/index" {
  70863. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70864. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70865. export * from "babylonjs/Meshes/Builders/discBuilder";
  70866. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70867. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70868. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70869. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70870. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70871. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70872. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70873. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70874. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70875. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70876. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70877. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70878. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70879. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70880. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70881. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70882. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70883. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70884. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70885. }
  70886. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70887. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70888. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70889. import { Matrix } from "babylonjs/Maths/math.vector";
  70890. module "babylonjs/Meshes/mesh" {
  70891. interface Mesh {
  70892. /**
  70893. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70894. */
  70895. thinInstanceEnablePicking: boolean;
  70896. /**
  70897. * Creates a new thin instance
  70898. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70899. * @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
  70900. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70901. */
  70902. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70903. /**
  70904. * Adds the transformation (matrix) of the current mesh as a thin instance
  70905. * @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
  70906. * @returns the thin instance index number
  70907. */
  70908. thinInstanceAddSelf(refresh: boolean): number;
  70909. /**
  70910. * Registers a custom attribute to be used with thin instances
  70911. * @param kind name of the attribute
  70912. * @param stride size in floats of the attribute
  70913. */
  70914. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70915. /**
  70916. * Sets the matrix of a thin instance
  70917. * @param index index of the thin instance
  70918. * @param matrix matrix to set
  70919. * @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
  70920. */
  70921. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70922. /**
  70923. * Sets the value of a custom attribute for a thin instance
  70924. * @param kind name of the attribute
  70925. * @param index index of the thin instance
  70926. * @param value value to set
  70927. * @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
  70928. */
  70929. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70930. /**
  70931. * 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.
  70932. */
  70933. thinInstanceCount: number;
  70934. /**
  70935. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70936. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70937. * @param buffer buffer to set
  70938. * @param stride size in floats of each value of the buffer
  70939. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70940. */
  70941. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70942. /**
  70943. * Gets the list of world matrices
  70944. * @return an array containing all the world matrices from the thin instances
  70945. */
  70946. thinInstanceGetWorldMatrices(): Matrix[];
  70947. /**
  70948. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70949. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70950. */
  70951. thinInstanceBufferUpdated(kind: string): void;
  70952. /**
  70953. * Applies a partial update to a buffer directly on the GPU
  70954. * 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
  70955. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70956. * @param data the data to set in the GPU buffer
  70957. * @param offset the offset in the GPU buffer where to update the data
  70958. */
  70959. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70960. /**
  70961. * Refreshes the bounding info, taking into account all the thin instances defined
  70962. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70963. */
  70964. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70965. /** @hidden */
  70966. _thinInstanceInitializeUserStorage(): void;
  70967. /** @hidden */
  70968. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70969. /** @hidden */
  70970. _userThinInstanceBuffersStorage: {
  70971. data: {
  70972. [key: string]: Float32Array;
  70973. };
  70974. sizes: {
  70975. [key: string]: number;
  70976. };
  70977. vertexBuffers: {
  70978. [key: string]: Nullable<VertexBuffer>;
  70979. };
  70980. strides: {
  70981. [key: string]: number;
  70982. };
  70983. };
  70984. }
  70985. }
  70986. }
  70987. declare module "babylonjs/Meshes/index" {
  70988. export * from "babylonjs/Meshes/abstractMesh";
  70989. export * from "babylonjs/Meshes/buffer";
  70990. export * from "babylonjs/Meshes/Compression/index";
  70991. export * from "babylonjs/Meshes/csg";
  70992. export * from "babylonjs/Meshes/geometry";
  70993. export * from "babylonjs/Meshes/groundMesh";
  70994. export * from "babylonjs/Meshes/trailMesh";
  70995. export * from "babylonjs/Meshes/instancedMesh";
  70996. export * from "babylonjs/Meshes/linesMesh";
  70997. export * from "babylonjs/Meshes/mesh";
  70998. export * from "babylonjs/Meshes/mesh.vertexData";
  70999. export * from "babylonjs/Meshes/meshBuilder";
  71000. export * from "babylonjs/Meshes/meshSimplification";
  71001. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71002. export * from "babylonjs/Meshes/polygonMesh";
  71003. export * from "babylonjs/Meshes/subMesh";
  71004. export * from "babylonjs/Meshes/meshLODLevel";
  71005. export * from "babylonjs/Meshes/transformNode";
  71006. export * from "babylonjs/Meshes/Builders/index";
  71007. export * from "babylonjs/Meshes/dataBuffer";
  71008. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71009. import "babylonjs/Meshes/thinInstanceMesh";
  71010. export * from "babylonjs/Meshes/thinInstanceMesh";
  71011. }
  71012. declare module "babylonjs/Morph/index" {
  71013. export * from "babylonjs/Morph/morphTarget";
  71014. export * from "babylonjs/Morph/morphTargetManager";
  71015. }
  71016. declare module "babylonjs/Navigation/INavigationEngine" {
  71017. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71018. import { Vector3 } from "babylonjs/Maths/math";
  71019. import { Mesh } from "babylonjs/Meshes/mesh";
  71020. import { Scene } from "babylonjs/scene";
  71021. /**
  71022. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71023. */
  71024. export interface INavigationEnginePlugin {
  71025. /**
  71026. * plugin name
  71027. */
  71028. name: string;
  71029. /**
  71030. * Creates a navigation mesh
  71031. * @param meshes array of all the geometry used to compute the navigatio mesh
  71032. * @param parameters bunch of parameters used to filter geometry
  71033. */
  71034. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71035. /**
  71036. * Create a navigation mesh debug mesh
  71037. * @param scene is where the mesh will be added
  71038. * @returns debug display mesh
  71039. */
  71040. createDebugNavMesh(scene: Scene): Mesh;
  71041. /**
  71042. * Get a navigation mesh constrained position, closest to the parameter position
  71043. * @param position world position
  71044. * @returns the closest point to position constrained by the navigation mesh
  71045. */
  71046. getClosestPoint(position: Vector3): Vector3;
  71047. /**
  71048. * Get a navigation mesh constrained position, closest to the parameter position
  71049. * @param position world position
  71050. * @param result output the closest point to position constrained by the navigation mesh
  71051. */
  71052. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71053. /**
  71054. * Get a navigation mesh constrained position, within a particular radius
  71055. * @param position world position
  71056. * @param maxRadius the maximum distance to the constrained world position
  71057. * @returns the closest point to position constrained by the navigation mesh
  71058. */
  71059. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71060. /**
  71061. * Get a navigation mesh constrained position, within a particular radius
  71062. * @param position world position
  71063. * @param maxRadius the maximum distance to the constrained world position
  71064. * @param result output the closest point to position constrained by the navigation mesh
  71065. */
  71066. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71067. /**
  71068. * Compute the final position from a segment made of destination-position
  71069. * @param position world position
  71070. * @param destination world position
  71071. * @returns the resulting point along the navmesh
  71072. */
  71073. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71074. /**
  71075. * Compute the final position from a segment made of destination-position
  71076. * @param position world position
  71077. * @param destination world position
  71078. * @param result output the resulting point along the navmesh
  71079. */
  71080. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71081. /**
  71082. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71083. * @param start world position
  71084. * @param end world position
  71085. * @returns array containing world position composing the path
  71086. */
  71087. computePath(start: Vector3, end: Vector3): Vector3[];
  71088. /**
  71089. * If this plugin is supported
  71090. * @returns true if plugin is supported
  71091. */
  71092. isSupported(): boolean;
  71093. /**
  71094. * Create a new Crowd so you can add agents
  71095. * @param maxAgents the maximum agent count in the crowd
  71096. * @param maxAgentRadius the maximum radius an agent can have
  71097. * @param scene to attach the crowd to
  71098. * @returns the crowd you can add agents to
  71099. */
  71100. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71101. /**
  71102. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71103. * The queries will try to find a solution within those bounds
  71104. * default is (1,1,1)
  71105. * @param extent x,y,z value that define the extent around the queries point of reference
  71106. */
  71107. setDefaultQueryExtent(extent: Vector3): void;
  71108. /**
  71109. * Get the Bounding box extent specified by setDefaultQueryExtent
  71110. * @returns the box extent values
  71111. */
  71112. getDefaultQueryExtent(): Vector3;
  71113. /**
  71114. * build the navmesh from a previously saved state using getNavmeshData
  71115. * @param data the Uint8Array returned by getNavmeshData
  71116. */
  71117. buildFromNavmeshData(data: Uint8Array): void;
  71118. /**
  71119. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71120. * @returns data the Uint8Array that can be saved and reused
  71121. */
  71122. getNavmeshData(): Uint8Array;
  71123. /**
  71124. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71125. * @param result output the box extent values
  71126. */
  71127. getDefaultQueryExtentToRef(result: Vector3): void;
  71128. /**
  71129. * Release all resources
  71130. */
  71131. dispose(): void;
  71132. }
  71133. /**
  71134. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71135. */
  71136. export interface ICrowd {
  71137. /**
  71138. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71139. * You can attach anything to that node. The node position is updated in the scene update tick.
  71140. * @param pos world position that will be constrained by the navigation mesh
  71141. * @param parameters agent parameters
  71142. * @param transform hooked to the agent that will be update by the scene
  71143. * @returns agent index
  71144. */
  71145. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71146. /**
  71147. * Returns the agent position in world space
  71148. * @param index agent index returned by addAgent
  71149. * @returns world space position
  71150. */
  71151. getAgentPosition(index: number): Vector3;
  71152. /**
  71153. * Gets the agent position result in world space
  71154. * @param index agent index returned by addAgent
  71155. * @param result output world space position
  71156. */
  71157. getAgentPositionToRef(index: number, result: Vector3): void;
  71158. /**
  71159. * Gets the agent velocity in world space
  71160. * @param index agent index returned by addAgent
  71161. * @returns world space velocity
  71162. */
  71163. getAgentVelocity(index: number): Vector3;
  71164. /**
  71165. * Gets the agent velocity result in world space
  71166. * @param index agent index returned by addAgent
  71167. * @param result output world space velocity
  71168. */
  71169. getAgentVelocityToRef(index: number, result: Vector3): void;
  71170. /**
  71171. * remove a particular agent previously created
  71172. * @param index agent index returned by addAgent
  71173. */
  71174. removeAgent(index: number): void;
  71175. /**
  71176. * get the list of all agents attached to this crowd
  71177. * @returns list of agent indices
  71178. */
  71179. getAgents(): number[];
  71180. /**
  71181. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71182. * @param deltaTime in seconds
  71183. */
  71184. update(deltaTime: number): void;
  71185. /**
  71186. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71187. * @param index agent index returned by addAgent
  71188. * @param destination targeted world position
  71189. */
  71190. agentGoto(index: number, destination: Vector3): void;
  71191. /**
  71192. * Teleport the agent to a new position
  71193. * @param index agent index returned by addAgent
  71194. * @param destination targeted world position
  71195. */
  71196. agentTeleport(index: number, destination: Vector3): void;
  71197. /**
  71198. * Update agent parameters
  71199. * @param index agent index returned by addAgent
  71200. * @param parameters agent parameters
  71201. */
  71202. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71203. /**
  71204. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71205. * The queries will try to find a solution within those bounds
  71206. * default is (1,1,1)
  71207. * @param extent x,y,z value that define the extent around the queries point of reference
  71208. */
  71209. setDefaultQueryExtent(extent: Vector3): void;
  71210. /**
  71211. * Get the Bounding box extent specified by setDefaultQueryExtent
  71212. * @returns the box extent values
  71213. */
  71214. getDefaultQueryExtent(): Vector3;
  71215. /**
  71216. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71217. * @param result output the box extent values
  71218. */
  71219. getDefaultQueryExtentToRef(result: Vector3): void;
  71220. /**
  71221. * Release all resources
  71222. */
  71223. dispose(): void;
  71224. }
  71225. /**
  71226. * Configures an agent
  71227. */
  71228. export interface IAgentParameters {
  71229. /**
  71230. * Agent radius. [Limit: >= 0]
  71231. */
  71232. radius: number;
  71233. /**
  71234. * Agent height. [Limit: > 0]
  71235. */
  71236. height: number;
  71237. /**
  71238. * Maximum allowed acceleration. [Limit: >= 0]
  71239. */
  71240. maxAcceleration: number;
  71241. /**
  71242. * Maximum allowed speed. [Limit: >= 0]
  71243. */
  71244. maxSpeed: number;
  71245. /**
  71246. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71247. */
  71248. collisionQueryRange: number;
  71249. /**
  71250. * The path visibility optimization range. [Limit: > 0]
  71251. */
  71252. pathOptimizationRange: number;
  71253. /**
  71254. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71255. */
  71256. separationWeight: number;
  71257. }
  71258. /**
  71259. * Configures the navigation mesh creation
  71260. */
  71261. export interface INavMeshParameters {
  71262. /**
  71263. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71264. */
  71265. cs: number;
  71266. /**
  71267. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71268. */
  71269. ch: number;
  71270. /**
  71271. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71272. */
  71273. walkableSlopeAngle: number;
  71274. /**
  71275. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71276. * be considered walkable. [Limit: >= 3] [Units: vx]
  71277. */
  71278. walkableHeight: number;
  71279. /**
  71280. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71281. */
  71282. walkableClimb: number;
  71283. /**
  71284. * The distance to erode/shrink the walkable area of the heightfield away from
  71285. * obstructions. [Limit: >=0] [Units: vx]
  71286. */
  71287. walkableRadius: number;
  71288. /**
  71289. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71290. */
  71291. maxEdgeLen: number;
  71292. /**
  71293. * The maximum distance a simplfied contour's border edges should deviate
  71294. * the original raw contour. [Limit: >=0] [Units: vx]
  71295. */
  71296. maxSimplificationError: number;
  71297. /**
  71298. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71299. */
  71300. minRegionArea: number;
  71301. /**
  71302. * Any regions with a span count smaller than this value will, if possible,
  71303. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71304. */
  71305. mergeRegionArea: number;
  71306. /**
  71307. * The maximum number of vertices allowed for polygons generated during the
  71308. * contour to polygon conversion process. [Limit: >= 3]
  71309. */
  71310. maxVertsPerPoly: number;
  71311. /**
  71312. * Sets the sampling distance to use when generating the detail mesh.
  71313. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71314. */
  71315. detailSampleDist: number;
  71316. /**
  71317. * The maximum distance the detail mesh surface should deviate from heightfield
  71318. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71319. */
  71320. detailSampleMaxError: number;
  71321. }
  71322. }
  71323. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71324. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71325. import { Mesh } from "babylonjs/Meshes/mesh";
  71326. import { Scene } from "babylonjs/scene";
  71327. import { Vector3 } from "babylonjs/Maths/math";
  71328. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71329. /**
  71330. * RecastJS navigation plugin
  71331. */
  71332. export class RecastJSPlugin implements INavigationEnginePlugin {
  71333. /**
  71334. * Reference to the Recast library
  71335. */
  71336. bjsRECAST: any;
  71337. /**
  71338. * plugin name
  71339. */
  71340. name: string;
  71341. /**
  71342. * the first navmesh created. We might extend this to support multiple navmeshes
  71343. */
  71344. navMesh: any;
  71345. /**
  71346. * Initializes the recastJS plugin
  71347. * @param recastInjection can be used to inject your own recast reference
  71348. */
  71349. constructor(recastInjection?: any);
  71350. /**
  71351. * Creates a navigation mesh
  71352. * @param meshes array of all the geometry used to compute the navigatio mesh
  71353. * @param parameters bunch of parameters used to filter geometry
  71354. */
  71355. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71356. /**
  71357. * Create a navigation mesh debug mesh
  71358. * @param scene is where the mesh will be added
  71359. * @returns debug display mesh
  71360. */
  71361. createDebugNavMesh(scene: Scene): Mesh;
  71362. /**
  71363. * Get a navigation mesh constrained position, closest to the parameter position
  71364. * @param position world position
  71365. * @returns the closest point to position constrained by the navigation mesh
  71366. */
  71367. getClosestPoint(position: Vector3): Vector3;
  71368. /**
  71369. * Get a navigation mesh constrained position, closest to the parameter position
  71370. * @param position world position
  71371. * @param result output the closest point to position constrained by the navigation mesh
  71372. */
  71373. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71374. /**
  71375. * Get a navigation mesh constrained position, within a particular radius
  71376. * @param position world position
  71377. * @param maxRadius the maximum distance to the constrained world position
  71378. * @returns the closest point to position constrained by the navigation mesh
  71379. */
  71380. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71381. /**
  71382. * Get a navigation mesh constrained position, within a particular radius
  71383. * @param position world position
  71384. * @param maxRadius the maximum distance to the constrained world position
  71385. * @param result output the closest point to position constrained by the navigation mesh
  71386. */
  71387. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71388. /**
  71389. * Compute the final position from a segment made of destination-position
  71390. * @param position world position
  71391. * @param destination world position
  71392. * @returns the resulting point along the navmesh
  71393. */
  71394. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71395. /**
  71396. * Compute the final position from a segment made of destination-position
  71397. * @param position world position
  71398. * @param destination world position
  71399. * @param result output the resulting point along the navmesh
  71400. */
  71401. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71402. /**
  71403. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71404. * @param start world position
  71405. * @param end world position
  71406. * @returns array containing world position composing the path
  71407. */
  71408. computePath(start: Vector3, end: Vector3): Vector3[];
  71409. /**
  71410. * Create a new Crowd so you can add agents
  71411. * @param maxAgents the maximum agent count in the crowd
  71412. * @param maxAgentRadius the maximum radius an agent can have
  71413. * @param scene to attach the crowd to
  71414. * @returns the crowd you can add agents to
  71415. */
  71416. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71417. /**
  71418. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71419. * The queries will try to find a solution within those bounds
  71420. * default is (1,1,1)
  71421. * @param extent x,y,z value that define the extent around the queries point of reference
  71422. */
  71423. setDefaultQueryExtent(extent: Vector3): void;
  71424. /**
  71425. * Get the Bounding box extent specified by setDefaultQueryExtent
  71426. * @returns the box extent values
  71427. */
  71428. getDefaultQueryExtent(): Vector3;
  71429. /**
  71430. * build the navmesh from a previously saved state using getNavmeshData
  71431. * @param data the Uint8Array returned by getNavmeshData
  71432. */
  71433. buildFromNavmeshData(data: Uint8Array): void;
  71434. /**
  71435. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71436. * @returns data the Uint8Array that can be saved and reused
  71437. */
  71438. getNavmeshData(): Uint8Array;
  71439. /**
  71440. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71441. * @param result output the box extent values
  71442. */
  71443. getDefaultQueryExtentToRef(result: Vector3): void;
  71444. /**
  71445. * Disposes
  71446. */
  71447. dispose(): void;
  71448. /**
  71449. * If this plugin is supported
  71450. * @returns true if plugin is supported
  71451. */
  71452. isSupported(): boolean;
  71453. }
  71454. /**
  71455. * Recast detour crowd implementation
  71456. */
  71457. export class RecastJSCrowd implements ICrowd {
  71458. /**
  71459. * Recast/detour plugin
  71460. */
  71461. bjsRECASTPlugin: RecastJSPlugin;
  71462. /**
  71463. * Link to the detour crowd
  71464. */
  71465. recastCrowd: any;
  71466. /**
  71467. * One transform per agent
  71468. */
  71469. transforms: TransformNode[];
  71470. /**
  71471. * All agents created
  71472. */
  71473. agents: number[];
  71474. /**
  71475. * Link to the scene is kept to unregister the crowd from the scene
  71476. */
  71477. private _scene;
  71478. /**
  71479. * Observer for crowd updates
  71480. */
  71481. private _onBeforeAnimationsObserver;
  71482. /**
  71483. * Constructor
  71484. * @param plugin recastJS plugin
  71485. * @param maxAgents the maximum agent count in the crowd
  71486. * @param maxAgentRadius the maximum radius an agent can have
  71487. * @param scene to attach the crowd to
  71488. * @returns the crowd you can add agents to
  71489. */
  71490. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71491. /**
  71492. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71493. * You can attach anything to that node. The node position is updated in the scene update tick.
  71494. * @param pos world position that will be constrained by the navigation mesh
  71495. * @param parameters agent parameters
  71496. * @param transform hooked to the agent that will be update by the scene
  71497. * @returns agent index
  71498. */
  71499. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71500. /**
  71501. * Returns the agent position in world space
  71502. * @param index agent index returned by addAgent
  71503. * @returns world space position
  71504. */
  71505. getAgentPosition(index: number): Vector3;
  71506. /**
  71507. * Returns the agent position result in world space
  71508. * @param index agent index returned by addAgent
  71509. * @param result output world space position
  71510. */
  71511. getAgentPositionToRef(index: number, result: Vector3): void;
  71512. /**
  71513. * Returns the agent velocity in world space
  71514. * @param index agent index returned by addAgent
  71515. * @returns world space velocity
  71516. */
  71517. getAgentVelocity(index: number): Vector3;
  71518. /**
  71519. * Returns the agent velocity result in world space
  71520. * @param index agent index returned by addAgent
  71521. * @param result output world space velocity
  71522. */
  71523. getAgentVelocityToRef(index: number, result: Vector3): void;
  71524. /**
  71525. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71526. * @param index agent index returned by addAgent
  71527. * @param destination targeted world position
  71528. */
  71529. agentGoto(index: number, destination: Vector3): void;
  71530. /**
  71531. * Teleport the agent to a new position
  71532. * @param index agent index returned by addAgent
  71533. * @param destination targeted world position
  71534. */
  71535. agentTeleport(index: number, destination: Vector3): void;
  71536. /**
  71537. * Update agent parameters
  71538. * @param index agent index returned by addAgent
  71539. * @param parameters agent parameters
  71540. */
  71541. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71542. /**
  71543. * remove a particular agent previously created
  71544. * @param index agent index returned by addAgent
  71545. */
  71546. removeAgent(index: number): void;
  71547. /**
  71548. * get the list of all agents attached to this crowd
  71549. * @returns list of agent indices
  71550. */
  71551. getAgents(): number[];
  71552. /**
  71553. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71554. * @param deltaTime in seconds
  71555. */
  71556. update(deltaTime: number): void;
  71557. /**
  71558. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71559. * The queries will try to find a solution within those bounds
  71560. * default is (1,1,1)
  71561. * @param extent x,y,z value that define the extent around the queries point of reference
  71562. */
  71563. setDefaultQueryExtent(extent: Vector3): void;
  71564. /**
  71565. * Get the Bounding box extent specified by setDefaultQueryExtent
  71566. * @returns the box extent values
  71567. */
  71568. getDefaultQueryExtent(): Vector3;
  71569. /**
  71570. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71571. * @param result output the box extent values
  71572. */
  71573. getDefaultQueryExtentToRef(result: Vector3): void;
  71574. /**
  71575. * Release all resources
  71576. */
  71577. dispose(): void;
  71578. }
  71579. }
  71580. declare module "babylonjs/Navigation/Plugins/index" {
  71581. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71582. }
  71583. declare module "babylonjs/Navigation/index" {
  71584. export * from "babylonjs/Navigation/INavigationEngine";
  71585. export * from "babylonjs/Navigation/Plugins/index";
  71586. }
  71587. declare module "babylonjs/Offline/database" {
  71588. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71589. /**
  71590. * Class used to enable access to IndexedDB
  71591. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71592. */
  71593. export class Database implements IOfflineProvider {
  71594. private _callbackManifestChecked;
  71595. private _currentSceneUrl;
  71596. private _db;
  71597. private _enableSceneOffline;
  71598. private _enableTexturesOffline;
  71599. private _manifestVersionFound;
  71600. private _mustUpdateRessources;
  71601. private _hasReachedQuota;
  71602. private _isSupported;
  71603. private _idbFactory;
  71604. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71605. private static IsUASupportingBlobStorage;
  71606. /**
  71607. * Gets a boolean indicating if Database storate is enabled (off by default)
  71608. */
  71609. static IDBStorageEnabled: boolean;
  71610. /**
  71611. * Gets a boolean indicating if scene must be saved in the database
  71612. */
  71613. get enableSceneOffline(): boolean;
  71614. /**
  71615. * Gets a boolean indicating if textures must be saved in the database
  71616. */
  71617. get enableTexturesOffline(): boolean;
  71618. /**
  71619. * Creates a new Database
  71620. * @param urlToScene defines the url to load the scene
  71621. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71622. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71623. */
  71624. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71625. private static _ParseURL;
  71626. private static _ReturnFullUrlLocation;
  71627. private _checkManifestFile;
  71628. /**
  71629. * Open the database and make it available
  71630. * @param successCallback defines the callback to call on success
  71631. * @param errorCallback defines the callback to call on error
  71632. */
  71633. open(successCallback: () => void, errorCallback: () => void): void;
  71634. /**
  71635. * Loads an image from the database
  71636. * @param url defines the url to load from
  71637. * @param image defines the target DOM image
  71638. */
  71639. loadImage(url: string, image: HTMLImageElement): void;
  71640. private _loadImageFromDBAsync;
  71641. private _saveImageIntoDBAsync;
  71642. private _checkVersionFromDB;
  71643. private _loadVersionFromDBAsync;
  71644. private _saveVersionIntoDBAsync;
  71645. /**
  71646. * Loads a file from database
  71647. * @param url defines the URL to load from
  71648. * @param sceneLoaded defines a callback to call on success
  71649. * @param progressCallBack defines a callback to call when progress changed
  71650. * @param errorCallback defines a callback to call on error
  71651. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71652. */
  71653. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71654. private _loadFileAsync;
  71655. private _saveFileAsync;
  71656. /**
  71657. * Validates if xhr data is correct
  71658. * @param xhr defines the request to validate
  71659. * @param dataType defines the expected data type
  71660. * @returns true if data is correct
  71661. */
  71662. private static _ValidateXHRData;
  71663. }
  71664. }
  71665. declare module "babylonjs/Offline/index" {
  71666. export * from "babylonjs/Offline/database";
  71667. export * from "babylonjs/Offline/IOfflineProvider";
  71668. }
  71669. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71670. /** @hidden */
  71671. export var gpuUpdateParticlesPixelShader: {
  71672. name: string;
  71673. shader: string;
  71674. };
  71675. }
  71676. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71677. /** @hidden */
  71678. export var gpuUpdateParticlesVertexShader: {
  71679. name: string;
  71680. shader: string;
  71681. };
  71682. }
  71683. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71684. /** @hidden */
  71685. export var clipPlaneFragmentDeclaration2: {
  71686. name: string;
  71687. shader: string;
  71688. };
  71689. }
  71690. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71691. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71692. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71693. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71694. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71695. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71696. /** @hidden */
  71697. export var gpuRenderParticlesPixelShader: {
  71698. name: string;
  71699. shader: string;
  71700. };
  71701. }
  71702. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71703. /** @hidden */
  71704. export var clipPlaneVertexDeclaration2: {
  71705. name: string;
  71706. shader: string;
  71707. };
  71708. }
  71709. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71710. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71711. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71712. /** @hidden */
  71713. export var gpuRenderParticlesVertexShader: {
  71714. name: string;
  71715. shader: string;
  71716. };
  71717. }
  71718. declare module "babylonjs/Particles/gpuParticleSystem" {
  71719. import { Nullable } from "babylonjs/types";
  71720. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71721. import { Observable } from "babylonjs/Misc/observable";
  71722. import { Matrix } from "babylonjs/Maths/math.vector";
  71723. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71724. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71725. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71726. import { IDisposable } from "babylonjs/scene";
  71727. import { Effect } from "babylonjs/Materials/effect";
  71728. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71729. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71730. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71731. import { Scene } from "babylonjs/scene";
  71732. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71733. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71734. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71735. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71736. /**
  71737. * This represents a GPU particle system in Babylon
  71738. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71739. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71740. */
  71741. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71742. /**
  71743. * The layer mask we are rendering the particles through.
  71744. */
  71745. layerMask: number;
  71746. private _capacity;
  71747. private _activeCount;
  71748. private _currentActiveCount;
  71749. private _accumulatedCount;
  71750. private _renderEffect;
  71751. private _updateEffect;
  71752. private _buffer0;
  71753. private _buffer1;
  71754. private _spriteBuffer;
  71755. private _updateVAO;
  71756. private _renderVAO;
  71757. private _targetIndex;
  71758. private _sourceBuffer;
  71759. private _targetBuffer;
  71760. private _currentRenderId;
  71761. private _started;
  71762. private _stopped;
  71763. private _timeDelta;
  71764. private _randomTexture;
  71765. private _randomTexture2;
  71766. private _attributesStrideSize;
  71767. private _updateEffectOptions;
  71768. private _randomTextureSize;
  71769. private _actualFrame;
  71770. private _customEffect;
  71771. private readonly _rawTextureWidth;
  71772. /**
  71773. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71774. */
  71775. static get IsSupported(): boolean;
  71776. /**
  71777. * An event triggered when the system is disposed.
  71778. */
  71779. onDisposeObservable: Observable<IParticleSystem>;
  71780. /**
  71781. * An event triggered when the system is stopped
  71782. */
  71783. onStoppedObservable: Observable<IParticleSystem>;
  71784. /**
  71785. * Gets the maximum number of particles active at the same time.
  71786. * @returns The max number of active particles.
  71787. */
  71788. getCapacity(): number;
  71789. /**
  71790. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71791. * to override the particles.
  71792. */
  71793. forceDepthWrite: boolean;
  71794. /**
  71795. * Gets or set the number of active particles
  71796. */
  71797. get activeParticleCount(): number;
  71798. set activeParticleCount(value: number);
  71799. private _preWarmDone;
  71800. /**
  71801. * Specifies if the particles are updated in emitter local space or world space.
  71802. */
  71803. isLocal: boolean;
  71804. /** Gets or sets a matrix to use to compute projection */
  71805. defaultProjectionMatrix: Matrix;
  71806. /**
  71807. * Is this system ready to be used/rendered
  71808. * @return true if the system is ready
  71809. */
  71810. isReady(): boolean;
  71811. /**
  71812. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71813. * @returns True if it has been started, otherwise false.
  71814. */
  71815. isStarted(): boolean;
  71816. /**
  71817. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71818. * @returns True if it has been stopped, otherwise false.
  71819. */
  71820. isStopped(): boolean;
  71821. /**
  71822. * Gets a boolean indicating that the system is stopping
  71823. * @returns true if the system is currently stopping
  71824. */
  71825. isStopping(): boolean;
  71826. /**
  71827. * Gets the number of particles active at the same time.
  71828. * @returns The number of active particles.
  71829. */
  71830. getActiveCount(): number;
  71831. /**
  71832. * Starts the particle system and begins to emit
  71833. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71834. */
  71835. start(delay?: number): void;
  71836. /**
  71837. * Stops the particle system.
  71838. */
  71839. stop(): void;
  71840. /**
  71841. * Remove all active particles
  71842. */
  71843. reset(): void;
  71844. /**
  71845. * Returns the string "GPUParticleSystem"
  71846. * @returns a string containing the class name
  71847. */
  71848. getClassName(): string;
  71849. /**
  71850. * Gets the custom effect used to render the particles
  71851. * @param blendMode Blend mode for which the effect should be retrieved
  71852. * @returns The effect
  71853. */
  71854. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71855. /**
  71856. * Sets the custom effect used to render the particles
  71857. * @param effect The effect to set
  71858. * @param blendMode Blend mode for which the effect should be set
  71859. */
  71860. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71861. /** @hidden */
  71862. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71863. /**
  71864. * Observable that will be called just before the particles are drawn
  71865. */
  71866. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71867. /**
  71868. * Gets the name of the particle vertex shader
  71869. */
  71870. get vertexShaderName(): string;
  71871. private _colorGradientsTexture;
  71872. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71873. /**
  71874. * Adds a new color gradient
  71875. * @param gradient defines the gradient to use (between 0 and 1)
  71876. * @param color1 defines the color to affect to the specified gradient
  71877. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71878. * @returns the current particle system
  71879. */
  71880. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71881. private _refreshColorGradient;
  71882. /** Force the system to rebuild all gradients that need to be resync */
  71883. forceRefreshGradients(): void;
  71884. /**
  71885. * Remove a specific color gradient
  71886. * @param gradient defines the gradient to remove
  71887. * @returns the current particle system
  71888. */
  71889. removeColorGradient(gradient: number): GPUParticleSystem;
  71890. private _angularSpeedGradientsTexture;
  71891. private _sizeGradientsTexture;
  71892. private _velocityGradientsTexture;
  71893. private _limitVelocityGradientsTexture;
  71894. private _dragGradientsTexture;
  71895. private _addFactorGradient;
  71896. /**
  71897. * Adds a new size gradient
  71898. * @param gradient defines the gradient to use (between 0 and 1)
  71899. * @param factor defines the size factor to affect to the specified gradient
  71900. * @returns the current particle system
  71901. */
  71902. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71903. /**
  71904. * Remove a specific size gradient
  71905. * @param gradient defines the gradient to remove
  71906. * @returns the current particle system
  71907. */
  71908. removeSizeGradient(gradient: number): GPUParticleSystem;
  71909. private _refreshFactorGradient;
  71910. /**
  71911. * Adds a new angular speed gradient
  71912. * @param gradient defines the gradient to use (between 0 and 1)
  71913. * @param factor defines the angular speed to affect to the specified gradient
  71914. * @returns the current particle system
  71915. */
  71916. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71917. /**
  71918. * Remove a specific angular speed gradient
  71919. * @param gradient defines the gradient to remove
  71920. * @returns the current particle system
  71921. */
  71922. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71923. /**
  71924. * Adds a new velocity gradient
  71925. * @param gradient defines the gradient to use (between 0 and 1)
  71926. * @param factor defines the velocity to affect to the specified gradient
  71927. * @returns the current particle system
  71928. */
  71929. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71930. /**
  71931. * Remove a specific velocity gradient
  71932. * @param gradient defines the gradient to remove
  71933. * @returns the current particle system
  71934. */
  71935. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71936. /**
  71937. * Adds a new limit velocity gradient
  71938. * @param gradient defines the gradient to use (between 0 and 1)
  71939. * @param factor defines the limit velocity value to affect to the specified gradient
  71940. * @returns the current particle system
  71941. */
  71942. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71943. /**
  71944. * Remove a specific limit velocity gradient
  71945. * @param gradient defines the gradient to remove
  71946. * @returns the current particle system
  71947. */
  71948. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71949. /**
  71950. * Adds a new drag gradient
  71951. * @param gradient defines the gradient to use (between 0 and 1)
  71952. * @param factor defines the drag value to affect to the specified gradient
  71953. * @returns the current particle system
  71954. */
  71955. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71956. /**
  71957. * Remove a specific drag gradient
  71958. * @param gradient defines the gradient to remove
  71959. * @returns the current particle system
  71960. */
  71961. removeDragGradient(gradient: number): GPUParticleSystem;
  71962. /**
  71963. * Not supported by GPUParticleSystem
  71964. * @param gradient defines the gradient to use (between 0 and 1)
  71965. * @param factor defines the emit rate value to affect to the specified gradient
  71966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71967. * @returns the current particle system
  71968. */
  71969. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71970. /**
  71971. * Not supported by GPUParticleSystem
  71972. * @param gradient defines the gradient to remove
  71973. * @returns the current particle system
  71974. */
  71975. removeEmitRateGradient(gradient: number): IParticleSystem;
  71976. /**
  71977. * Not supported by GPUParticleSystem
  71978. * @param gradient defines the gradient to use (between 0 and 1)
  71979. * @param factor defines the start size value to affect to the specified gradient
  71980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71981. * @returns the current particle system
  71982. */
  71983. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71984. /**
  71985. * Not supported by GPUParticleSystem
  71986. * @param gradient defines the gradient to remove
  71987. * @returns the current particle system
  71988. */
  71989. removeStartSizeGradient(gradient: number): IParticleSystem;
  71990. /**
  71991. * Not supported by GPUParticleSystem
  71992. * @param gradient defines the gradient to use (between 0 and 1)
  71993. * @param min defines the color remap minimal range
  71994. * @param max defines the color remap maximal range
  71995. * @returns the current particle system
  71996. */
  71997. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71998. /**
  71999. * Not supported by GPUParticleSystem
  72000. * @param gradient defines the gradient to remove
  72001. * @returns the current particle system
  72002. */
  72003. removeColorRemapGradient(): IParticleSystem;
  72004. /**
  72005. * Not supported by GPUParticleSystem
  72006. * @param gradient defines the gradient to use (between 0 and 1)
  72007. * @param min defines the alpha remap minimal range
  72008. * @param max defines the alpha remap maximal range
  72009. * @returns the current particle system
  72010. */
  72011. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72012. /**
  72013. * Not supported by GPUParticleSystem
  72014. * @param gradient defines the gradient to remove
  72015. * @returns the current particle system
  72016. */
  72017. removeAlphaRemapGradient(): IParticleSystem;
  72018. /**
  72019. * Not supported by GPUParticleSystem
  72020. * @param gradient defines the gradient to use (between 0 and 1)
  72021. * @param color defines the color to affect to the specified gradient
  72022. * @returns the current particle system
  72023. */
  72024. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72025. /**
  72026. * Not supported by GPUParticleSystem
  72027. * @param gradient defines the gradient to remove
  72028. * @returns the current particle system
  72029. */
  72030. removeRampGradient(): IParticleSystem;
  72031. /**
  72032. * Not supported by GPUParticleSystem
  72033. * @returns the list of ramp gradients
  72034. */
  72035. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72036. /**
  72037. * Not supported by GPUParticleSystem
  72038. * Gets or sets a boolean indicating that ramp gradients must be used
  72039. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72040. */
  72041. get useRampGradients(): boolean;
  72042. set useRampGradients(value: boolean);
  72043. /**
  72044. * Not supported by GPUParticleSystem
  72045. * @param gradient defines the gradient to use (between 0 and 1)
  72046. * @param factor defines the life time factor to affect to the specified gradient
  72047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72048. * @returns the current particle system
  72049. */
  72050. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72051. /**
  72052. * Not supported by GPUParticleSystem
  72053. * @param gradient defines the gradient to remove
  72054. * @returns the current particle system
  72055. */
  72056. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72057. /**
  72058. * Instantiates a GPU particle system.
  72059. * 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.
  72060. * @param name The name of the particle system
  72061. * @param options The options used to create the system
  72062. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72063. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72064. * @param customEffect a custom effect used to change the way particles are rendered by default
  72065. */
  72066. constructor(name: string, options: Partial<{
  72067. capacity: number;
  72068. randomTextureSize: number;
  72069. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72070. protected _reset(): void;
  72071. private _createUpdateVAO;
  72072. private _createRenderVAO;
  72073. private _initialize;
  72074. /** @hidden */
  72075. _recreateUpdateEffect(): void;
  72076. private _getEffect;
  72077. /**
  72078. * Fill the defines array according to the current settings of the particle system
  72079. * @param defines Array to be updated
  72080. * @param blendMode blend mode to take into account when updating the array
  72081. */
  72082. fillDefines(defines: Array<string>, blendMode?: number): void;
  72083. /**
  72084. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72085. * @param uniforms Uniforms array to fill
  72086. * @param attributes Attributes array to fill
  72087. * @param samplers Samplers array to fill
  72088. */
  72089. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72090. /** @hidden */
  72091. _recreateRenderEffect(): Effect;
  72092. /**
  72093. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72094. * @param preWarm defines if we are in the pre-warmimg phase
  72095. */
  72096. animate(preWarm?: boolean): void;
  72097. private _createFactorGradientTexture;
  72098. private _createSizeGradientTexture;
  72099. private _createAngularSpeedGradientTexture;
  72100. private _createVelocityGradientTexture;
  72101. private _createLimitVelocityGradientTexture;
  72102. private _createDragGradientTexture;
  72103. private _createColorGradientTexture;
  72104. /**
  72105. * Renders the particle system in its current state
  72106. * @param preWarm defines if the system should only update the particles but not render them
  72107. * @returns the current number of particles
  72108. */
  72109. render(preWarm?: boolean): number;
  72110. /**
  72111. * Rebuilds the particle system
  72112. */
  72113. rebuild(): void;
  72114. private _releaseBuffers;
  72115. private _releaseVAOs;
  72116. /**
  72117. * Disposes the particle system and free the associated resources
  72118. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72119. */
  72120. dispose(disposeTexture?: boolean): void;
  72121. /**
  72122. * Clones the particle system.
  72123. * @param name The name of the cloned object
  72124. * @param newEmitter The new emitter to use
  72125. * @returns the cloned particle system
  72126. */
  72127. clone(name: string, newEmitter: any): GPUParticleSystem;
  72128. /**
  72129. * Serializes the particle system to a JSON object
  72130. * @param serializeTexture defines if the texture must be serialized as well
  72131. * @returns the JSON object
  72132. */
  72133. serialize(serializeTexture?: boolean): any;
  72134. /**
  72135. * Parses a JSON object to create a GPU particle system.
  72136. * @param parsedParticleSystem The JSON object to parse
  72137. * @param sceneOrEngine The scene or the engine to create the particle system in
  72138. * @param rootUrl The root url to use to load external dependencies like texture
  72139. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72140. * @returns the parsed GPU particle system
  72141. */
  72142. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72143. }
  72144. }
  72145. declare module "babylonjs/Particles/particleSystemSet" {
  72146. import { Nullable } from "babylonjs/types";
  72147. import { Color3 } from "babylonjs/Maths/math.color";
  72148. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72150. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72151. import { Scene, IDisposable } from "babylonjs/scene";
  72152. /**
  72153. * Represents a set of particle systems working together to create a specific effect
  72154. */
  72155. export class ParticleSystemSet implements IDisposable {
  72156. /**
  72157. * Gets or sets base Assets URL
  72158. */
  72159. static BaseAssetsUrl: string;
  72160. private _emitterCreationOptions;
  72161. private _emitterNode;
  72162. /**
  72163. * Gets the particle system list
  72164. */
  72165. systems: IParticleSystem[];
  72166. /**
  72167. * Gets the emitter node used with this set
  72168. */
  72169. get emitterNode(): Nullable<TransformNode>;
  72170. /**
  72171. * Creates a new emitter mesh as a sphere
  72172. * @param options defines the options used to create the sphere
  72173. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72174. * @param scene defines the hosting scene
  72175. */
  72176. setEmitterAsSphere(options: {
  72177. diameter: number;
  72178. segments: number;
  72179. color: Color3;
  72180. }, renderingGroupId: number, scene: Scene): void;
  72181. /**
  72182. * Starts all particle systems of the set
  72183. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72184. */
  72185. start(emitter?: AbstractMesh): void;
  72186. /**
  72187. * Release all associated resources
  72188. */
  72189. dispose(): void;
  72190. /**
  72191. * Serialize the set into a JSON compatible object
  72192. * @param serializeTexture defines if the texture must be serialized as well
  72193. * @returns a JSON compatible representation of the set
  72194. */
  72195. serialize(serializeTexture?: boolean): any;
  72196. /**
  72197. * Parse a new ParticleSystemSet from a serialized source
  72198. * @param data defines a JSON compatible representation of the set
  72199. * @param scene defines the hosting scene
  72200. * @param gpu defines if we want GPU particles or CPU particles
  72201. * @returns a new ParticleSystemSet
  72202. */
  72203. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72204. }
  72205. }
  72206. declare module "babylonjs/Particles/particleHelper" {
  72207. import { Nullable } from "babylonjs/types";
  72208. import { Scene } from "babylonjs/scene";
  72209. import { Vector3 } from "babylonjs/Maths/math.vector";
  72210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72211. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72212. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72213. /**
  72214. * This class is made for on one-liner static method to help creating particle system set.
  72215. */
  72216. export class ParticleHelper {
  72217. /**
  72218. * Gets or sets base Assets URL
  72219. */
  72220. static BaseAssetsUrl: string;
  72221. /** Define the Url to load snippets */
  72222. static SnippetUrl: string;
  72223. /**
  72224. * Create a default particle system that you can tweak
  72225. * @param emitter defines the emitter to use
  72226. * @param capacity defines the system capacity (default is 500 particles)
  72227. * @param scene defines the hosting scene
  72228. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72229. * @returns the new Particle system
  72230. */
  72231. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72232. /**
  72233. * This is the main static method (one-liner) of this helper to create different particle systems
  72234. * @param type This string represents the type to the particle system to create
  72235. * @param scene The scene where the particle system should live
  72236. * @param gpu If the system will use gpu
  72237. * @returns the ParticleSystemSet created
  72238. */
  72239. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72240. /**
  72241. * Static function used to export a particle system to a ParticleSystemSet variable.
  72242. * Please note that the emitter shape is not exported
  72243. * @param systems defines the particle systems to export
  72244. * @returns the created particle system set
  72245. */
  72246. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72247. /**
  72248. * Creates a particle system from a snippet saved in a remote file
  72249. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72250. * @param url defines the url to load from
  72251. * @param scene defines the hosting scene
  72252. * @param gpu If the system will use gpu
  72253. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72254. * @returns a promise that will resolve to the new particle system
  72255. */
  72256. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72257. /**
  72258. * Creates a particle system from a snippet saved by the particle system editor
  72259. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72260. * @param scene defines the hosting scene
  72261. * @param gpu If the system will use gpu
  72262. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72263. * @returns a promise that will resolve to the new particle system
  72264. */
  72265. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72266. }
  72267. }
  72268. declare module "babylonjs/Particles/particleSystemComponent" {
  72269. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72270. import { Effect } from "babylonjs/Materials/effect";
  72271. import "babylonjs/Shaders/particles.vertex";
  72272. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72273. module "babylonjs/Engines/engine" {
  72274. interface Engine {
  72275. /**
  72276. * Create an effect to use with particle systems.
  72277. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72278. * the particle system for which you want to create a custom effect in the last parameter
  72279. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72280. * @param uniformsNames defines a list of attribute names
  72281. * @param samplers defines an array of string used to represent textures
  72282. * @param defines defines the string containing the defines to use to compile the shaders
  72283. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72284. * @param onCompiled defines a function to call when the effect creation is successful
  72285. * @param onError defines a function to call when the effect creation has failed
  72286. * @param particleSystem the particle system you want to create the effect for
  72287. * @returns the new Effect
  72288. */
  72289. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72290. }
  72291. }
  72292. module "babylonjs/Meshes/mesh" {
  72293. interface Mesh {
  72294. /**
  72295. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72296. * @returns an array of IParticleSystem
  72297. */
  72298. getEmittedParticleSystems(): IParticleSystem[];
  72299. /**
  72300. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72301. * @returns an array of IParticleSystem
  72302. */
  72303. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72304. }
  72305. }
  72306. }
  72307. declare module "babylonjs/Particles/pointsCloudSystem" {
  72308. import { Color4 } from "babylonjs/Maths/math";
  72309. import { Mesh } from "babylonjs/Meshes/mesh";
  72310. import { Scene, IDisposable } from "babylonjs/scene";
  72311. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72312. /** Defines the 4 color options */
  72313. export enum PointColor {
  72314. /** color value */
  72315. Color = 2,
  72316. /** uv value */
  72317. UV = 1,
  72318. /** random value */
  72319. Random = 0,
  72320. /** stated value */
  72321. Stated = 3
  72322. }
  72323. /**
  72324. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72325. * 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.
  72326. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72327. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72328. *
  72329. * Full documentation here : TO BE ENTERED
  72330. */
  72331. export class PointsCloudSystem implements IDisposable {
  72332. /**
  72333. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72334. * Example : var p = SPS.particles[i];
  72335. */
  72336. particles: CloudPoint[];
  72337. /**
  72338. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72339. */
  72340. nbParticles: number;
  72341. /**
  72342. * This a counter for your own usage. It's not set by any SPS functions.
  72343. */
  72344. counter: number;
  72345. /**
  72346. * The PCS name. This name is also given to the underlying mesh.
  72347. */
  72348. name: string;
  72349. /**
  72350. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72351. */
  72352. mesh: Mesh;
  72353. /**
  72354. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72355. * Please read :
  72356. */
  72357. vars: any;
  72358. /**
  72359. * @hidden
  72360. */
  72361. _size: number;
  72362. private _scene;
  72363. private _promises;
  72364. private _positions;
  72365. private _indices;
  72366. private _normals;
  72367. private _colors;
  72368. private _uvs;
  72369. private _indices32;
  72370. private _positions32;
  72371. private _colors32;
  72372. private _uvs32;
  72373. private _updatable;
  72374. private _isVisibilityBoxLocked;
  72375. private _alwaysVisible;
  72376. private _groups;
  72377. private _groupCounter;
  72378. private _computeParticleColor;
  72379. private _computeParticleTexture;
  72380. private _computeParticleRotation;
  72381. private _computeBoundingBox;
  72382. private _isReady;
  72383. /**
  72384. * Creates a PCS (Points Cloud System) object
  72385. * @param name (String) is the PCS name, this will be the underlying mesh name
  72386. * @param pointSize (number) is the size for each point
  72387. * @param scene (Scene) is the scene in which the PCS is added
  72388. * @param options defines the options of the PCS e.g.
  72389. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72390. */
  72391. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72392. updatable?: boolean;
  72393. });
  72394. /**
  72395. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72396. * If no points were added to the PCS, the returned mesh is just a single point.
  72397. * @returns a promise for the created mesh
  72398. */
  72399. buildMeshAsync(): Promise<Mesh>;
  72400. /**
  72401. * @hidden
  72402. */
  72403. private _buildMesh;
  72404. private _addParticle;
  72405. private _randomUnitVector;
  72406. private _getColorIndicesForCoord;
  72407. private _setPointsColorOrUV;
  72408. private _colorFromTexture;
  72409. private _calculateDensity;
  72410. /**
  72411. * Adds points to the PCS in random positions within a unit sphere
  72412. * @param nb (positive integer) the number of particles to be created from this model
  72413. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72414. * @returns the number of groups in the system
  72415. */
  72416. addPoints(nb: number, pointFunction?: any): number;
  72417. /**
  72418. * Adds points to the PCS from the surface of the model shape
  72419. * @param mesh is any Mesh object that will be used as a surface model for the points
  72420. * @param nb (positive integer) the number of particles to be created from this model
  72421. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72422. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72423. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72424. * @returns the number of groups in the system
  72425. */
  72426. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72427. /**
  72428. * Adds points to the PCS inside the model shape
  72429. * @param mesh is any Mesh object that will be used as a surface model for the points
  72430. * @param nb (positive integer) the number of particles to be created from this model
  72431. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72432. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72433. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72434. * @returns the number of groups in the system
  72435. */
  72436. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72437. /**
  72438. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72439. * This method calls `updateParticle()` for each particle of the SPS.
  72440. * For an animated SPS, it is usually called within the render loop.
  72441. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72442. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72443. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72444. * @returns the PCS.
  72445. */
  72446. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72447. /**
  72448. * Disposes the PCS.
  72449. */
  72450. dispose(): void;
  72451. /**
  72452. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72453. * doc :
  72454. * @returns the PCS.
  72455. */
  72456. refreshVisibleSize(): PointsCloudSystem;
  72457. /**
  72458. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72459. * @param size the size (float) of the visibility box
  72460. * note : this doesn't lock the PCS mesh bounding box.
  72461. * doc :
  72462. */
  72463. setVisibilityBox(size: number): void;
  72464. /**
  72465. * Gets whether the PCS is always visible or not
  72466. * doc :
  72467. */
  72468. get isAlwaysVisible(): boolean;
  72469. /**
  72470. * Sets the PCS as always visible or not
  72471. * doc :
  72472. */
  72473. set isAlwaysVisible(val: boolean);
  72474. /**
  72475. * Tells to `setParticles()` to compute the particle rotations or not
  72476. * Default value : false. The PCS is faster when it's set to false
  72477. * Note : particle rotations are only applied to parent particles
  72478. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72479. */
  72480. set computeParticleRotation(val: boolean);
  72481. /**
  72482. * Tells to `setParticles()` to compute the particle colors or not.
  72483. * Default value : true. The PCS is faster when it's set to false.
  72484. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72485. */
  72486. set computeParticleColor(val: boolean);
  72487. set computeParticleTexture(val: boolean);
  72488. /**
  72489. * Gets if `setParticles()` computes the particle colors or not.
  72490. * Default value : false. The PCS is faster when it's set to false.
  72491. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72492. */
  72493. get computeParticleColor(): boolean;
  72494. /**
  72495. * Gets if `setParticles()` computes the particle textures or not.
  72496. * Default value : false. The PCS is faster when it's set to false.
  72497. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72498. */
  72499. get computeParticleTexture(): boolean;
  72500. /**
  72501. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72502. */
  72503. set computeBoundingBox(val: boolean);
  72504. /**
  72505. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72506. */
  72507. get computeBoundingBox(): boolean;
  72508. /**
  72509. * This function does nothing. It may be overwritten to set all the particle first values.
  72510. * The PCS doesn't call this function, you may have to call it by your own.
  72511. * doc :
  72512. */
  72513. initParticles(): void;
  72514. /**
  72515. * This function does nothing. It may be overwritten to recycle a particle
  72516. * The PCS doesn't call this function, you can to call it
  72517. * doc :
  72518. * @param particle The particle to recycle
  72519. * @returns the recycled particle
  72520. */
  72521. recycleParticle(particle: CloudPoint): CloudPoint;
  72522. /**
  72523. * Updates a particle : this function should be overwritten by the user.
  72524. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72525. * doc :
  72526. * @example : just set a particle position or velocity and recycle conditions
  72527. * @param particle The particle to update
  72528. * @returns the updated particle
  72529. */
  72530. updateParticle(particle: CloudPoint): CloudPoint;
  72531. /**
  72532. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72533. * This does nothing and may be overwritten by the user.
  72534. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72535. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72536. * @param update the boolean update value actually passed to setParticles()
  72537. */
  72538. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72539. /**
  72540. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72541. * This will be passed three parameters.
  72542. * This does nothing and may be overwritten by the user.
  72543. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72544. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72545. * @param update the boolean update value actually passed to setParticles()
  72546. */
  72547. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72548. }
  72549. }
  72550. declare module "babylonjs/Particles/cloudPoint" {
  72551. import { Nullable } from "babylonjs/types";
  72552. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72553. import { Mesh } from "babylonjs/Meshes/mesh";
  72554. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72555. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72556. /**
  72557. * Represents one particle of a points cloud system.
  72558. */
  72559. export class CloudPoint {
  72560. /**
  72561. * particle global index
  72562. */
  72563. idx: number;
  72564. /**
  72565. * The color of the particle
  72566. */
  72567. color: Nullable<Color4>;
  72568. /**
  72569. * The world space position of the particle.
  72570. */
  72571. position: Vector3;
  72572. /**
  72573. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72574. */
  72575. rotation: Vector3;
  72576. /**
  72577. * The world space rotation quaternion of the particle.
  72578. */
  72579. rotationQuaternion: Nullable<Quaternion>;
  72580. /**
  72581. * The uv of the particle.
  72582. */
  72583. uv: Nullable<Vector2>;
  72584. /**
  72585. * The current speed of the particle.
  72586. */
  72587. velocity: Vector3;
  72588. /**
  72589. * The pivot point in the particle local space.
  72590. */
  72591. pivot: Vector3;
  72592. /**
  72593. * Must the particle be translated from its pivot point in its local space ?
  72594. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72595. * Default : false
  72596. */
  72597. translateFromPivot: boolean;
  72598. /**
  72599. * Index of this particle in the global "positions" array (Internal use)
  72600. * @hidden
  72601. */
  72602. _pos: number;
  72603. /**
  72604. * @hidden Index of this particle in the global "indices" array (Internal use)
  72605. */
  72606. _ind: number;
  72607. /**
  72608. * Group this particle belongs to
  72609. */
  72610. _group: PointsGroup;
  72611. /**
  72612. * Group id of this particle
  72613. */
  72614. groupId: number;
  72615. /**
  72616. * Index of the particle in its group id (Internal use)
  72617. */
  72618. idxInGroup: number;
  72619. /**
  72620. * @hidden Particle BoundingInfo object (Internal use)
  72621. */
  72622. _boundingInfo: BoundingInfo;
  72623. /**
  72624. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72625. */
  72626. _pcs: PointsCloudSystem;
  72627. /**
  72628. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72629. */
  72630. _stillInvisible: boolean;
  72631. /**
  72632. * @hidden Last computed particle rotation matrix
  72633. */
  72634. _rotationMatrix: number[];
  72635. /**
  72636. * Parent particle Id, if any.
  72637. * Default null.
  72638. */
  72639. parentId: Nullable<number>;
  72640. /**
  72641. * @hidden Internal global position in the PCS.
  72642. */
  72643. _globalPosition: Vector3;
  72644. /**
  72645. * Creates a Point Cloud object.
  72646. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72647. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72648. * @param group (PointsGroup) is the group the particle belongs to
  72649. * @param groupId (integer) is the group identifier in the PCS.
  72650. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72651. * @param pcs defines the PCS it is associated to
  72652. */
  72653. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72654. /**
  72655. * get point size
  72656. */
  72657. get size(): Vector3;
  72658. /**
  72659. * Set point size
  72660. */
  72661. set size(scale: Vector3);
  72662. /**
  72663. * Legacy support, changed quaternion to rotationQuaternion
  72664. */
  72665. get quaternion(): Nullable<Quaternion>;
  72666. /**
  72667. * Legacy support, changed quaternion to rotationQuaternion
  72668. */
  72669. set quaternion(q: Nullable<Quaternion>);
  72670. /**
  72671. * Returns a boolean. True if the particle intersects a mesh, else false
  72672. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72673. * @param target is the object (point or mesh) what the intersection is computed against
  72674. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72675. * @returns true if it intersects
  72676. */
  72677. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72678. /**
  72679. * get the rotation matrix of the particle
  72680. * @hidden
  72681. */
  72682. getRotationMatrix(m: Matrix): void;
  72683. }
  72684. /**
  72685. * Represents a group of points in a points cloud system
  72686. * * PCS internal tool, don't use it manually.
  72687. */
  72688. export class PointsGroup {
  72689. /**
  72690. * The group id
  72691. * @hidden
  72692. */
  72693. groupID: number;
  72694. /**
  72695. * image data for group (internal use)
  72696. * @hidden
  72697. */
  72698. _groupImageData: Nullable<ArrayBufferView>;
  72699. /**
  72700. * Image Width (internal use)
  72701. * @hidden
  72702. */
  72703. _groupImgWidth: number;
  72704. /**
  72705. * Image Height (internal use)
  72706. * @hidden
  72707. */
  72708. _groupImgHeight: number;
  72709. /**
  72710. * Custom position function (internal use)
  72711. * @hidden
  72712. */
  72713. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72714. /**
  72715. * density per facet for surface points
  72716. * @hidden
  72717. */
  72718. _groupDensity: number[];
  72719. /**
  72720. * Only when points are colored by texture carries pointer to texture list array
  72721. * @hidden
  72722. */
  72723. _textureNb: number;
  72724. /**
  72725. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72726. * PCS internal tool, don't use it manually.
  72727. * @hidden
  72728. */
  72729. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72730. }
  72731. }
  72732. declare module "babylonjs/Particles/index" {
  72733. export * from "babylonjs/Particles/baseParticleSystem";
  72734. export * from "babylonjs/Particles/EmitterTypes/index";
  72735. export * from "babylonjs/Particles/gpuParticleSystem";
  72736. export * from "babylonjs/Particles/IParticleSystem";
  72737. export * from "babylonjs/Particles/particle";
  72738. export * from "babylonjs/Particles/particleHelper";
  72739. export * from "babylonjs/Particles/particleSystem";
  72740. import "babylonjs/Particles/particleSystemComponent";
  72741. export * from "babylonjs/Particles/particleSystemComponent";
  72742. export * from "babylonjs/Particles/particleSystemSet";
  72743. export * from "babylonjs/Particles/solidParticle";
  72744. export * from "babylonjs/Particles/solidParticleSystem";
  72745. export * from "babylonjs/Particles/cloudPoint";
  72746. export * from "babylonjs/Particles/pointsCloudSystem";
  72747. export * from "babylonjs/Particles/subEmitter";
  72748. }
  72749. declare module "babylonjs/Physics/physicsEngineComponent" {
  72750. import { Nullable } from "babylonjs/types";
  72751. import { Observable, Observer } from "babylonjs/Misc/observable";
  72752. import { Vector3 } from "babylonjs/Maths/math.vector";
  72753. import { Mesh } from "babylonjs/Meshes/mesh";
  72754. import { ISceneComponent } from "babylonjs/sceneComponent";
  72755. import { Scene } from "babylonjs/scene";
  72756. import { Node } from "babylonjs/node";
  72757. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72758. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72759. module "babylonjs/scene" {
  72760. interface Scene {
  72761. /** @hidden (Backing field) */
  72762. _physicsEngine: Nullable<IPhysicsEngine>;
  72763. /** @hidden */
  72764. _physicsTimeAccumulator: number;
  72765. /**
  72766. * Gets the current physics engine
  72767. * @returns a IPhysicsEngine or null if none attached
  72768. */
  72769. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72770. /**
  72771. * Enables physics to the current scene
  72772. * @param gravity defines the scene's gravity for the physics engine
  72773. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72774. * @return a boolean indicating if the physics engine was initialized
  72775. */
  72776. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72777. /**
  72778. * Disables and disposes the physics engine associated with the scene
  72779. */
  72780. disablePhysicsEngine(): void;
  72781. /**
  72782. * Gets a boolean indicating if there is an active physics engine
  72783. * @returns a boolean indicating if there is an active physics engine
  72784. */
  72785. isPhysicsEnabled(): boolean;
  72786. /**
  72787. * Deletes a physics compound impostor
  72788. * @param compound defines the compound to delete
  72789. */
  72790. deleteCompoundImpostor(compound: any): void;
  72791. /**
  72792. * An event triggered when physic simulation is about to be run
  72793. */
  72794. onBeforePhysicsObservable: Observable<Scene>;
  72795. /**
  72796. * An event triggered when physic simulation has been done
  72797. */
  72798. onAfterPhysicsObservable: Observable<Scene>;
  72799. }
  72800. }
  72801. module "babylonjs/Meshes/abstractMesh" {
  72802. interface AbstractMesh {
  72803. /** @hidden */
  72804. _physicsImpostor: Nullable<PhysicsImpostor>;
  72805. /**
  72806. * Gets or sets impostor used for physic simulation
  72807. * @see https://doc.babylonjs.com/features/physics_engine
  72808. */
  72809. physicsImpostor: Nullable<PhysicsImpostor>;
  72810. /**
  72811. * Gets the current physics impostor
  72812. * @see https://doc.babylonjs.com/features/physics_engine
  72813. * @returns a physics impostor or null
  72814. */
  72815. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72816. /** Apply a physic impulse to the mesh
  72817. * @param force defines the force to apply
  72818. * @param contactPoint defines where to apply the force
  72819. * @returns the current mesh
  72820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72821. */
  72822. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72823. /**
  72824. * Creates a physic joint between two meshes
  72825. * @param otherMesh defines the other mesh to use
  72826. * @param pivot1 defines the pivot to use on this mesh
  72827. * @param pivot2 defines the pivot to use on the other mesh
  72828. * @param options defines additional options (can be plugin dependent)
  72829. * @returns the current mesh
  72830. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72831. */
  72832. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72833. /** @hidden */
  72834. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72835. }
  72836. }
  72837. /**
  72838. * Defines the physics engine scene component responsible to manage a physics engine
  72839. */
  72840. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72841. /**
  72842. * The component name helpful to identify the component in the list of scene components.
  72843. */
  72844. readonly name: string;
  72845. /**
  72846. * The scene the component belongs to.
  72847. */
  72848. scene: Scene;
  72849. /**
  72850. * Creates a new instance of the component for the given scene
  72851. * @param scene Defines the scene to register the component in
  72852. */
  72853. constructor(scene: Scene);
  72854. /**
  72855. * Registers the component in a given scene
  72856. */
  72857. register(): void;
  72858. /**
  72859. * Rebuilds the elements related to this component in case of
  72860. * context lost for instance.
  72861. */
  72862. rebuild(): void;
  72863. /**
  72864. * Disposes the component and the associated ressources
  72865. */
  72866. dispose(): void;
  72867. }
  72868. }
  72869. declare module "babylonjs/Physics/physicsHelper" {
  72870. import { Nullable } from "babylonjs/types";
  72871. import { Vector3 } from "babylonjs/Maths/math.vector";
  72872. import { Mesh } from "babylonjs/Meshes/mesh";
  72873. import { Scene } from "babylonjs/scene";
  72874. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72875. /**
  72876. * A helper for physics simulations
  72877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72878. */
  72879. export class PhysicsHelper {
  72880. private _scene;
  72881. private _physicsEngine;
  72882. /**
  72883. * Initializes the Physics helper
  72884. * @param scene Babylon.js scene
  72885. */
  72886. constructor(scene: Scene);
  72887. /**
  72888. * Applies a radial explosion impulse
  72889. * @param origin the origin of the explosion
  72890. * @param radiusOrEventOptions the radius or the options of radial explosion
  72891. * @param strength the explosion strength
  72892. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72893. * @returns A physics radial explosion event, or null
  72894. */
  72895. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72896. /**
  72897. * Applies a radial explosion force
  72898. * @param origin the origin of the explosion
  72899. * @param radiusOrEventOptions the radius or the options of radial explosion
  72900. * @param strength the explosion strength
  72901. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72902. * @returns A physics radial explosion event, or null
  72903. */
  72904. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72905. /**
  72906. * Creates a gravitational field
  72907. * @param origin the origin of the explosion
  72908. * @param radiusOrEventOptions the radius or the options of radial explosion
  72909. * @param strength the explosion strength
  72910. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72911. * @returns A physics gravitational field event, or null
  72912. */
  72913. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72914. /**
  72915. * Creates a physics updraft event
  72916. * @param origin the origin of the updraft
  72917. * @param radiusOrEventOptions the radius or the options of the updraft
  72918. * @param strength the strength of the updraft
  72919. * @param height the height of the updraft
  72920. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72921. * @returns A physics updraft event, or null
  72922. */
  72923. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72924. /**
  72925. * Creates a physics vortex event
  72926. * @param origin the of the vortex
  72927. * @param radiusOrEventOptions the radius or the options of the vortex
  72928. * @param strength the strength of the vortex
  72929. * @param height the height of the vortex
  72930. * @returns a Physics vortex event, or null
  72931. * A physics vortex event or null
  72932. */
  72933. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72934. }
  72935. /**
  72936. * Represents a physics radial explosion event
  72937. */
  72938. class PhysicsRadialExplosionEvent {
  72939. private _scene;
  72940. private _options;
  72941. private _sphere;
  72942. private _dataFetched;
  72943. /**
  72944. * Initializes a radial explosioin event
  72945. * @param _scene BabylonJS scene
  72946. * @param _options The options for the vortex event
  72947. */
  72948. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72949. /**
  72950. * Returns the data related to the radial explosion event (sphere).
  72951. * @returns The radial explosion event data
  72952. */
  72953. getData(): PhysicsRadialExplosionEventData;
  72954. /**
  72955. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72956. * @param impostor A physics imposter
  72957. * @param origin the origin of the explosion
  72958. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72959. */
  72960. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72961. /**
  72962. * Triggers affecterd impostors callbacks
  72963. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72964. */
  72965. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72966. /**
  72967. * Disposes the sphere.
  72968. * @param force Specifies if the sphere should be disposed by force
  72969. */
  72970. dispose(force?: boolean): void;
  72971. /*** Helpers ***/
  72972. private _prepareSphere;
  72973. private _intersectsWithSphere;
  72974. }
  72975. /**
  72976. * Represents a gravitational field event
  72977. */
  72978. class PhysicsGravitationalFieldEvent {
  72979. private _physicsHelper;
  72980. private _scene;
  72981. private _origin;
  72982. private _options;
  72983. private _tickCallback;
  72984. private _sphere;
  72985. private _dataFetched;
  72986. /**
  72987. * Initializes the physics gravitational field event
  72988. * @param _physicsHelper A physics helper
  72989. * @param _scene BabylonJS scene
  72990. * @param _origin The origin position of the gravitational field event
  72991. * @param _options The options for the vortex event
  72992. */
  72993. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72994. /**
  72995. * Returns the data related to the gravitational field event (sphere).
  72996. * @returns A gravitational field event
  72997. */
  72998. getData(): PhysicsGravitationalFieldEventData;
  72999. /**
  73000. * Enables the gravitational field.
  73001. */
  73002. enable(): void;
  73003. /**
  73004. * Disables the gravitational field.
  73005. */
  73006. disable(): void;
  73007. /**
  73008. * Disposes the sphere.
  73009. * @param force The force to dispose from the gravitational field event
  73010. */
  73011. dispose(force?: boolean): void;
  73012. private _tick;
  73013. }
  73014. /**
  73015. * Represents a physics updraft event
  73016. */
  73017. class PhysicsUpdraftEvent {
  73018. private _scene;
  73019. private _origin;
  73020. private _options;
  73021. private _physicsEngine;
  73022. private _originTop;
  73023. private _originDirection;
  73024. private _tickCallback;
  73025. private _cylinder;
  73026. private _cylinderPosition;
  73027. private _dataFetched;
  73028. /**
  73029. * Initializes the physics updraft event
  73030. * @param _scene BabylonJS scene
  73031. * @param _origin The origin position of the updraft
  73032. * @param _options The options for the updraft event
  73033. */
  73034. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73035. /**
  73036. * Returns the data related to the updraft event (cylinder).
  73037. * @returns A physics updraft event
  73038. */
  73039. getData(): PhysicsUpdraftEventData;
  73040. /**
  73041. * Enables the updraft.
  73042. */
  73043. enable(): void;
  73044. /**
  73045. * Disables the updraft.
  73046. */
  73047. disable(): void;
  73048. /**
  73049. * Disposes the cylinder.
  73050. * @param force Specifies if the updraft should be disposed by force
  73051. */
  73052. dispose(force?: boolean): void;
  73053. private getImpostorHitData;
  73054. private _tick;
  73055. /*** Helpers ***/
  73056. private _prepareCylinder;
  73057. private _intersectsWithCylinder;
  73058. }
  73059. /**
  73060. * Represents a physics vortex event
  73061. */
  73062. class PhysicsVortexEvent {
  73063. private _scene;
  73064. private _origin;
  73065. private _options;
  73066. private _physicsEngine;
  73067. private _originTop;
  73068. private _tickCallback;
  73069. private _cylinder;
  73070. private _cylinderPosition;
  73071. private _dataFetched;
  73072. /**
  73073. * Initializes the physics vortex event
  73074. * @param _scene The BabylonJS scene
  73075. * @param _origin The origin position of the vortex
  73076. * @param _options The options for the vortex event
  73077. */
  73078. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73079. /**
  73080. * Returns the data related to the vortex event (cylinder).
  73081. * @returns The physics vortex event data
  73082. */
  73083. getData(): PhysicsVortexEventData;
  73084. /**
  73085. * Enables the vortex.
  73086. */
  73087. enable(): void;
  73088. /**
  73089. * Disables the cortex.
  73090. */
  73091. disable(): void;
  73092. /**
  73093. * Disposes the sphere.
  73094. * @param force
  73095. */
  73096. dispose(force?: boolean): void;
  73097. private getImpostorHitData;
  73098. private _tick;
  73099. /*** Helpers ***/
  73100. private _prepareCylinder;
  73101. private _intersectsWithCylinder;
  73102. }
  73103. /**
  73104. * Options fot the radial explosion event
  73105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73106. */
  73107. export class PhysicsRadialExplosionEventOptions {
  73108. /**
  73109. * The radius of the sphere for the radial explosion.
  73110. */
  73111. radius: number;
  73112. /**
  73113. * The strenth of the explosion.
  73114. */
  73115. strength: number;
  73116. /**
  73117. * The strenght of the force in correspondence to the distance of the affected object
  73118. */
  73119. falloff: PhysicsRadialImpulseFalloff;
  73120. /**
  73121. * Sphere options for the radial explosion.
  73122. */
  73123. sphere: {
  73124. segments: number;
  73125. diameter: number;
  73126. };
  73127. /**
  73128. * Sphere options for the radial explosion.
  73129. */
  73130. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73131. }
  73132. /**
  73133. * Options fot the updraft event
  73134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73135. */
  73136. export class PhysicsUpdraftEventOptions {
  73137. /**
  73138. * The radius of the cylinder for the vortex
  73139. */
  73140. radius: number;
  73141. /**
  73142. * The strenth of the updraft.
  73143. */
  73144. strength: number;
  73145. /**
  73146. * The height of the cylinder for the updraft.
  73147. */
  73148. height: number;
  73149. /**
  73150. * The mode for the the updraft.
  73151. */
  73152. updraftMode: PhysicsUpdraftMode;
  73153. }
  73154. /**
  73155. * Options fot the vortex event
  73156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73157. */
  73158. export class PhysicsVortexEventOptions {
  73159. /**
  73160. * The radius of the cylinder for the vortex
  73161. */
  73162. radius: number;
  73163. /**
  73164. * The strenth of the vortex.
  73165. */
  73166. strength: number;
  73167. /**
  73168. * The height of the cylinder for the vortex.
  73169. */
  73170. height: number;
  73171. /**
  73172. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73173. */
  73174. centripetalForceThreshold: number;
  73175. /**
  73176. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73177. */
  73178. centripetalForceMultiplier: number;
  73179. /**
  73180. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73181. */
  73182. centrifugalForceMultiplier: number;
  73183. /**
  73184. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73185. */
  73186. updraftForceMultiplier: number;
  73187. }
  73188. /**
  73189. * The strenght of the force in correspondence to the distance of the affected object
  73190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73191. */
  73192. export enum PhysicsRadialImpulseFalloff {
  73193. /** Defines that impulse is constant in strength across it's whole radius */
  73194. Constant = 0,
  73195. /** Defines that impulse gets weaker if it's further from the origin */
  73196. Linear = 1
  73197. }
  73198. /**
  73199. * The strength of the force in correspondence to the distance of the affected object
  73200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73201. */
  73202. export enum PhysicsUpdraftMode {
  73203. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73204. Center = 0,
  73205. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73206. Perpendicular = 1
  73207. }
  73208. /**
  73209. * Interface for a physics hit data
  73210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73211. */
  73212. export interface PhysicsHitData {
  73213. /**
  73214. * The force applied at the contact point
  73215. */
  73216. force: Vector3;
  73217. /**
  73218. * The contact point
  73219. */
  73220. contactPoint: Vector3;
  73221. /**
  73222. * The distance from the origin to the contact point
  73223. */
  73224. distanceFromOrigin: number;
  73225. }
  73226. /**
  73227. * Interface for radial explosion event data
  73228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73229. */
  73230. export interface PhysicsRadialExplosionEventData {
  73231. /**
  73232. * A sphere used for the radial explosion event
  73233. */
  73234. sphere: Mesh;
  73235. }
  73236. /**
  73237. * Interface for gravitational field event data
  73238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73239. */
  73240. export interface PhysicsGravitationalFieldEventData {
  73241. /**
  73242. * A sphere mesh used for the gravitational field event
  73243. */
  73244. sphere: Mesh;
  73245. }
  73246. /**
  73247. * Interface for updraft event data
  73248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73249. */
  73250. export interface PhysicsUpdraftEventData {
  73251. /**
  73252. * A cylinder used for the updraft event
  73253. */
  73254. cylinder: Mesh;
  73255. }
  73256. /**
  73257. * Interface for vortex event data
  73258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73259. */
  73260. export interface PhysicsVortexEventData {
  73261. /**
  73262. * A cylinder used for the vortex event
  73263. */
  73264. cylinder: Mesh;
  73265. }
  73266. /**
  73267. * Interface for an affected physics impostor
  73268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73269. */
  73270. export interface PhysicsAffectedImpostorWithData {
  73271. /**
  73272. * The impostor affected by the effect
  73273. */
  73274. impostor: PhysicsImpostor;
  73275. /**
  73276. * The data about the hit/horce from the explosion
  73277. */
  73278. hitData: PhysicsHitData;
  73279. }
  73280. }
  73281. declare module "babylonjs/Physics/Plugins/index" {
  73282. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73283. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73284. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73285. }
  73286. declare module "babylonjs/Physics/index" {
  73287. export * from "babylonjs/Physics/IPhysicsEngine";
  73288. export * from "babylonjs/Physics/physicsEngine";
  73289. export * from "babylonjs/Physics/physicsEngineComponent";
  73290. export * from "babylonjs/Physics/physicsHelper";
  73291. export * from "babylonjs/Physics/physicsImpostor";
  73292. export * from "babylonjs/Physics/physicsJoint";
  73293. export * from "babylonjs/Physics/Plugins/index";
  73294. }
  73295. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73296. /** @hidden */
  73297. export var blackAndWhitePixelShader: {
  73298. name: string;
  73299. shader: string;
  73300. };
  73301. }
  73302. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73303. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73304. import { Camera } from "babylonjs/Cameras/camera";
  73305. import { Engine } from "babylonjs/Engines/engine";
  73306. import "babylonjs/Shaders/blackAndWhite.fragment";
  73307. import { Nullable } from "babylonjs/types";
  73308. import { Scene } from "babylonjs/scene";
  73309. /**
  73310. * Post process used to render in black and white
  73311. */
  73312. export class BlackAndWhitePostProcess extends PostProcess {
  73313. /**
  73314. * Linear about to convert he result to black and white (default: 1)
  73315. */
  73316. degree: number;
  73317. /**
  73318. * Gets a string identifying the name of the class
  73319. * @returns "BlackAndWhitePostProcess" string
  73320. */
  73321. getClassName(): string;
  73322. /**
  73323. * Creates a black and white post process
  73324. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73325. * @param name The name of the effect.
  73326. * @param options The required width/height ratio to downsize to before computing the render pass.
  73327. * @param camera The camera to apply the render pass to.
  73328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73329. * @param engine The engine which the post process will be applied. (default: current engine)
  73330. * @param reusable If the post process can be reused on the same frame. (default: false)
  73331. */
  73332. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73333. /** @hidden */
  73334. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73335. }
  73336. }
  73337. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73338. import { Nullable } from "babylonjs/types";
  73339. import { Camera } from "babylonjs/Cameras/camera";
  73340. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73341. import { Engine } from "babylonjs/Engines/engine";
  73342. /**
  73343. * This represents a set of one or more post processes in Babylon.
  73344. * A post process can be used to apply a shader to a texture after it is rendered.
  73345. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73346. */
  73347. export class PostProcessRenderEffect {
  73348. private _postProcesses;
  73349. private _getPostProcesses;
  73350. private _singleInstance;
  73351. private _cameras;
  73352. private _indicesForCamera;
  73353. /**
  73354. * Name of the effect
  73355. * @hidden
  73356. */
  73357. _name: string;
  73358. /**
  73359. * Instantiates a post process render effect.
  73360. * A post process can be used to apply a shader to a texture after it is rendered.
  73361. * @param engine The engine the effect is tied to
  73362. * @param name The name of the effect
  73363. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73364. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73365. */
  73366. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73367. /**
  73368. * Checks if all the post processes in the effect are supported.
  73369. */
  73370. get isSupported(): boolean;
  73371. /**
  73372. * Updates the current state of the effect
  73373. * @hidden
  73374. */
  73375. _update(): void;
  73376. /**
  73377. * Attaches the effect on cameras
  73378. * @param cameras The camera to attach to.
  73379. * @hidden
  73380. */
  73381. _attachCameras(cameras: Camera): void;
  73382. /**
  73383. * Attaches the effect on cameras
  73384. * @param cameras The camera to attach to.
  73385. * @hidden
  73386. */
  73387. _attachCameras(cameras: Camera[]): void;
  73388. /**
  73389. * Detaches the effect on cameras
  73390. * @param cameras The camera to detatch from.
  73391. * @hidden
  73392. */
  73393. _detachCameras(cameras: Camera): void;
  73394. /**
  73395. * Detatches the effect on cameras
  73396. * @param cameras The camera to detatch from.
  73397. * @hidden
  73398. */
  73399. _detachCameras(cameras: Camera[]): void;
  73400. /**
  73401. * Enables the effect on given cameras
  73402. * @param cameras The camera to enable.
  73403. * @hidden
  73404. */
  73405. _enable(cameras: Camera): void;
  73406. /**
  73407. * Enables the effect on given cameras
  73408. * @param cameras The camera to enable.
  73409. * @hidden
  73410. */
  73411. _enable(cameras: Nullable<Camera[]>): void;
  73412. /**
  73413. * Disables the effect on the given cameras
  73414. * @param cameras The camera to disable.
  73415. * @hidden
  73416. */
  73417. _disable(cameras: Camera): void;
  73418. /**
  73419. * Disables the effect on the given cameras
  73420. * @param cameras The camera to disable.
  73421. * @hidden
  73422. */
  73423. _disable(cameras: Nullable<Camera[]>): void;
  73424. /**
  73425. * Gets a list of the post processes contained in the effect.
  73426. * @param camera The camera to get the post processes on.
  73427. * @returns The list of the post processes in the effect.
  73428. */
  73429. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73430. }
  73431. }
  73432. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73433. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73434. /** @hidden */
  73435. export var extractHighlightsPixelShader: {
  73436. name: string;
  73437. shader: string;
  73438. };
  73439. }
  73440. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73441. import { Nullable } from "babylonjs/types";
  73442. import { Camera } from "babylonjs/Cameras/camera";
  73443. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73444. import { Engine } from "babylonjs/Engines/engine";
  73445. import "babylonjs/Shaders/extractHighlights.fragment";
  73446. /**
  73447. * 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.
  73448. */
  73449. export class ExtractHighlightsPostProcess extends PostProcess {
  73450. /**
  73451. * The luminance threshold, pixels below this value will be set to black.
  73452. */
  73453. threshold: number;
  73454. /** @hidden */
  73455. _exposure: number;
  73456. /**
  73457. * Post process which has the input texture to be used when performing highlight extraction
  73458. * @hidden
  73459. */
  73460. _inputPostProcess: Nullable<PostProcess>;
  73461. /**
  73462. * Gets a string identifying the name of the class
  73463. * @returns "ExtractHighlightsPostProcess" string
  73464. */
  73465. getClassName(): string;
  73466. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73467. }
  73468. }
  73469. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73470. /** @hidden */
  73471. export var bloomMergePixelShader: {
  73472. name: string;
  73473. shader: string;
  73474. };
  73475. }
  73476. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73477. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73478. import { Nullable } from "babylonjs/types";
  73479. import { Engine } from "babylonjs/Engines/engine";
  73480. import { Camera } from "babylonjs/Cameras/camera";
  73481. import "babylonjs/Shaders/bloomMerge.fragment";
  73482. /**
  73483. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73484. */
  73485. export class BloomMergePostProcess extends PostProcess {
  73486. /** Weight of the bloom to be added to the original input. */
  73487. weight: number;
  73488. /**
  73489. * Gets a string identifying the name of the class
  73490. * @returns "BloomMergePostProcess" string
  73491. */
  73492. getClassName(): string;
  73493. /**
  73494. * Creates a new instance of @see BloomMergePostProcess
  73495. * @param name The name of the effect.
  73496. * @param originalFromInput Post process which's input will be used for the merge.
  73497. * @param blurred Blurred highlights post process which's output will be used.
  73498. * @param weight Weight of the bloom to be added to the original input.
  73499. * @param options The required width/height ratio to downsize to before computing the render pass.
  73500. * @param camera The camera to apply the render pass to.
  73501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73502. * @param engine The engine which the post process will be applied. (default: current engine)
  73503. * @param reusable If the post process can be reused on the same frame. (default: false)
  73504. * @param textureType Type of textures used when performing the post process. (default: 0)
  73505. * @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)
  73506. */
  73507. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73508. /** Weight of the bloom to be added to the original input. */
  73509. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73510. }
  73511. }
  73512. declare module "babylonjs/PostProcesses/bloomEffect" {
  73513. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73514. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73515. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73516. import { Camera } from "babylonjs/Cameras/camera";
  73517. import { Scene } from "babylonjs/scene";
  73518. /**
  73519. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73520. */
  73521. export class BloomEffect extends PostProcessRenderEffect {
  73522. private bloomScale;
  73523. /**
  73524. * @hidden Internal
  73525. */
  73526. _effects: Array<PostProcess>;
  73527. /**
  73528. * @hidden Internal
  73529. */
  73530. _downscale: ExtractHighlightsPostProcess;
  73531. private _blurX;
  73532. private _blurY;
  73533. private _merge;
  73534. /**
  73535. * The luminance threshold to find bright areas of the image to bloom.
  73536. */
  73537. get threshold(): number;
  73538. set threshold(value: number);
  73539. /**
  73540. * The strength of the bloom.
  73541. */
  73542. get weight(): number;
  73543. set weight(value: number);
  73544. /**
  73545. * Specifies the size of the bloom blur kernel, relative to the final output size
  73546. */
  73547. get kernel(): number;
  73548. set kernel(value: number);
  73549. /**
  73550. * Creates a new instance of @see BloomEffect
  73551. * @param scene The scene the effect belongs to.
  73552. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73553. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73554. * @param bloomWeight The the strength of bloom.
  73555. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73556. * @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)
  73557. */
  73558. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73559. /**
  73560. * Disposes each of the internal effects for a given camera.
  73561. * @param camera The camera to dispose the effect on.
  73562. */
  73563. disposeEffects(camera: Camera): void;
  73564. /**
  73565. * @hidden Internal
  73566. */
  73567. _updateEffects(): void;
  73568. /**
  73569. * Internal
  73570. * @returns if all the contained post processes are ready.
  73571. * @hidden
  73572. */
  73573. _isReady(): boolean;
  73574. }
  73575. }
  73576. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73577. /** @hidden */
  73578. export var chromaticAberrationPixelShader: {
  73579. name: string;
  73580. shader: string;
  73581. };
  73582. }
  73583. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73584. import { Vector2 } from "babylonjs/Maths/math.vector";
  73585. import { Nullable } from "babylonjs/types";
  73586. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73587. import { Camera } from "babylonjs/Cameras/camera";
  73588. import { Engine } from "babylonjs/Engines/engine";
  73589. import "babylonjs/Shaders/chromaticAberration.fragment";
  73590. import { Scene } from "babylonjs/scene";
  73591. /**
  73592. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73593. */
  73594. export class ChromaticAberrationPostProcess extends PostProcess {
  73595. /**
  73596. * The amount of seperation of rgb channels (default: 30)
  73597. */
  73598. aberrationAmount: number;
  73599. /**
  73600. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73601. */
  73602. radialIntensity: number;
  73603. /**
  73604. * 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))
  73605. */
  73606. direction: Vector2;
  73607. /**
  73608. * 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))
  73609. */
  73610. centerPosition: Vector2;
  73611. /** The width of the screen to apply the effect on */
  73612. screenWidth: number;
  73613. /** The height of the screen to apply the effect on */
  73614. screenHeight: number;
  73615. /**
  73616. * Gets a string identifying the name of the class
  73617. * @returns "ChromaticAberrationPostProcess" string
  73618. */
  73619. getClassName(): string;
  73620. /**
  73621. * Creates a new instance ChromaticAberrationPostProcess
  73622. * @param name The name of the effect.
  73623. * @param screenWidth The width of the screen to apply the effect on.
  73624. * @param screenHeight The height of the screen to apply the effect on.
  73625. * @param options The required width/height ratio to downsize to before computing the render pass.
  73626. * @param camera The camera to apply the render pass to.
  73627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73628. * @param engine The engine which the post process will be applied. (default: current engine)
  73629. * @param reusable If the post process can be reused on the same frame. (default: false)
  73630. * @param textureType Type of textures used when performing the post process. (default: 0)
  73631. * @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)
  73632. */
  73633. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73634. /** @hidden */
  73635. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73636. }
  73637. }
  73638. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73639. /** @hidden */
  73640. export var circleOfConfusionPixelShader: {
  73641. name: string;
  73642. shader: string;
  73643. };
  73644. }
  73645. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73646. import { Nullable } from "babylonjs/types";
  73647. import { Engine } from "babylonjs/Engines/engine";
  73648. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73649. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73650. import { Camera } from "babylonjs/Cameras/camera";
  73651. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73652. /**
  73653. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73654. */
  73655. export class CircleOfConfusionPostProcess extends PostProcess {
  73656. /**
  73657. * 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.
  73658. */
  73659. lensSize: number;
  73660. /**
  73661. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73662. */
  73663. fStop: number;
  73664. /**
  73665. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73666. */
  73667. focusDistance: number;
  73668. /**
  73669. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73670. */
  73671. focalLength: number;
  73672. /**
  73673. * Gets a string identifying the name of the class
  73674. * @returns "CircleOfConfusionPostProcess" string
  73675. */
  73676. getClassName(): string;
  73677. private _depthTexture;
  73678. /**
  73679. * Creates a new instance CircleOfConfusionPostProcess
  73680. * @param name The name of the effect.
  73681. * @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.
  73682. * @param options The required width/height ratio to downsize to before computing the render pass.
  73683. * @param camera The camera to apply the render pass to.
  73684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73685. * @param engine The engine which the post process will be applied. (default: current engine)
  73686. * @param reusable If the post process can be reused on the same frame. (default: false)
  73687. * @param textureType Type of textures used when performing the post process. (default: 0)
  73688. * @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)
  73689. */
  73690. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73691. /**
  73692. * 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.
  73693. */
  73694. set depthTexture(value: RenderTargetTexture);
  73695. }
  73696. }
  73697. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73698. /** @hidden */
  73699. export var colorCorrectionPixelShader: {
  73700. name: string;
  73701. shader: string;
  73702. };
  73703. }
  73704. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73705. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73706. import { Engine } from "babylonjs/Engines/engine";
  73707. import { Camera } from "babylonjs/Cameras/camera";
  73708. import "babylonjs/Shaders/colorCorrection.fragment";
  73709. import { Nullable } from "babylonjs/types";
  73710. import { Scene } from "babylonjs/scene";
  73711. /**
  73712. *
  73713. * This post-process allows the modification of rendered colors by using
  73714. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73715. *
  73716. * The object needs to be provided an url to a texture containing the color
  73717. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73718. * Use an image editing software to tweak the LUT to match your needs.
  73719. *
  73720. * For an example of a color LUT, see here:
  73721. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73722. * For explanations on color grading, see here:
  73723. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73724. *
  73725. */
  73726. export class ColorCorrectionPostProcess extends PostProcess {
  73727. private _colorTableTexture;
  73728. /**
  73729. * Gets the color table url used to create the LUT texture
  73730. */
  73731. colorTableUrl: string;
  73732. /**
  73733. * Gets a string identifying the name of the class
  73734. * @returns "ColorCorrectionPostProcess" string
  73735. */
  73736. getClassName(): string;
  73737. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73738. /** @hidden */
  73739. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73740. }
  73741. }
  73742. declare module "babylonjs/Shaders/convolution.fragment" {
  73743. /** @hidden */
  73744. export var convolutionPixelShader: {
  73745. name: string;
  73746. shader: string;
  73747. };
  73748. }
  73749. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73750. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73751. import { Nullable } from "babylonjs/types";
  73752. import { Camera } from "babylonjs/Cameras/camera";
  73753. import { Engine } from "babylonjs/Engines/engine";
  73754. import "babylonjs/Shaders/convolution.fragment";
  73755. import { Scene } from "babylonjs/scene";
  73756. /**
  73757. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73758. * input texture to perform effects such as edge detection or sharpening
  73759. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73760. */
  73761. export class ConvolutionPostProcess extends PostProcess {
  73762. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73763. kernel: number[];
  73764. /**
  73765. * Gets a string identifying the name of the class
  73766. * @returns "ConvolutionPostProcess" string
  73767. */
  73768. getClassName(): string;
  73769. /**
  73770. * Creates a new instance ConvolutionPostProcess
  73771. * @param name The name of the effect.
  73772. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73773. * @param options The required width/height ratio to downsize to before computing the render pass.
  73774. * @param camera The camera to apply the render pass to.
  73775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73776. * @param engine The engine which the post process will be applied. (default: current engine)
  73777. * @param reusable If the post process can be reused on the same frame. (default: false)
  73778. * @param textureType Type of textures used when performing the post process. (default: 0)
  73779. */
  73780. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73781. /** @hidden */
  73782. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73783. /**
  73784. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73785. */
  73786. static EdgeDetect0Kernel: number[];
  73787. /**
  73788. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73789. */
  73790. static EdgeDetect1Kernel: number[];
  73791. /**
  73792. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73793. */
  73794. static EdgeDetect2Kernel: number[];
  73795. /**
  73796. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73797. */
  73798. static SharpenKernel: number[];
  73799. /**
  73800. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73801. */
  73802. static EmbossKernel: number[];
  73803. /**
  73804. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73805. */
  73806. static GaussianKernel: number[];
  73807. }
  73808. }
  73809. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73810. import { Nullable } from "babylonjs/types";
  73811. import { Vector2 } from "babylonjs/Maths/math.vector";
  73812. import { Camera } from "babylonjs/Cameras/camera";
  73813. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73814. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73815. import { Engine } from "babylonjs/Engines/engine";
  73816. import { Scene } from "babylonjs/scene";
  73817. /**
  73818. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73819. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73820. * based on samples that have a large difference in distance than the center pixel.
  73821. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73822. */
  73823. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73824. /**
  73825. * The direction the blur should be applied
  73826. */
  73827. direction: Vector2;
  73828. /**
  73829. * Gets a string identifying the name of the class
  73830. * @returns "DepthOfFieldBlurPostProcess" string
  73831. */
  73832. getClassName(): string;
  73833. /**
  73834. * Creates a new instance CircleOfConfusionPostProcess
  73835. * @param name The name of the effect.
  73836. * @param scene The scene the effect belongs to.
  73837. * @param direction The direction the blur should be applied.
  73838. * @param kernel The size of the kernel used to blur.
  73839. * @param options The required width/height ratio to downsize to before computing the render pass.
  73840. * @param camera The camera to apply the render pass to.
  73841. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73842. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73844. * @param engine The engine which the post process will be applied. (default: current engine)
  73845. * @param reusable If the post process can be reused on the same frame. (default: false)
  73846. * @param textureType Type of textures used when performing the post process. (default: 0)
  73847. * @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)
  73848. */
  73849. 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);
  73850. }
  73851. }
  73852. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73853. /** @hidden */
  73854. export var depthOfFieldMergePixelShader: {
  73855. name: string;
  73856. shader: string;
  73857. };
  73858. }
  73859. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73860. import { Nullable } from "babylonjs/types";
  73861. import { Camera } from "babylonjs/Cameras/camera";
  73862. import { Effect } from "babylonjs/Materials/effect";
  73863. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73864. import { Engine } from "babylonjs/Engines/engine";
  73865. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73866. /**
  73867. * Options to be set when merging outputs from the default pipeline.
  73868. */
  73869. export class DepthOfFieldMergePostProcessOptions {
  73870. /**
  73871. * The original image to merge on top of
  73872. */
  73873. originalFromInput: PostProcess;
  73874. /**
  73875. * Parameters to perform the merge of the depth of field effect
  73876. */
  73877. depthOfField?: {
  73878. circleOfConfusion: PostProcess;
  73879. blurSteps: Array<PostProcess>;
  73880. };
  73881. /**
  73882. * Parameters to perform the merge of bloom effect
  73883. */
  73884. bloom?: {
  73885. blurred: PostProcess;
  73886. weight: number;
  73887. };
  73888. }
  73889. /**
  73890. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73891. */
  73892. export class DepthOfFieldMergePostProcess extends PostProcess {
  73893. private blurSteps;
  73894. /**
  73895. * Gets a string identifying the name of the class
  73896. * @returns "DepthOfFieldMergePostProcess" string
  73897. */
  73898. getClassName(): string;
  73899. /**
  73900. * Creates a new instance of DepthOfFieldMergePostProcess
  73901. * @param name The name of the effect.
  73902. * @param originalFromInput Post process which's input will be used for the merge.
  73903. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73904. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73905. * @param options The required width/height ratio to downsize to before computing the render pass.
  73906. * @param camera The camera to apply the render pass to.
  73907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73908. * @param engine The engine which the post process will be applied. (default: current engine)
  73909. * @param reusable If the post process can be reused on the same frame. (default: false)
  73910. * @param textureType Type of textures used when performing the post process. (default: 0)
  73911. * @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)
  73912. */
  73913. 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);
  73914. /**
  73915. * Updates the effect with the current post process compile time values and recompiles the shader.
  73916. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73917. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73918. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73919. * @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
  73920. * @param onCompiled Called when the shader has been compiled.
  73921. * @param onError Called if there is an error when compiling a shader.
  73922. */
  73923. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73924. }
  73925. }
  73926. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73927. import { Nullable } from "babylonjs/types";
  73928. import { Camera } from "babylonjs/Cameras/camera";
  73929. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73930. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73931. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73932. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73933. import { Scene } from "babylonjs/scene";
  73934. /**
  73935. * Specifies the level of max blur that should be applied when using the depth of field effect
  73936. */
  73937. export enum DepthOfFieldEffectBlurLevel {
  73938. /**
  73939. * Subtle blur
  73940. */
  73941. Low = 0,
  73942. /**
  73943. * Medium blur
  73944. */
  73945. Medium = 1,
  73946. /**
  73947. * Large blur
  73948. */
  73949. High = 2
  73950. }
  73951. /**
  73952. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73953. */
  73954. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73955. private _circleOfConfusion;
  73956. /**
  73957. * @hidden Internal, blurs from high to low
  73958. */
  73959. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73960. private _depthOfFieldBlurY;
  73961. private _dofMerge;
  73962. /**
  73963. * @hidden Internal post processes in depth of field effect
  73964. */
  73965. _effects: Array<PostProcess>;
  73966. /**
  73967. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73968. */
  73969. set focalLength(value: number);
  73970. get focalLength(): number;
  73971. /**
  73972. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73973. */
  73974. set fStop(value: number);
  73975. get fStop(): number;
  73976. /**
  73977. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73978. */
  73979. set focusDistance(value: number);
  73980. get focusDistance(): number;
  73981. /**
  73982. * 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.
  73983. */
  73984. set lensSize(value: number);
  73985. get lensSize(): number;
  73986. /**
  73987. * Creates a new instance DepthOfFieldEffect
  73988. * @param scene The scene the effect belongs to.
  73989. * @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.
  73990. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73991. * @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)
  73992. */
  73993. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73994. /**
  73995. * Get the current class name of the current effet
  73996. * @returns "DepthOfFieldEffect"
  73997. */
  73998. getClassName(): string;
  73999. /**
  74000. * 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.
  74001. */
  74002. set depthTexture(value: RenderTargetTexture);
  74003. /**
  74004. * Disposes each of the internal effects for a given camera.
  74005. * @param camera The camera to dispose the effect on.
  74006. */
  74007. disposeEffects(camera: Camera): void;
  74008. /**
  74009. * @hidden Internal
  74010. */
  74011. _updateEffects(): void;
  74012. /**
  74013. * Internal
  74014. * @returns if all the contained post processes are ready.
  74015. * @hidden
  74016. */
  74017. _isReady(): boolean;
  74018. }
  74019. }
  74020. declare module "babylonjs/Shaders/displayPass.fragment" {
  74021. /** @hidden */
  74022. export var displayPassPixelShader: {
  74023. name: string;
  74024. shader: string;
  74025. };
  74026. }
  74027. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74028. import { Nullable } from "babylonjs/types";
  74029. import { Camera } from "babylonjs/Cameras/camera";
  74030. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74031. import { Engine } from "babylonjs/Engines/engine";
  74032. import "babylonjs/Shaders/displayPass.fragment";
  74033. import { Scene } from "babylonjs/scene";
  74034. /**
  74035. * DisplayPassPostProcess which produces an output the same as it's input
  74036. */
  74037. export class DisplayPassPostProcess extends PostProcess {
  74038. /**
  74039. * Gets a string identifying the name of the class
  74040. * @returns "DisplayPassPostProcess" string
  74041. */
  74042. getClassName(): string;
  74043. /**
  74044. * Creates the DisplayPassPostProcess
  74045. * @param name The name of the effect.
  74046. * @param options The required width/height ratio to downsize to before computing the render pass.
  74047. * @param camera The camera to apply the render pass to.
  74048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74049. * @param engine The engine which the post process will be applied. (default: current engine)
  74050. * @param reusable If the post process can be reused on the same frame. (default: false)
  74051. */
  74052. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74053. /** @hidden */
  74054. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74055. }
  74056. }
  74057. declare module "babylonjs/Shaders/filter.fragment" {
  74058. /** @hidden */
  74059. export var filterPixelShader: {
  74060. name: string;
  74061. shader: string;
  74062. };
  74063. }
  74064. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74065. import { Nullable } from "babylonjs/types";
  74066. import { Matrix } from "babylonjs/Maths/math.vector";
  74067. import { Camera } from "babylonjs/Cameras/camera";
  74068. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74069. import { Engine } from "babylonjs/Engines/engine";
  74070. import "babylonjs/Shaders/filter.fragment";
  74071. import { Scene } from "babylonjs/scene";
  74072. /**
  74073. * Applies a kernel filter to the image
  74074. */
  74075. export class FilterPostProcess extends PostProcess {
  74076. /** The matrix to be applied to the image */
  74077. kernelMatrix: Matrix;
  74078. /**
  74079. * Gets a string identifying the name of the class
  74080. * @returns "FilterPostProcess" string
  74081. */
  74082. getClassName(): string;
  74083. /**
  74084. *
  74085. * @param name The name of the effect.
  74086. * @param kernelMatrix The matrix to be applied to the image
  74087. * @param options The required width/height ratio to downsize to before computing the render pass.
  74088. * @param camera The camera to apply the render pass to.
  74089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74090. * @param engine The engine which the post process will be applied. (default: current engine)
  74091. * @param reusable If the post process can be reused on the same frame. (default: false)
  74092. */
  74093. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74094. /** @hidden */
  74095. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74096. }
  74097. }
  74098. declare module "babylonjs/Shaders/fxaa.fragment" {
  74099. /** @hidden */
  74100. export var fxaaPixelShader: {
  74101. name: string;
  74102. shader: string;
  74103. };
  74104. }
  74105. declare module "babylonjs/Shaders/fxaa.vertex" {
  74106. /** @hidden */
  74107. export var fxaaVertexShader: {
  74108. name: string;
  74109. shader: string;
  74110. };
  74111. }
  74112. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74113. import { Nullable } from "babylonjs/types";
  74114. import { Camera } from "babylonjs/Cameras/camera";
  74115. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74116. import { Engine } from "babylonjs/Engines/engine";
  74117. import "babylonjs/Shaders/fxaa.fragment";
  74118. import "babylonjs/Shaders/fxaa.vertex";
  74119. import { Scene } from "babylonjs/scene";
  74120. /**
  74121. * Fxaa post process
  74122. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74123. */
  74124. export class FxaaPostProcess extends PostProcess {
  74125. /**
  74126. * Gets a string identifying the name of the class
  74127. * @returns "FxaaPostProcess" string
  74128. */
  74129. getClassName(): string;
  74130. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74131. private _getDefines;
  74132. /** @hidden */
  74133. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74134. }
  74135. }
  74136. declare module "babylonjs/Shaders/grain.fragment" {
  74137. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74138. /** @hidden */
  74139. export var grainPixelShader: {
  74140. name: string;
  74141. shader: string;
  74142. };
  74143. }
  74144. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74145. import { Nullable } from "babylonjs/types";
  74146. import { Camera } from "babylonjs/Cameras/camera";
  74147. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74148. import { Engine } from "babylonjs/Engines/engine";
  74149. import "babylonjs/Shaders/grain.fragment";
  74150. import { Scene } from "babylonjs/scene";
  74151. /**
  74152. * The GrainPostProcess adds noise to the image at mid luminance levels
  74153. */
  74154. export class GrainPostProcess extends PostProcess {
  74155. /**
  74156. * The intensity of the grain added (default: 30)
  74157. */
  74158. intensity: number;
  74159. /**
  74160. * If the grain should be randomized on every frame
  74161. */
  74162. animated: boolean;
  74163. /**
  74164. * Gets a string identifying the name of the class
  74165. * @returns "GrainPostProcess" string
  74166. */
  74167. getClassName(): string;
  74168. /**
  74169. * Creates a new instance of @see GrainPostProcess
  74170. * @param name The name of the effect.
  74171. * @param options The required width/height ratio to downsize to before computing the render pass.
  74172. * @param camera The camera to apply the render pass to.
  74173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74174. * @param engine The engine which the post process will be applied. (default: current engine)
  74175. * @param reusable If the post process can be reused on the same frame. (default: false)
  74176. * @param textureType Type of textures used when performing the post process. (default: 0)
  74177. * @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)
  74178. */
  74179. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74180. /** @hidden */
  74181. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74182. }
  74183. }
  74184. declare module "babylonjs/Shaders/highlights.fragment" {
  74185. /** @hidden */
  74186. export var highlightsPixelShader: {
  74187. name: string;
  74188. shader: string;
  74189. };
  74190. }
  74191. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74192. import { Nullable } from "babylonjs/types";
  74193. import { Camera } from "babylonjs/Cameras/camera";
  74194. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74195. import { Engine } from "babylonjs/Engines/engine";
  74196. import "babylonjs/Shaders/highlights.fragment";
  74197. /**
  74198. * Extracts highlights from the image
  74199. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74200. */
  74201. export class HighlightsPostProcess extends PostProcess {
  74202. /**
  74203. * Gets a string identifying the name of the class
  74204. * @returns "HighlightsPostProcess" string
  74205. */
  74206. getClassName(): string;
  74207. /**
  74208. * Extracts highlights from the image
  74209. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74210. * @param name The name of the effect.
  74211. * @param options The required width/height ratio to downsize to before computing the render pass.
  74212. * @param camera The camera to apply the render pass to.
  74213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74214. * @param engine The engine which the post process will be applied. (default: current engine)
  74215. * @param reusable If the post process can be reused on the same frame. (default: false)
  74216. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74217. */
  74218. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74219. }
  74220. }
  74221. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74222. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74223. /**
  74224. * Contains all parameters needed for the prepass to perform
  74225. * motion blur
  74226. */
  74227. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74228. /**
  74229. * Is motion blur enabled
  74230. */
  74231. enabled: boolean;
  74232. /**
  74233. * Name of the configuration
  74234. */
  74235. name: string;
  74236. /**
  74237. * Textures that should be present in the MRT for this effect to work
  74238. */
  74239. readonly texturesRequired: number[];
  74240. }
  74241. }
  74242. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74243. import { Nullable } from "babylonjs/types";
  74244. import { Scene } from "babylonjs/scene";
  74245. import { ISceneComponent } from "babylonjs/sceneComponent";
  74246. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74247. module "babylonjs/scene" {
  74248. interface Scene {
  74249. /** @hidden (Backing field) */
  74250. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74251. /**
  74252. * Gets or Sets the current geometry buffer associated to the scene.
  74253. */
  74254. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74255. /**
  74256. * Enables a GeometryBufferRender and associates it with the scene
  74257. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74258. * @returns the GeometryBufferRenderer
  74259. */
  74260. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74261. /**
  74262. * Disables the GeometryBufferRender associated with the scene
  74263. */
  74264. disableGeometryBufferRenderer(): void;
  74265. }
  74266. }
  74267. /**
  74268. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74269. * in several rendering techniques.
  74270. */
  74271. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74272. /**
  74273. * The component name helpful to identify the component in the list of scene components.
  74274. */
  74275. readonly name: string;
  74276. /**
  74277. * The scene the component belongs to.
  74278. */
  74279. scene: Scene;
  74280. /**
  74281. * Creates a new instance of the component for the given scene
  74282. * @param scene Defines the scene to register the component in
  74283. */
  74284. constructor(scene: Scene);
  74285. /**
  74286. * Registers the component in a given scene
  74287. */
  74288. register(): void;
  74289. /**
  74290. * Rebuilds the elements related to this component in case of
  74291. * context lost for instance.
  74292. */
  74293. rebuild(): void;
  74294. /**
  74295. * Disposes the component and the associated ressources
  74296. */
  74297. dispose(): void;
  74298. private _gatherRenderTargets;
  74299. }
  74300. }
  74301. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74302. /** @hidden */
  74303. export var motionBlurPixelShader: {
  74304. name: string;
  74305. shader: string;
  74306. };
  74307. }
  74308. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74309. import { Nullable } from "babylonjs/types";
  74310. import { Camera } from "babylonjs/Cameras/camera";
  74311. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74313. import "babylonjs/Animations/animatable";
  74314. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74315. import "babylonjs/Shaders/motionBlur.fragment";
  74316. import { Engine } from "babylonjs/Engines/engine";
  74317. import { Scene } from "babylonjs/scene";
  74318. /**
  74319. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74320. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74321. * As an example, all you have to do is to create the post-process:
  74322. * var mb = new BABYLON.MotionBlurPostProcess(
  74323. * 'mb', // The name of the effect.
  74324. * scene, // The scene containing the objects to blur according to their velocity.
  74325. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74326. * camera // The camera to apply the render pass to.
  74327. * );
  74328. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74329. */
  74330. export class MotionBlurPostProcess extends PostProcess {
  74331. /**
  74332. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74333. */
  74334. motionStrength: number;
  74335. /**
  74336. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74337. */
  74338. get motionBlurSamples(): number;
  74339. /**
  74340. * Sets the number of iterations to be used for motion blur quality
  74341. */
  74342. set motionBlurSamples(samples: number);
  74343. private _motionBlurSamples;
  74344. private _forceGeometryBuffer;
  74345. private _geometryBufferRenderer;
  74346. private _prePassRenderer;
  74347. /**
  74348. * Gets a string identifying the name of the class
  74349. * @returns "MotionBlurPostProcess" string
  74350. */
  74351. getClassName(): string;
  74352. /**
  74353. * Creates a new instance MotionBlurPostProcess
  74354. * @param name The name of the effect.
  74355. * @param scene The scene containing the objects to blur according to their velocity.
  74356. * @param options The required width/height ratio to downsize to before computing the render pass.
  74357. * @param camera The camera to apply the render pass to.
  74358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74359. * @param engine The engine which the post process will be applied. (default: current engine)
  74360. * @param reusable If the post process can be reused on the same frame. (default: false)
  74361. * @param textureType Type of textures used when performing the post process. (default: 0)
  74362. * @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)
  74363. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74364. */
  74365. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74366. /**
  74367. * Excludes the given skinned mesh from computing bones velocities.
  74368. * 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.
  74369. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74370. */
  74371. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74372. /**
  74373. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74374. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74375. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74376. */
  74377. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74378. /**
  74379. * Disposes the post process.
  74380. * @param camera The camera to dispose the post process on.
  74381. */
  74382. dispose(camera?: Camera): void;
  74383. /** @hidden */
  74384. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74385. }
  74386. }
  74387. declare module "babylonjs/Shaders/refraction.fragment" {
  74388. /** @hidden */
  74389. export var refractionPixelShader: {
  74390. name: string;
  74391. shader: string;
  74392. };
  74393. }
  74394. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74395. import { Color3 } from "babylonjs/Maths/math.color";
  74396. import { Camera } from "babylonjs/Cameras/camera";
  74397. import { Texture } from "babylonjs/Materials/Textures/texture";
  74398. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74399. import { Engine } from "babylonjs/Engines/engine";
  74400. import "babylonjs/Shaders/refraction.fragment";
  74401. import { Scene } from "babylonjs/scene";
  74402. /**
  74403. * Post process which applies a refractin texture
  74404. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74405. */
  74406. export class RefractionPostProcess extends PostProcess {
  74407. private _refTexture;
  74408. private _ownRefractionTexture;
  74409. /** the base color of the refraction (used to taint the rendering) */
  74410. color: Color3;
  74411. /** simulated refraction depth */
  74412. depth: number;
  74413. /** the coefficient of the base color (0 to remove base color tainting) */
  74414. colorLevel: number;
  74415. /** Gets the url used to load the refraction texture */
  74416. refractionTextureUrl: string;
  74417. /**
  74418. * Gets or sets the refraction texture
  74419. * Please note that you are responsible for disposing the texture if you set it manually
  74420. */
  74421. get refractionTexture(): Texture;
  74422. set refractionTexture(value: Texture);
  74423. /**
  74424. * Gets a string identifying the name of the class
  74425. * @returns "RefractionPostProcess" string
  74426. */
  74427. getClassName(): string;
  74428. /**
  74429. * Initializes the RefractionPostProcess
  74430. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74431. * @param name The name of the effect.
  74432. * @param refractionTextureUrl Url of the refraction texture to use
  74433. * @param color the base color of the refraction (used to taint the rendering)
  74434. * @param depth simulated refraction depth
  74435. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74436. * @param camera The camera to apply the render pass to.
  74437. * @param options The required width/height ratio to downsize to before computing the render pass.
  74438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74439. * @param engine The engine which the post process will be applied. (default: current engine)
  74440. * @param reusable If the post process can be reused on the same frame. (default: false)
  74441. */
  74442. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74443. /**
  74444. * Disposes of the post process
  74445. * @param camera Camera to dispose post process on
  74446. */
  74447. dispose(camera: Camera): void;
  74448. /** @hidden */
  74449. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74450. }
  74451. }
  74452. declare module "babylonjs/Shaders/sharpen.fragment" {
  74453. /** @hidden */
  74454. export var sharpenPixelShader: {
  74455. name: string;
  74456. shader: string;
  74457. };
  74458. }
  74459. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74460. import { Nullable } from "babylonjs/types";
  74461. import { Camera } from "babylonjs/Cameras/camera";
  74462. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74463. import "babylonjs/Shaders/sharpen.fragment";
  74464. import { Engine } from "babylonjs/Engines/engine";
  74465. import { Scene } from "babylonjs/scene";
  74466. /**
  74467. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74468. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74469. */
  74470. export class SharpenPostProcess extends PostProcess {
  74471. /**
  74472. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74473. */
  74474. colorAmount: number;
  74475. /**
  74476. * How much sharpness should be applied (default: 0.3)
  74477. */
  74478. edgeAmount: number;
  74479. /**
  74480. * Gets a string identifying the name of the class
  74481. * @returns "SharpenPostProcess" string
  74482. */
  74483. getClassName(): string;
  74484. /**
  74485. * Creates a new instance ConvolutionPostProcess
  74486. * @param name The name of the effect.
  74487. * @param options The required width/height ratio to downsize to before computing the render pass.
  74488. * @param camera The camera to apply the render pass to.
  74489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74490. * @param engine The engine which the post process will be applied. (default: current engine)
  74491. * @param reusable If the post process can be reused on the same frame. (default: false)
  74492. * @param textureType Type of textures used when performing the post process. (default: 0)
  74493. * @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)
  74494. */
  74495. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74496. /** @hidden */
  74497. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74498. }
  74499. }
  74500. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74501. import { Nullable } from "babylonjs/types";
  74502. import { Camera } from "babylonjs/Cameras/camera";
  74503. import { Engine } from "babylonjs/Engines/engine";
  74504. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74505. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74506. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74507. /**
  74508. * PostProcessRenderPipeline
  74509. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74510. */
  74511. export class PostProcessRenderPipeline {
  74512. private engine;
  74513. private _renderEffects;
  74514. private _renderEffectsForIsolatedPass;
  74515. /**
  74516. * List of inspectable custom properties (used by the Inspector)
  74517. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74518. */
  74519. inspectableCustomProperties: IInspectable[];
  74520. /**
  74521. * @hidden
  74522. */
  74523. protected _cameras: Camera[];
  74524. /** @hidden */
  74525. _name: string;
  74526. /**
  74527. * Gets pipeline name
  74528. */
  74529. get name(): string;
  74530. /** Gets the list of attached cameras */
  74531. get cameras(): Camera[];
  74532. /**
  74533. * Initializes a PostProcessRenderPipeline
  74534. * @param engine engine to add the pipeline to
  74535. * @param name name of the pipeline
  74536. */
  74537. constructor(engine: Engine, name: string);
  74538. /**
  74539. * Gets the class name
  74540. * @returns "PostProcessRenderPipeline"
  74541. */
  74542. getClassName(): string;
  74543. /**
  74544. * If all the render effects in the pipeline are supported
  74545. */
  74546. get isSupported(): boolean;
  74547. /**
  74548. * Adds an effect to the pipeline
  74549. * @param renderEffect the effect to add
  74550. */
  74551. addEffect(renderEffect: PostProcessRenderEffect): void;
  74552. /** @hidden */
  74553. _rebuild(): void;
  74554. /** @hidden */
  74555. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74556. /** @hidden */
  74557. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74558. /** @hidden */
  74559. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74560. /** @hidden */
  74561. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74562. /** @hidden */
  74563. _attachCameras(cameras: Camera, unique: boolean): void;
  74564. /** @hidden */
  74565. _attachCameras(cameras: Camera[], unique: boolean): void;
  74566. /** @hidden */
  74567. _detachCameras(cameras: Camera): void;
  74568. /** @hidden */
  74569. _detachCameras(cameras: Nullable<Camera[]>): void;
  74570. /** @hidden */
  74571. _update(): void;
  74572. /** @hidden */
  74573. _reset(): void;
  74574. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74575. /**
  74576. * Sets the required values to the prepass renderer.
  74577. * @param prePassRenderer defines the prepass renderer to setup.
  74578. * @returns true if the pre pass is needed.
  74579. */
  74580. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74581. /**
  74582. * Disposes of the pipeline
  74583. */
  74584. dispose(): void;
  74585. }
  74586. }
  74587. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74588. import { Camera } from "babylonjs/Cameras/camera";
  74589. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74590. /**
  74591. * PostProcessRenderPipelineManager class
  74592. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74593. */
  74594. export class PostProcessRenderPipelineManager {
  74595. private _renderPipelines;
  74596. /**
  74597. * Initializes a PostProcessRenderPipelineManager
  74598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74599. */
  74600. constructor();
  74601. /**
  74602. * Gets the list of supported render pipelines
  74603. */
  74604. get supportedPipelines(): PostProcessRenderPipeline[];
  74605. /**
  74606. * Adds a pipeline to the manager
  74607. * @param renderPipeline The pipeline to add
  74608. */
  74609. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74610. /**
  74611. * Attaches a camera to the pipeline
  74612. * @param renderPipelineName The name of the pipeline to attach to
  74613. * @param cameras the camera to attach
  74614. * @param unique if the camera can be attached multiple times to the pipeline
  74615. */
  74616. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74617. /**
  74618. * Detaches a camera from the pipeline
  74619. * @param renderPipelineName The name of the pipeline to detach from
  74620. * @param cameras the camera to detach
  74621. */
  74622. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74623. /**
  74624. * Enables an effect by name on a pipeline
  74625. * @param renderPipelineName the name of the pipeline to enable the effect in
  74626. * @param renderEffectName the name of the effect to enable
  74627. * @param cameras the cameras that the effect should be enabled on
  74628. */
  74629. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74630. /**
  74631. * Disables an effect by name on a pipeline
  74632. * @param renderPipelineName the name of the pipeline to disable the effect in
  74633. * @param renderEffectName the name of the effect to disable
  74634. * @param cameras the cameras that the effect should be disabled on
  74635. */
  74636. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74637. /**
  74638. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74639. */
  74640. update(): void;
  74641. /** @hidden */
  74642. _rebuild(): void;
  74643. /**
  74644. * Disposes of the manager and pipelines
  74645. */
  74646. dispose(): void;
  74647. }
  74648. }
  74649. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74650. import { ISceneComponent } from "babylonjs/sceneComponent";
  74651. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74652. import { Scene } from "babylonjs/scene";
  74653. module "babylonjs/scene" {
  74654. interface Scene {
  74655. /** @hidden (Backing field) */
  74656. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74657. /**
  74658. * Gets the postprocess render pipeline manager
  74659. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74660. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74661. */
  74662. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74663. }
  74664. }
  74665. /**
  74666. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74667. */
  74668. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74669. /**
  74670. * The component name helpfull to identify the component in the list of scene components.
  74671. */
  74672. readonly name: string;
  74673. /**
  74674. * The scene the component belongs to.
  74675. */
  74676. scene: Scene;
  74677. /**
  74678. * Creates a new instance of the component for the given scene
  74679. * @param scene Defines the scene to register the component in
  74680. */
  74681. constructor(scene: Scene);
  74682. /**
  74683. * Registers the component in a given scene
  74684. */
  74685. register(): void;
  74686. /**
  74687. * Rebuilds the elements related to this component in case of
  74688. * context lost for instance.
  74689. */
  74690. rebuild(): void;
  74691. /**
  74692. * Disposes the component and the associated ressources
  74693. */
  74694. dispose(): void;
  74695. private _gatherRenderTargets;
  74696. }
  74697. }
  74698. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74699. import { Nullable } from "babylonjs/types";
  74700. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74701. import { Camera } from "babylonjs/Cameras/camera";
  74702. import { IDisposable } from "babylonjs/scene";
  74703. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74704. import { Scene } from "babylonjs/scene";
  74705. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74706. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74707. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74708. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74709. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74710. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74711. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74712. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74713. import { Animation } from "babylonjs/Animations/animation";
  74714. /**
  74715. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74716. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74717. */
  74718. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74719. private _scene;
  74720. private _camerasToBeAttached;
  74721. /**
  74722. * ID of the sharpen post process,
  74723. */
  74724. private readonly SharpenPostProcessId;
  74725. /**
  74726. * @ignore
  74727. * ID of the image processing post process;
  74728. */
  74729. readonly ImageProcessingPostProcessId: string;
  74730. /**
  74731. * @ignore
  74732. * ID of the Fast Approximate Anti-Aliasing post process;
  74733. */
  74734. readonly FxaaPostProcessId: string;
  74735. /**
  74736. * ID of the chromatic aberration post process,
  74737. */
  74738. private readonly ChromaticAberrationPostProcessId;
  74739. /**
  74740. * ID of the grain post process
  74741. */
  74742. private readonly GrainPostProcessId;
  74743. /**
  74744. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74745. */
  74746. sharpen: SharpenPostProcess;
  74747. private _sharpenEffect;
  74748. private bloom;
  74749. /**
  74750. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74751. */
  74752. depthOfField: DepthOfFieldEffect;
  74753. /**
  74754. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74755. */
  74756. fxaa: FxaaPostProcess;
  74757. /**
  74758. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74759. */
  74760. imageProcessing: ImageProcessingPostProcess;
  74761. /**
  74762. * Chromatic aberration post process which will shift rgb colors in the image
  74763. */
  74764. chromaticAberration: ChromaticAberrationPostProcess;
  74765. private _chromaticAberrationEffect;
  74766. /**
  74767. * Grain post process which add noise to the image
  74768. */
  74769. grain: GrainPostProcess;
  74770. private _grainEffect;
  74771. /**
  74772. * Glow post process which adds a glow to emissive areas of the image
  74773. */
  74774. private _glowLayer;
  74775. /**
  74776. * Animations which can be used to tweak settings over a period of time
  74777. */
  74778. animations: Animation[];
  74779. private _imageProcessingConfigurationObserver;
  74780. private _sharpenEnabled;
  74781. private _bloomEnabled;
  74782. private _depthOfFieldEnabled;
  74783. private _depthOfFieldBlurLevel;
  74784. private _fxaaEnabled;
  74785. private _imageProcessingEnabled;
  74786. private _defaultPipelineTextureType;
  74787. private _bloomScale;
  74788. private _chromaticAberrationEnabled;
  74789. private _grainEnabled;
  74790. private _buildAllowed;
  74791. /**
  74792. * Gets active scene
  74793. */
  74794. get scene(): Scene;
  74795. /**
  74796. * Enable or disable the sharpen process from the pipeline
  74797. */
  74798. set sharpenEnabled(enabled: boolean);
  74799. get sharpenEnabled(): boolean;
  74800. private _resizeObserver;
  74801. private _hardwareScaleLevel;
  74802. private _bloomKernel;
  74803. /**
  74804. * Specifies the size of the bloom blur kernel, relative to the final output size
  74805. */
  74806. get bloomKernel(): number;
  74807. set bloomKernel(value: number);
  74808. /**
  74809. * Specifies the weight of the bloom in the final rendering
  74810. */
  74811. private _bloomWeight;
  74812. /**
  74813. * Specifies the luma threshold for the area that will be blurred by the bloom
  74814. */
  74815. private _bloomThreshold;
  74816. private _hdr;
  74817. /**
  74818. * The strength of the bloom.
  74819. */
  74820. set bloomWeight(value: number);
  74821. get bloomWeight(): number;
  74822. /**
  74823. * The strength of the bloom.
  74824. */
  74825. set bloomThreshold(value: number);
  74826. get bloomThreshold(): number;
  74827. /**
  74828. * The scale of the bloom, lower value will provide better performance.
  74829. */
  74830. set bloomScale(value: number);
  74831. get bloomScale(): number;
  74832. /**
  74833. * Enable or disable the bloom from the pipeline
  74834. */
  74835. set bloomEnabled(enabled: boolean);
  74836. get bloomEnabled(): boolean;
  74837. private _rebuildBloom;
  74838. /**
  74839. * If the depth of field is enabled.
  74840. */
  74841. get depthOfFieldEnabled(): boolean;
  74842. set depthOfFieldEnabled(enabled: boolean);
  74843. /**
  74844. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74845. */
  74846. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74847. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74848. /**
  74849. * If the anti aliasing is enabled.
  74850. */
  74851. set fxaaEnabled(enabled: boolean);
  74852. get fxaaEnabled(): boolean;
  74853. private _samples;
  74854. /**
  74855. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74856. */
  74857. set samples(sampleCount: number);
  74858. get samples(): number;
  74859. /**
  74860. * If image processing is enabled.
  74861. */
  74862. set imageProcessingEnabled(enabled: boolean);
  74863. get imageProcessingEnabled(): boolean;
  74864. /**
  74865. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74866. */
  74867. set glowLayerEnabled(enabled: boolean);
  74868. get glowLayerEnabled(): boolean;
  74869. /**
  74870. * Gets the glow layer (or null if not defined)
  74871. */
  74872. get glowLayer(): Nullable<GlowLayer>;
  74873. /**
  74874. * Enable or disable the chromaticAberration process from the pipeline
  74875. */
  74876. set chromaticAberrationEnabled(enabled: boolean);
  74877. get chromaticAberrationEnabled(): boolean;
  74878. /**
  74879. * Enable or disable the grain process from the pipeline
  74880. */
  74881. set grainEnabled(enabled: boolean);
  74882. get grainEnabled(): boolean;
  74883. /**
  74884. * @constructor
  74885. * @param name - The rendering pipeline name (default: "")
  74886. * @param hdr - If high dynamic range textures should be used (default: true)
  74887. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74888. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74889. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74890. */
  74891. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74892. /**
  74893. * Get the class name
  74894. * @returns "DefaultRenderingPipeline"
  74895. */
  74896. getClassName(): string;
  74897. /**
  74898. * Force the compilation of the entire pipeline.
  74899. */
  74900. prepare(): void;
  74901. private _hasCleared;
  74902. private _prevPostProcess;
  74903. private _prevPrevPostProcess;
  74904. private _setAutoClearAndTextureSharing;
  74905. private _depthOfFieldSceneObserver;
  74906. private _buildPipeline;
  74907. private _disposePostProcesses;
  74908. /**
  74909. * Adds a camera to the pipeline
  74910. * @param camera the camera to be added
  74911. */
  74912. addCamera(camera: Camera): void;
  74913. /**
  74914. * Removes a camera from the pipeline
  74915. * @param camera the camera to remove
  74916. */
  74917. removeCamera(camera: Camera): void;
  74918. /**
  74919. * Dispose of the pipeline and stop all post processes
  74920. */
  74921. dispose(): void;
  74922. /**
  74923. * Serialize the rendering pipeline (Used when exporting)
  74924. * @returns the serialized object
  74925. */
  74926. serialize(): any;
  74927. /**
  74928. * Parse the serialized pipeline
  74929. * @param source Source pipeline.
  74930. * @param scene The scene to load the pipeline to.
  74931. * @param rootUrl The URL of the serialized pipeline.
  74932. * @returns An instantiated pipeline from the serialized object.
  74933. */
  74934. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74935. }
  74936. }
  74937. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74938. /** @hidden */
  74939. export var lensHighlightsPixelShader: {
  74940. name: string;
  74941. shader: string;
  74942. };
  74943. }
  74944. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74945. /** @hidden */
  74946. export var depthOfFieldPixelShader: {
  74947. name: string;
  74948. shader: string;
  74949. };
  74950. }
  74951. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74952. import { Camera } from "babylonjs/Cameras/camera";
  74953. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74954. import { Scene } from "babylonjs/scene";
  74955. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74956. import "babylonjs/Shaders/chromaticAberration.fragment";
  74957. import "babylonjs/Shaders/lensHighlights.fragment";
  74958. import "babylonjs/Shaders/depthOfField.fragment";
  74959. /**
  74960. * BABYLON.JS Chromatic Aberration GLSL Shader
  74961. * Author: Olivier Guyot
  74962. * Separates very slightly R, G and B colors on the edges of the screen
  74963. * Inspired by Francois Tarlier & Martins Upitis
  74964. */
  74965. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74966. /**
  74967. * @ignore
  74968. * The chromatic aberration PostProcess id in the pipeline
  74969. */
  74970. LensChromaticAberrationEffect: string;
  74971. /**
  74972. * @ignore
  74973. * The highlights enhancing PostProcess id in the pipeline
  74974. */
  74975. HighlightsEnhancingEffect: string;
  74976. /**
  74977. * @ignore
  74978. * The depth-of-field PostProcess id in the pipeline
  74979. */
  74980. LensDepthOfFieldEffect: string;
  74981. private _scene;
  74982. private _depthTexture;
  74983. private _grainTexture;
  74984. private _chromaticAberrationPostProcess;
  74985. private _highlightsPostProcess;
  74986. private _depthOfFieldPostProcess;
  74987. private _edgeBlur;
  74988. private _grainAmount;
  74989. private _chromaticAberration;
  74990. private _distortion;
  74991. private _highlightsGain;
  74992. private _highlightsThreshold;
  74993. private _dofDistance;
  74994. private _dofAperture;
  74995. private _dofDarken;
  74996. private _dofPentagon;
  74997. private _blurNoise;
  74998. /**
  74999. * @constructor
  75000. *
  75001. * Effect parameters are as follow:
  75002. * {
  75003. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75004. * edge_blur: number; // from 0 to x (1 for realism)
  75005. * distortion: number; // from 0 to x (1 for realism)
  75006. * grain_amount: number; // from 0 to 1
  75007. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75008. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75009. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75010. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75011. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75012. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75013. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75014. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75015. * }
  75016. * Note: if an effect parameter is unset, effect is disabled
  75017. *
  75018. * @param name The rendering pipeline name
  75019. * @param parameters - An object containing all parameters (see above)
  75020. * @param scene The scene linked to this pipeline
  75021. * @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)
  75022. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75023. */
  75024. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75025. /**
  75026. * Get the class name
  75027. * @returns "LensRenderingPipeline"
  75028. */
  75029. getClassName(): string;
  75030. /**
  75031. * Gets associated scene
  75032. */
  75033. get scene(): Scene;
  75034. /**
  75035. * Gets or sets the edge blur
  75036. */
  75037. get edgeBlur(): number;
  75038. set edgeBlur(value: number);
  75039. /**
  75040. * Gets or sets the grain amount
  75041. */
  75042. get grainAmount(): number;
  75043. set grainAmount(value: number);
  75044. /**
  75045. * Gets or sets the chromatic aberration amount
  75046. */
  75047. get chromaticAberration(): number;
  75048. set chromaticAberration(value: number);
  75049. /**
  75050. * Gets or sets the depth of field aperture
  75051. */
  75052. get dofAperture(): number;
  75053. set dofAperture(value: number);
  75054. /**
  75055. * Gets or sets the edge distortion
  75056. */
  75057. get edgeDistortion(): number;
  75058. set edgeDistortion(value: number);
  75059. /**
  75060. * Gets or sets the depth of field distortion
  75061. */
  75062. get dofDistortion(): number;
  75063. set dofDistortion(value: number);
  75064. /**
  75065. * Gets or sets the darken out of focus amount
  75066. */
  75067. get darkenOutOfFocus(): number;
  75068. set darkenOutOfFocus(value: number);
  75069. /**
  75070. * Gets or sets a boolean indicating if blur noise is enabled
  75071. */
  75072. get blurNoise(): boolean;
  75073. set blurNoise(value: boolean);
  75074. /**
  75075. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75076. */
  75077. get pentagonBokeh(): boolean;
  75078. set pentagonBokeh(value: boolean);
  75079. /**
  75080. * Gets or sets the highlight grain amount
  75081. */
  75082. get highlightsGain(): number;
  75083. set highlightsGain(value: number);
  75084. /**
  75085. * Gets or sets the highlight threshold
  75086. */
  75087. get highlightsThreshold(): number;
  75088. set highlightsThreshold(value: number);
  75089. /**
  75090. * Sets the amount of blur at the edges
  75091. * @param amount blur amount
  75092. */
  75093. setEdgeBlur(amount: number): void;
  75094. /**
  75095. * Sets edge blur to 0
  75096. */
  75097. disableEdgeBlur(): void;
  75098. /**
  75099. * Sets the amout of grain
  75100. * @param amount Amount of grain
  75101. */
  75102. setGrainAmount(amount: number): void;
  75103. /**
  75104. * Set grain amount to 0
  75105. */
  75106. disableGrain(): void;
  75107. /**
  75108. * Sets the chromatic aberration amount
  75109. * @param amount amount of chromatic aberration
  75110. */
  75111. setChromaticAberration(amount: number): void;
  75112. /**
  75113. * Sets chromatic aberration amount to 0
  75114. */
  75115. disableChromaticAberration(): void;
  75116. /**
  75117. * Sets the EdgeDistortion amount
  75118. * @param amount amount of EdgeDistortion
  75119. */
  75120. setEdgeDistortion(amount: number): void;
  75121. /**
  75122. * Sets edge distortion to 0
  75123. */
  75124. disableEdgeDistortion(): void;
  75125. /**
  75126. * Sets the FocusDistance amount
  75127. * @param amount amount of FocusDistance
  75128. */
  75129. setFocusDistance(amount: number): void;
  75130. /**
  75131. * Disables depth of field
  75132. */
  75133. disableDepthOfField(): void;
  75134. /**
  75135. * Sets the Aperture amount
  75136. * @param amount amount of Aperture
  75137. */
  75138. setAperture(amount: number): void;
  75139. /**
  75140. * Sets the DarkenOutOfFocus amount
  75141. * @param amount amount of DarkenOutOfFocus
  75142. */
  75143. setDarkenOutOfFocus(amount: number): void;
  75144. private _pentagonBokehIsEnabled;
  75145. /**
  75146. * Creates a pentagon bokeh effect
  75147. */
  75148. enablePentagonBokeh(): void;
  75149. /**
  75150. * Disables the pentagon bokeh effect
  75151. */
  75152. disablePentagonBokeh(): void;
  75153. /**
  75154. * Enables noise blur
  75155. */
  75156. enableNoiseBlur(): void;
  75157. /**
  75158. * Disables noise blur
  75159. */
  75160. disableNoiseBlur(): void;
  75161. /**
  75162. * Sets the HighlightsGain amount
  75163. * @param amount amount of HighlightsGain
  75164. */
  75165. setHighlightsGain(amount: number): void;
  75166. /**
  75167. * Sets the HighlightsThreshold amount
  75168. * @param amount amount of HighlightsThreshold
  75169. */
  75170. setHighlightsThreshold(amount: number): void;
  75171. /**
  75172. * Disables highlights
  75173. */
  75174. disableHighlights(): void;
  75175. /**
  75176. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75177. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75178. */
  75179. dispose(disableDepthRender?: boolean): void;
  75180. private _createChromaticAberrationPostProcess;
  75181. private _createHighlightsPostProcess;
  75182. private _createDepthOfFieldPostProcess;
  75183. private _createGrainTexture;
  75184. }
  75185. }
  75186. declare module "babylonjs/Rendering/ssao2Configuration" {
  75187. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75188. /**
  75189. * Contains all parameters needed for the prepass to perform
  75190. * screen space subsurface scattering
  75191. */
  75192. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75193. /**
  75194. * Is subsurface enabled
  75195. */
  75196. enabled: boolean;
  75197. /**
  75198. * Name of the configuration
  75199. */
  75200. name: string;
  75201. /**
  75202. * Textures that should be present in the MRT for this effect to work
  75203. */
  75204. readonly texturesRequired: number[];
  75205. }
  75206. }
  75207. declare module "babylonjs/Shaders/ssao2.fragment" {
  75208. /** @hidden */
  75209. export var ssao2PixelShader: {
  75210. name: string;
  75211. shader: string;
  75212. };
  75213. }
  75214. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75215. /** @hidden */
  75216. export var ssaoCombinePixelShader: {
  75217. name: string;
  75218. shader: string;
  75219. };
  75220. }
  75221. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75222. import { Camera } from "babylonjs/Cameras/camera";
  75223. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75224. import { Scene } from "babylonjs/scene";
  75225. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75226. import "babylonjs/Shaders/ssao2.fragment";
  75227. import "babylonjs/Shaders/ssaoCombine.fragment";
  75228. /**
  75229. * Render pipeline to produce ssao effect
  75230. */
  75231. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75232. /**
  75233. * @ignore
  75234. * The PassPostProcess id in the pipeline that contains the original scene color
  75235. */
  75236. SSAOOriginalSceneColorEffect: string;
  75237. /**
  75238. * @ignore
  75239. * The SSAO PostProcess id in the pipeline
  75240. */
  75241. SSAORenderEffect: string;
  75242. /**
  75243. * @ignore
  75244. * The horizontal blur PostProcess id in the pipeline
  75245. */
  75246. SSAOBlurHRenderEffect: string;
  75247. /**
  75248. * @ignore
  75249. * The vertical blur PostProcess id in the pipeline
  75250. */
  75251. SSAOBlurVRenderEffect: string;
  75252. /**
  75253. * @ignore
  75254. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75255. */
  75256. SSAOCombineRenderEffect: string;
  75257. /**
  75258. * The output strength of the SSAO post-process. Default value is 1.0.
  75259. */
  75260. totalStrength: number;
  75261. /**
  75262. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75263. */
  75264. maxZ: number;
  75265. /**
  75266. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75267. */
  75268. minZAspect: number;
  75269. private _samples;
  75270. /**
  75271. * Number of samples used for the SSAO calculations. Default value is 8
  75272. */
  75273. set samples(n: number);
  75274. get samples(): number;
  75275. private _textureSamples;
  75276. /**
  75277. * Number of samples to use for antialiasing
  75278. */
  75279. set textureSamples(n: number);
  75280. get textureSamples(): number;
  75281. /**
  75282. * Force rendering the geometry through geometry buffer
  75283. */
  75284. private _forceGeometryBuffer;
  75285. /**
  75286. * Ratio object used for SSAO ratio and blur ratio
  75287. */
  75288. private _ratio;
  75289. /**
  75290. * Dynamically generated sphere sampler.
  75291. */
  75292. private _sampleSphere;
  75293. /**
  75294. * Blur filter offsets
  75295. */
  75296. private _samplerOffsets;
  75297. private _expensiveBlur;
  75298. /**
  75299. * If bilateral blur should be used
  75300. */
  75301. set expensiveBlur(b: boolean);
  75302. get expensiveBlur(): boolean;
  75303. /**
  75304. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75305. */
  75306. radius: number;
  75307. /**
  75308. * The base color of the SSAO post-process
  75309. * The final result is "base + ssao" between [0, 1]
  75310. */
  75311. base: number;
  75312. /**
  75313. * Support test.
  75314. */
  75315. static get IsSupported(): boolean;
  75316. private _scene;
  75317. private _randomTexture;
  75318. private _originalColorPostProcess;
  75319. private _ssaoPostProcess;
  75320. private _blurHPostProcess;
  75321. private _blurVPostProcess;
  75322. private _ssaoCombinePostProcess;
  75323. private _prePassRenderer;
  75324. /**
  75325. * Gets active scene
  75326. */
  75327. get scene(): Scene;
  75328. /**
  75329. * @constructor
  75330. * @param name The rendering pipeline name
  75331. * @param scene The scene linked to this pipeline
  75332. * @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 }
  75333. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75334. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75335. */
  75336. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75337. /**
  75338. * Get the class name
  75339. * @returns "SSAO2RenderingPipeline"
  75340. */
  75341. getClassName(): string;
  75342. /**
  75343. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75344. */
  75345. dispose(disableGeometryBufferRenderer?: boolean): void;
  75346. private _createBlurPostProcess;
  75347. /** @hidden */
  75348. _rebuild(): void;
  75349. private _bits;
  75350. private _radicalInverse_VdC;
  75351. private _hammersley;
  75352. private _hemisphereSample_uniform;
  75353. private _generateHemisphere;
  75354. private _getDefinesForSSAO;
  75355. private _createSSAOPostProcess;
  75356. private _createSSAOCombinePostProcess;
  75357. private _createRandomTexture;
  75358. /**
  75359. * Serialize the rendering pipeline (Used when exporting)
  75360. * @returns the serialized object
  75361. */
  75362. serialize(): any;
  75363. /**
  75364. * Parse the serialized pipeline
  75365. * @param source Source pipeline.
  75366. * @param scene The scene to load the pipeline to.
  75367. * @param rootUrl The URL of the serialized pipeline.
  75368. * @returns An instantiated pipeline from the serialized object.
  75369. */
  75370. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75371. }
  75372. }
  75373. declare module "babylonjs/Shaders/ssao.fragment" {
  75374. /** @hidden */
  75375. export var ssaoPixelShader: {
  75376. name: string;
  75377. shader: string;
  75378. };
  75379. }
  75380. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75381. import { Camera } from "babylonjs/Cameras/camera";
  75382. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75383. import { Scene } from "babylonjs/scene";
  75384. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75385. import "babylonjs/Shaders/ssao.fragment";
  75386. import "babylonjs/Shaders/ssaoCombine.fragment";
  75387. /**
  75388. * Render pipeline to produce ssao effect
  75389. */
  75390. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75391. /**
  75392. * @ignore
  75393. * The PassPostProcess id in the pipeline that contains the original scene color
  75394. */
  75395. SSAOOriginalSceneColorEffect: string;
  75396. /**
  75397. * @ignore
  75398. * The SSAO PostProcess id in the pipeline
  75399. */
  75400. SSAORenderEffect: string;
  75401. /**
  75402. * @ignore
  75403. * The horizontal blur PostProcess id in the pipeline
  75404. */
  75405. SSAOBlurHRenderEffect: string;
  75406. /**
  75407. * @ignore
  75408. * The vertical blur PostProcess id in the pipeline
  75409. */
  75410. SSAOBlurVRenderEffect: string;
  75411. /**
  75412. * @ignore
  75413. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75414. */
  75415. SSAOCombineRenderEffect: string;
  75416. /**
  75417. * The output strength of the SSAO post-process. Default value is 1.0.
  75418. */
  75419. totalStrength: number;
  75420. /**
  75421. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75422. */
  75423. radius: number;
  75424. /**
  75425. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75426. * Must not be equal to fallOff and superior to fallOff.
  75427. * Default value is 0.0075
  75428. */
  75429. area: number;
  75430. /**
  75431. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75432. * Must not be equal to area and inferior to area.
  75433. * Default value is 0.000001
  75434. */
  75435. fallOff: number;
  75436. /**
  75437. * The base color of the SSAO post-process
  75438. * The final result is "base + ssao" between [0, 1]
  75439. */
  75440. base: number;
  75441. private _scene;
  75442. private _depthTexture;
  75443. private _randomTexture;
  75444. private _originalColorPostProcess;
  75445. private _ssaoPostProcess;
  75446. private _blurHPostProcess;
  75447. private _blurVPostProcess;
  75448. private _ssaoCombinePostProcess;
  75449. private _firstUpdate;
  75450. /**
  75451. * Gets active scene
  75452. */
  75453. get scene(): Scene;
  75454. /**
  75455. * @constructor
  75456. * @param name - The rendering pipeline name
  75457. * @param scene - The scene linked to this pipeline
  75458. * @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 }
  75459. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75460. */
  75461. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75462. /**
  75463. * Get the class name
  75464. * @returns "SSAORenderingPipeline"
  75465. */
  75466. getClassName(): string;
  75467. /**
  75468. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75469. */
  75470. dispose(disableDepthRender?: boolean): void;
  75471. private _createBlurPostProcess;
  75472. /** @hidden */
  75473. _rebuild(): void;
  75474. private _createSSAOPostProcess;
  75475. private _createSSAOCombinePostProcess;
  75476. private _createRandomTexture;
  75477. }
  75478. }
  75479. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75480. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75481. /**
  75482. * Contains all parameters needed for the prepass to perform
  75483. * screen space reflections
  75484. */
  75485. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75486. /**
  75487. * Is ssr enabled
  75488. */
  75489. enabled: boolean;
  75490. /**
  75491. * Name of the configuration
  75492. */
  75493. name: string;
  75494. /**
  75495. * Textures that should be present in the MRT for this effect to work
  75496. */
  75497. readonly texturesRequired: number[];
  75498. }
  75499. }
  75500. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75501. /** @hidden */
  75502. export var screenSpaceReflectionPixelShader: {
  75503. name: string;
  75504. shader: string;
  75505. };
  75506. }
  75507. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75508. import { Nullable } from "babylonjs/types";
  75509. import { Camera } from "babylonjs/Cameras/camera";
  75510. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75511. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75512. import { Engine } from "babylonjs/Engines/engine";
  75513. import { Scene } from "babylonjs/scene";
  75514. /**
  75515. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75516. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75517. */
  75518. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75519. /**
  75520. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75521. */
  75522. threshold: number;
  75523. /**
  75524. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75525. */
  75526. strength: number;
  75527. /**
  75528. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75529. */
  75530. reflectionSpecularFalloffExponent: number;
  75531. /**
  75532. * 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]
  75533. */
  75534. step: number;
  75535. /**
  75536. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75537. */
  75538. roughnessFactor: number;
  75539. private _forceGeometryBuffer;
  75540. private _geometryBufferRenderer;
  75541. private _prePassRenderer;
  75542. private _enableSmoothReflections;
  75543. private _reflectionSamples;
  75544. private _smoothSteps;
  75545. /**
  75546. * Gets a string identifying the name of the class
  75547. * @returns "ScreenSpaceReflectionPostProcess" string
  75548. */
  75549. getClassName(): string;
  75550. /**
  75551. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75552. * @param name The name of the effect.
  75553. * @param scene The scene containing the objects to calculate reflections.
  75554. * @param options The required width/height ratio to downsize to before computing the render pass.
  75555. * @param camera The camera to apply the render pass to.
  75556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75557. * @param engine The engine which the post process will be applied. (default: current engine)
  75558. * @param reusable If the post process can be reused on the same frame. (default: false)
  75559. * @param textureType Type of textures used when performing the post process. (default: 0)
  75560. * @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)
  75561. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75562. */
  75563. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75564. /**
  75565. * Gets wether or not smoothing reflections is enabled.
  75566. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75567. */
  75568. get enableSmoothReflections(): boolean;
  75569. /**
  75570. * Sets wether or not smoothing reflections is enabled.
  75571. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75572. */
  75573. set enableSmoothReflections(enabled: boolean);
  75574. /**
  75575. * Gets the number of samples taken while computing reflections. More samples count is high,
  75576. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75577. */
  75578. get reflectionSamples(): number;
  75579. /**
  75580. * Sets the number of samples taken while computing reflections. More samples count is high,
  75581. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75582. */
  75583. set reflectionSamples(samples: number);
  75584. /**
  75585. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75586. * more the post-process will require GPU power and can generate a drop in FPS.
  75587. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75588. */
  75589. get smoothSteps(): number;
  75590. set smoothSteps(steps: number);
  75591. private _updateEffectDefines;
  75592. /** @hidden */
  75593. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75594. }
  75595. }
  75596. declare module "babylonjs/Shaders/standard.fragment" {
  75597. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75598. /** @hidden */
  75599. export var standardPixelShader: {
  75600. name: string;
  75601. shader: string;
  75602. };
  75603. }
  75604. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75605. import { Nullable } from "babylonjs/types";
  75606. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75607. import { Camera } from "babylonjs/Cameras/camera";
  75608. import { Texture } from "babylonjs/Materials/Textures/texture";
  75609. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75610. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75611. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75612. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75613. import { IDisposable } from "babylonjs/scene";
  75614. import { SpotLight } from "babylonjs/Lights/spotLight";
  75615. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75616. import { Scene } from "babylonjs/scene";
  75617. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75618. import { Animation } from "babylonjs/Animations/animation";
  75619. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75620. import "babylonjs/Shaders/standard.fragment";
  75621. /**
  75622. * Standard rendering pipeline
  75623. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75624. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75625. */
  75626. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75627. /**
  75628. * Public members
  75629. */
  75630. /**
  75631. * Post-process which contains the original scene color before the pipeline applies all the effects
  75632. */
  75633. originalPostProcess: Nullable<PostProcess>;
  75634. /**
  75635. * Post-process used to down scale an image x4
  75636. */
  75637. downSampleX4PostProcess: Nullable<PostProcess>;
  75638. /**
  75639. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75640. */
  75641. brightPassPostProcess: Nullable<PostProcess>;
  75642. /**
  75643. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75644. */
  75645. blurHPostProcesses: PostProcess[];
  75646. /**
  75647. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75648. */
  75649. blurVPostProcesses: PostProcess[];
  75650. /**
  75651. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75652. */
  75653. textureAdderPostProcess: Nullable<PostProcess>;
  75654. /**
  75655. * Post-process used to create volumetric lighting effect
  75656. */
  75657. volumetricLightPostProcess: Nullable<PostProcess>;
  75658. /**
  75659. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75660. */
  75661. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75662. /**
  75663. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75664. */
  75665. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75666. /**
  75667. * Post-process used to merge the volumetric light effect and the real scene color
  75668. */
  75669. volumetricLightMergePostProces: Nullable<PostProcess>;
  75670. /**
  75671. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75672. */
  75673. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75674. /**
  75675. * Base post-process used to calculate the average luminance of the final image for HDR
  75676. */
  75677. luminancePostProcess: Nullable<PostProcess>;
  75678. /**
  75679. * Post-processes used to create down sample post-processes in order to get
  75680. * the average luminance of the final image for HDR
  75681. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75682. */
  75683. luminanceDownSamplePostProcesses: PostProcess[];
  75684. /**
  75685. * Post-process used to create a HDR effect (light adaptation)
  75686. */
  75687. hdrPostProcess: Nullable<PostProcess>;
  75688. /**
  75689. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75690. */
  75691. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75692. /**
  75693. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75694. */
  75695. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75696. /**
  75697. * Post-process used to merge the final HDR post-process and the real scene color
  75698. */
  75699. hdrFinalPostProcess: Nullable<PostProcess>;
  75700. /**
  75701. * Post-process used to create a lens flare effect
  75702. */
  75703. lensFlarePostProcess: Nullable<PostProcess>;
  75704. /**
  75705. * Post-process that merges the result of the lens flare post-process and the real scene color
  75706. */
  75707. lensFlareComposePostProcess: Nullable<PostProcess>;
  75708. /**
  75709. * Post-process used to create a motion blur effect
  75710. */
  75711. motionBlurPostProcess: Nullable<PostProcess>;
  75712. /**
  75713. * Post-process used to create a depth of field effect
  75714. */
  75715. depthOfFieldPostProcess: Nullable<PostProcess>;
  75716. /**
  75717. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75718. */
  75719. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75720. /**
  75721. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75722. */
  75723. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75724. /**
  75725. * Represents the brightness threshold in order to configure the illuminated surfaces
  75726. */
  75727. brightThreshold: number;
  75728. /**
  75729. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75730. */
  75731. blurWidth: number;
  75732. /**
  75733. * Sets if the blur for highlighted surfaces must be only horizontal
  75734. */
  75735. horizontalBlur: boolean;
  75736. /**
  75737. * Gets the overall exposure used by the pipeline
  75738. */
  75739. get exposure(): number;
  75740. /**
  75741. * Sets the overall exposure used by the pipeline
  75742. */
  75743. set exposure(value: number);
  75744. /**
  75745. * Texture used typically to simulate "dirty" on camera lens
  75746. */
  75747. lensTexture: Nullable<Texture>;
  75748. /**
  75749. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75750. */
  75751. volumetricLightCoefficient: number;
  75752. /**
  75753. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75754. */
  75755. volumetricLightPower: number;
  75756. /**
  75757. * Used the set the blur intensity to smooth the volumetric lights
  75758. */
  75759. volumetricLightBlurScale: number;
  75760. /**
  75761. * Light (spot or directional) used to generate the volumetric lights rays
  75762. * The source light must have a shadow generate so the pipeline can get its
  75763. * depth map
  75764. */
  75765. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75766. /**
  75767. * For eye adaptation, represents the minimum luminance the eye can see
  75768. */
  75769. hdrMinimumLuminance: number;
  75770. /**
  75771. * For eye adaptation, represents the decrease luminance speed
  75772. */
  75773. hdrDecreaseRate: number;
  75774. /**
  75775. * For eye adaptation, represents the increase luminance speed
  75776. */
  75777. hdrIncreaseRate: number;
  75778. /**
  75779. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75780. */
  75781. get hdrAutoExposure(): boolean;
  75782. /**
  75783. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75784. */
  75785. set hdrAutoExposure(value: boolean);
  75786. /**
  75787. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75788. */
  75789. lensColorTexture: Nullable<Texture>;
  75790. /**
  75791. * The overall strengh for the lens flare effect
  75792. */
  75793. lensFlareStrength: number;
  75794. /**
  75795. * Dispersion coefficient for lens flare ghosts
  75796. */
  75797. lensFlareGhostDispersal: number;
  75798. /**
  75799. * Main lens flare halo width
  75800. */
  75801. lensFlareHaloWidth: number;
  75802. /**
  75803. * Based on the lens distortion effect, defines how much the lens flare result
  75804. * is distorted
  75805. */
  75806. lensFlareDistortionStrength: number;
  75807. /**
  75808. * Configures the blur intensity used for for lens flare (halo)
  75809. */
  75810. lensFlareBlurWidth: number;
  75811. /**
  75812. * Lens star texture must be used to simulate rays on the flares and is available
  75813. * in the documentation
  75814. */
  75815. lensStarTexture: Nullable<Texture>;
  75816. /**
  75817. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75818. * flare effect by taking account of the dirt texture
  75819. */
  75820. lensFlareDirtTexture: Nullable<Texture>;
  75821. /**
  75822. * Represents the focal length for the depth of field effect
  75823. */
  75824. depthOfFieldDistance: number;
  75825. /**
  75826. * Represents the blur intensity for the blurred part of the depth of field effect
  75827. */
  75828. depthOfFieldBlurWidth: number;
  75829. /**
  75830. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75831. */
  75832. get motionStrength(): number;
  75833. /**
  75834. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75835. */
  75836. set motionStrength(strength: number);
  75837. /**
  75838. * Gets wether or not the motion blur post-process is object based or screen based.
  75839. */
  75840. get objectBasedMotionBlur(): boolean;
  75841. /**
  75842. * Sets wether or not the motion blur post-process should be object based or screen based
  75843. */
  75844. set objectBasedMotionBlur(value: boolean);
  75845. /**
  75846. * List of animations for the pipeline (IAnimatable implementation)
  75847. */
  75848. animations: Animation[];
  75849. /**
  75850. * Private members
  75851. */
  75852. private _scene;
  75853. private _currentDepthOfFieldSource;
  75854. private _basePostProcess;
  75855. private _fixedExposure;
  75856. private _currentExposure;
  75857. private _hdrAutoExposure;
  75858. private _hdrCurrentLuminance;
  75859. private _motionStrength;
  75860. private _isObjectBasedMotionBlur;
  75861. private _floatTextureType;
  75862. private _camerasToBeAttached;
  75863. private _ratio;
  75864. private _bloomEnabled;
  75865. private _depthOfFieldEnabled;
  75866. private _vlsEnabled;
  75867. private _lensFlareEnabled;
  75868. private _hdrEnabled;
  75869. private _motionBlurEnabled;
  75870. private _fxaaEnabled;
  75871. private _screenSpaceReflectionsEnabled;
  75872. private _motionBlurSamples;
  75873. private _volumetricLightStepsCount;
  75874. private _samples;
  75875. /**
  75876. * @ignore
  75877. * Specifies if the bloom pipeline is enabled
  75878. */
  75879. get BloomEnabled(): boolean;
  75880. set BloomEnabled(enabled: boolean);
  75881. /**
  75882. * @ignore
  75883. * Specifies if the depth of field pipeline is enabed
  75884. */
  75885. get DepthOfFieldEnabled(): boolean;
  75886. set DepthOfFieldEnabled(enabled: boolean);
  75887. /**
  75888. * @ignore
  75889. * Specifies if the lens flare pipeline is enabed
  75890. */
  75891. get LensFlareEnabled(): boolean;
  75892. set LensFlareEnabled(enabled: boolean);
  75893. /**
  75894. * @ignore
  75895. * Specifies if the HDR pipeline is enabled
  75896. */
  75897. get HDREnabled(): boolean;
  75898. set HDREnabled(enabled: boolean);
  75899. /**
  75900. * @ignore
  75901. * Specifies if the volumetric lights scattering effect is enabled
  75902. */
  75903. get VLSEnabled(): boolean;
  75904. set VLSEnabled(enabled: boolean);
  75905. /**
  75906. * @ignore
  75907. * Specifies if the motion blur effect is enabled
  75908. */
  75909. get MotionBlurEnabled(): boolean;
  75910. set MotionBlurEnabled(enabled: boolean);
  75911. /**
  75912. * Specifies if anti-aliasing is enabled
  75913. */
  75914. get fxaaEnabled(): boolean;
  75915. set fxaaEnabled(enabled: boolean);
  75916. /**
  75917. * Specifies if screen space reflections are enabled.
  75918. */
  75919. get screenSpaceReflectionsEnabled(): boolean;
  75920. set screenSpaceReflectionsEnabled(enabled: boolean);
  75921. /**
  75922. * Specifies the number of steps used to calculate the volumetric lights
  75923. * Typically in interval [50, 200]
  75924. */
  75925. get volumetricLightStepsCount(): number;
  75926. set volumetricLightStepsCount(count: number);
  75927. /**
  75928. * Specifies the number of samples used for the motion blur effect
  75929. * Typically in interval [16, 64]
  75930. */
  75931. get motionBlurSamples(): number;
  75932. set motionBlurSamples(samples: number);
  75933. /**
  75934. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75935. */
  75936. get samples(): number;
  75937. set samples(sampleCount: number);
  75938. /**
  75939. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75940. * @constructor
  75941. * @param name The rendering pipeline name
  75942. * @param scene The scene linked to this pipeline
  75943. * @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)
  75944. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75945. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75946. */
  75947. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75948. private _buildPipeline;
  75949. private _createDownSampleX4PostProcess;
  75950. private _createBrightPassPostProcess;
  75951. private _createBlurPostProcesses;
  75952. private _createTextureAdderPostProcess;
  75953. private _createVolumetricLightPostProcess;
  75954. private _createLuminancePostProcesses;
  75955. private _createHdrPostProcess;
  75956. private _createLensFlarePostProcess;
  75957. private _createDepthOfFieldPostProcess;
  75958. private _createMotionBlurPostProcess;
  75959. private _getDepthTexture;
  75960. private _disposePostProcesses;
  75961. /**
  75962. * Dispose of the pipeline and stop all post processes
  75963. */
  75964. dispose(): void;
  75965. /**
  75966. * Serialize the rendering pipeline (Used when exporting)
  75967. * @returns the serialized object
  75968. */
  75969. serialize(): any;
  75970. /**
  75971. * Parse the serialized pipeline
  75972. * @param source Source pipeline.
  75973. * @param scene The scene to load the pipeline to.
  75974. * @param rootUrl The URL of the serialized pipeline.
  75975. * @returns An instantiated pipeline from the serialized object.
  75976. */
  75977. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75978. /**
  75979. * Luminance steps
  75980. */
  75981. static LuminanceSteps: number;
  75982. }
  75983. }
  75984. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75985. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75986. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75987. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75988. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75989. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75990. }
  75991. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75992. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75993. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75994. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75995. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75996. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75997. }
  75998. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75999. /** @hidden */
  76000. export var stereoscopicInterlacePixelShader: {
  76001. name: string;
  76002. shader: string;
  76003. };
  76004. }
  76005. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76006. import { Camera } from "babylonjs/Cameras/camera";
  76007. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76008. import { Engine } from "babylonjs/Engines/engine";
  76009. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76010. /**
  76011. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76012. */
  76013. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76014. private _stepSize;
  76015. private _passedProcess;
  76016. /**
  76017. * Gets a string identifying the name of the class
  76018. * @returns "StereoscopicInterlacePostProcessI" string
  76019. */
  76020. getClassName(): string;
  76021. /**
  76022. * Initializes a StereoscopicInterlacePostProcessI
  76023. * @param name The name of the effect.
  76024. * @param rigCameras The rig cameras to be appled to the post process
  76025. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76026. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76028. * @param engine The engine which the post process will be applied. (default: current engine)
  76029. * @param reusable If the post process can be reused on the same frame. (default: false)
  76030. */
  76031. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76032. }
  76033. /**
  76034. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76035. */
  76036. export class StereoscopicInterlacePostProcess extends PostProcess {
  76037. private _stepSize;
  76038. private _passedProcess;
  76039. /**
  76040. * Gets a string identifying the name of the class
  76041. * @returns "StereoscopicInterlacePostProcess" string
  76042. */
  76043. getClassName(): string;
  76044. /**
  76045. * Initializes a StereoscopicInterlacePostProcess
  76046. * @param name The name of the effect.
  76047. * @param rigCameras The rig cameras to be appled to the post process
  76048. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76050. * @param engine The engine which the post process will be applied. (default: current engine)
  76051. * @param reusable If the post process can be reused on the same frame. (default: false)
  76052. */
  76053. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76054. }
  76055. }
  76056. declare module "babylonjs/Shaders/tonemap.fragment" {
  76057. /** @hidden */
  76058. export var tonemapPixelShader: {
  76059. name: string;
  76060. shader: string;
  76061. };
  76062. }
  76063. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76064. import { Camera } from "babylonjs/Cameras/camera";
  76065. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76066. import "babylonjs/Shaders/tonemap.fragment";
  76067. import { Engine } from "babylonjs/Engines/engine";
  76068. /** Defines operator used for tonemapping */
  76069. export enum TonemappingOperator {
  76070. /** Hable */
  76071. Hable = 0,
  76072. /** Reinhard */
  76073. Reinhard = 1,
  76074. /** HejiDawson */
  76075. HejiDawson = 2,
  76076. /** Photographic */
  76077. Photographic = 3
  76078. }
  76079. /**
  76080. * Defines a post process to apply tone mapping
  76081. */
  76082. export class TonemapPostProcess extends PostProcess {
  76083. private _operator;
  76084. /** Defines the required exposure adjustement */
  76085. exposureAdjustment: number;
  76086. /**
  76087. * Gets a string identifying the name of the class
  76088. * @returns "TonemapPostProcess" string
  76089. */
  76090. getClassName(): string;
  76091. /**
  76092. * Creates a new TonemapPostProcess
  76093. * @param name defines the name of the postprocess
  76094. * @param _operator defines the operator to use
  76095. * @param exposureAdjustment defines the required exposure adjustement
  76096. * @param camera defines the camera to use (can be null)
  76097. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76098. * @param engine defines the hosting engine (can be ignore if camera is set)
  76099. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76100. */
  76101. constructor(name: string, _operator: TonemappingOperator,
  76102. /** Defines the required exposure adjustement */
  76103. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76104. }
  76105. }
  76106. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76107. /** @hidden */
  76108. export var volumetricLightScatteringPixelShader: {
  76109. name: string;
  76110. shader: string;
  76111. };
  76112. }
  76113. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76114. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76115. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76116. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76117. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76118. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76119. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76120. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76121. /** @hidden */
  76122. export var volumetricLightScatteringPassVertexShader: {
  76123. name: string;
  76124. shader: string;
  76125. };
  76126. }
  76127. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76128. /** @hidden */
  76129. export var volumetricLightScatteringPassPixelShader: {
  76130. name: string;
  76131. shader: string;
  76132. };
  76133. }
  76134. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76135. import { Vector3 } from "babylonjs/Maths/math.vector";
  76136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76137. import { Mesh } from "babylonjs/Meshes/mesh";
  76138. import { Camera } from "babylonjs/Cameras/camera";
  76139. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76140. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76141. import { Scene } from "babylonjs/scene";
  76142. import "babylonjs/Meshes/Builders/planeBuilder";
  76143. import "babylonjs/Shaders/depth.vertex";
  76144. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76145. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76146. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76147. import { Engine } from "babylonjs/Engines/engine";
  76148. /**
  76149. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76150. */
  76151. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76152. private _volumetricLightScatteringPass;
  76153. private _volumetricLightScatteringRTT;
  76154. private _viewPort;
  76155. private _screenCoordinates;
  76156. private _cachedDefines;
  76157. /**
  76158. * If not undefined, the mesh position is computed from the attached node position
  76159. */
  76160. attachedNode: {
  76161. position: Vector3;
  76162. };
  76163. /**
  76164. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76165. */
  76166. customMeshPosition: Vector3;
  76167. /**
  76168. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76169. */
  76170. useCustomMeshPosition: boolean;
  76171. /**
  76172. * If the post-process should inverse the light scattering direction
  76173. */
  76174. invert: boolean;
  76175. /**
  76176. * The internal mesh used by the post-process
  76177. */
  76178. mesh: Mesh;
  76179. /**
  76180. * @hidden
  76181. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76182. */
  76183. get useDiffuseColor(): boolean;
  76184. set useDiffuseColor(useDiffuseColor: boolean);
  76185. /**
  76186. * Array containing the excluded meshes not rendered in the internal pass
  76187. */
  76188. excludedMeshes: AbstractMesh[];
  76189. /**
  76190. * Controls the overall intensity of the post-process
  76191. */
  76192. exposure: number;
  76193. /**
  76194. * Dissipates each sample's contribution in range [0, 1]
  76195. */
  76196. decay: number;
  76197. /**
  76198. * Controls the overall intensity of each sample
  76199. */
  76200. weight: number;
  76201. /**
  76202. * Controls the density of each sample
  76203. */
  76204. density: number;
  76205. /**
  76206. * @constructor
  76207. * @param name The post-process name
  76208. * @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)
  76209. * @param camera The camera that the post-process will be attached to
  76210. * @param mesh The mesh used to create the light scattering
  76211. * @param samples The post-process quality, default 100
  76212. * @param samplingModeThe post-process filtering mode
  76213. * @param engine The babylon engine
  76214. * @param reusable If the post-process is reusable
  76215. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76216. */
  76217. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76218. /**
  76219. * Returns the string "VolumetricLightScatteringPostProcess"
  76220. * @returns "VolumetricLightScatteringPostProcess"
  76221. */
  76222. getClassName(): string;
  76223. private _isReady;
  76224. /**
  76225. * Sets the new light position for light scattering effect
  76226. * @param position The new custom light position
  76227. */
  76228. setCustomMeshPosition(position: Vector3): void;
  76229. /**
  76230. * Returns the light position for light scattering effect
  76231. * @return Vector3 The custom light position
  76232. */
  76233. getCustomMeshPosition(): Vector3;
  76234. /**
  76235. * Disposes the internal assets and detaches the post-process from the camera
  76236. */
  76237. dispose(camera: Camera): void;
  76238. /**
  76239. * Returns the render target texture used by the post-process
  76240. * @return the render target texture used by the post-process
  76241. */
  76242. getPass(): RenderTargetTexture;
  76243. private _meshExcluded;
  76244. private _createPass;
  76245. private _updateMeshScreenCoordinates;
  76246. /**
  76247. * Creates a default mesh for the Volumeric Light Scattering post-process
  76248. * @param name The mesh name
  76249. * @param scene The scene where to create the mesh
  76250. * @return the default mesh
  76251. */
  76252. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76253. }
  76254. }
  76255. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76256. /** @hidden */
  76257. export var screenSpaceCurvaturePixelShader: {
  76258. name: string;
  76259. shader: string;
  76260. };
  76261. }
  76262. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76263. import { Nullable } from "babylonjs/types";
  76264. import { Camera } from "babylonjs/Cameras/camera";
  76265. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76266. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76267. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76268. import { Engine } from "babylonjs/Engines/engine";
  76269. import { Scene } from "babylonjs/scene";
  76270. /**
  76271. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76272. */
  76273. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76274. /**
  76275. * Defines how much ridge the curvature effect displays.
  76276. */
  76277. ridge: number;
  76278. /**
  76279. * Defines how much valley the curvature effect displays.
  76280. */
  76281. valley: number;
  76282. private _geometryBufferRenderer;
  76283. /**
  76284. * Gets a string identifying the name of the class
  76285. * @returns "ScreenSpaceCurvaturePostProcess" string
  76286. */
  76287. getClassName(): string;
  76288. /**
  76289. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76290. * @param name The name of the effect.
  76291. * @param scene The scene containing the objects to blur according to their velocity.
  76292. * @param options The required width/height ratio to downsize to before computing the render pass.
  76293. * @param camera The camera to apply the render pass to.
  76294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76295. * @param engine The engine which the post process will be applied. (default: current engine)
  76296. * @param reusable If the post process can be reused on the same frame. (default: false)
  76297. * @param textureType Type of textures used when performing the post process. (default: 0)
  76298. * @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)
  76299. */
  76300. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76301. /**
  76302. * Support test.
  76303. */
  76304. static get IsSupported(): boolean;
  76305. /** @hidden */
  76306. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76307. }
  76308. }
  76309. declare module "babylonjs/PostProcesses/index" {
  76310. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76311. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76312. export * from "babylonjs/PostProcesses/bloomEffect";
  76313. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76314. export * from "babylonjs/PostProcesses/blurPostProcess";
  76315. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76316. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76317. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76318. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76319. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76320. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76321. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76322. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76323. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76324. export * from "babylonjs/PostProcesses/filterPostProcess";
  76325. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76326. export * from "babylonjs/PostProcesses/grainPostProcess";
  76327. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76328. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76329. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76330. export * from "babylonjs/PostProcesses/passPostProcess";
  76331. export * from "babylonjs/PostProcesses/postProcess";
  76332. export * from "babylonjs/PostProcesses/postProcessManager";
  76333. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76334. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76335. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76336. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76337. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76338. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76339. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76340. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76341. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76342. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76343. }
  76344. declare module "babylonjs/Probes/index" {
  76345. export * from "babylonjs/Probes/reflectionProbe";
  76346. }
  76347. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76348. import { Scene } from "babylonjs/scene";
  76349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76350. import { SmartArray } from "babylonjs/Misc/smartArray";
  76351. import { ISceneComponent } from "babylonjs/sceneComponent";
  76352. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76353. import "babylonjs/Meshes/Builders/boxBuilder";
  76354. import "babylonjs/Shaders/color.fragment";
  76355. import "babylonjs/Shaders/color.vertex";
  76356. import { Color3 } from "babylonjs/Maths/math.color";
  76357. import { Observable } from "babylonjs/Misc/observable";
  76358. module "babylonjs/scene" {
  76359. interface Scene {
  76360. /** @hidden (Backing field) */
  76361. _boundingBoxRenderer: BoundingBoxRenderer;
  76362. /** @hidden (Backing field) */
  76363. _forceShowBoundingBoxes: boolean;
  76364. /**
  76365. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76366. */
  76367. forceShowBoundingBoxes: boolean;
  76368. /**
  76369. * Gets the bounding box renderer associated with the scene
  76370. * @returns a BoundingBoxRenderer
  76371. */
  76372. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76373. }
  76374. }
  76375. module "babylonjs/Meshes/abstractMesh" {
  76376. interface AbstractMesh {
  76377. /** @hidden (Backing field) */
  76378. _showBoundingBox: boolean;
  76379. /**
  76380. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76381. */
  76382. showBoundingBox: boolean;
  76383. }
  76384. }
  76385. /**
  76386. * Component responsible of rendering the bounding box of the meshes in a scene.
  76387. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76388. */
  76389. export class BoundingBoxRenderer implements ISceneComponent {
  76390. /**
  76391. * The component name helpfull to identify the component in the list of scene components.
  76392. */
  76393. readonly name: string;
  76394. /**
  76395. * The scene the component belongs to.
  76396. */
  76397. scene: Scene;
  76398. /**
  76399. * Color of the bounding box lines placed in front of an object
  76400. */
  76401. frontColor: Color3;
  76402. /**
  76403. * Color of the bounding box lines placed behind an object
  76404. */
  76405. backColor: Color3;
  76406. /**
  76407. * Defines if the renderer should show the back lines or not
  76408. */
  76409. showBackLines: boolean;
  76410. /**
  76411. * Observable raised before rendering a bounding box
  76412. */
  76413. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76414. /**
  76415. * Observable raised after rendering a bounding box
  76416. */
  76417. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76418. /**
  76419. * @hidden
  76420. */
  76421. renderList: SmartArray<BoundingBox>;
  76422. private _colorShader;
  76423. private _vertexBuffers;
  76424. private _indexBuffer;
  76425. private _fillIndexBuffer;
  76426. private _fillIndexData;
  76427. /**
  76428. * Instantiates a new bounding box renderer in a scene.
  76429. * @param scene the scene the renderer renders in
  76430. */
  76431. constructor(scene: Scene);
  76432. /**
  76433. * Registers the component in a given scene
  76434. */
  76435. register(): void;
  76436. private _evaluateSubMesh;
  76437. private _activeMesh;
  76438. private _prepareRessources;
  76439. private _createIndexBuffer;
  76440. /**
  76441. * Rebuilds the elements related to this component in case of
  76442. * context lost for instance.
  76443. */
  76444. rebuild(): void;
  76445. /**
  76446. * @hidden
  76447. */
  76448. reset(): void;
  76449. /**
  76450. * Render the bounding boxes of a specific rendering group
  76451. * @param renderingGroupId defines the rendering group to render
  76452. */
  76453. render(renderingGroupId: number): void;
  76454. /**
  76455. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76456. * @param mesh Define the mesh to render the occlusion bounding box for
  76457. */
  76458. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76459. /**
  76460. * Dispose and release the resources attached to this renderer.
  76461. */
  76462. dispose(): void;
  76463. }
  76464. }
  76465. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76466. import { Nullable } from "babylonjs/types";
  76467. import { Scene } from "babylonjs/scene";
  76468. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76469. import { Camera } from "babylonjs/Cameras/camera";
  76470. import { ISceneComponent } from "babylonjs/sceneComponent";
  76471. module "babylonjs/scene" {
  76472. interface Scene {
  76473. /** @hidden (Backing field) */
  76474. _depthRenderer: {
  76475. [id: string]: DepthRenderer;
  76476. };
  76477. /**
  76478. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76479. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76480. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76481. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76482. * @returns the created depth renderer
  76483. */
  76484. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76485. /**
  76486. * Disables a depth renderer for a given camera
  76487. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76488. */
  76489. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76490. }
  76491. }
  76492. /**
  76493. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76494. * in several rendering techniques.
  76495. */
  76496. export class DepthRendererSceneComponent implements ISceneComponent {
  76497. /**
  76498. * The component name helpfull to identify the component in the list of scene components.
  76499. */
  76500. readonly name: string;
  76501. /**
  76502. * The scene the component belongs to.
  76503. */
  76504. scene: Scene;
  76505. /**
  76506. * Creates a new instance of the component for the given scene
  76507. * @param scene Defines the scene to register the component in
  76508. */
  76509. constructor(scene: Scene);
  76510. /**
  76511. * Registers the component in a given scene
  76512. */
  76513. register(): void;
  76514. /**
  76515. * Rebuilds the elements related to this component in case of
  76516. * context lost for instance.
  76517. */
  76518. rebuild(): void;
  76519. /**
  76520. * Disposes the component and the associated ressources
  76521. */
  76522. dispose(): void;
  76523. private _gatherRenderTargets;
  76524. private _gatherActiveCameraRenderTargets;
  76525. }
  76526. }
  76527. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76528. import { Nullable } from "babylonjs/types";
  76529. import { Scene } from "babylonjs/scene";
  76530. import { ISceneComponent } from "babylonjs/sceneComponent";
  76531. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76532. module "babylonjs/abstractScene" {
  76533. interface AbstractScene {
  76534. /** @hidden (Backing field) */
  76535. _prePassRenderer: Nullable<PrePassRenderer>;
  76536. /**
  76537. * Gets or Sets the current prepass renderer associated to the scene.
  76538. */
  76539. prePassRenderer: Nullable<PrePassRenderer>;
  76540. /**
  76541. * Enables the prepass and associates it with the scene
  76542. * @returns the PrePassRenderer
  76543. */
  76544. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76545. /**
  76546. * Disables the prepass associated with the scene
  76547. */
  76548. disablePrePassRenderer(): void;
  76549. }
  76550. }
  76551. /**
  76552. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76553. * in several rendering techniques.
  76554. */
  76555. export class PrePassRendererSceneComponent implements ISceneComponent {
  76556. /**
  76557. * The component name helpful to identify the component in the list of scene components.
  76558. */
  76559. readonly name: string;
  76560. /**
  76561. * The scene the component belongs to.
  76562. */
  76563. scene: Scene;
  76564. /**
  76565. * Creates a new instance of the component for the given scene
  76566. * @param scene Defines the scene to register the component in
  76567. */
  76568. constructor(scene: Scene);
  76569. /**
  76570. * Registers the component in a given scene
  76571. */
  76572. register(): void;
  76573. private _beforeCameraDraw;
  76574. private _afterCameraDraw;
  76575. private _beforeClearStage;
  76576. /**
  76577. * Rebuilds the elements related to this component in case of
  76578. * context lost for instance.
  76579. */
  76580. rebuild(): void;
  76581. /**
  76582. * Disposes the component and the associated ressources
  76583. */
  76584. dispose(): void;
  76585. }
  76586. }
  76587. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76588. /** @hidden */
  76589. export var fibonacci: {
  76590. name: string;
  76591. shader: string;
  76592. };
  76593. }
  76594. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76595. /** @hidden */
  76596. export var diffusionProfile: {
  76597. name: string;
  76598. shader: string;
  76599. };
  76600. }
  76601. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76602. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76603. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76604. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76605. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76606. /** @hidden */
  76607. export var subSurfaceScatteringPixelShader: {
  76608. name: string;
  76609. shader: string;
  76610. };
  76611. }
  76612. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76613. import { Nullable } from "babylonjs/types";
  76614. import { Camera } from "babylonjs/Cameras/camera";
  76615. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76616. import { Engine } from "babylonjs/Engines/engine";
  76617. import { Scene } from "babylonjs/scene";
  76618. import "babylonjs/Shaders/imageProcessing.fragment";
  76619. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76620. import "babylonjs/Shaders/postprocess.vertex";
  76621. /**
  76622. * Sub surface scattering post process
  76623. */
  76624. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76625. /**
  76626. * Gets a string identifying the name of the class
  76627. * @returns "SubSurfaceScatteringPostProcess" string
  76628. */
  76629. getClassName(): string;
  76630. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76631. }
  76632. }
  76633. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76634. import { Scene } from "babylonjs/scene";
  76635. import { Color3 } from "babylonjs/Maths/math.color";
  76636. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76637. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76638. /**
  76639. * Contains all parameters needed for the prepass to perform
  76640. * screen space subsurface scattering
  76641. */
  76642. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76643. /** @hidden */
  76644. static _SceneComponentInitialization: (scene: Scene) => void;
  76645. private _ssDiffusionS;
  76646. private _ssFilterRadii;
  76647. private _ssDiffusionD;
  76648. /**
  76649. * Post process to attach for screen space subsurface scattering
  76650. */
  76651. postProcess: SubSurfaceScatteringPostProcess;
  76652. /**
  76653. * Diffusion profile color for subsurface scattering
  76654. */
  76655. get ssDiffusionS(): number[];
  76656. /**
  76657. * Diffusion profile max color channel value for subsurface scattering
  76658. */
  76659. get ssDiffusionD(): number[];
  76660. /**
  76661. * Diffusion profile filter radius for subsurface scattering
  76662. */
  76663. get ssFilterRadii(): number[];
  76664. /**
  76665. * Is subsurface enabled
  76666. */
  76667. enabled: boolean;
  76668. /**
  76669. * Name of the configuration
  76670. */
  76671. name: string;
  76672. /**
  76673. * Diffusion profile colors for subsurface scattering
  76674. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76675. * See ...
  76676. * Note that you can only store up to 5 of them
  76677. */
  76678. ssDiffusionProfileColors: Color3[];
  76679. /**
  76680. * Defines the ratio real world => scene units.
  76681. * Used for subsurface scattering
  76682. */
  76683. metersPerUnit: number;
  76684. /**
  76685. * Textures that should be present in the MRT for this effect to work
  76686. */
  76687. readonly texturesRequired: number[];
  76688. private _scene;
  76689. /**
  76690. * Builds a subsurface configuration object
  76691. * @param scene The scene
  76692. */
  76693. constructor(scene: Scene);
  76694. /**
  76695. * Adds a new diffusion profile.
  76696. * Useful for more realistic subsurface scattering on diverse materials.
  76697. * @param color The color of the diffusion profile. Should be the average color of the material.
  76698. * @return The index of the diffusion profile for the material subsurface configuration
  76699. */
  76700. addDiffusionProfile(color: Color3): number;
  76701. /**
  76702. * Creates the sss post process
  76703. * @return The created post process
  76704. */
  76705. createPostProcess(): SubSurfaceScatteringPostProcess;
  76706. /**
  76707. * Deletes all diffusion profiles.
  76708. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76709. */
  76710. clearAllDiffusionProfiles(): void;
  76711. /**
  76712. * Disposes this object
  76713. */
  76714. dispose(): void;
  76715. /**
  76716. * @hidden
  76717. * https://zero-radiance.github.io/post/sampling-diffusion/
  76718. *
  76719. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76720. * ------------------------------------------------------------------------------------
  76721. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76722. * PDF[r, phi, s] = r * R[r, phi, s]
  76723. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76724. * ------------------------------------------------------------------------------------
  76725. * We importance sample the color channel with the widest scattering distance.
  76726. */
  76727. getDiffusionProfileParameters(color: Color3): number;
  76728. /**
  76729. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76730. * 'u' is the random number (the value of the CDF): [0, 1).
  76731. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76732. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76733. */
  76734. private _sampleBurleyDiffusionProfile;
  76735. }
  76736. }
  76737. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76738. import { Nullable } from "babylonjs/types";
  76739. import { Scene } from "babylonjs/scene";
  76740. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76741. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76742. import { AbstractScene } from "babylonjs/abstractScene";
  76743. module "babylonjs/abstractScene" {
  76744. interface AbstractScene {
  76745. /** @hidden (Backing field) */
  76746. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76747. /**
  76748. * Gets or Sets the current prepass renderer associated to the scene.
  76749. */
  76750. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76751. /**
  76752. * Enables the subsurface effect for prepass
  76753. * @returns the SubSurfaceConfiguration
  76754. */
  76755. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76756. /**
  76757. * Disables the subsurface effect for prepass
  76758. */
  76759. disableSubSurfaceForPrePass(): void;
  76760. }
  76761. }
  76762. /**
  76763. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76764. * in several rendering techniques.
  76765. */
  76766. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76767. /**
  76768. * The component name helpful to identify the component in the list of scene components.
  76769. */
  76770. readonly name: string;
  76771. /**
  76772. * The scene the component belongs to.
  76773. */
  76774. scene: Scene;
  76775. /**
  76776. * Creates a new instance of the component for the given scene
  76777. * @param scene Defines the scene to register the component in
  76778. */
  76779. constructor(scene: Scene);
  76780. /**
  76781. * Registers the component in a given scene
  76782. */
  76783. register(): void;
  76784. /**
  76785. * Serializes the component data to the specified json object
  76786. * @param serializationObject The object to serialize to
  76787. */
  76788. serialize(serializationObject: any): void;
  76789. /**
  76790. * Adds all the elements from the container to the scene
  76791. * @param container the container holding the elements
  76792. */
  76793. addFromContainer(container: AbstractScene): void;
  76794. /**
  76795. * Removes all the elements in the container from the scene
  76796. * @param container contains the elements to remove
  76797. * @param dispose if the removed element should be disposed (default: false)
  76798. */
  76799. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76800. /**
  76801. * Rebuilds the elements related to this component in case of
  76802. * context lost for instance.
  76803. */
  76804. rebuild(): void;
  76805. /**
  76806. * Disposes the component and the associated ressources
  76807. */
  76808. dispose(): void;
  76809. }
  76810. }
  76811. declare module "babylonjs/Shaders/outline.fragment" {
  76812. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76813. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76814. /** @hidden */
  76815. export var outlinePixelShader: {
  76816. name: string;
  76817. shader: string;
  76818. };
  76819. }
  76820. declare module "babylonjs/Shaders/outline.vertex" {
  76821. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76822. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76823. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76824. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76825. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76826. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76827. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76828. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76829. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76830. /** @hidden */
  76831. export var outlineVertexShader: {
  76832. name: string;
  76833. shader: string;
  76834. };
  76835. }
  76836. declare module "babylonjs/Rendering/outlineRenderer" {
  76837. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76838. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76839. import { Scene } from "babylonjs/scene";
  76840. import { ISceneComponent } from "babylonjs/sceneComponent";
  76841. import "babylonjs/Shaders/outline.fragment";
  76842. import "babylonjs/Shaders/outline.vertex";
  76843. module "babylonjs/scene" {
  76844. interface Scene {
  76845. /** @hidden */
  76846. _outlineRenderer: OutlineRenderer;
  76847. /**
  76848. * Gets the outline renderer associated with the scene
  76849. * @returns a OutlineRenderer
  76850. */
  76851. getOutlineRenderer(): OutlineRenderer;
  76852. }
  76853. }
  76854. module "babylonjs/Meshes/abstractMesh" {
  76855. interface AbstractMesh {
  76856. /** @hidden (Backing field) */
  76857. _renderOutline: boolean;
  76858. /**
  76859. * Gets or sets a boolean indicating if the outline must be rendered as well
  76860. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76861. */
  76862. renderOutline: boolean;
  76863. /** @hidden (Backing field) */
  76864. _renderOverlay: boolean;
  76865. /**
  76866. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76867. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76868. */
  76869. renderOverlay: boolean;
  76870. }
  76871. }
  76872. /**
  76873. * This class is responsible to draw bothe outline/overlay of meshes.
  76874. * It should not be used directly but through the available method on mesh.
  76875. */
  76876. export class OutlineRenderer implements ISceneComponent {
  76877. /**
  76878. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76879. */
  76880. private static _StencilReference;
  76881. /**
  76882. * The name of the component. Each component must have a unique name.
  76883. */
  76884. name: string;
  76885. /**
  76886. * The scene the component belongs to.
  76887. */
  76888. scene: Scene;
  76889. /**
  76890. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76891. */
  76892. zOffset: number;
  76893. private _engine;
  76894. private _effect;
  76895. private _cachedDefines;
  76896. private _savedDepthWrite;
  76897. /**
  76898. * Instantiates a new outline renderer. (There could be only one per scene).
  76899. * @param scene Defines the scene it belongs to
  76900. */
  76901. constructor(scene: Scene);
  76902. /**
  76903. * Register the component to one instance of a scene.
  76904. */
  76905. register(): void;
  76906. /**
  76907. * Rebuilds the elements related to this component in case of
  76908. * context lost for instance.
  76909. */
  76910. rebuild(): void;
  76911. /**
  76912. * Disposes the component and the associated ressources.
  76913. */
  76914. dispose(): void;
  76915. /**
  76916. * Renders the outline in the canvas.
  76917. * @param subMesh Defines the sumesh to render
  76918. * @param batch Defines the batch of meshes in case of instances
  76919. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76920. */
  76921. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76922. /**
  76923. * Returns whether or not the outline renderer is ready for a given submesh.
  76924. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76925. * @param subMesh Defines the submesh to check readyness for
  76926. * @param useInstances Defines wheter wee are trying to render instances or not
  76927. * @returns true if ready otherwise false
  76928. */
  76929. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76930. private _beforeRenderingMesh;
  76931. private _afterRenderingMesh;
  76932. }
  76933. }
  76934. declare module "babylonjs/Rendering/index" {
  76935. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76936. export * from "babylonjs/Rendering/depthRenderer";
  76937. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76938. export * from "babylonjs/Rendering/edgesRenderer";
  76939. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76940. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76941. export * from "babylonjs/Rendering/prePassRenderer";
  76942. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76943. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76944. export * from "babylonjs/Rendering/outlineRenderer";
  76945. export * from "babylonjs/Rendering/renderingGroup";
  76946. export * from "babylonjs/Rendering/renderingManager";
  76947. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76948. }
  76949. declare module "babylonjs/Sprites/ISprites" {
  76950. /**
  76951. * Defines the basic options interface of a Sprite Frame Source Size.
  76952. */
  76953. export interface ISpriteJSONSpriteSourceSize {
  76954. /**
  76955. * number of the original width of the Frame
  76956. */
  76957. w: number;
  76958. /**
  76959. * number of the original height of the Frame
  76960. */
  76961. h: number;
  76962. }
  76963. /**
  76964. * Defines the basic options interface of a Sprite Frame Data.
  76965. */
  76966. export interface ISpriteJSONSpriteFrameData {
  76967. /**
  76968. * number of the x offset of the Frame
  76969. */
  76970. x: number;
  76971. /**
  76972. * number of the y offset of the Frame
  76973. */
  76974. y: number;
  76975. /**
  76976. * number of the width of the Frame
  76977. */
  76978. w: number;
  76979. /**
  76980. * number of the height of the Frame
  76981. */
  76982. h: number;
  76983. }
  76984. /**
  76985. * Defines the basic options interface of a JSON Sprite.
  76986. */
  76987. export interface ISpriteJSONSprite {
  76988. /**
  76989. * string name of the Frame
  76990. */
  76991. filename: string;
  76992. /**
  76993. * ISpriteJSONSpriteFrame basic object of the frame data
  76994. */
  76995. frame: ISpriteJSONSpriteFrameData;
  76996. /**
  76997. * boolean to flag is the frame was rotated.
  76998. */
  76999. rotated: boolean;
  77000. /**
  77001. * boolean to flag is the frame was trimmed.
  77002. */
  77003. trimmed: boolean;
  77004. /**
  77005. * ISpriteJSONSpriteFrame basic object of the source data
  77006. */
  77007. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77008. /**
  77009. * ISpriteJSONSpriteFrame basic object of the source data
  77010. */
  77011. sourceSize: ISpriteJSONSpriteSourceSize;
  77012. }
  77013. /**
  77014. * Defines the basic options interface of a JSON atlas.
  77015. */
  77016. export interface ISpriteJSONAtlas {
  77017. /**
  77018. * Array of objects that contain the frame data.
  77019. */
  77020. frames: Array<ISpriteJSONSprite>;
  77021. /**
  77022. * object basic object containing the sprite meta data.
  77023. */
  77024. meta?: object;
  77025. }
  77026. }
  77027. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77028. /** @hidden */
  77029. export var spriteMapPixelShader: {
  77030. name: string;
  77031. shader: string;
  77032. };
  77033. }
  77034. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77035. /** @hidden */
  77036. export var spriteMapVertexShader: {
  77037. name: string;
  77038. shader: string;
  77039. };
  77040. }
  77041. declare module "babylonjs/Sprites/spriteMap" {
  77042. import { IDisposable, Scene } from "babylonjs/scene";
  77043. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77044. import { Texture } from "babylonjs/Materials/Textures/texture";
  77045. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77046. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77047. import "babylonjs/Meshes/Builders/planeBuilder";
  77048. import "babylonjs/Shaders/spriteMap.fragment";
  77049. import "babylonjs/Shaders/spriteMap.vertex";
  77050. /**
  77051. * Defines the basic options interface of a SpriteMap
  77052. */
  77053. export interface ISpriteMapOptions {
  77054. /**
  77055. * Vector2 of the number of cells in the grid.
  77056. */
  77057. stageSize?: Vector2;
  77058. /**
  77059. * Vector2 of the size of the output plane in World Units.
  77060. */
  77061. outputSize?: Vector2;
  77062. /**
  77063. * Vector3 of the position of the output plane in World Units.
  77064. */
  77065. outputPosition?: Vector3;
  77066. /**
  77067. * Vector3 of the rotation of the output plane.
  77068. */
  77069. outputRotation?: Vector3;
  77070. /**
  77071. * number of layers that the system will reserve in resources.
  77072. */
  77073. layerCount?: number;
  77074. /**
  77075. * number of max animation frames a single cell will reserve in resources.
  77076. */
  77077. maxAnimationFrames?: number;
  77078. /**
  77079. * number cell index of the base tile when the system compiles.
  77080. */
  77081. baseTile?: number;
  77082. /**
  77083. * boolean flip the sprite after its been repositioned by the framing data.
  77084. */
  77085. flipU?: boolean;
  77086. /**
  77087. * Vector3 scalar of the global RGB values of the SpriteMap.
  77088. */
  77089. colorMultiply?: Vector3;
  77090. }
  77091. /**
  77092. * Defines the IDisposable interface in order to be cleanable from resources.
  77093. */
  77094. export interface ISpriteMap extends IDisposable {
  77095. /**
  77096. * String name of the SpriteMap.
  77097. */
  77098. name: string;
  77099. /**
  77100. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77101. */
  77102. atlasJSON: ISpriteJSONAtlas;
  77103. /**
  77104. * Texture of the SpriteMap.
  77105. */
  77106. spriteSheet: Texture;
  77107. /**
  77108. * The parameters to initialize the SpriteMap with.
  77109. */
  77110. options: ISpriteMapOptions;
  77111. }
  77112. /**
  77113. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77114. */
  77115. export class SpriteMap implements ISpriteMap {
  77116. /** The Name of the spriteMap */
  77117. name: string;
  77118. /** The JSON file with the frame and meta data */
  77119. atlasJSON: ISpriteJSONAtlas;
  77120. /** The systems Sprite Sheet Texture */
  77121. spriteSheet: Texture;
  77122. /** Arguments passed with the Constructor */
  77123. options: ISpriteMapOptions;
  77124. /** Public Sprite Storage array, parsed from atlasJSON */
  77125. sprites: Array<ISpriteJSONSprite>;
  77126. /** Returns the Number of Sprites in the System */
  77127. get spriteCount(): number;
  77128. /** Returns the Position of Output Plane*/
  77129. get position(): Vector3;
  77130. /** Returns the Position of Output Plane*/
  77131. set position(v: Vector3);
  77132. /** Returns the Rotation of Output Plane*/
  77133. get rotation(): Vector3;
  77134. /** Returns the Rotation of Output Plane*/
  77135. set rotation(v: Vector3);
  77136. /** Sets the AnimationMap*/
  77137. get animationMap(): RawTexture;
  77138. /** Sets the AnimationMap*/
  77139. set animationMap(v: RawTexture);
  77140. /** Scene that the SpriteMap was created in */
  77141. private _scene;
  77142. /** Texture Buffer of Float32 that holds tile frame data*/
  77143. private _frameMap;
  77144. /** Texture Buffers of Float32 that holds tileMap data*/
  77145. private _tileMaps;
  77146. /** Texture Buffer of Float32 that holds Animation Data*/
  77147. private _animationMap;
  77148. /** Custom ShaderMaterial Central to the System*/
  77149. private _material;
  77150. /** Custom ShaderMaterial Central to the System*/
  77151. private _output;
  77152. /** Systems Time Ticker*/
  77153. private _time;
  77154. /**
  77155. * Creates a new SpriteMap
  77156. * @param name defines the SpriteMaps Name
  77157. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77158. * @param spriteSheet is the Texture that the Sprites are on.
  77159. * @param options a basic deployment configuration
  77160. * @param scene The Scene that the map is deployed on
  77161. */
  77162. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77163. /**
  77164. * Returns tileID location
  77165. * @returns Vector2 the cell position ID
  77166. */
  77167. getTileID(): Vector2;
  77168. /**
  77169. * Gets the UV location of the mouse over the SpriteMap.
  77170. * @returns Vector2 the UV position of the mouse interaction
  77171. */
  77172. getMousePosition(): Vector2;
  77173. /**
  77174. * Creates the "frame" texture Buffer
  77175. * -------------------------------------
  77176. * Structure of frames
  77177. * "filename": "Falling-Water-2.png",
  77178. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77179. * "rotated": true,
  77180. * "trimmed": true,
  77181. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77182. * "sourceSize": {"w":32,"h":32}
  77183. * @returns RawTexture of the frameMap
  77184. */
  77185. private _createFrameBuffer;
  77186. /**
  77187. * Creates the tileMap texture Buffer
  77188. * @param buffer normally and array of numbers, or a false to generate from scratch
  77189. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77190. * @returns RawTexture of the tileMap
  77191. */
  77192. private _createTileBuffer;
  77193. /**
  77194. * Modifies the data of the tileMaps
  77195. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77196. * @param pos is the iVector2 Coordinates of the Tile
  77197. * @param tile The SpriteIndex of the new Tile
  77198. */
  77199. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77200. /**
  77201. * Creates the animationMap texture Buffer
  77202. * @param buffer normally and array of numbers, or a false to generate from scratch
  77203. * @returns RawTexture of the animationMap
  77204. */
  77205. private _createTileAnimationBuffer;
  77206. /**
  77207. * Modifies the data of the animationMap
  77208. * @param cellID is the Index of the Sprite
  77209. * @param _frame is the target Animation frame
  77210. * @param toCell is the Target Index of the next frame of the animation
  77211. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77212. * @param speed is a global scalar of the time variable on the map.
  77213. */
  77214. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77215. /**
  77216. * Exports the .tilemaps file
  77217. */
  77218. saveTileMaps(): void;
  77219. /**
  77220. * Imports the .tilemaps file
  77221. * @param url of the .tilemaps file
  77222. */
  77223. loadTileMaps(url: string): void;
  77224. /**
  77225. * Release associated resources
  77226. */
  77227. dispose(): void;
  77228. }
  77229. }
  77230. declare module "babylonjs/Sprites/spritePackedManager" {
  77231. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77232. import { Scene } from "babylonjs/scene";
  77233. /**
  77234. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77235. * @see https://doc.babylonjs.com/babylon101/sprites
  77236. */
  77237. export class SpritePackedManager extends SpriteManager {
  77238. /** defines the packed manager's name */
  77239. name: string;
  77240. /**
  77241. * Creates a new sprite manager from a packed sprite sheet
  77242. * @param name defines the manager's name
  77243. * @param imgUrl defines the sprite sheet url
  77244. * @param capacity defines the maximum allowed number of sprites
  77245. * @param scene defines the hosting scene
  77246. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77247. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77248. * @param samplingMode defines the smapling mode to use with spritesheet
  77249. * @param fromPacked set to true; do not alter
  77250. */
  77251. constructor(
  77252. /** defines the packed manager's name */
  77253. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77254. }
  77255. }
  77256. declare module "babylonjs/Sprites/index" {
  77257. export * from "babylonjs/Sprites/sprite";
  77258. export * from "babylonjs/Sprites/ISprites";
  77259. export * from "babylonjs/Sprites/spriteManager";
  77260. export * from "babylonjs/Sprites/spriteMap";
  77261. export * from "babylonjs/Sprites/spritePackedManager";
  77262. export * from "babylonjs/Sprites/spriteSceneComponent";
  77263. }
  77264. declare module "babylonjs/States/index" {
  77265. export * from "babylonjs/States/alphaCullingState";
  77266. export * from "babylonjs/States/depthCullingState";
  77267. export * from "babylonjs/States/stencilState";
  77268. }
  77269. declare module "babylonjs/Misc/assetsManager" {
  77270. import { Scene } from "babylonjs/scene";
  77271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77272. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77273. import { Skeleton } from "babylonjs/Bones/skeleton";
  77274. import { Observable } from "babylonjs/Misc/observable";
  77275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77276. import { Texture } from "babylonjs/Materials/Textures/texture";
  77277. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77278. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77279. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77280. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77281. import { AssetContainer } from "babylonjs/assetContainer";
  77282. /**
  77283. * Defines the list of states available for a task inside a AssetsManager
  77284. */
  77285. export enum AssetTaskState {
  77286. /**
  77287. * Initialization
  77288. */
  77289. INIT = 0,
  77290. /**
  77291. * Running
  77292. */
  77293. RUNNING = 1,
  77294. /**
  77295. * Done
  77296. */
  77297. DONE = 2,
  77298. /**
  77299. * Error
  77300. */
  77301. ERROR = 3
  77302. }
  77303. /**
  77304. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77305. */
  77306. export abstract class AbstractAssetTask {
  77307. /**
  77308. * Task name
  77309. */ name: string;
  77310. /**
  77311. * Callback called when the task is successful
  77312. */
  77313. onSuccess: (task: any) => void;
  77314. /**
  77315. * Callback called when the task is not successful
  77316. */
  77317. onError: (task: any, message?: string, exception?: any) => void;
  77318. /**
  77319. * Creates a new AssetsManager
  77320. * @param name defines the name of the task
  77321. */
  77322. constructor(
  77323. /**
  77324. * Task name
  77325. */ name: string);
  77326. private _isCompleted;
  77327. private _taskState;
  77328. private _errorObject;
  77329. /**
  77330. * Get if the task is completed
  77331. */
  77332. get isCompleted(): boolean;
  77333. /**
  77334. * Gets the current state of the task
  77335. */
  77336. get taskState(): AssetTaskState;
  77337. /**
  77338. * Gets the current error object (if task is in error)
  77339. */
  77340. get errorObject(): {
  77341. message?: string;
  77342. exception?: any;
  77343. };
  77344. /**
  77345. * Internal only
  77346. * @hidden
  77347. */
  77348. _setErrorObject(message?: string, exception?: any): void;
  77349. /**
  77350. * Execute the current task
  77351. * @param scene defines the scene where you want your assets to be loaded
  77352. * @param onSuccess is a callback called when the task is successfully executed
  77353. * @param onError is a callback called if an error occurs
  77354. */
  77355. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77356. /**
  77357. * Execute the current task
  77358. * @param scene defines the scene where you want your assets to be loaded
  77359. * @param onSuccess is a callback called when the task is successfully executed
  77360. * @param onError is a callback called if an error occurs
  77361. */
  77362. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77363. /**
  77364. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77365. * This can be used with failed tasks that have the reason for failure fixed.
  77366. */
  77367. reset(): void;
  77368. private onErrorCallback;
  77369. private onDoneCallback;
  77370. }
  77371. /**
  77372. * Define the interface used by progress events raised during assets loading
  77373. */
  77374. export interface IAssetsProgressEvent {
  77375. /**
  77376. * Defines the number of remaining tasks to process
  77377. */
  77378. remainingCount: number;
  77379. /**
  77380. * Defines the total number of tasks
  77381. */
  77382. totalCount: number;
  77383. /**
  77384. * Defines the task that was just processed
  77385. */
  77386. task: AbstractAssetTask;
  77387. }
  77388. /**
  77389. * Class used to share progress information about assets loading
  77390. */
  77391. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77392. /**
  77393. * Defines the number of remaining tasks to process
  77394. */
  77395. remainingCount: number;
  77396. /**
  77397. * Defines the total number of tasks
  77398. */
  77399. totalCount: number;
  77400. /**
  77401. * Defines the task that was just processed
  77402. */
  77403. task: AbstractAssetTask;
  77404. /**
  77405. * Creates a AssetsProgressEvent
  77406. * @param remainingCount defines the number of remaining tasks to process
  77407. * @param totalCount defines the total number of tasks
  77408. * @param task defines the task that was just processed
  77409. */
  77410. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77411. }
  77412. /**
  77413. * Define a task used by AssetsManager to load assets into a container
  77414. */
  77415. export class ContainerAssetTask extends AbstractAssetTask {
  77416. /**
  77417. * Defines the name of the task
  77418. */
  77419. name: string;
  77420. /**
  77421. * Defines the list of mesh's names you want to load
  77422. */
  77423. meshesNames: any;
  77424. /**
  77425. * Defines the root url to use as a base to load your meshes and associated resources
  77426. */
  77427. rootUrl: string;
  77428. /**
  77429. * Defines the filename or File of the scene to load from
  77430. */
  77431. sceneFilename: string | File;
  77432. /**
  77433. * Get the loaded asset container
  77434. */
  77435. loadedContainer: AssetContainer;
  77436. /**
  77437. * Gets the list of loaded meshes
  77438. */
  77439. loadedMeshes: Array<AbstractMesh>;
  77440. /**
  77441. * Gets the list of loaded particle systems
  77442. */
  77443. loadedParticleSystems: Array<IParticleSystem>;
  77444. /**
  77445. * Gets the list of loaded skeletons
  77446. */
  77447. loadedSkeletons: Array<Skeleton>;
  77448. /**
  77449. * Gets the list of loaded animation groups
  77450. */
  77451. loadedAnimationGroups: Array<AnimationGroup>;
  77452. /**
  77453. * Callback called when the task is successful
  77454. */
  77455. onSuccess: (task: ContainerAssetTask) => void;
  77456. /**
  77457. * Callback called when the task is successful
  77458. */
  77459. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77460. /**
  77461. * Creates a new ContainerAssetTask
  77462. * @param name defines the name of the task
  77463. * @param meshesNames defines the list of mesh's names you want to load
  77464. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77465. * @param sceneFilename defines the filename or File of the scene to load from
  77466. */
  77467. constructor(
  77468. /**
  77469. * Defines the name of the task
  77470. */
  77471. name: string,
  77472. /**
  77473. * Defines the list of mesh's names you want to load
  77474. */
  77475. meshesNames: any,
  77476. /**
  77477. * Defines the root url to use as a base to load your meshes and associated resources
  77478. */
  77479. rootUrl: string,
  77480. /**
  77481. * Defines the filename or File of the scene to load from
  77482. */
  77483. sceneFilename: string | File);
  77484. /**
  77485. * Execute the current task
  77486. * @param scene defines the scene where you want your assets to be loaded
  77487. * @param onSuccess is a callback called when the task is successfully executed
  77488. * @param onError is a callback called if an error occurs
  77489. */
  77490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77491. }
  77492. /**
  77493. * Define a task used by AssetsManager to load meshes
  77494. */
  77495. export class MeshAssetTask extends AbstractAssetTask {
  77496. /**
  77497. * Defines the name of the task
  77498. */
  77499. name: string;
  77500. /**
  77501. * Defines the list of mesh's names you want to load
  77502. */
  77503. meshesNames: any;
  77504. /**
  77505. * Defines the root url to use as a base to load your meshes and associated resources
  77506. */
  77507. rootUrl: string;
  77508. /**
  77509. * Defines the filename or File of the scene to load from
  77510. */
  77511. sceneFilename: string | File;
  77512. /**
  77513. * Gets the list of loaded meshes
  77514. */
  77515. loadedMeshes: Array<AbstractMesh>;
  77516. /**
  77517. * Gets the list of loaded particle systems
  77518. */
  77519. loadedParticleSystems: Array<IParticleSystem>;
  77520. /**
  77521. * Gets the list of loaded skeletons
  77522. */
  77523. loadedSkeletons: Array<Skeleton>;
  77524. /**
  77525. * Gets the list of loaded animation groups
  77526. */
  77527. loadedAnimationGroups: Array<AnimationGroup>;
  77528. /**
  77529. * Callback called when the task is successful
  77530. */
  77531. onSuccess: (task: MeshAssetTask) => void;
  77532. /**
  77533. * Callback called when the task is successful
  77534. */
  77535. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77536. /**
  77537. * Creates a new MeshAssetTask
  77538. * @param name defines the name of the task
  77539. * @param meshesNames defines the list of mesh's names you want to load
  77540. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77541. * @param sceneFilename defines the filename or File of the scene to load from
  77542. */
  77543. constructor(
  77544. /**
  77545. * Defines the name of the task
  77546. */
  77547. name: string,
  77548. /**
  77549. * Defines the list of mesh's names you want to load
  77550. */
  77551. meshesNames: any,
  77552. /**
  77553. * Defines the root url to use as a base to load your meshes and associated resources
  77554. */
  77555. rootUrl: string,
  77556. /**
  77557. * Defines the filename or File of the scene to load from
  77558. */
  77559. sceneFilename: string | File);
  77560. /**
  77561. * Execute the current task
  77562. * @param scene defines the scene where you want your assets to be loaded
  77563. * @param onSuccess is a callback called when the task is successfully executed
  77564. * @param onError is a callback called if an error occurs
  77565. */
  77566. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77567. }
  77568. /**
  77569. * Define a task used by AssetsManager to load text content
  77570. */
  77571. export class TextFileAssetTask extends AbstractAssetTask {
  77572. /**
  77573. * Defines the name of the task
  77574. */
  77575. name: string;
  77576. /**
  77577. * Defines the location of the file to load
  77578. */
  77579. url: string;
  77580. /**
  77581. * Gets the loaded text string
  77582. */
  77583. text: string;
  77584. /**
  77585. * Callback called when the task is successful
  77586. */
  77587. onSuccess: (task: TextFileAssetTask) => void;
  77588. /**
  77589. * Callback called when the task is successful
  77590. */
  77591. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77592. /**
  77593. * Creates a new TextFileAssetTask object
  77594. * @param name defines the name of the task
  77595. * @param url defines the location of the file to load
  77596. */
  77597. constructor(
  77598. /**
  77599. * Defines the name of the task
  77600. */
  77601. name: string,
  77602. /**
  77603. * Defines the location of the file to load
  77604. */
  77605. url: string);
  77606. /**
  77607. * Execute the current task
  77608. * @param scene defines the scene where you want your assets to be loaded
  77609. * @param onSuccess is a callback called when the task is successfully executed
  77610. * @param onError is a callback called if an error occurs
  77611. */
  77612. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77613. }
  77614. /**
  77615. * Define a task used by AssetsManager to load binary data
  77616. */
  77617. export class BinaryFileAssetTask extends AbstractAssetTask {
  77618. /**
  77619. * Defines the name of the task
  77620. */
  77621. name: string;
  77622. /**
  77623. * Defines the location of the file to load
  77624. */
  77625. url: string;
  77626. /**
  77627. * Gets the lodaded data (as an array buffer)
  77628. */
  77629. data: ArrayBuffer;
  77630. /**
  77631. * Callback called when the task is successful
  77632. */
  77633. onSuccess: (task: BinaryFileAssetTask) => void;
  77634. /**
  77635. * Callback called when the task is successful
  77636. */
  77637. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77638. /**
  77639. * Creates a new BinaryFileAssetTask object
  77640. * @param name defines the name of the new task
  77641. * @param url defines the location of the file to load
  77642. */
  77643. constructor(
  77644. /**
  77645. * Defines the name of the task
  77646. */
  77647. name: string,
  77648. /**
  77649. * Defines the location of the file to load
  77650. */
  77651. url: string);
  77652. /**
  77653. * Execute the current task
  77654. * @param scene defines the scene where you want your assets to be loaded
  77655. * @param onSuccess is a callback called when the task is successfully executed
  77656. * @param onError is a callback called if an error occurs
  77657. */
  77658. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77659. }
  77660. /**
  77661. * Define a task used by AssetsManager to load images
  77662. */
  77663. export class ImageAssetTask extends AbstractAssetTask {
  77664. /**
  77665. * Defines the name of the task
  77666. */
  77667. name: string;
  77668. /**
  77669. * Defines the location of the image to load
  77670. */
  77671. url: string;
  77672. /**
  77673. * Gets the loaded images
  77674. */
  77675. image: HTMLImageElement;
  77676. /**
  77677. * Callback called when the task is successful
  77678. */
  77679. onSuccess: (task: ImageAssetTask) => void;
  77680. /**
  77681. * Callback called when the task is successful
  77682. */
  77683. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77684. /**
  77685. * Creates a new ImageAssetTask
  77686. * @param name defines the name of the task
  77687. * @param url defines the location of the image to load
  77688. */
  77689. constructor(
  77690. /**
  77691. * Defines the name of the task
  77692. */
  77693. name: string,
  77694. /**
  77695. * Defines the location of the image to load
  77696. */
  77697. url: string);
  77698. /**
  77699. * Execute the current task
  77700. * @param scene defines the scene where you want your assets to be loaded
  77701. * @param onSuccess is a callback called when the task is successfully executed
  77702. * @param onError is a callback called if an error occurs
  77703. */
  77704. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77705. }
  77706. /**
  77707. * Defines the interface used by texture loading tasks
  77708. */
  77709. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77710. /**
  77711. * Gets the loaded texture
  77712. */
  77713. texture: TEX;
  77714. }
  77715. /**
  77716. * Define a task used by AssetsManager to load 2D textures
  77717. */
  77718. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77719. /**
  77720. * Defines the name of the task
  77721. */
  77722. name: string;
  77723. /**
  77724. * Defines the location of the file to load
  77725. */
  77726. url: string;
  77727. /**
  77728. * Defines if mipmap should not be generated (default is false)
  77729. */
  77730. noMipmap?: boolean | undefined;
  77731. /**
  77732. * Defines if texture must be inverted on Y axis (default is true)
  77733. */
  77734. invertY: boolean;
  77735. /**
  77736. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77737. */
  77738. samplingMode: number;
  77739. /**
  77740. * Gets the loaded texture
  77741. */
  77742. texture: Texture;
  77743. /**
  77744. * Callback called when the task is successful
  77745. */
  77746. onSuccess: (task: TextureAssetTask) => void;
  77747. /**
  77748. * Callback called when the task is successful
  77749. */
  77750. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77751. /**
  77752. * Creates a new TextureAssetTask object
  77753. * @param name defines the name of the task
  77754. * @param url defines the location of the file to load
  77755. * @param noMipmap defines if mipmap should not be generated (default is false)
  77756. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77757. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77758. */
  77759. constructor(
  77760. /**
  77761. * Defines the name of the task
  77762. */
  77763. name: string,
  77764. /**
  77765. * Defines the location of the file to load
  77766. */
  77767. url: string,
  77768. /**
  77769. * Defines if mipmap should not be generated (default is false)
  77770. */
  77771. noMipmap?: boolean | undefined,
  77772. /**
  77773. * Defines if texture must be inverted on Y axis (default is true)
  77774. */
  77775. invertY?: boolean,
  77776. /**
  77777. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77778. */
  77779. samplingMode?: number);
  77780. /**
  77781. * Execute the current task
  77782. * @param scene defines the scene where you want your assets to be loaded
  77783. * @param onSuccess is a callback called when the task is successfully executed
  77784. * @param onError is a callback called if an error occurs
  77785. */
  77786. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77787. }
  77788. /**
  77789. * Define a task used by AssetsManager to load cube textures
  77790. */
  77791. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77792. /**
  77793. * Defines the name of the task
  77794. */
  77795. name: string;
  77796. /**
  77797. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77798. */
  77799. url: string;
  77800. /**
  77801. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77802. */
  77803. extensions?: string[] | undefined;
  77804. /**
  77805. * Defines if mipmaps should not be generated (default is false)
  77806. */
  77807. noMipmap?: boolean | undefined;
  77808. /**
  77809. * Defines the explicit list of files (undefined by default)
  77810. */
  77811. files?: string[] | undefined;
  77812. /**
  77813. * Gets the loaded texture
  77814. */
  77815. texture: CubeTexture;
  77816. /**
  77817. * Callback called when the task is successful
  77818. */
  77819. onSuccess: (task: CubeTextureAssetTask) => void;
  77820. /**
  77821. * Callback called when the task is successful
  77822. */
  77823. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77824. /**
  77825. * Creates a new CubeTextureAssetTask
  77826. * @param name defines the name of the task
  77827. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77828. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77829. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77830. * @param files defines the explicit list of files (undefined by default)
  77831. */
  77832. constructor(
  77833. /**
  77834. * Defines the name of the task
  77835. */
  77836. name: string,
  77837. /**
  77838. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77839. */
  77840. url: string,
  77841. /**
  77842. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77843. */
  77844. extensions?: string[] | undefined,
  77845. /**
  77846. * Defines if mipmaps should not be generated (default is false)
  77847. */
  77848. noMipmap?: boolean | undefined,
  77849. /**
  77850. * Defines the explicit list of files (undefined by default)
  77851. */
  77852. files?: string[] | undefined);
  77853. /**
  77854. * Execute the current task
  77855. * @param scene defines the scene where you want your assets to be loaded
  77856. * @param onSuccess is a callback called when the task is successfully executed
  77857. * @param onError is a callback called if an error occurs
  77858. */
  77859. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77860. }
  77861. /**
  77862. * Define a task used by AssetsManager to load HDR cube textures
  77863. */
  77864. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77865. /**
  77866. * Defines the name of the task
  77867. */
  77868. name: string;
  77869. /**
  77870. * Defines the location of the file to load
  77871. */
  77872. url: string;
  77873. /**
  77874. * Defines the desired size (the more it increases the longer the generation will be)
  77875. */
  77876. size: number;
  77877. /**
  77878. * Defines if mipmaps should not be generated (default is false)
  77879. */
  77880. noMipmap: boolean;
  77881. /**
  77882. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77883. */
  77884. generateHarmonics: boolean;
  77885. /**
  77886. * 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)
  77887. */
  77888. gammaSpace: boolean;
  77889. /**
  77890. * Internal Use Only
  77891. */
  77892. reserved: boolean;
  77893. /**
  77894. * Gets the loaded texture
  77895. */
  77896. texture: HDRCubeTexture;
  77897. /**
  77898. * Callback called when the task is successful
  77899. */
  77900. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77901. /**
  77902. * Callback called when the task is successful
  77903. */
  77904. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77905. /**
  77906. * Creates a new HDRCubeTextureAssetTask object
  77907. * @param name defines the name of the task
  77908. * @param url defines the location of the file to load
  77909. * @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.
  77910. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77911. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77912. * @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)
  77913. * @param reserved Internal use only
  77914. */
  77915. constructor(
  77916. /**
  77917. * Defines the name of the task
  77918. */
  77919. name: string,
  77920. /**
  77921. * Defines the location of the file to load
  77922. */
  77923. url: string,
  77924. /**
  77925. * Defines the desired size (the more it increases the longer the generation will be)
  77926. */
  77927. size: number,
  77928. /**
  77929. * Defines if mipmaps should not be generated (default is false)
  77930. */
  77931. noMipmap?: boolean,
  77932. /**
  77933. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77934. */
  77935. generateHarmonics?: boolean,
  77936. /**
  77937. * 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)
  77938. */
  77939. gammaSpace?: boolean,
  77940. /**
  77941. * Internal Use Only
  77942. */
  77943. reserved?: boolean);
  77944. /**
  77945. * Execute the current task
  77946. * @param scene defines the scene where you want your assets to be loaded
  77947. * @param onSuccess is a callback called when the task is successfully executed
  77948. * @param onError is a callback called if an error occurs
  77949. */
  77950. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77951. }
  77952. /**
  77953. * Define a task used by AssetsManager to load Equirectangular cube textures
  77954. */
  77955. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77956. /**
  77957. * Defines the name of the task
  77958. */
  77959. name: string;
  77960. /**
  77961. * Defines the location of the file to load
  77962. */
  77963. url: string;
  77964. /**
  77965. * Defines the desired size (the more it increases the longer the generation will be)
  77966. */
  77967. size: number;
  77968. /**
  77969. * Defines if mipmaps should not be generated (default is false)
  77970. */
  77971. noMipmap: boolean;
  77972. /**
  77973. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77974. * but the standard material would require them in Gamma space) (default is true)
  77975. */
  77976. gammaSpace: boolean;
  77977. /**
  77978. * Gets the loaded texture
  77979. */
  77980. texture: EquiRectangularCubeTexture;
  77981. /**
  77982. * Callback called when the task is successful
  77983. */
  77984. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77985. /**
  77986. * Callback called when the task is successful
  77987. */
  77988. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77989. /**
  77990. * Creates a new EquiRectangularCubeTextureAssetTask object
  77991. * @param name defines the name of the task
  77992. * @param url defines the location of the file to load
  77993. * @param size defines the desired size (the more it increases the longer the generation will be)
  77994. * If the size is omitted this implies you are using a preprocessed cubemap.
  77995. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77996. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77997. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77998. * (default is true)
  77999. */
  78000. constructor(
  78001. /**
  78002. * Defines the name of the task
  78003. */
  78004. name: string,
  78005. /**
  78006. * Defines the location of the file to load
  78007. */
  78008. url: string,
  78009. /**
  78010. * Defines the desired size (the more it increases the longer the generation will be)
  78011. */
  78012. size: number,
  78013. /**
  78014. * Defines if mipmaps should not be generated (default is false)
  78015. */
  78016. noMipmap?: boolean,
  78017. /**
  78018. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78019. * but the standard material would require them in Gamma space) (default is true)
  78020. */
  78021. gammaSpace?: boolean);
  78022. /**
  78023. * Execute the current task
  78024. * @param scene defines the scene where you want your assets to be loaded
  78025. * @param onSuccess is a callback called when the task is successfully executed
  78026. * @param onError is a callback called if an error occurs
  78027. */
  78028. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78029. }
  78030. /**
  78031. * This class can be used to easily import assets into a scene
  78032. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78033. */
  78034. export class AssetsManager {
  78035. private _scene;
  78036. private _isLoading;
  78037. protected _tasks: AbstractAssetTask[];
  78038. protected _waitingTasksCount: number;
  78039. protected _totalTasksCount: number;
  78040. /**
  78041. * Callback called when all tasks are processed
  78042. */
  78043. onFinish: (tasks: AbstractAssetTask[]) => void;
  78044. /**
  78045. * Callback called when a task is successful
  78046. */
  78047. onTaskSuccess: (task: AbstractAssetTask) => void;
  78048. /**
  78049. * Callback called when a task had an error
  78050. */
  78051. onTaskError: (task: AbstractAssetTask) => void;
  78052. /**
  78053. * Callback called when a task is done (whatever the result is)
  78054. */
  78055. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78056. /**
  78057. * Observable called when all tasks are processed
  78058. */
  78059. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78060. /**
  78061. * Observable called when a task had an error
  78062. */
  78063. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78064. /**
  78065. * Observable called when all tasks were executed
  78066. */
  78067. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78068. /**
  78069. * Observable called when a task is done (whatever the result is)
  78070. */
  78071. onProgressObservable: Observable<IAssetsProgressEvent>;
  78072. /**
  78073. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78074. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78075. */
  78076. useDefaultLoadingScreen: boolean;
  78077. /**
  78078. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78079. * when all assets have been downloaded.
  78080. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78081. */
  78082. autoHideLoadingUI: boolean;
  78083. /**
  78084. * Creates a new AssetsManager
  78085. * @param scene defines the scene to work on
  78086. */
  78087. constructor(scene: Scene);
  78088. /**
  78089. * Add a ContainerAssetTask to the list of active tasks
  78090. * @param taskName defines the name of the new task
  78091. * @param meshesNames defines the name of meshes to load
  78092. * @param rootUrl defines the root url to use to locate files
  78093. * @param sceneFilename defines the filename of the scene file
  78094. * @returns a new ContainerAssetTask object
  78095. */
  78096. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78097. /**
  78098. * Add a MeshAssetTask to the list of active tasks
  78099. * @param taskName defines the name of the new task
  78100. * @param meshesNames defines the name of meshes to load
  78101. * @param rootUrl defines the root url to use to locate files
  78102. * @param sceneFilename defines the filename of the scene file
  78103. * @returns a new MeshAssetTask object
  78104. */
  78105. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78106. /**
  78107. * Add a TextFileAssetTask to the list of active tasks
  78108. * @param taskName defines the name of the new task
  78109. * @param url defines the url of the file to load
  78110. * @returns a new TextFileAssetTask object
  78111. */
  78112. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78113. /**
  78114. * Add a BinaryFileAssetTask to the list of active tasks
  78115. * @param taskName defines the name of the new task
  78116. * @param url defines the url of the file to load
  78117. * @returns a new BinaryFileAssetTask object
  78118. */
  78119. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78120. /**
  78121. * Add a ImageAssetTask to the list of active tasks
  78122. * @param taskName defines the name of the new task
  78123. * @param url defines the url of the file to load
  78124. * @returns a new ImageAssetTask object
  78125. */
  78126. addImageTask(taskName: string, url: string): ImageAssetTask;
  78127. /**
  78128. * Add a TextureAssetTask to the list of active tasks
  78129. * @param taskName defines the name of the new task
  78130. * @param url defines the url of the file to load
  78131. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78132. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78133. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78134. * @returns a new TextureAssetTask object
  78135. */
  78136. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78137. /**
  78138. * Add a CubeTextureAssetTask to the list of active tasks
  78139. * @param taskName defines the name of the new task
  78140. * @param url defines the url of the file to load
  78141. * @param extensions defines the extension to use to load the cube map (can be null)
  78142. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78143. * @param files defines the list of files to load (can be null)
  78144. * @returns a new CubeTextureAssetTask object
  78145. */
  78146. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78147. /**
  78148. *
  78149. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78150. * @param taskName defines the name of the new task
  78151. * @param url defines the url of the file to load
  78152. * @param size defines the size you want for the cubemap (can be null)
  78153. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78154. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78155. * @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)
  78156. * @param reserved Internal use only
  78157. * @returns a new HDRCubeTextureAssetTask object
  78158. */
  78159. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78160. /**
  78161. *
  78162. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78163. * @param taskName defines the name of the new task
  78164. * @param url defines the url of the file to load
  78165. * @param size defines the size you want for the cubemap (can be null)
  78166. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78167. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78168. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78169. * @returns a new EquiRectangularCubeTextureAssetTask object
  78170. */
  78171. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78172. /**
  78173. * Remove a task from the assets manager.
  78174. * @param task the task to remove
  78175. */
  78176. removeTask(task: AbstractAssetTask): void;
  78177. private _decreaseWaitingTasksCount;
  78178. private _runTask;
  78179. /**
  78180. * Reset the AssetsManager and remove all tasks
  78181. * @return the current instance of the AssetsManager
  78182. */
  78183. reset(): AssetsManager;
  78184. /**
  78185. * Start the loading process
  78186. * @return the current instance of the AssetsManager
  78187. */
  78188. load(): AssetsManager;
  78189. /**
  78190. * Start the loading process as an async operation
  78191. * @return a promise returning the list of failed tasks
  78192. */
  78193. loadAsync(): Promise<void>;
  78194. }
  78195. }
  78196. declare module "babylonjs/Misc/deferred" {
  78197. /**
  78198. * Wrapper class for promise with external resolve and reject.
  78199. */
  78200. export class Deferred<T> {
  78201. /**
  78202. * The promise associated with this deferred object.
  78203. */
  78204. readonly promise: Promise<T>;
  78205. private _resolve;
  78206. private _reject;
  78207. /**
  78208. * The resolve method of the promise associated with this deferred object.
  78209. */
  78210. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78211. /**
  78212. * The reject method of the promise associated with this deferred object.
  78213. */
  78214. get reject(): (reason?: any) => void;
  78215. /**
  78216. * Constructor for this deferred object.
  78217. */
  78218. constructor();
  78219. }
  78220. }
  78221. declare module "babylonjs/Misc/meshExploder" {
  78222. import { Mesh } from "babylonjs/Meshes/mesh";
  78223. /**
  78224. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78225. */
  78226. export class MeshExploder {
  78227. private _centerMesh;
  78228. private _meshes;
  78229. private _meshesOrigins;
  78230. private _toCenterVectors;
  78231. private _scaledDirection;
  78232. private _newPosition;
  78233. private _centerPosition;
  78234. /**
  78235. * Explodes meshes from a center mesh.
  78236. * @param meshes The meshes to explode.
  78237. * @param centerMesh The mesh to be center of explosion.
  78238. */
  78239. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78240. private _setCenterMesh;
  78241. /**
  78242. * Get class name
  78243. * @returns "MeshExploder"
  78244. */
  78245. getClassName(): string;
  78246. /**
  78247. * "Exploded meshes"
  78248. * @returns Array of meshes with the centerMesh at index 0.
  78249. */
  78250. getMeshes(): Array<Mesh>;
  78251. /**
  78252. * Explodes meshes giving a specific direction
  78253. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78254. */
  78255. explode(direction?: number): void;
  78256. }
  78257. }
  78258. declare module "babylonjs/Misc/filesInput" {
  78259. import { Engine } from "babylonjs/Engines/engine";
  78260. import { Scene } from "babylonjs/scene";
  78261. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78262. import { Nullable } from "babylonjs/types";
  78263. /**
  78264. * Class used to help managing file picking and drag'n'drop
  78265. */
  78266. export class FilesInput {
  78267. /**
  78268. * List of files ready to be loaded
  78269. */
  78270. static get FilesToLoad(): {
  78271. [key: string]: File;
  78272. };
  78273. /**
  78274. * Callback called when a file is processed
  78275. */
  78276. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78277. private _engine;
  78278. private _currentScene;
  78279. private _sceneLoadedCallback;
  78280. private _progressCallback;
  78281. private _additionalRenderLoopLogicCallback;
  78282. private _textureLoadingCallback;
  78283. private _startingProcessingFilesCallback;
  78284. private _onReloadCallback;
  78285. private _errorCallback;
  78286. private _elementToMonitor;
  78287. private _sceneFileToLoad;
  78288. private _filesToLoad;
  78289. /**
  78290. * Creates a new FilesInput
  78291. * @param engine defines the rendering engine
  78292. * @param scene defines the hosting scene
  78293. * @param sceneLoadedCallback callback called when scene is loaded
  78294. * @param progressCallback callback called to track progress
  78295. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78296. * @param textureLoadingCallback callback called when a texture is loading
  78297. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78298. * @param onReloadCallback callback called when a reload is requested
  78299. * @param errorCallback callback call if an error occurs
  78300. */
  78301. 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>);
  78302. private _dragEnterHandler;
  78303. private _dragOverHandler;
  78304. private _dropHandler;
  78305. /**
  78306. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78307. * @param elementToMonitor defines the DOM element to track
  78308. */
  78309. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78310. /** Gets the current list of files to load */
  78311. get filesToLoad(): File[];
  78312. /**
  78313. * Release all associated resources
  78314. */
  78315. dispose(): void;
  78316. private renderFunction;
  78317. private drag;
  78318. private drop;
  78319. private _traverseFolder;
  78320. private _processFiles;
  78321. /**
  78322. * Load files from a drop event
  78323. * @param event defines the drop event to use as source
  78324. */
  78325. loadFiles(event: any): void;
  78326. private _processReload;
  78327. /**
  78328. * Reload the current scene from the loaded files
  78329. */
  78330. reload(): void;
  78331. }
  78332. }
  78333. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78334. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78335. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78336. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78337. }
  78338. declare module "babylonjs/Misc/sceneOptimizer" {
  78339. import { Scene, IDisposable } from "babylonjs/scene";
  78340. import { Observable } from "babylonjs/Misc/observable";
  78341. /**
  78342. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78343. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78344. */
  78345. export class SceneOptimization {
  78346. /**
  78347. * Defines the priority of this optimization (0 by default which means first in the list)
  78348. */
  78349. priority: number;
  78350. /**
  78351. * Gets a string describing the action executed by the current optimization
  78352. * @returns description string
  78353. */
  78354. getDescription(): string;
  78355. /**
  78356. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78357. * @param scene defines the current scene where to apply this optimization
  78358. * @param optimizer defines the current optimizer
  78359. * @returns true if everything that can be done was applied
  78360. */
  78361. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78362. /**
  78363. * Creates the SceneOptimization object
  78364. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78365. * @param desc defines the description associated with the optimization
  78366. */
  78367. constructor(
  78368. /**
  78369. * Defines the priority of this optimization (0 by default which means first in the list)
  78370. */
  78371. priority?: number);
  78372. }
  78373. /**
  78374. * Defines an optimization used to reduce the size of render target textures
  78375. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78376. */
  78377. export class TextureOptimization extends SceneOptimization {
  78378. /**
  78379. * Defines the priority of this optimization (0 by default which means first in the list)
  78380. */
  78381. priority: number;
  78382. /**
  78383. * 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
  78384. */
  78385. maximumSize: number;
  78386. /**
  78387. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78388. */
  78389. step: number;
  78390. /**
  78391. * Gets a string describing the action executed by the current optimization
  78392. * @returns description string
  78393. */
  78394. getDescription(): string;
  78395. /**
  78396. * Creates the TextureOptimization object
  78397. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78398. * @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
  78399. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78400. */
  78401. constructor(
  78402. /**
  78403. * Defines the priority of this optimization (0 by default which means first in the list)
  78404. */
  78405. priority?: number,
  78406. /**
  78407. * 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
  78408. */
  78409. maximumSize?: number,
  78410. /**
  78411. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78412. */
  78413. step?: number);
  78414. /**
  78415. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78416. * @param scene defines the current scene where to apply this optimization
  78417. * @param optimizer defines the current optimizer
  78418. * @returns true if everything that can be done was applied
  78419. */
  78420. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78421. }
  78422. /**
  78423. * Defines an optimization used to increase or decrease the rendering resolution
  78424. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78425. */
  78426. export class HardwareScalingOptimization extends SceneOptimization {
  78427. /**
  78428. * Defines the priority of this optimization (0 by default which means first in the list)
  78429. */
  78430. priority: number;
  78431. /**
  78432. * Defines the maximum scale to use (2 by default)
  78433. */
  78434. maximumScale: number;
  78435. /**
  78436. * Defines the step to use between two passes (0.5 by default)
  78437. */
  78438. step: number;
  78439. private _currentScale;
  78440. private _directionOffset;
  78441. /**
  78442. * Gets a string describing the action executed by the current optimization
  78443. * @return description string
  78444. */
  78445. getDescription(): string;
  78446. /**
  78447. * Creates the HardwareScalingOptimization object
  78448. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78449. * @param maximumScale defines the maximum scale to use (2 by default)
  78450. * @param step defines the step to use between two passes (0.5 by default)
  78451. */
  78452. constructor(
  78453. /**
  78454. * Defines the priority of this optimization (0 by default which means first in the list)
  78455. */
  78456. priority?: number,
  78457. /**
  78458. * Defines the maximum scale to use (2 by default)
  78459. */
  78460. maximumScale?: number,
  78461. /**
  78462. * Defines the step to use between two passes (0.5 by default)
  78463. */
  78464. step?: number);
  78465. /**
  78466. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78467. * @param scene defines the current scene where to apply this optimization
  78468. * @param optimizer defines the current optimizer
  78469. * @returns true if everything that can be done was applied
  78470. */
  78471. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78472. }
  78473. /**
  78474. * Defines an optimization used to remove shadows
  78475. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78476. */
  78477. export class ShadowsOptimization extends SceneOptimization {
  78478. /**
  78479. * Gets a string describing the action executed by the current optimization
  78480. * @return description string
  78481. */
  78482. getDescription(): string;
  78483. /**
  78484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78485. * @param scene defines the current scene where to apply this optimization
  78486. * @param optimizer defines the current optimizer
  78487. * @returns true if everything that can be done was applied
  78488. */
  78489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78490. }
  78491. /**
  78492. * Defines an optimization used to turn post-processes off
  78493. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78494. */
  78495. export class PostProcessesOptimization extends SceneOptimization {
  78496. /**
  78497. * Gets a string describing the action executed by the current optimization
  78498. * @return description string
  78499. */
  78500. getDescription(): string;
  78501. /**
  78502. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78503. * @param scene defines the current scene where to apply this optimization
  78504. * @param optimizer defines the current optimizer
  78505. * @returns true if everything that can be done was applied
  78506. */
  78507. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78508. }
  78509. /**
  78510. * Defines an optimization used to turn lens flares off
  78511. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78512. */
  78513. export class LensFlaresOptimization extends SceneOptimization {
  78514. /**
  78515. * Gets a string describing the action executed by the current optimization
  78516. * @return description string
  78517. */
  78518. getDescription(): string;
  78519. /**
  78520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78521. * @param scene defines the current scene where to apply this optimization
  78522. * @param optimizer defines the current optimizer
  78523. * @returns true if everything that can be done was applied
  78524. */
  78525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78526. }
  78527. /**
  78528. * Defines an optimization based on user defined callback.
  78529. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78530. */
  78531. export class CustomOptimization extends SceneOptimization {
  78532. /**
  78533. * Callback called to apply the custom optimization.
  78534. */
  78535. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78536. /**
  78537. * Callback called to get custom description
  78538. */
  78539. onGetDescription: () => string;
  78540. /**
  78541. * Gets a string describing the action executed by the current optimization
  78542. * @returns description string
  78543. */
  78544. getDescription(): string;
  78545. /**
  78546. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78547. * @param scene defines the current scene where to apply this optimization
  78548. * @param optimizer defines the current optimizer
  78549. * @returns true if everything that can be done was applied
  78550. */
  78551. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78552. }
  78553. /**
  78554. * Defines an optimization used to turn particles off
  78555. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78556. */
  78557. export class ParticlesOptimization extends SceneOptimization {
  78558. /**
  78559. * Gets a string describing the action executed by the current optimization
  78560. * @return description string
  78561. */
  78562. getDescription(): string;
  78563. /**
  78564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78565. * @param scene defines the current scene where to apply this optimization
  78566. * @param optimizer defines the current optimizer
  78567. * @returns true if everything that can be done was applied
  78568. */
  78569. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78570. }
  78571. /**
  78572. * Defines an optimization used to turn render targets off
  78573. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78574. */
  78575. export class RenderTargetsOptimization extends SceneOptimization {
  78576. /**
  78577. * Gets a string describing the action executed by the current optimization
  78578. * @return description string
  78579. */
  78580. getDescription(): string;
  78581. /**
  78582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78583. * @param scene defines the current scene where to apply this optimization
  78584. * @param optimizer defines the current optimizer
  78585. * @returns true if everything that can be done was applied
  78586. */
  78587. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78588. }
  78589. /**
  78590. * Defines an optimization used to merge meshes with compatible materials
  78591. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78592. */
  78593. export class MergeMeshesOptimization extends SceneOptimization {
  78594. private static _UpdateSelectionTree;
  78595. /**
  78596. * Gets or sets a boolean which defines if optimization octree has to be updated
  78597. */
  78598. static get UpdateSelectionTree(): boolean;
  78599. /**
  78600. * Gets or sets a boolean which defines if optimization octree has to be updated
  78601. */
  78602. static set UpdateSelectionTree(value: boolean);
  78603. /**
  78604. * Gets a string describing the action executed by the current optimization
  78605. * @return description string
  78606. */
  78607. getDescription(): string;
  78608. private _canBeMerged;
  78609. /**
  78610. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78611. * @param scene defines the current scene where to apply this optimization
  78612. * @param optimizer defines the current optimizer
  78613. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78614. * @returns true if everything that can be done was applied
  78615. */
  78616. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78617. }
  78618. /**
  78619. * Defines a list of options used by SceneOptimizer
  78620. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78621. */
  78622. export class SceneOptimizerOptions {
  78623. /**
  78624. * Defines the target frame rate to reach (60 by default)
  78625. */
  78626. targetFrameRate: number;
  78627. /**
  78628. * Defines the interval between two checkes (2000ms by default)
  78629. */
  78630. trackerDuration: number;
  78631. /**
  78632. * Gets the list of optimizations to apply
  78633. */
  78634. optimizations: SceneOptimization[];
  78635. /**
  78636. * Creates a new list of options used by SceneOptimizer
  78637. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78638. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78639. */
  78640. constructor(
  78641. /**
  78642. * Defines the target frame rate to reach (60 by default)
  78643. */
  78644. targetFrameRate?: number,
  78645. /**
  78646. * Defines the interval between two checkes (2000ms by default)
  78647. */
  78648. trackerDuration?: number);
  78649. /**
  78650. * Add a new optimization
  78651. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78652. * @returns the current SceneOptimizerOptions
  78653. */
  78654. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78655. /**
  78656. * Add a new custom optimization
  78657. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78658. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78659. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78660. * @returns the current SceneOptimizerOptions
  78661. */
  78662. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78663. /**
  78664. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78665. * @param targetFrameRate defines the target frame rate (60 by default)
  78666. * @returns a SceneOptimizerOptions object
  78667. */
  78668. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78669. /**
  78670. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78671. * @param targetFrameRate defines the target frame rate (60 by default)
  78672. * @returns a SceneOptimizerOptions object
  78673. */
  78674. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78675. /**
  78676. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78677. * @param targetFrameRate defines the target frame rate (60 by default)
  78678. * @returns a SceneOptimizerOptions object
  78679. */
  78680. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78681. }
  78682. /**
  78683. * Class used to run optimizations in order to reach a target frame rate
  78684. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78685. */
  78686. export class SceneOptimizer implements IDisposable {
  78687. private _isRunning;
  78688. private _options;
  78689. private _scene;
  78690. private _currentPriorityLevel;
  78691. private _targetFrameRate;
  78692. private _trackerDuration;
  78693. private _currentFrameRate;
  78694. private _sceneDisposeObserver;
  78695. private _improvementMode;
  78696. /**
  78697. * Defines an observable called when the optimizer reaches the target frame rate
  78698. */
  78699. onSuccessObservable: Observable<SceneOptimizer>;
  78700. /**
  78701. * Defines an observable called when the optimizer enables an optimization
  78702. */
  78703. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78704. /**
  78705. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78706. */
  78707. onFailureObservable: Observable<SceneOptimizer>;
  78708. /**
  78709. * Gets a boolean indicating if the optimizer is in improvement mode
  78710. */
  78711. get isInImprovementMode(): boolean;
  78712. /**
  78713. * Gets the current priority level (0 at start)
  78714. */
  78715. get currentPriorityLevel(): number;
  78716. /**
  78717. * Gets the current frame rate checked by the SceneOptimizer
  78718. */
  78719. get currentFrameRate(): number;
  78720. /**
  78721. * Gets or sets the current target frame rate (60 by default)
  78722. */
  78723. get targetFrameRate(): number;
  78724. /**
  78725. * Gets or sets the current target frame rate (60 by default)
  78726. */
  78727. set targetFrameRate(value: number);
  78728. /**
  78729. * Gets or sets the current interval between two checks (every 2000ms by default)
  78730. */
  78731. get trackerDuration(): number;
  78732. /**
  78733. * Gets or sets the current interval between two checks (every 2000ms by default)
  78734. */
  78735. set trackerDuration(value: number);
  78736. /**
  78737. * Gets the list of active optimizations
  78738. */
  78739. get optimizations(): SceneOptimization[];
  78740. /**
  78741. * Creates a new SceneOptimizer
  78742. * @param scene defines the scene to work on
  78743. * @param options defines the options to use with the SceneOptimizer
  78744. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78745. * @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)
  78746. */
  78747. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78748. /**
  78749. * Stops the current optimizer
  78750. */
  78751. stop(): void;
  78752. /**
  78753. * Reset the optimizer to initial step (current priority level = 0)
  78754. */
  78755. reset(): void;
  78756. /**
  78757. * Start the optimizer. By default it will try to reach a specific framerate
  78758. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78759. */
  78760. start(): void;
  78761. private _checkCurrentState;
  78762. /**
  78763. * Release all resources
  78764. */
  78765. dispose(): void;
  78766. /**
  78767. * Helper function to create a SceneOptimizer with one single line of code
  78768. * @param scene defines the scene to work on
  78769. * @param options defines the options to use with the SceneOptimizer
  78770. * @param onSuccess defines a callback to call on success
  78771. * @param onFailure defines a callback to call on failure
  78772. * @returns the new SceneOptimizer object
  78773. */
  78774. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78775. }
  78776. }
  78777. declare module "babylonjs/Misc/sceneSerializer" {
  78778. import { Scene } from "babylonjs/scene";
  78779. /**
  78780. * Class used to serialize a scene into a string
  78781. */
  78782. export class SceneSerializer {
  78783. /**
  78784. * Clear cache used by a previous serialization
  78785. */
  78786. static ClearCache(): void;
  78787. /**
  78788. * Serialize a scene into a JSON compatible object
  78789. * @param scene defines the scene to serialize
  78790. * @returns a JSON compatible object
  78791. */
  78792. static Serialize(scene: Scene): any;
  78793. /**
  78794. * Serialize a mesh into a JSON compatible object
  78795. * @param toSerialize defines the mesh to serialize
  78796. * @param withParents defines if parents must be serialized as well
  78797. * @param withChildren defines if children must be serialized as well
  78798. * @returns a JSON compatible object
  78799. */
  78800. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78801. }
  78802. }
  78803. declare module "babylonjs/Misc/textureTools" {
  78804. import { Texture } from "babylonjs/Materials/Textures/texture";
  78805. /**
  78806. * Class used to host texture specific utilities
  78807. */
  78808. export class TextureTools {
  78809. /**
  78810. * Uses the GPU to create a copy texture rescaled at a given size
  78811. * @param texture Texture to copy from
  78812. * @param width defines the desired width
  78813. * @param height defines the desired height
  78814. * @param useBilinearMode defines if bilinear mode has to be used
  78815. * @return the generated texture
  78816. */
  78817. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78818. }
  78819. }
  78820. declare module "babylonjs/Misc/videoRecorder" {
  78821. import { Nullable } from "babylonjs/types";
  78822. import { Engine } from "babylonjs/Engines/engine";
  78823. /**
  78824. * This represents the different options available for the video capture.
  78825. */
  78826. export interface VideoRecorderOptions {
  78827. /** Defines the mime type of the video. */
  78828. mimeType: string;
  78829. /** Defines the FPS the video should be recorded at. */
  78830. fps: number;
  78831. /** Defines the chunk size for the recording data. */
  78832. recordChunckSize: number;
  78833. /** The audio tracks to attach to the recording. */
  78834. audioTracks?: MediaStreamTrack[];
  78835. }
  78836. /**
  78837. * This can help with recording videos from BabylonJS.
  78838. * This is based on the available WebRTC functionalities of the browser.
  78839. *
  78840. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78841. */
  78842. export class VideoRecorder {
  78843. private static readonly _defaultOptions;
  78844. /**
  78845. * Returns whether or not the VideoRecorder is available in your browser.
  78846. * @param engine Defines the Babylon Engine.
  78847. * @returns true if supported otherwise false.
  78848. */
  78849. static IsSupported(engine: Engine): boolean;
  78850. private readonly _options;
  78851. private _canvas;
  78852. private _mediaRecorder;
  78853. private _recordedChunks;
  78854. private _fileName;
  78855. private _resolve;
  78856. private _reject;
  78857. /**
  78858. * True when a recording is already in progress.
  78859. */
  78860. get isRecording(): boolean;
  78861. /**
  78862. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78863. * @param engine Defines the BabylonJS Engine you wish to record.
  78864. * @param options Defines options that can be used to customize the capture.
  78865. */
  78866. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78867. /**
  78868. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78869. */
  78870. stopRecording(): void;
  78871. /**
  78872. * Starts recording the canvas for a max duration specified in parameters.
  78873. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78874. * If null no automatic download will start and you can rely on the promise to get the data back.
  78875. * @param maxDuration Defines the maximum recording time in seconds.
  78876. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78877. * @return A promise callback at the end of the recording with the video data in Blob.
  78878. */
  78879. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78880. /**
  78881. * Releases internal resources used during the recording.
  78882. */
  78883. dispose(): void;
  78884. private _handleDataAvailable;
  78885. private _handleError;
  78886. private _handleStop;
  78887. }
  78888. }
  78889. declare module "babylonjs/Misc/screenshotTools" {
  78890. import { Camera } from "babylonjs/Cameras/camera";
  78891. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78892. import { Engine } from "babylonjs/Engines/engine";
  78893. /**
  78894. * Class containing a set of static utilities functions for screenshots
  78895. */
  78896. export class ScreenshotTools {
  78897. /**
  78898. * Captures a screenshot of the current rendering
  78899. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78900. * @param engine defines the rendering engine
  78901. * @param camera defines the source camera
  78902. * @param size This parameter can be set to a single number or to an object with the
  78903. * following (optional) properties: precision, width, height. If a single number is passed,
  78904. * it will be used for both width and height. If an object is passed, the screenshot size
  78905. * will be derived from the parameters. The precision property is a multiplier allowing
  78906. * rendering at a higher or lower resolution
  78907. * @param successCallback defines the callback receives a single parameter which contains the
  78908. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78909. * src parameter of an <img> to display it
  78910. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78911. * Check your browser for supported MIME types
  78912. */
  78913. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78914. /**
  78915. * Captures a screenshot of the current rendering
  78916. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78917. * @param engine defines the rendering engine
  78918. * @param camera defines the source camera
  78919. * @param size This parameter can be set to a single number or to an object with the
  78920. * following (optional) properties: precision, width, height. If a single number is passed,
  78921. * it will be used for both width and height. If an object is passed, the screenshot size
  78922. * will be derived from the parameters. The precision property is a multiplier allowing
  78923. * rendering at a higher or lower resolution
  78924. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78925. * Check your browser for supported MIME types
  78926. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78927. * to the src parameter of an <img> to display it
  78928. */
  78929. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78930. /**
  78931. * Generates an image screenshot from the specified camera.
  78932. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78933. * @param engine The engine to use for rendering
  78934. * @param camera The camera to use for rendering
  78935. * @param size This parameter can be set to a single number or to an object with the
  78936. * following (optional) properties: precision, width, height. If a single number is passed,
  78937. * it will be used for both width and height. If an object is passed, the screenshot size
  78938. * will be derived from the parameters. The precision property is a multiplier allowing
  78939. * rendering at a higher or lower resolution
  78940. * @param successCallback The callback receives a single parameter which contains the
  78941. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78942. * src parameter of an <img> to display it
  78943. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78944. * Check your browser for supported MIME types
  78945. * @param samples Texture samples (default: 1)
  78946. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78947. * @param fileName A name for for the downloaded file.
  78948. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78949. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78950. */
  78951. 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;
  78952. /**
  78953. * Generates an image screenshot from the specified camera.
  78954. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78955. * @param engine The engine to use for rendering
  78956. * @param camera The camera to use for rendering
  78957. * @param size This parameter can be set to a single number or to an object with the
  78958. * following (optional) properties: precision, width, height. If a single number is passed,
  78959. * it will be used for both width and height. If an object is passed, the screenshot size
  78960. * will be derived from the parameters. The precision property is a multiplier allowing
  78961. * rendering at a higher or lower resolution
  78962. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78963. * Check your browser for supported MIME types
  78964. * @param samples Texture samples (default: 1)
  78965. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78966. * @param fileName A name for for the downloaded file.
  78967. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78968. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78969. * to the src parameter of an <img> to display it
  78970. */
  78971. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78972. /**
  78973. * Gets height and width for screenshot size
  78974. * @private
  78975. */
  78976. private static _getScreenshotSize;
  78977. }
  78978. }
  78979. declare module "babylonjs/Misc/dataReader" {
  78980. /**
  78981. * Interface for a data buffer
  78982. */
  78983. export interface IDataBuffer {
  78984. /**
  78985. * Reads bytes from the data buffer.
  78986. * @param byteOffset The byte offset to read
  78987. * @param byteLength The byte length to read
  78988. * @returns A promise that resolves when the bytes are read
  78989. */
  78990. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78991. /**
  78992. * The byte length of the buffer.
  78993. */
  78994. readonly byteLength: number;
  78995. }
  78996. /**
  78997. * Utility class for reading from a data buffer
  78998. */
  78999. export class DataReader {
  79000. /**
  79001. * The data buffer associated with this data reader.
  79002. */
  79003. readonly buffer: IDataBuffer;
  79004. /**
  79005. * The current byte offset from the beginning of the data buffer.
  79006. */
  79007. byteOffset: number;
  79008. private _dataView;
  79009. private _dataByteOffset;
  79010. /**
  79011. * Constructor
  79012. * @param buffer The buffer to read
  79013. */
  79014. constructor(buffer: IDataBuffer);
  79015. /**
  79016. * Loads the given byte length.
  79017. * @param byteLength The byte length to load
  79018. * @returns A promise that resolves when the load is complete
  79019. */
  79020. loadAsync(byteLength: number): Promise<void>;
  79021. /**
  79022. * Read a unsigned 32-bit integer from the currently loaded data range.
  79023. * @returns The 32-bit integer read
  79024. */
  79025. readUint32(): number;
  79026. /**
  79027. * Read a byte array from the currently loaded data range.
  79028. * @param byteLength The byte length to read
  79029. * @returns The byte array read
  79030. */
  79031. readUint8Array(byteLength: number): Uint8Array;
  79032. /**
  79033. * Read a string from the currently loaded data range.
  79034. * @param byteLength The byte length to read
  79035. * @returns The string read
  79036. */
  79037. readString(byteLength: number): string;
  79038. /**
  79039. * Skips the given byte length the currently loaded data range.
  79040. * @param byteLength The byte length to skip
  79041. */
  79042. skipBytes(byteLength: number): void;
  79043. }
  79044. }
  79045. declare module "babylonjs/Misc/dataStorage" {
  79046. /**
  79047. * Class for storing data to local storage if available or in-memory storage otherwise
  79048. */
  79049. export class DataStorage {
  79050. private static _Storage;
  79051. private static _GetStorage;
  79052. /**
  79053. * Reads a string from the data storage
  79054. * @param key The key to read
  79055. * @param defaultValue The value if the key doesn't exist
  79056. * @returns The string value
  79057. */
  79058. static ReadString(key: string, defaultValue: string): string;
  79059. /**
  79060. * Writes a string to the data storage
  79061. * @param key The key to write
  79062. * @param value The value to write
  79063. */
  79064. static WriteString(key: string, value: string): void;
  79065. /**
  79066. * Reads a boolean from the data storage
  79067. * @param key The key to read
  79068. * @param defaultValue The value if the key doesn't exist
  79069. * @returns The boolean value
  79070. */
  79071. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79072. /**
  79073. * Writes a boolean to the data storage
  79074. * @param key The key to write
  79075. * @param value The value to write
  79076. */
  79077. static WriteBoolean(key: string, value: boolean): void;
  79078. /**
  79079. * Reads a number from the data storage
  79080. * @param key The key to read
  79081. * @param defaultValue The value if the key doesn't exist
  79082. * @returns The number value
  79083. */
  79084. static ReadNumber(key: string, defaultValue: number): number;
  79085. /**
  79086. * Writes a number to the data storage
  79087. * @param key The key to write
  79088. * @param value The value to write
  79089. */
  79090. static WriteNumber(key: string, value: number): void;
  79091. }
  79092. }
  79093. declare module "babylonjs/Misc/sceneRecorder" {
  79094. import { Scene } from "babylonjs/scene";
  79095. /**
  79096. * Class used to record delta files between 2 scene states
  79097. */
  79098. export class SceneRecorder {
  79099. private _trackedScene;
  79100. private _savedJSON;
  79101. /**
  79102. * Track a given scene. This means the current scene state will be considered the original state
  79103. * @param scene defines the scene to track
  79104. */
  79105. track(scene: Scene): void;
  79106. /**
  79107. * Get the delta between current state and original state
  79108. * @returns a string containing the delta
  79109. */
  79110. getDelta(): any;
  79111. private _compareArray;
  79112. private _compareObjects;
  79113. private _compareCollections;
  79114. private static GetShadowGeneratorById;
  79115. /**
  79116. * Apply a given delta to a given scene
  79117. * @param deltaJSON defines the JSON containing the delta
  79118. * @param scene defines the scene to apply the delta to
  79119. */
  79120. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79121. private static _ApplyPropertiesToEntity;
  79122. private static _ApplyDeltaForEntity;
  79123. }
  79124. }
  79125. declare module "babylonjs/Misc/trajectoryClassifier" {
  79126. import { DeepImmutable, Nullable } from "babylonjs/types";
  79127. import { Vector3 } from "babylonjs/Maths/math.vector";
  79128. /**
  79129. * A 3D trajectory consisting of an order list of vectors describing a
  79130. * path of motion through 3D space.
  79131. */
  79132. export class Trajectory {
  79133. private _points;
  79134. private readonly _segmentLength;
  79135. /**
  79136. * Serialize to JSON.
  79137. * @returns serialized JSON string
  79138. */
  79139. serialize(): string;
  79140. /**
  79141. * Deserialize from JSON.
  79142. * @param json serialized JSON string
  79143. * @returns deserialized Trajectory
  79144. */
  79145. static Deserialize(json: string): Trajectory;
  79146. /**
  79147. * Create a new empty Trajectory.
  79148. * @param segmentLength radius of discretization for Trajectory points
  79149. */
  79150. constructor(segmentLength?: number);
  79151. /**
  79152. * Get the length of the Trajectory.
  79153. * @returns length of the Trajectory
  79154. */
  79155. getLength(): number;
  79156. /**
  79157. * Append a new point to the Trajectory.
  79158. * NOTE: This implementation has many allocations.
  79159. * @param point point to append to the Trajectory
  79160. */
  79161. add(point: DeepImmutable<Vector3>): void;
  79162. /**
  79163. * Create a new Trajectory with a segment length chosen to make it
  79164. * probable that the new Trajectory will have a specified number of
  79165. * segments. This operation is imprecise.
  79166. * @param targetResolution number of segments desired
  79167. * @returns new Trajectory with approximately the requested number of segments
  79168. */
  79169. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79170. /**
  79171. * Convert Trajectory segments into tokenized representation. This
  79172. * representation is an array of numbers where each nth number is the
  79173. * index of the token which is most similar to the nth segment of the
  79174. * Trajectory.
  79175. * @param tokens list of vectors which serve as discrete tokens
  79176. * @returns list of indices of most similar token per segment
  79177. */
  79178. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79179. private static _forwardDir;
  79180. private static _inverseFromVec;
  79181. private static _upDir;
  79182. private static _fromToVec;
  79183. private static _lookMatrix;
  79184. /**
  79185. * Transform the rotation (i.e., direction) of a segment to isolate
  79186. * the relative transformation represented by the segment. This operation
  79187. * may or may not succeed due to singularities in the equations that define
  79188. * motion relativity in this context.
  79189. * @param priorVec the origin of the prior segment
  79190. * @param fromVec the origin of the current segment
  79191. * @param toVec the destination of the current segment
  79192. * @param result reference to output variable
  79193. * @returns whether or not transformation was successful
  79194. */
  79195. private static _transformSegmentDirToRef;
  79196. private static _bestMatch;
  79197. private static _score;
  79198. private static _bestScore;
  79199. /**
  79200. * Determine which token vector is most similar to the
  79201. * segment vector.
  79202. * @param segment segment vector
  79203. * @param tokens token vector list
  79204. * @returns index of the most similar token to the segment
  79205. */
  79206. private static _tokenizeSegment;
  79207. }
  79208. /**
  79209. * Class representing a set of known, named trajectories to which Trajectories can be
  79210. * added and using which Trajectories can be recognized.
  79211. */
  79212. export class TrajectoryClassifier {
  79213. private _maximumAllowableMatchCost;
  79214. private _vector3Alphabet;
  79215. private _levenshteinAlphabet;
  79216. private _nameToDescribedTrajectory;
  79217. /**
  79218. * Serialize to JSON.
  79219. * @returns JSON serialization
  79220. */
  79221. serialize(): string;
  79222. /**
  79223. * Deserialize from JSON.
  79224. * @param json JSON serialization
  79225. * @returns deserialized TrajectorySet
  79226. */
  79227. static Deserialize(json: string): TrajectoryClassifier;
  79228. /**
  79229. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79230. * VERY naive, need to be generating these things from known
  79231. * sets. Better version later, probably eliminating this one.
  79232. * @returns auto-generated TrajectorySet
  79233. */
  79234. static Generate(): TrajectoryClassifier;
  79235. private constructor();
  79236. /**
  79237. * Add a new Trajectory to the set with a given name.
  79238. * @param trajectory new Trajectory to be added
  79239. * @param classification name to which to add the Trajectory
  79240. */
  79241. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79242. /**
  79243. * Remove a known named trajectory and all Trajectories associated with it.
  79244. * @param classification name to remove
  79245. * @returns whether anything was removed
  79246. */
  79247. deleteClassification(classification: string): boolean;
  79248. /**
  79249. * Attempt to recognize a Trajectory from among all the classifications
  79250. * already known to the classifier.
  79251. * @param trajectory Trajectory to be recognized
  79252. * @returns classification of Trajectory if recognized, null otherwise
  79253. */
  79254. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79255. }
  79256. }
  79257. declare module "babylonjs/Misc/index" {
  79258. export * from "babylonjs/Misc/andOrNotEvaluator";
  79259. export * from "babylonjs/Misc/assetsManager";
  79260. export * from "babylonjs/Misc/basis";
  79261. export * from "babylonjs/Misc/dds";
  79262. export * from "babylonjs/Misc/decorators";
  79263. export * from "babylonjs/Misc/deferred";
  79264. export * from "babylonjs/Misc/environmentTextureTools";
  79265. export * from "babylonjs/Misc/meshExploder";
  79266. export * from "babylonjs/Misc/filesInput";
  79267. export * from "babylonjs/Misc/HighDynamicRange/index";
  79268. export * from "babylonjs/Misc/khronosTextureContainer";
  79269. export * from "babylonjs/Misc/observable";
  79270. export * from "babylonjs/Misc/performanceMonitor";
  79271. export * from "babylonjs/Misc/promise";
  79272. export * from "babylonjs/Misc/sceneOptimizer";
  79273. export * from "babylonjs/Misc/sceneSerializer";
  79274. export * from "babylonjs/Misc/smartArray";
  79275. export * from "babylonjs/Misc/stringDictionary";
  79276. export * from "babylonjs/Misc/tags";
  79277. export * from "babylonjs/Misc/textureTools";
  79278. export * from "babylonjs/Misc/tga";
  79279. export * from "babylonjs/Misc/tools";
  79280. export * from "babylonjs/Misc/videoRecorder";
  79281. export * from "babylonjs/Misc/virtualJoystick";
  79282. export * from "babylonjs/Misc/workerPool";
  79283. export * from "babylonjs/Misc/logger";
  79284. export * from "babylonjs/Misc/typeStore";
  79285. export * from "babylonjs/Misc/filesInputStore";
  79286. export * from "babylonjs/Misc/deepCopier";
  79287. export * from "babylonjs/Misc/pivotTools";
  79288. export * from "babylonjs/Misc/precisionDate";
  79289. export * from "babylonjs/Misc/screenshotTools";
  79290. export * from "babylonjs/Misc/typeStore";
  79291. export * from "babylonjs/Misc/webRequest";
  79292. export * from "babylonjs/Misc/iInspectable";
  79293. export * from "babylonjs/Misc/brdfTextureTools";
  79294. export * from "babylonjs/Misc/rgbdTextureTools";
  79295. export * from "babylonjs/Misc/gradients";
  79296. export * from "babylonjs/Misc/perfCounter";
  79297. export * from "babylonjs/Misc/fileRequest";
  79298. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79299. export * from "babylonjs/Misc/retryStrategy";
  79300. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79301. export * from "babylonjs/Misc/canvasGenerator";
  79302. export * from "babylonjs/Misc/fileTools";
  79303. export * from "babylonjs/Misc/stringTools";
  79304. export * from "babylonjs/Misc/dataReader";
  79305. export * from "babylonjs/Misc/minMaxReducer";
  79306. export * from "babylonjs/Misc/depthReducer";
  79307. export * from "babylonjs/Misc/dataStorage";
  79308. export * from "babylonjs/Misc/sceneRecorder";
  79309. export * from "babylonjs/Misc/khronosTextureContainer2";
  79310. export * from "babylonjs/Misc/trajectoryClassifier";
  79311. export * from "babylonjs/Misc/timer";
  79312. }
  79313. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79314. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79315. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79316. import { Observable } from "babylonjs/Misc/observable";
  79317. import { Matrix } from "babylonjs/Maths/math.vector";
  79318. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79319. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79320. /**
  79321. * An interface for all Hit test features
  79322. */
  79323. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79324. /**
  79325. * Triggered when new babylon (transformed) hit test results are available
  79326. */
  79327. onHitTestResultObservable: Observable<T[]>;
  79328. }
  79329. /**
  79330. * Options used for hit testing
  79331. */
  79332. export interface IWebXRLegacyHitTestOptions {
  79333. /**
  79334. * Only test when user interacted with the scene. Default - hit test every frame
  79335. */
  79336. testOnPointerDownOnly?: boolean;
  79337. /**
  79338. * The node to use to transform the local results to world coordinates
  79339. */
  79340. worldParentNode?: TransformNode;
  79341. }
  79342. /**
  79343. * Interface defining the babylon result of raycasting/hit-test
  79344. */
  79345. export interface IWebXRLegacyHitResult {
  79346. /**
  79347. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79348. */
  79349. transformationMatrix: Matrix;
  79350. /**
  79351. * The native hit test result
  79352. */
  79353. xrHitResult: XRHitResult | XRHitTestResult;
  79354. }
  79355. /**
  79356. * The currently-working hit-test module.
  79357. * Hit test (or Ray-casting) is used to interact with the real world.
  79358. * For further information read here - https://github.com/immersive-web/hit-test
  79359. */
  79360. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79361. /**
  79362. * options to use when constructing this feature
  79363. */
  79364. readonly options: IWebXRLegacyHitTestOptions;
  79365. private _direction;
  79366. private _mat;
  79367. private _onSelectEnabled;
  79368. private _origin;
  79369. /**
  79370. * The module's name
  79371. */
  79372. static readonly Name: string;
  79373. /**
  79374. * The (Babylon) version of this module.
  79375. * This is an integer representing the implementation version.
  79376. * This number does not correspond to the WebXR specs version
  79377. */
  79378. static readonly Version: number;
  79379. /**
  79380. * Populated with the last native XR Hit Results
  79381. */
  79382. lastNativeXRHitResults: XRHitResult[];
  79383. /**
  79384. * Triggered when new babylon (transformed) hit test results are available
  79385. */
  79386. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79387. /**
  79388. * Creates a new instance of the (legacy version) hit test feature
  79389. * @param _xrSessionManager an instance of WebXRSessionManager
  79390. * @param options options to use when constructing this feature
  79391. */
  79392. constructor(_xrSessionManager: WebXRSessionManager,
  79393. /**
  79394. * options to use when constructing this feature
  79395. */
  79396. options?: IWebXRLegacyHitTestOptions);
  79397. /**
  79398. * execute a hit test with an XR Ray
  79399. *
  79400. * @param xrSession a native xrSession that will execute this hit test
  79401. * @param xrRay the ray (position and direction) to use for ray-casting
  79402. * @param referenceSpace native XR reference space to use for the hit-test
  79403. * @param filter filter function that will filter the results
  79404. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79405. */
  79406. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79407. /**
  79408. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79409. * @param event the (select) event to use to select with
  79410. * @param referenceSpace the reference space to use for this hit test
  79411. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79412. */
  79413. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79414. /**
  79415. * attach this feature
  79416. * Will usually be called by the features manager
  79417. *
  79418. * @returns true if successful.
  79419. */
  79420. attach(): boolean;
  79421. /**
  79422. * detach this feature.
  79423. * Will usually be called by the features manager
  79424. *
  79425. * @returns true if successful.
  79426. */
  79427. detach(): boolean;
  79428. /**
  79429. * Dispose this feature and all of the resources attached
  79430. */
  79431. dispose(): void;
  79432. protected _onXRFrame(frame: XRFrame): void;
  79433. private _onHitTestResults;
  79434. private _onSelect;
  79435. }
  79436. }
  79437. declare module "babylonjs/XR/features/WebXRHitTest" {
  79438. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79439. import { Observable } from "babylonjs/Misc/observable";
  79440. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79441. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79442. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79443. /**
  79444. * Options used for hit testing (version 2)
  79445. */
  79446. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79447. /**
  79448. * Do not create a permanent hit test. Will usually be used when only
  79449. * transient inputs are needed.
  79450. */
  79451. disablePermanentHitTest?: boolean;
  79452. /**
  79453. * Enable transient (for example touch-based) hit test inspections
  79454. */
  79455. enableTransientHitTest?: boolean;
  79456. /**
  79457. * Offset ray for the permanent hit test
  79458. */
  79459. offsetRay?: Vector3;
  79460. /**
  79461. * Offset ray for the transient hit test
  79462. */
  79463. transientOffsetRay?: Vector3;
  79464. /**
  79465. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79466. */
  79467. useReferenceSpace?: boolean;
  79468. /**
  79469. * Override the default entity type(s) of the hit-test result
  79470. */
  79471. entityTypes?: XRHitTestTrackableType[];
  79472. }
  79473. /**
  79474. * Interface defining the babylon result of hit-test
  79475. */
  79476. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79477. /**
  79478. * The input source that generated this hit test (if transient)
  79479. */
  79480. inputSource?: XRInputSource;
  79481. /**
  79482. * Is this a transient hit test
  79483. */
  79484. isTransient?: boolean;
  79485. /**
  79486. * Position of the hit test result
  79487. */
  79488. position: Vector3;
  79489. /**
  79490. * Rotation of the hit test result
  79491. */
  79492. rotationQuaternion: Quaternion;
  79493. /**
  79494. * The native hit test result
  79495. */
  79496. xrHitResult: XRHitTestResult;
  79497. }
  79498. /**
  79499. * The currently-working hit-test module.
  79500. * Hit test (or Ray-casting) is used to interact with the real world.
  79501. * For further information read here - https://github.com/immersive-web/hit-test
  79502. *
  79503. * Tested on chrome (mobile) 80.
  79504. */
  79505. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79506. /**
  79507. * options to use when constructing this feature
  79508. */
  79509. readonly options: IWebXRHitTestOptions;
  79510. private _tmpMat;
  79511. private _tmpPos;
  79512. private _tmpQuat;
  79513. private _transientXrHitTestSource;
  79514. private _xrHitTestSource;
  79515. private initHitTestSource;
  79516. /**
  79517. * The module's name
  79518. */
  79519. static readonly Name: string;
  79520. /**
  79521. * The (Babylon) version of this module.
  79522. * This is an integer representing the implementation version.
  79523. * This number does not correspond to the WebXR specs version
  79524. */
  79525. static readonly Version: number;
  79526. /**
  79527. * When set to true, each hit test will have its own position/rotation objects
  79528. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79529. * the developers will clone them or copy them as they see fit.
  79530. */
  79531. autoCloneTransformation: boolean;
  79532. /**
  79533. * Triggered when new babylon (transformed) hit test results are available
  79534. * Note - this will be called when results come back from the device. It can be an empty array!!
  79535. */
  79536. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79537. /**
  79538. * Use this to temporarily pause hit test checks.
  79539. */
  79540. paused: boolean;
  79541. /**
  79542. * Creates a new instance of the hit test feature
  79543. * @param _xrSessionManager an instance of WebXRSessionManager
  79544. * @param options options to use when constructing this feature
  79545. */
  79546. constructor(_xrSessionManager: WebXRSessionManager,
  79547. /**
  79548. * options to use when constructing this feature
  79549. */
  79550. options?: IWebXRHitTestOptions);
  79551. /**
  79552. * attach this feature
  79553. * Will usually be called by the features manager
  79554. *
  79555. * @returns true if successful.
  79556. */
  79557. attach(): boolean;
  79558. /**
  79559. * detach this feature.
  79560. * Will usually be called by the features manager
  79561. *
  79562. * @returns true if successful.
  79563. */
  79564. detach(): boolean;
  79565. /**
  79566. * Dispose this feature and all of the resources attached
  79567. */
  79568. dispose(): void;
  79569. protected _onXRFrame(frame: XRFrame): void;
  79570. private _processWebXRHitTestResult;
  79571. }
  79572. }
  79573. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79574. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79575. import { Observable } from "babylonjs/Misc/observable";
  79576. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79577. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79578. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79579. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79580. /**
  79581. * Configuration options of the anchor system
  79582. */
  79583. export interface IWebXRAnchorSystemOptions {
  79584. /**
  79585. * a node that will be used to convert local to world coordinates
  79586. */
  79587. worldParentNode?: TransformNode;
  79588. /**
  79589. * If set to true a reference of the created anchors will be kept until the next session starts
  79590. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79591. */
  79592. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79593. }
  79594. /**
  79595. * A babylon container for an XR Anchor
  79596. */
  79597. export interface IWebXRAnchor {
  79598. /**
  79599. * A babylon-assigned ID for this anchor
  79600. */
  79601. id: number;
  79602. /**
  79603. * Transformation matrix to apply to an object attached to this anchor
  79604. */
  79605. transformationMatrix: Matrix;
  79606. /**
  79607. * The native anchor object
  79608. */
  79609. xrAnchor: XRAnchor;
  79610. /**
  79611. * if defined, this object will be constantly updated by the anchor's position and rotation
  79612. */
  79613. attachedNode?: TransformNode;
  79614. }
  79615. /**
  79616. * An implementation of the anchor system for WebXR.
  79617. * For further information see https://github.com/immersive-web/anchors/
  79618. */
  79619. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79620. private _options;
  79621. private _lastFrameDetected;
  79622. private _trackedAnchors;
  79623. private _referenceSpaceForFrameAnchors;
  79624. private _futureAnchors;
  79625. /**
  79626. * The module's name
  79627. */
  79628. static readonly Name: string;
  79629. /**
  79630. * The (Babylon) version of this module.
  79631. * This is an integer representing the implementation version.
  79632. * This number does not correspond to the WebXR specs version
  79633. */
  79634. static readonly Version: number;
  79635. /**
  79636. * Observers registered here will be executed when a new anchor was added to the session
  79637. */
  79638. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79639. /**
  79640. * Observers registered here will be executed when an anchor was removed from the session
  79641. */
  79642. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79643. /**
  79644. * Observers registered here will be executed when an existing anchor updates
  79645. * This can execute N times every frame
  79646. */
  79647. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79648. /**
  79649. * Set the reference space to use for anchor creation, when not using a hit test.
  79650. * Will default to the session's reference space if not defined
  79651. */
  79652. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79653. /**
  79654. * constructs a new anchor system
  79655. * @param _xrSessionManager an instance of WebXRSessionManager
  79656. * @param _options configuration object for this feature
  79657. */
  79658. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79659. private _tmpVector;
  79660. private _tmpQuaternion;
  79661. private _populateTmpTransformation;
  79662. /**
  79663. * Create a new anchor point using a hit test result at a specific point in the scene
  79664. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79665. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79666. *
  79667. * @param hitTestResult The hit test result to use for this anchor creation
  79668. * @param position an optional position offset for this anchor
  79669. * @param rotationQuaternion an optional rotation offset for this anchor
  79670. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79671. */
  79672. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79673. /**
  79674. * Add a new anchor at a specific position and rotation
  79675. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79676. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79677. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79678. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79679. *
  79680. * @param position the position in which to add an anchor
  79681. * @param rotationQuaternion an optional rotation for the anchor transformation
  79682. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79683. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79684. */
  79685. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79686. /**
  79687. * detach this feature.
  79688. * Will usually be called by the features manager
  79689. *
  79690. * @returns true if successful.
  79691. */
  79692. detach(): boolean;
  79693. /**
  79694. * Dispose this feature and all of the resources attached
  79695. */
  79696. dispose(): void;
  79697. protected _onXRFrame(frame: XRFrame): void;
  79698. /**
  79699. * avoiding using Array.find for global support.
  79700. * @param xrAnchor the plane to find in the array
  79701. */
  79702. private _findIndexInAnchorArray;
  79703. private _updateAnchorWithXRFrame;
  79704. private _createAnchorAtTransformation;
  79705. }
  79706. }
  79707. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79708. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79709. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79710. import { Observable } from "babylonjs/Misc/observable";
  79711. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79712. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79713. /**
  79714. * Options used in the plane detector module
  79715. */
  79716. export interface IWebXRPlaneDetectorOptions {
  79717. /**
  79718. * The node to use to transform the local results to world coordinates
  79719. */
  79720. worldParentNode?: TransformNode;
  79721. /**
  79722. * If set to true a reference of the created planes will be kept until the next session starts
  79723. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79724. */
  79725. doNotRemovePlanesOnSessionEnded?: boolean;
  79726. }
  79727. /**
  79728. * A babylon interface for a WebXR plane.
  79729. * A Plane is actually a polygon, built from N points in space
  79730. *
  79731. * Supported in chrome 79, not supported in canary 81 ATM
  79732. */
  79733. export interface IWebXRPlane {
  79734. /**
  79735. * a babylon-assigned ID for this polygon
  79736. */
  79737. id: number;
  79738. /**
  79739. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79740. */
  79741. polygonDefinition: Array<Vector3>;
  79742. /**
  79743. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79744. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79745. */
  79746. transformationMatrix: Matrix;
  79747. /**
  79748. * the native xr-plane object
  79749. */
  79750. xrPlane: XRPlane;
  79751. }
  79752. /**
  79753. * The plane detector is used to detect planes in the real world when in AR
  79754. * For more information see https://github.com/immersive-web/real-world-geometry/
  79755. */
  79756. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79757. private _options;
  79758. private _detectedPlanes;
  79759. private _enabled;
  79760. private _lastFrameDetected;
  79761. /**
  79762. * The module's name
  79763. */
  79764. static readonly Name: string;
  79765. /**
  79766. * The (Babylon) version of this module.
  79767. * This is an integer representing the implementation version.
  79768. * This number does not correspond to the WebXR specs version
  79769. */
  79770. static readonly Version: number;
  79771. /**
  79772. * Observers registered here will be executed when a new plane was added to the session
  79773. */
  79774. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79775. /**
  79776. * Observers registered here will be executed when a plane is no longer detected in the session
  79777. */
  79778. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79779. /**
  79780. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79781. * This can execute N times every frame
  79782. */
  79783. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79784. /**
  79785. * construct a new Plane Detector
  79786. * @param _xrSessionManager an instance of xr Session manager
  79787. * @param _options configuration to use when constructing this feature
  79788. */
  79789. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79790. /**
  79791. * detach this feature.
  79792. * Will usually be called by the features manager
  79793. *
  79794. * @returns true if successful.
  79795. */
  79796. detach(): boolean;
  79797. /**
  79798. * Dispose this feature and all of the resources attached
  79799. */
  79800. dispose(): void;
  79801. protected _onXRFrame(frame: XRFrame): void;
  79802. private _init;
  79803. private _updatePlaneWithXRPlane;
  79804. /**
  79805. * avoiding using Array.find for global support.
  79806. * @param xrPlane the plane to find in the array
  79807. */
  79808. private findIndexInPlaneArray;
  79809. }
  79810. }
  79811. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79812. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79814. import { Observable } from "babylonjs/Misc/observable";
  79815. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79816. /**
  79817. * Options interface for the background remover plugin
  79818. */
  79819. export interface IWebXRBackgroundRemoverOptions {
  79820. /**
  79821. * Further background meshes to disable when entering AR
  79822. */
  79823. backgroundMeshes?: AbstractMesh[];
  79824. /**
  79825. * flags to configure the removal of the environment helper.
  79826. * If not set, the entire background will be removed. If set, flags should be set as well.
  79827. */
  79828. environmentHelperRemovalFlags?: {
  79829. /**
  79830. * Should the skybox be removed (default false)
  79831. */
  79832. skyBox?: boolean;
  79833. /**
  79834. * Should the ground be removed (default false)
  79835. */
  79836. ground?: boolean;
  79837. };
  79838. /**
  79839. * don't disable the environment helper
  79840. */
  79841. ignoreEnvironmentHelper?: boolean;
  79842. }
  79843. /**
  79844. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79845. */
  79846. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79847. /**
  79848. * read-only options to be used in this module
  79849. */
  79850. readonly options: IWebXRBackgroundRemoverOptions;
  79851. /**
  79852. * The module's name
  79853. */
  79854. static readonly Name: string;
  79855. /**
  79856. * The (Babylon) version of this module.
  79857. * This is an integer representing the implementation version.
  79858. * This number does not correspond to the WebXR specs version
  79859. */
  79860. static readonly Version: number;
  79861. /**
  79862. * registered observers will be triggered when the background state changes
  79863. */
  79864. onBackgroundStateChangedObservable: Observable<boolean>;
  79865. /**
  79866. * constructs a new background remover module
  79867. * @param _xrSessionManager the session manager for this module
  79868. * @param options read-only options to be used in this module
  79869. */
  79870. constructor(_xrSessionManager: WebXRSessionManager,
  79871. /**
  79872. * read-only options to be used in this module
  79873. */
  79874. options?: IWebXRBackgroundRemoverOptions);
  79875. /**
  79876. * attach this feature
  79877. * Will usually be called by the features manager
  79878. *
  79879. * @returns true if successful.
  79880. */
  79881. attach(): boolean;
  79882. /**
  79883. * detach this feature.
  79884. * Will usually be called by the features manager
  79885. *
  79886. * @returns true if successful.
  79887. */
  79888. detach(): boolean;
  79889. /**
  79890. * Dispose this feature and all of the resources attached
  79891. */
  79892. dispose(): void;
  79893. protected _onXRFrame(_xrFrame: XRFrame): void;
  79894. private _setBackgroundState;
  79895. }
  79896. }
  79897. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79898. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79899. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79900. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79901. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79902. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79903. import { Nullable } from "babylonjs/types";
  79904. /**
  79905. * Options for the controller physics feature
  79906. */
  79907. export class IWebXRControllerPhysicsOptions {
  79908. /**
  79909. * Should the headset get its own impostor
  79910. */
  79911. enableHeadsetImpostor?: boolean;
  79912. /**
  79913. * Optional parameters for the headset impostor
  79914. */
  79915. headsetImpostorParams?: {
  79916. /**
  79917. * The type of impostor to create. Default is sphere
  79918. */
  79919. impostorType: number;
  79920. /**
  79921. * the size of the impostor. Defaults to 10cm
  79922. */
  79923. impostorSize?: number | {
  79924. width: number;
  79925. height: number;
  79926. depth: number;
  79927. };
  79928. /**
  79929. * Friction definitions
  79930. */
  79931. friction?: number;
  79932. /**
  79933. * Restitution
  79934. */
  79935. restitution?: number;
  79936. };
  79937. /**
  79938. * The physics properties of the future impostors
  79939. */
  79940. physicsProperties?: {
  79941. /**
  79942. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79943. * Note that this requires a physics engine that supports mesh impostors!
  79944. */
  79945. useControllerMesh?: boolean;
  79946. /**
  79947. * The type of impostor to create. Default is sphere
  79948. */
  79949. impostorType?: number;
  79950. /**
  79951. * the size of the impostor. Defaults to 10cm
  79952. */
  79953. impostorSize?: number | {
  79954. width: number;
  79955. height: number;
  79956. depth: number;
  79957. };
  79958. /**
  79959. * Friction definitions
  79960. */
  79961. friction?: number;
  79962. /**
  79963. * Restitution
  79964. */
  79965. restitution?: number;
  79966. };
  79967. /**
  79968. * the xr input to use with this pointer selection
  79969. */
  79970. xrInput: WebXRInput;
  79971. }
  79972. /**
  79973. * Add physics impostor to your webxr controllers,
  79974. * including naive calculation of their linear and angular velocity
  79975. */
  79976. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79977. private readonly _options;
  79978. private _attachController;
  79979. private _controllers;
  79980. private _debugMode;
  79981. private _delta;
  79982. private _headsetImpostor?;
  79983. private _headsetMesh?;
  79984. private _lastTimestamp;
  79985. private _tmpQuaternion;
  79986. private _tmpVector;
  79987. /**
  79988. * The module's name
  79989. */
  79990. static readonly Name: string;
  79991. /**
  79992. * The (Babylon) version of this module.
  79993. * This is an integer representing the implementation version.
  79994. * This number does not correspond to the webxr specs version
  79995. */
  79996. static readonly Version: number;
  79997. /**
  79998. * Construct a new Controller Physics Feature
  79999. * @param _xrSessionManager the corresponding xr session manager
  80000. * @param _options options to create this feature with
  80001. */
  80002. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80003. /**
  80004. * @hidden
  80005. * enable debugging - will show console outputs and the impostor mesh
  80006. */
  80007. _enablePhysicsDebug(): void;
  80008. /**
  80009. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80010. * @param xrController the controller to add
  80011. */
  80012. addController(xrController: WebXRInputSource): void;
  80013. /**
  80014. * attach this feature
  80015. * Will usually be called by the features manager
  80016. *
  80017. * @returns true if successful.
  80018. */
  80019. attach(): boolean;
  80020. /**
  80021. * detach this feature.
  80022. * Will usually be called by the features manager
  80023. *
  80024. * @returns true if successful.
  80025. */
  80026. detach(): boolean;
  80027. /**
  80028. * Get the headset impostor, if enabled
  80029. * @returns the impostor
  80030. */
  80031. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80032. /**
  80033. * Get the physics impostor of a specific controller.
  80034. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80035. * @param controller the controller or the controller id of which to get the impostor
  80036. * @returns the impostor or null
  80037. */
  80038. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80039. /**
  80040. * Update the physics properties provided in the constructor
  80041. * @param newProperties the new properties object
  80042. */
  80043. setPhysicsProperties(newProperties: {
  80044. impostorType?: number;
  80045. impostorSize?: number | {
  80046. width: number;
  80047. height: number;
  80048. depth: number;
  80049. };
  80050. friction?: number;
  80051. restitution?: number;
  80052. }): void;
  80053. protected _onXRFrame(_xrFrame: any): void;
  80054. private _detachController;
  80055. }
  80056. }
  80057. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80058. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80059. import { Observable } from "babylonjs/Misc/observable";
  80060. import { Vector3 } from "babylonjs/Maths/math.vector";
  80061. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80062. /**
  80063. * A babylon interface for a "WebXR" feature point.
  80064. * Represents the position and confidence value of a given feature point.
  80065. */
  80066. export interface IWebXRFeaturePoint {
  80067. /**
  80068. * Represents the position of the feature point in world space.
  80069. */
  80070. position: Vector3;
  80071. /**
  80072. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80073. */
  80074. confidenceValue: number;
  80075. }
  80076. /**
  80077. * The feature point system is used to detect feature points from real world geometry.
  80078. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80079. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80080. */
  80081. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80082. private _enabled;
  80083. private _featurePointCloud;
  80084. /**
  80085. * The module's name
  80086. */
  80087. static readonly Name: string;
  80088. /**
  80089. * The (Babylon) version of this module.
  80090. * This is an integer representing the implementation version.
  80091. * This number does not correspond to the WebXR specs version
  80092. */
  80093. static readonly Version: number;
  80094. /**
  80095. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80096. * Will notify the observers about which feature points have been added.
  80097. */
  80098. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80099. /**
  80100. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80101. * Will notify the observers about which feature points have been updated.
  80102. */
  80103. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80104. /**
  80105. * The current feature point cloud maintained across frames.
  80106. */
  80107. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80108. /**
  80109. * construct the feature point system
  80110. * @param _xrSessionManager an instance of xr Session manager
  80111. */
  80112. constructor(_xrSessionManager: WebXRSessionManager);
  80113. /**
  80114. * Detach this feature.
  80115. * Will usually be called by the features manager
  80116. *
  80117. * @returns true if successful.
  80118. */
  80119. detach(): boolean;
  80120. /**
  80121. * Dispose this feature and all of the resources attached
  80122. */
  80123. dispose(): void;
  80124. /**
  80125. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80126. */
  80127. protected _onXRFrame(frame: XRFrame): void;
  80128. /**
  80129. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80130. */
  80131. private _init;
  80132. }
  80133. }
  80134. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80135. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80136. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80138. import { Mesh } from "babylonjs/Meshes/mesh";
  80139. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80140. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80141. import { Nullable } from "babylonjs/types";
  80142. import { IDisposable } from "babylonjs/scene";
  80143. import { Observable } from "babylonjs/Misc/observable";
  80144. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80145. /**
  80146. * Configuration interface for the hand tracking feature
  80147. */
  80148. export interface IWebXRHandTrackingOptions {
  80149. /**
  80150. * The xrInput that will be used as source for new hands
  80151. */
  80152. xrInput: WebXRInput;
  80153. /**
  80154. * Configuration object for the joint meshes
  80155. */
  80156. jointMeshes?: {
  80157. /**
  80158. * Should the meshes created be invisible (defaults to false)
  80159. */
  80160. invisible?: boolean;
  80161. /**
  80162. * A source mesh to be used to create instances. Defaults to a sphere.
  80163. * This mesh will be the source for all other (25) meshes.
  80164. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80165. */
  80166. sourceMesh?: Mesh;
  80167. /**
  80168. * This function will be called after a mesh was created for a specific joint.
  80169. * Using this function you can either manipulate the instance or return a new mesh.
  80170. * When returning a new mesh the instance created before will be disposed
  80171. */
  80172. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80173. /**
  80174. * Should the source mesh stay visible. Defaults to false
  80175. */
  80176. keepOriginalVisible?: boolean;
  80177. /**
  80178. * Scale factor for all instances (defaults to 2)
  80179. */
  80180. scaleFactor?: number;
  80181. /**
  80182. * Should each instance have its own physics impostor
  80183. */
  80184. enablePhysics?: boolean;
  80185. /**
  80186. * If enabled, override default physics properties
  80187. */
  80188. physicsProps?: {
  80189. friction?: number;
  80190. restitution?: number;
  80191. impostorType?: number;
  80192. };
  80193. /**
  80194. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80195. */
  80196. handMesh?: AbstractMesh;
  80197. };
  80198. }
  80199. /**
  80200. * Parts of the hands divided to writs and finger names
  80201. */
  80202. export const enum HandPart {
  80203. /**
  80204. * HandPart - Wrist
  80205. */
  80206. WRIST = "wrist",
  80207. /**
  80208. * HandPart - The THumb
  80209. */
  80210. THUMB = "thumb",
  80211. /**
  80212. * HandPart - Index finger
  80213. */
  80214. INDEX = "index",
  80215. /**
  80216. * HandPart - Middle finger
  80217. */
  80218. MIDDLE = "middle",
  80219. /**
  80220. * HandPart - Ring finger
  80221. */
  80222. RING = "ring",
  80223. /**
  80224. * HandPart - Little finger
  80225. */
  80226. LITTLE = "little"
  80227. }
  80228. /**
  80229. * Representing a single hand (with its corresponding native XRHand object)
  80230. */
  80231. export class WebXRHand implements IDisposable {
  80232. /** the controller to which the hand correlates */
  80233. readonly xrController: WebXRInputSource;
  80234. /** the meshes to be used to track the hand joints */
  80235. readonly trackedMeshes: AbstractMesh[];
  80236. /**
  80237. * Hand-parts definition (key is HandPart)
  80238. */
  80239. handPartsDefinition: {
  80240. [key: string]: number[];
  80241. };
  80242. /**
  80243. * Populate the HandPartsDefinition object.
  80244. * This is called as a side effect since certain browsers don't have XRHand defined.
  80245. */
  80246. private generateHandPartsDefinition;
  80247. /**
  80248. * Construct a new hand object
  80249. * @param xrController the controller to which the hand correlates
  80250. * @param trackedMeshes the meshes to be used to track the hand joints
  80251. */
  80252. constructor(
  80253. /** the controller to which the hand correlates */
  80254. xrController: WebXRInputSource,
  80255. /** the meshes to be used to track the hand joints */
  80256. trackedMeshes: AbstractMesh[]);
  80257. /**
  80258. * Update this hand from the latest xr frame
  80259. * @param xrFrame xrFrame to update from
  80260. * @param referenceSpace The current viewer reference space
  80261. * @param scaleFactor optional scale factor for the meshes
  80262. */
  80263. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80264. /**
  80265. * Get meshes of part of the hand
  80266. * @param part the part of hand to get
  80267. * @returns An array of meshes that correlate to the hand part requested
  80268. */
  80269. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80270. /**
  80271. * Dispose this Hand object
  80272. */
  80273. dispose(): void;
  80274. }
  80275. /**
  80276. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80277. */
  80278. export class WebXRHandTracking extends WebXRAbstractFeature {
  80279. /**
  80280. * options to use when constructing this feature
  80281. */
  80282. readonly options: IWebXRHandTrackingOptions;
  80283. private static _idCounter;
  80284. /**
  80285. * The module's name
  80286. */
  80287. static readonly Name: string;
  80288. /**
  80289. * The (Babylon) version of this module.
  80290. * This is an integer representing the implementation version.
  80291. * This number does not correspond to the WebXR specs version
  80292. */
  80293. static readonly Version: number;
  80294. /**
  80295. * This observable will notify registered observers when a new hand object was added and initialized
  80296. */
  80297. onHandAddedObservable: Observable<WebXRHand>;
  80298. /**
  80299. * This observable will notify its observers right before the hand object is disposed
  80300. */
  80301. onHandRemovedObservable: Observable<WebXRHand>;
  80302. private _hands;
  80303. /**
  80304. * Creates a new instance of the hit test feature
  80305. * @param _xrSessionManager an instance of WebXRSessionManager
  80306. * @param options options to use when constructing this feature
  80307. */
  80308. constructor(_xrSessionManager: WebXRSessionManager,
  80309. /**
  80310. * options to use when constructing this feature
  80311. */
  80312. options: IWebXRHandTrackingOptions);
  80313. /**
  80314. * Check if the needed objects are defined.
  80315. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80316. */
  80317. isCompatible(): boolean;
  80318. /**
  80319. * attach this feature
  80320. * Will usually be called by the features manager
  80321. *
  80322. * @returns true if successful.
  80323. */
  80324. attach(): boolean;
  80325. /**
  80326. * detach this feature.
  80327. * Will usually be called by the features manager
  80328. *
  80329. * @returns true if successful.
  80330. */
  80331. detach(): boolean;
  80332. /**
  80333. * Dispose this feature and all of the resources attached
  80334. */
  80335. dispose(): void;
  80336. /**
  80337. * Get the hand object according to the controller id
  80338. * @param controllerId the controller id to which we want to get the hand
  80339. * @returns null if not found or the WebXRHand object if found
  80340. */
  80341. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80342. /**
  80343. * Get a hand object according to the requested handedness
  80344. * @param handedness the handedness to request
  80345. * @returns null if not found or the WebXRHand object if found
  80346. */
  80347. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80348. protected _onXRFrame(_xrFrame: XRFrame): void;
  80349. private _attachHand;
  80350. private _detachHand;
  80351. }
  80352. }
  80353. declare module "babylonjs/XR/features/index" {
  80354. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80355. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80356. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80357. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80358. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80359. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80360. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80361. export * from "babylonjs/XR/features/WebXRHitTest";
  80362. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80363. export * from "babylonjs/XR/features/WebXRHandTracking";
  80364. }
  80365. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80366. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80368. import { Scene } from "babylonjs/scene";
  80369. /**
  80370. * The motion controller class for all microsoft mixed reality controllers
  80371. */
  80372. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80373. protected readonly _mapping: {
  80374. defaultButton: {
  80375. valueNodeName: string;
  80376. unpressedNodeName: string;
  80377. pressedNodeName: string;
  80378. };
  80379. defaultAxis: {
  80380. valueNodeName: string;
  80381. minNodeName: string;
  80382. maxNodeName: string;
  80383. };
  80384. buttons: {
  80385. "xr-standard-trigger": {
  80386. rootNodeName: string;
  80387. componentProperty: string;
  80388. states: string[];
  80389. };
  80390. "xr-standard-squeeze": {
  80391. rootNodeName: string;
  80392. componentProperty: string;
  80393. states: string[];
  80394. };
  80395. "xr-standard-touchpad": {
  80396. rootNodeName: string;
  80397. labelAnchorNodeName: string;
  80398. touchPointNodeName: string;
  80399. };
  80400. "xr-standard-thumbstick": {
  80401. rootNodeName: string;
  80402. componentProperty: string;
  80403. states: string[];
  80404. };
  80405. };
  80406. axes: {
  80407. "xr-standard-touchpad": {
  80408. "x-axis": {
  80409. rootNodeName: string;
  80410. };
  80411. "y-axis": {
  80412. rootNodeName: string;
  80413. };
  80414. };
  80415. "xr-standard-thumbstick": {
  80416. "x-axis": {
  80417. rootNodeName: string;
  80418. };
  80419. "y-axis": {
  80420. rootNodeName: string;
  80421. };
  80422. };
  80423. };
  80424. };
  80425. /**
  80426. * The base url used to load the left and right controller models
  80427. */
  80428. static MODEL_BASE_URL: string;
  80429. /**
  80430. * The name of the left controller model file
  80431. */
  80432. static MODEL_LEFT_FILENAME: string;
  80433. /**
  80434. * The name of the right controller model file
  80435. */
  80436. static MODEL_RIGHT_FILENAME: string;
  80437. profileId: string;
  80438. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80439. protected _getFilenameAndPath(): {
  80440. filename: string;
  80441. path: string;
  80442. };
  80443. protected _getModelLoadingConstraints(): boolean;
  80444. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80445. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80446. protected _updateModel(): void;
  80447. }
  80448. }
  80449. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80450. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80452. import { Scene } from "babylonjs/scene";
  80453. /**
  80454. * The motion controller class for oculus touch (quest, rift).
  80455. * This class supports legacy mapping as well the standard xr mapping
  80456. */
  80457. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80458. private _forceLegacyControllers;
  80459. private _modelRootNode;
  80460. /**
  80461. * The base url used to load the left and right controller models
  80462. */
  80463. static MODEL_BASE_URL: string;
  80464. /**
  80465. * The name of the left controller model file
  80466. */
  80467. static MODEL_LEFT_FILENAME: string;
  80468. /**
  80469. * The name of the right controller model file
  80470. */
  80471. static MODEL_RIGHT_FILENAME: string;
  80472. /**
  80473. * Base Url for the Quest controller model.
  80474. */
  80475. static QUEST_MODEL_BASE_URL: string;
  80476. profileId: string;
  80477. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80478. protected _getFilenameAndPath(): {
  80479. filename: string;
  80480. path: string;
  80481. };
  80482. protected _getModelLoadingConstraints(): boolean;
  80483. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80484. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80485. protected _updateModel(): void;
  80486. /**
  80487. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80488. * between the touch and touch 2.
  80489. */
  80490. private _isQuest;
  80491. }
  80492. }
  80493. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80494. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80495. import { Scene } from "babylonjs/scene";
  80496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80497. /**
  80498. * The motion controller class for the standard HTC-Vive controllers
  80499. */
  80500. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80501. private _modelRootNode;
  80502. /**
  80503. * The base url used to load the left and right controller models
  80504. */
  80505. static MODEL_BASE_URL: string;
  80506. /**
  80507. * File name for the controller model.
  80508. */
  80509. static MODEL_FILENAME: string;
  80510. profileId: string;
  80511. /**
  80512. * Create a new Vive motion controller object
  80513. * @param scene the scene to use to create this controller
  80514. * @param gamepadObject the corresponding gamepad object
  80515. * @param handedness the handedness of the controller
  80516. */
  80517. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80518. protected _getFilenameAndPath(): {
  80519. filename: string;
  80520. path: string;
  80521. };
  80522. protected _getModelLoadingConstraints(): boolean;
  80523. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80524. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80525. protected _updateModel(): void;
  80526. }
  80527. }
  80528. declare module "babylonjs/XR/motionController/index" {
  80529. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80530. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80531. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80532. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80533. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80534. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80535. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80536. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80537. }
  80538. declare module "babylonjs/XR/index" {
  80539. export * from "babylonjs/XR/webXRCamera";
  80540. export * from "babylonjs/XR/webXREnterExitUI";
  80541. export * from "babylonjs/XR/webXRExperienceHelper";
  80542. export * from "babylonjs/XR/webXRInput";
  80543. export * from "babylonjs/XR/webXRInputSource";
  80544. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80545. export * from "babylonjs/XR/webXRTypes";
  80546. export * from "babylonjs/XR/webXRSessionManager";
  80547. export * from "babylonjs/XR/webXRDefaultExperience";
  80548. export * from "babylonjs/XR/webXRFeaturesManager";
  80549. export * from "babylonjs/XR/features/index";
  80550. export * from "babylonjs/XR/motionController/index";
  80551. }
  80552. declare module "babylonjs/index" {
  80553. export * from "babylonjs/abstractScene";
  80554. export * from "babylonjs/Actions/index";
  80555. export * from "babylonjs/Animations/index";
  80556. export * from "babylonjs/assetContainer";
  80557. export * from "babylonjs/Audio/index";
  80558. export * from "babylonjs/Behaviors/index";
  80559. export * from "babylonjs/Bones/index";
  80560. export * from "babylonjs/Cameras/index";
  80561. export * from "babylonjs/Collisions/index";
  80562. export * from "babylonjs/Culling/index";
  80563. export * from "babylonjs/Debug/index";
  80564. export * from "babylonjs/DeviceInput/index";
  80565. export * from "babylonjs/Engines/index";
  80566. export * from "babylonjs/Events/index";
  80567. export * from "babylonjs/Gamepads/index";
  80568. export * from "babylonjs/Gizmos/index";
  80569. export * from "babylonjs/Helpers/index";
  80570. export * from "babylonjs/Instrumentation/index";
  80571. export * from "babylonjs/Layers/index";
  80572. export * from "babylonjs/LensFlares/index";
  80573. export * from "babylonjs/Lights/index";
  80574. export * from "babylonjs/Loading/index";
  80575. export * from "babylonjs/Materials/index";
  80576. export * from "babylonjs/Maths/index";
  80577. export * from "babylonjs/Meshes/index";
  80578. export * from "babylonjs/Morph/index";
  80579. export * from "babylonjs/Navigation/index";
  80580. export * from "babylonjs/node";
  80581. export * from "babylonjs/Offline/index";
  80582. export * from "babylonjs/Particles/index";
  80583. export * from "babylonjs/Physics/index";
  80584. export * from "babylonjs/PostProcesses/index";
  80585. export * from "babylonjs/Probes/index";
  80586. export * from "babylonjs/Rendering/index";
  80587. export * from "babylonjs/scene";
  80588. export * from "babylonjs/sceneComponent";
  80589. export * from "babylonjs/Sprites/index";
  80590. export * from "babylonjs/States/index";
  80591. export * from "babylonjs/Misc/index";
  80592. export * from "babylonjs/XR/index";
  80593. export * from "babylonjs/types";
  80594. }
  80595. declare module "babylonjs/Animations/pathCursor" {
  80596. import { Vector3 } from "babylonjs/Maths/math.vector";
  80597. import { Path2 } from "babylonjs/Maths/math.path";
  80598. /**
  80599. * A cursor which tracks a point on a path
  80600. */
  80601. export class PathCursor {
  80602. private path;
  80603. /**
  80604. * Stores path cursor callbacks for when an onchange event is triggered
  80605. */
  80606. private _onchange;
  80607. /**
  80608. * The value of the path cursor
  80609. */
  80610. value: number;
  80611. /**
  80612. * The animation array of the path cursor
  80613. */
  80614. animations: Animation[];
  80615. /**
  80616. * Initializes the path cursor
  80617. * @param path The path to track
  80618. */
  80619. constructor(path: Path2);
  80620. /**
  80621. * Gets the cursor point on the path
  80622. * @returns A point on the path cursor at the cursor location
  80623. */
  80624. getPoint(): Vector3;
  80625. /**
  80626. * Moves the cursor ahead by the step amount
  80627. * @param step The amount to move the cursor forward
  80628. * @returns This path cursor
  80629. */
  80630. moveAhead(step?: number): PathCursor;
  80631. /**
  80632. * Moves the cursor behind by the step amount
  80633. * @param step The amount to move the cursor back
  80634. * @returns This path cursor
  80635. */
  80636. moveBack(step?: number): PathCursor;
  80637. /**
  80638. * Moves the cursor by the step amount
  80639. * If the step amount is greater than one, an exception is thrown
  80640. * @param step The amount to move the cursor
  80641. * @returns This path cursor
  80642. */
  80643. move(step: number): PathCursor;
  80644. /**
  80645. * Ensures that the value is limited between zero and one
  80646. * @returns This path cursor
  80647. */
  80648. private ensureLimits;
  80649. /**
  80650. * Runs onchange callbacks on change (used by the animation engine)
  80651. * @returns This path cursor
  80652. */
  80653. private raiseOnChange;
  80654. /**
  80655. * Executes a function on change
  80656. * @param f A path cursor onchange callback
  80657. * @returns This path cursor
  80658. */
  80659. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80660. }
  80661. }
  80662. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80663. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80664. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80665. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80666. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80667. }
  80668. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80669. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80670. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80671. }
  80672. declare module "babylonjs/Engines/Processors/index" {
  80673. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80674. export * from "babylonjs/Engines/Processors/Expressions/index";
  80675. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80676. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80677. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80678. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80679. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80680. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80681. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80682. }
  80683. declare module "babylonjs/Legacy/legacy" {
  80684. import * as Babylon from "babylonjs/index";
  80685. export * from "babylonjs/index";
  80686. }
  80687. declare module "babylonjs/Shaders/blur.fragment" {
  80688. /** @hidden */
  80689. export var blurPixelShader: {
  80690. name: string;
  80691. shader: string;
  80692. };
  80693. }
  80694. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80695. /** @hidden */
  80696. export var pointCloudVertexDeclaration: {
  80697. name: string;
  80698. shader: string;
  80699. };
  80700. }
  80701. declare module "babylonjs" {
  80702. export * from "babylonjs/Legacy/legacy";
  80703. }
  80704. declare module BABYLON {
  80705. /** Alias type for value that can be null */
  80706. export type Nullable<T> = T | null;
  80707. /**
  80708. * Alias type for number that are floats
  80709. * @ignorenaming
  80710. */
  80711. export type float = number;
  80712. /**
  80713. * Alias type for number that are doubles.
  80714. * @ignorenaming
  80715. */
  80716. export type double = number;
  80717. /**
  80718. * Alias type for number that are integer
  80719. * @ignorenaming
  80720. */
  80721. export type int = number;
  80722. /** Alias type for number array or Float32Array */
  80723. export type FloatArray = number[] | Float32Array;
  80724. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80725. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80726. /**
  80727. * Alias for types that can be used by a Buffer or VertexBuffer.
  80728. */
  80729. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80730. /**
  80731. * Alias type for primitive types
  80732. * @ignorenaming
  80733. */
  80734. type Primitive = undefined | null | boolean | string | number | Function;
  80735. /**
  80736. * Type modifier to make all the properties of an object Readonly
  80737. */
  80738. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80739. /**
  80740. * Type modifier to make all the properties of an object Readonly recursively
  80741. */
  80742. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80743. /**
  80744. * Type modifier to make object properties readonly.
  80745. */
  80746. export type DeepImmutableObject<T> = {
  80747. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80748. };
  80749. /** @hidden */
  80750. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80751. }
  80752. }
  80753. declare module BABYLON {
  80754. /**
  80755. * A class serves as a medium between the observable and its observers
  80756. */
  80757. export class EventState {
  80758. /**
  80759. * Create a new EventState
  80760. * @param mask defines the mask associated with this state
  80761. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80762. * @param target defines the original target of the state
  80763. * @param currentTarget defines the current target of the state
  80764. */
  80765. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80766. /**
  80767. * Initialize the current event state
  80768. * @param mask defines the mask associated with this state
  80769. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80770. * @param target defines the original target of the state
  80771. * @param currentTarget defines the current target of the state
  80772. * @returns the current event state
  80773. */
  80774. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80775. /**
  80776. * An Observer can set this property to true to prevent subsequent observers of being notified
  80777. */
  80778. skipNextObservers: boolean;
  80779. /**
  80780. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80781. */
  80782. mask: number;
  80783. /**
  80784. * The object that originally notified the event
  80785. */
  80786. target?: any;
  80787. /**
  80788. * The current object in the bubbling phase
  80789. */
  80790. currentTarget?: any;
  80791. /**
  80792. * This will be populated with the return value of the last function that was executed.
  80793. * If it is the first function in the callback chain it will be the event data.
  80794. */
  80795. lastReturnValue?: any;
  80796. /**
  80797. * User defined information that will be sent to observers
  80798. */
  80799. userInfo?: any;
  80800. }
  80801. /**
  80802. * Represent an Observer registered to a given Observable object.
  80803. */
  80804. export class Observer<T> {
  80805. /**
  80806. * Defines the callback to call when the observer is notified
  80807. */
  80808. callback: (eventData: T, eventState: EventState) => void;
  80809. /**
  80810. * Defines the mask of the observer (used to filter notifications)
  80811. */
  80812. mask: number;
  80813. /**
  80814. * Defines the current scope used to restore the JS context
  80815. */
  80816. scope: any;
  80817. /** @hidden */
  80818. _willBeUnregistered: boolean;
  80819. /**
  80820. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80821. */
  80822. unregisterOnNextCall: boolean;
  80823. /**
  80824. * Creates a new observer
  80825. * @param callback defines the callback to call when the observer is notified
  80826. * @param mask defines the mask of the observer (used to filter notifications)
  80827. * @param scope defines the current scope used to restore the JS context
  80828. */
  80829. constructor(
  80830. /**
  80831. * Defines the callback to call when the observer is notified
  80832. */
  80833. callback: (eventData: T, eventState: EventState) => void,
  80834. /**
  80835. * Defines the mask of the observer (used to filter notifications)
  80836. */
  80837. mask: number,
  80838. /**
  80839. * Defines the current scope used to restore the JS context
  80840. */
  80841. scope?: any);
  80842. }
  80843. /**
  80844. * Represent a list of observers registered to multiple Observables object.
  80845. */
  80846. export class MultiObserver<T> {
  80847. private _observers;
  80848. private _observables;
  80849. /**
  80850. * Release associated resources
  80851. */
  80852. dispose(): void;
  80853. /**
  80854. * Raise a callback when one of the observable will notify
  80855. * @param observables defines a list of observables to watch
  80856. * @param callback defines the callback to call on notification
  80857. * @param mask defines the mask used to filter notifications
  80858. * @param scope defines the current scope used to restore the JS context
  80859. * @returns the new MultiObserver
  80860. */
  80861. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80862. }
  80863. /**
  80864. * The Observable class is a simple implementation of the Observable pattern.
  80865. *
  80866. * 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.
  80867. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80868. * 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).
  80869. * 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.
  80870. */
  80871. export class Observable<T> {
  80872. private _observers;
  80873. private _eventState;
  80874. private _onObserverAdded;
  80875. /**
  80876. * Gets the list of observers
  80877. */
  80878. get observers(): Array<Observer<T>>;
  80879. /**
  80880. * Creates a new observable
  80881. * @param onObserverAdded defines a callback to call when a new observer is added
  80882. */
  80883. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80884. /**
  80885. * Create a new Observer with the specified callback
  80886. * @param callback the callback that will be executed for that Observer
  80887. * @param mask the mask used to filter observers
  80888. * @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.
  80889. * @param scope optional scope for the callback to be called from
  80890. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80891. * @returns the new observer created for the callback
  80892. */
  80893. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80894. /**
  80895. * Create a new Observer with the specified callback and unregisters after the next notification
  80896. * @param callback the callback that will be executed for that Observer
  80897. * @returns the new observer created for the callback
  80898. */
  80899. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80900. /**
  80901. * Remove an Observer from the Observable object
  80902. * @param observer the instance of the Observer to remove
  80903. * @returns false if it doesn't belong to this Observable
  80904. */
  80905. remove(observer: Nullable<Observer<T>>): boolean;
  80906. /**
  80907. * Remove a callback from the Observable object
  80908. * @param callback the callback to remove
  80909. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80910. * @returns false if it doesn't belong to this Observable
  80911. */
  80912. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80913. private _deferUnregister;
  80914. private _remove;
  80915. /**
  80916. * Moves the observable to the top of the observer list making it get called first when notified
  80917. * @param observer the observer to move
  80918. */
  80919. makeObserverTopPriority(observer: Observer<T>): void;
  80920. /**
  80921. * Moves the observable to the bottom of the observer list making it get called last when notified
  80922. * @param observer the observer to move
  80923. */
  80924. makeObserverBottomPriority(observer: Observer<T>): void;
  80925. /**
  80926. * Notify all Observers by calling their respective callback with the given data
  80927. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80928. * @param eventData defines the data to send to all observers
  80929. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80930. * @param target defines the original target of the state
  80931. * @param currentTarget defines the current target of the state
  80932. * @param userInfo defines any user info to send to observers
  80933. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80934. */
  80935. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  80936. /**
  80937. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80938. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80939. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80940. * and it is crucial that all callbacks will be executed.
  80941. * The order of the callbacks is kept, callbacks are not executed parallel.
  80942. *
  80943. * @param eventData The data to be sent to each callback
  80944. * @param mask is used to filter observers defaults to -1
  80945. * @param target defines the callback target (see EventState)
  80946. * @param currentTarget defines he current object in the bubbling phase
  80947. * @param userInfo defines any user info to send to observers
  80948. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80949. */
  80950. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  80951. /**
  80952. * Notify a specific observer
  80953. * @param observer defines the observer to notify
  80954. * @param eventData defines the data to be sent to each callback
  80955. * @param mask is used to filter observers defaults to -1
  80956. */
  80957. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80958. /**
  80959. * Gets a boolean indicating if the observable has at least one observer
  80960. * @returns true is the Observable has at least one Observer registered
  80961. */
  80962. hasObservers(): boolean;
  80963. /**
  80964. * Clear the list of observers
  80965. */
  80966. clear(): void;
  80967. /**
  80968. * Clone the current observable
  80969. * @returns a new observable
  80970. */
  80971. clone(): Observable<T>;
  80972. /**
  80973. * Does this observable handles observer registered with a given mask
  80974. * @param mask defines the mask to be tested
  80975. * @return whether or not one observer registered with the given mask is handeled
  80976. **/
  80977. hasSpecificMask(mask?: number): boolean;
  80978. }
  80979. }
  80980. declare module BABYLON {
  80981. /**
  80982. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80983. * Babylon.js
  80984. */
  80985. export class DomManagement {
  80986. /**
  80987. * Checks if the window object exists
  80988. * @returns true if the window object exists
  80989. */
  80990. static IsWindowObjectExist(): boolean;
  80991. /**
  80992. * Checks if the navigator object exists
  80993. * @returns true if the navigator object exists
  80994. */
  80995. static IsNavigatorAvailable(): boolean;
  80996. /**
  80997. * Check if the document object exists
  80998. * @returns true if the document object exists
  80999. */
  81000. static IsDocumentAvailable(): boolean;
  81001. /**
  81002. * Extracts text content from a DOM element hierarchy
  81003. * @param element defines the root element
  81004. * @returns a string
  81005. */
  81006. static GetDOMTextContent(element: HTMLElement): string;
  81007. }
  81008. }
  81009. declare module BABYLON {
  81010. /**
  81011. * Logger used througouht the application to allow configuration of
  81012. * the log level required for the messages.
  81013. */
  81014. export class Logger {
  81015. /**
  81016. * No log
  81017. */
  81018. static readonly NoneLogLevel: number;
  81019. /**
  81020. * Only message logs
  81021. */
  81022. static readonly MessageLogLevel: number;
  81023. /**
  81024. * Only warning logs
  81025. */
  81026. static readonly WarningLogLevel: number;
  81027. /**
  81028. * Only error logs
  81029. */
  81030. static readonly ErrorLogLevel: number;
  81031. /**
  81032. * All logs
  81033. */
  81034. static readonly AllLogLevel: number;
  81035. private static _LogCache;
  81036. /**
  81037. * Gets a value indicating the number of loading errors
  81038. * @ignorenaming
  81039. */
  81040. static errorsCount: number;
  81041. /**
  81042. * Callback called when a new log is added
  81043. */
  81044. static OnNewCacheEntry: (entry: string) => void;
  81045. private static _AddLogEntry;
  81046. private static _FormatMessage;
  81047. private static _LogDisabled;
  81048. private static _LogEnabled;
  81049. private static _WarnDisabled;
  81050. private static _WarnEnabled;
  81051. private static _ErrorDisabled;
  81052. private static _ErrorEnabled;
  81053. /**
  81054. * Log a message to the console
  81055. */
  81056. static Log: (message: string) => void;
  81057. /**
  81058. * Write a warning message to the console
  81059. */
  81060. static Warn: (message: string) => void;
  81061. /**
  81062. * Write an error message to the console
  81063. */
  81064. static Error: (message: string) => void;
  81065. /**
  81066. * Gets current log cache (list of logs)
  81067. */
  81068. static get LogCache(): string;
  81069. /**
  81070. * Clears the log cache
  81071. */
  81072. static ClearLogCache(): void;
  81073. /**
  81074. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81075. */
  81076. static set LogLevels(level: number);
  81077. }
  81078. }
  81079. declare module BABYLON {
  81080. /** @hidden */
  81081. export class _TypeStore {
  81082. /** @hidden */
  81083. static RegisteredTypes: {
  81084. [key: string]: Object;
  81085. };
  81086. /** @hidden */
  81087. static GetClass(fqdn: string): any;
  81088. }
  81089. }
  81090. declare module BABYLON {
  81091. /**
  81092. * Helper to manipulate strings
  81093. */
  81094. export class StringTools {
  81095. /**
  81096. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81097. * @param str Source string
  81098. * @param suffix Suffix to search for in the source string
  81099. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81100. */
  81101. static EndsWith(str: string, suffix: string): boolean;
  81102. /**
  81103. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81104. * @param str Source string
  81105. * @param suffix Suffix to search for in the source string
  81106. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81107. */
  81108. static StartsWith(str: string, suffix: string): boolean;
  81109. /**
  81110. * Decodes a buffer into a string
  81111. * @param buffer The buffer to decode
  81112. * @returns The decoded string
  81113. */
  81114. static Decode(buffer: Uint8Array | Uint16Array): string;
  81115. /**
  81116. * Encode a buffer to a base64 string
  81117. * @param buffer defines the buffer to encode
  81118. * @returns the encoded string
  81119. */
  81120. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81121. /**
  81122. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81123. * @param num the number to convert and pad
  81124. * @param length the expected length of the string
  81125. * @returns the padded string
  81126. */
  81127. static PadNumber(num: number, length: number): string;
  81128. }
  81129. }
  81130. declare module BABYLON {
  81131. /**
  81132. * Class containing a set of static utilities functions for deep copy.
  81133. */
  81134. export class DeepCopier {
  81135. /**
  81136. * Tries to copy an object by duplicating every property
  81137. * @param source defines the source object
  81138. * @param destination defines the target object
  81139. * @param doNotCopyList defines a list of properties to avoid
  81140. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81141. */
  81142. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81143. }
  81144. }
  81145. declare module BABYLON {
  81146. /**
  81147. * Class containing a set of static utilities functions for precision date
  81148. */
  81149. export class PrecisionDate {
  81150. /**
  81151. * Gets either window.performance.now() if supported or Date.now() else
  81152. */
  81153. static get Now(): number;
  81154. }
  81155. }
  81156. declare module BABYLON {
  81157. /** @hidden */
  81158. export class _DevTools {
  81159. static WarnImport(name: string): string;
  81160. }
  81161. }
  81162. declare module BABYLON {
  81163. /**
  81164. * Interface used to define the mechanism to get data from the network
  81165. */
  81166. export interface IWebRequest {
  81167. /**
  81168. * Returns client's response url
  81169. */
  81170. responseURL: string;
  81171. /**
  81172. * Returns client's status
  81173. */
  81174. status: number;
  81175. /**
  81176. * Returns client's status as a text
  81177. */
  81178. statusText: string;
  81179. }
  81180. }
  81181. declare module BABYLON {
  81182. /**
  81183. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81184. */
  81185. export class WebRequest implements IWebRequest {
  81186. private _xhr;
  81187. /**
  81188. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81189. * i.e. when loading files, where the server/service expects an Authorization header
  81190. */
  81191. static CustomRequestHeaders: {
  81192. [key: string]: string;
  81193. };
  81194. /**
  81195. * Add callback functions in this array to update all the requests before they get sent to the network
  81196. */
  81197. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81198. private _injectCustomRequestHeaders;
  81199. /**
  81200. * Gets or sets a function to be called when loading progress changes
  81201. */
  81202. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81203. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81204. /**
  81205. * Returns client's state
  81206. */
  81207. get readyState(): number;
  81208. /**
  81209. * Returns client's status
  81210. */
  81211. get status(): number;
  81212. /**
  81213. * Returns client's status as a text
  81214. */
  81215. get statusText(): string;
  81216. /**
  81217. * Returns client's response
  81218. */
  81219. get response(): any;
  81220. /**
  81221. * Returns client's response url
  81222. */
  81223. get responseURL(): string;
  81224. /**
  81225. * Returns client's response as text
  81226. */
  81227. get responseText(): string;
  81228. /**
  81229. * Gets or sets the expected response type
  81230. */
  81231. get responseType(): XMLHttpRequestResponseType;
  81232. set responseType(value: XMLHttpRequestResponseType);
  81233. /** @hidden */
  81234. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81235. /** @hidden */
  81236. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81237. /**
  81238. * Cancels any network activity
  81239. */
  81240. abort(): void;
  81241. /**
  81242. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81243. * @param body defines an optional request body
  81244. */
  81245. send(body?: Document | BodyInit | null): void;
  81246. /**
  81247. * Sets the request method, request URL
  81248. * @param method defines the method to use (GET, POST, etc..)
  81249. * @param url defines the url to connect with
  81250. */
  81251. open(method: string, url: string): void;
  81252. /**
  81253. * Sets the value of a request header.
  81254. * @param name The name of the header whose value is to be set
  81255. * @param value The value to set as the body of the header
  81256. */
  81257. setRequestHeader(name: string, value: string): void;
  81258. /**
  81259. * Get the string containing the text of a particular header's value.
  81260. * @param name The name of the header
  81261. * @returns The string containing the text of the given header name
  81262. */
  81263. getResponseHeader(name: string): Nullable<string>;
  81264. }
  81265. }
  81266. declare module BABYLON {
  81267. /**
  81268. * File request interface
  81269. */
  81270. export interface IFileRequest {
  81271. /**
  81272. * Raised when the request is complete (success or error).
  81273. */
  81274. onCompleteObservable: Observable<IFileRequest>;
  81275. /**
  81276. * Aborts the request for a file.
  81277. */
  81278. abort: () => void;
  81279. }
  81280. }
  81281. declare module BABYLON {
  81282. /**
  81283. * Define options used to create a render target texture
  81284. */
  81285. export class RenderTargetCreationOptions {
  81286. /**
  81287. * Specifies is mipmaps must be generated
  81288. */
  81289. generateMipMaps?: boolean;
  81290. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81291. generateDepthBuffer?: boolean;
  81292. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81293. generateStencilBuffer?: boolean;
  81294. /** Defines texture type (int by default) */
  81295. type?: number;
  81296. /** Defines sampling mode (trilinear by default) */
  81297. samplingMode?: number;
  81298. /** Defines format (RGBA by default) */
  81299. format?: number;
  81300. }
  81301. }
  81302. declare module BABYLON {
  81303. /** Defines the cross module used constants to avoid circular dependncies */
  81304. export class Constants {
  81305. /** Defines that alpha blending is disabled */
  81306. static readonly ALPHA_DISABLE: number;
  81307. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81308. static readonly ALPHA_ADD: number;
  81309. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81310. static readonly ALPHA_COMBINE: number;
  81311. /** Defines that alpha blending is DEST - SRC * DEST */
  81312. static readonly ALPHA_SUBTRACT: number;
  81313. /** Defines that alpha blending is SRC * DEST */
  81314. static readonly ALPHA_MULTIPLY: number;
  81315. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81316. static readonly ALPHA_MAXIMIZED: number;
  81317. /** Defines that alpha blending is SRC + DEST */
  81318. static readonly ALPHA_ONEONE: number;
  81319. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81320. static readonly ALPHA_PREMULTIPLIED: number;
  81321. /**
  81322. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81323. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81324. */
  81325. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81326. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81327. static readonly ALPHA_INTERPOLATE: number;
  81328. /**
  81329. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81330. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81331. */
  81332. static readonly ALPHA_SCREENMODE: number;
  81333. /**
  81334. * Defines that alpha blending is SRC + DST
  81335. * Alpha will be set to SRC ALPHA + DST ALPHA
  81336. */
  81337. static readonly ALPHA_ONEONE_ONEONE: number;
  81338. /**
  81339. * Defines that alpha blending is SRC * DST ALPHA + DST
  81340. * Alpha will be set to 0
  81341. */
  81342. static readonly ALPHA_ALPHATOCOLOR: number;
  81343. /**
  81344. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81345. */
  81346. static readonly ALPHA_REVERSEONEMINUS: number;
  81347. /**
  81348. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81349. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81350. */
  81351. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81352. /**
  81353. * Defines that alpha blending is SRC + DST
  81354. * Alpha will be set to SRC ALPHA
  81355. */
  81356. static readonly ALPHA_ONEONE_ONEZERO: number;
  81357. /**
  81358. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81359. * Alpha will be set to DST ALPHA
  81360. */
  81361. static readonly ALPHA_EXCLUSION: number;
  81362. /** Defines that alpha blending equation a SUM */
  81363. static readonly ALPHA_EQUATION_ADD: number;
  81364. /** Defines that alpha blending equation a SUBSTRACTION */
  81365. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81366. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81367. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81368. /** Defines that alpha blending equation a MAX operation */
  81369. static readonly ALPHA_EQUATION_MAX: number;
  81370. /** Defines that alpha blending equation a MIN operation */
  81371. static readonly ALPHA_EQUATION_MIN: number;
  81372. /**
  81373. * Defines that alpha blending equation a DARKEN operation:
  81374. * It takes the min of the src and sums the alpha channels.
  81375. */
  81376. static readonly ALPHA_EQUATION_DARKEN: number;
  81377. /** Defines that the ressource is not delayed*/
  81378. static readonly DELAYLOADSTATE_NONE: number;
  81379. /** Defines that the ressource was successfully delay loaded */
  81380. static readonly DELAYLOADSTATE_LOADED: number;
  81381. /** Defines that the ressource is currently delay loading */
  81382. static readonly DELAYLOADSTATE_LOADING: number;
  81383. /** Defines that the ressource is delayed and has not started loading */
  81384. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81385. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81386. static readonly NEVER: number;
  81387. /** 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 */
  81388. static readonly ALWAYS: number;
  81389. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81390. static readonly LESS: number;
  81391. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81392. static readonly EQUAL: number;
  81393. /** 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 */
  81394. static readonly LEQUAL: number;
  81395. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81396. static readonly GREATER: number;
  81397. /** 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 */
  81398. static readonly GEQUAL: number;
  81399. /** 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 */
  81400. static readonly NOTEQUAL: number;
  81401. /** Passed to stencilOperation to specify that stencil value must be kept */
  81402. static readonly KEEP: number;
  81403. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81404. static readonly REPLACE: number;
  81405. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81406. static readonly INCR: number;
  81407. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81408. static readonly DECR: number;
  81409. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81410. static readonly INVERT: number;
  81411. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81412. static readonly INCR_WRAP: number;
  81413. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81414. static readonly DECR_WRAP: number;
  81415. /** Texture is not repeating outside of 0..1 UVs */
  81416. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81417. /** Texture is repeating outside of 0..1 UVs */
  81418. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81419. /** Texture is repeating and mirrored */
  81420. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81421. /** ALPHA */
  81422. static readonly TEXTUREFORMAT_ALPHA: number;
  81423. /** LUMINANCE */
  81424. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81425. /** LUMINANCE_ALPHA */
  81426. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81427. /** RGB */
  81428. static readonly TEXTUREFORMAT_RGB: number;
  81429. /** RGBA */
  81430. static readonly TEXTUREFORMAT_RGBA: number;
  81431. /** RED */
  81432. static readonly TEXTUREFORMAT_RED: number;
  81433. /** RED (2nd reference) */
  81434. static readonly TEXTUREFORMAT_R: number;
  81435. /** RG */
  81436. static readonly TEXTUREFORMAT_RG: number;
  81437. /** RED_INTEGER */
  81438. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81439. /** RED_INTEGER (2nd reference) */
  81440. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81441. /** RG_INTEGER */
  81442. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81443. /** RGB_INTEGER */
  81444. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81445. /** RGBA_INTEGER */
  81446. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81447. /** UNSIGNED_BYTE */
  81448. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81449. /** UNSIGNED_BYTE (2nd reference) */
  81450. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81451. /** FLOAT */
  81452. static readonly TEXTURETYPE_FLOAT: number;
  81453. /** HALF_FLOAT */
  81454. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81455. /** BYTE */
  81456. static readonly TEXTURETYPE_BYTE: number;
  81457. /** SHORT */
  81458. static readonly TEXTURETYPE_SHORT: number;
  81459. /** UNSIGNED_SHORT */
  81460. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81461. /** INT */
  81462. static readonly TEXTURETYPE_INT: number;
  81463. /** UNSIGNED_INT */
  81464. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81465. /** UNSIGNED_SHORT_4_4_4_4 */
  81466. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81467. /** UNSIGNED_SHORT_5_5_5_1 */
  81468. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81469. /** UNSIGNED_SHORT_5_6_5 */
  81470. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81471. /** UNSIGNED_INT_2_10_10_10_REV */
  81472. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81473. /** UNSIGNED_INT_24_8 */
  81474. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81475. /** UNSIGNED_INT_10F_11F_11F_REV */
  81476. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81477. /** UNSIGNED_INT_5_9_9_9_REV */
  81478. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81479. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81480. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81481. /** nearest is mag = nearest and min = nearest and no mip */
  81482. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81483. /** mag = nearest and min = nearest and mip = none */
  81484. static readonly TEXTURE_NEAREST_NEAREST: number;
  81485. /** Bilinear is mag = linear and min = linear and no mip */
  81486. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81487. /** mag = linear and min = linear and mip = none */
  81488. static readonly TEXTURE_LINEAR_LINEAR: number;
  81489. /** Trilinear is mag = linear and min = linear and mip = linear */
  81490. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81491. /** Trilinear is mag = linear and min = linear and mip = linear */
  81492. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81493. /** mag = nearest and min = nearest and mip = nearest */
  81494. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81495. /** mag = nearest and min = linear and mip = nearest */
  81496. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81497. /** mag = nearest and min = linear and mip = linear */
  81498. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81499. /** mag = nearest and min = linear and mip = none */
  81500. static readonly TEXTURE_NEAREST_LINEAR: number;
  81501. /** nearest is mag = nearest and min = nearest and mip = linear */
  81502. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81503. /** mag = linear and min = nearest and mip = nearest */
  81504. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81505. /** mag = linear and min = nearest and mip = linear */
  81506. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81507. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81508. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81509. /** mag = linear and min = nearest and mip = none */
  81510. static readonly TEXTURE_LINEAR_NEAREST: number;
  81511. /** Explicit coordinates mode */
  81512. static readonly TEXTURE_EXPLICIT_MODE: number;
  81513. /** Spherical coordinates mode */
  81514. static readonly TEXTURE_SPHERICAL_MODE: number;
  81515. /** Planar coordinates mode */
  81516. static readonly TEXTURE_PLANAR_MODE: number;
  81517. /** Cubic coordinates mode */
  81518. static readonly TEXTURE_CUBIC_MODE: number;
  81519. /** Projection coordinates mode */
  81520. static readonly TEXTURE_PROJECTION_MODE: number;
  81521. /** Skybox coordinates mode */
  81522. static readonly TEXTURE_SKYBOX_MODE: number;
  81523. /** Inverse Cubic coordinates mode */
  81524. static readonly TEXTURE_INVCUBIC_MODE: number;
  81525. /** Equirectangular coordinates mode */
  81526. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81527. /** Equirectangular Fixed coordinates mode */
  81528. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81529. /** Equirectangular Fixed Mirrored coordinates mode */
  81530. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81531. /** Offline (baking) quality for texture filtering */
  81532. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81533. /** High quality for texture filtering */
  81534. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81535. /** Medium quality for texture filtering */
  81536. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81537. /** Low quality for texture filtering */
  81538. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81539. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81540. static readonly SCALEMODE_FLOOR: number;
  81541. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81542. static readonly SCALEMODE_NEAREST: number;
  81543. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81544. static readonly SCALEMODE_CEILING: number;
  81545. /**
  81546. * The dirty texture flag value
  81547. */
  81548. static readonly MATERIAL_TextureDirtyFlag: number;
  81549. /**
  81550. * The dirty light flag value
  81551. */
  81552. static readonly MATERIAL_LightDirtyFlag: number;
  81553. /**
  81554. * The dirty fresnel flag value
  81555. */
  81556. static readonly MATERIAL_FresnelDirtyFlag: number;
  81557. /**
  81558. * The dirty attribute flag value
  81559. */
  81560. static readonly MATERIAL_AttributesDirtyFlag: number;
  81561. /**
  81562. * The dirty misc flag value
  81563. */
  81564. static readonly MATERIAL_MiscDirtyFlag: number;
  81565. /**
  81566. * The dirty prepass flag value
  81567. */
  81568. static readonly MATERIAL_PrePassDirtyFlag: number;
  81569. /**
  81570. * The all dirty flag value
  81571. */
  81572. static readonly MATERIAL_AllDirtyFlag: number;
  81573. /**
  81574. * Returns the triangle fill mode
  81575. */
  81576. static readonly MATERIAL_TriangleFillMode: number;
  81577. /**
  81578. * Returns the wireframe mode
  81579. */
  81580. static readonly MATERIAL_WireFrameFillMode: number;
  81581. /**
  81582. * Returns the point fill mode
  81583. */
  81584. static readonly MATERIAL_PointFillMode: number;
  81585. /**
  81586. * Returns the point list draw mode
  81587. */
  81588. static readonly MATERIAL_PointListDrawMode: number;
  81589. /**
  81590. * Returns the line list draw mode
  81591. */
  81592. static readonly MATERIAL_LineListDrawMode: number;
  81593. /**
  81594. * Returns the line loop draw mode
  81595. */
  81596. static readonly MATERIAL_LineLoopDrawMode: number;
  81597. /**
  81598. * Returns the line strip draw mode
  81599. */
  81600. static readonly MATERIAL_LineStripDrawMode: number;
  81601. /**
  81602. * Returns the triangle strip draw mode
  81603. */
  81604. static readonly MATERIAL_TriangleStripDrawMode: number;
  81605. /**
  81606. * Returns the triangle fan draw mode
  81607. */
  81608. static readonly MATERIAL_TriangleFanDrawMode: number;
  81609. /**
  81610. * Stores the clock-wise side orientation
  81611. */
  81612. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81613. /**
  81614. * Stores the counter clock-wise side orientation
  81615. */
  81616. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81617. /**
  81618. * Nothing
  81619. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81620. */
  81621. static readonly ACTION_NothingTrigger: number;
  81622. /**
  81623. * On pick
  81624. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81625. */
  81626. static readonly ACTION_OnPickTrigger: number;
  81627. /**
  81628. * On left pick
  81629. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81630. */
  81631. static readonly ACTION_OnLeftPickTrigger: number;
  81632. /**
  81633. * On right pick
  81634. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81635. */
  81636. static readonly ACTION_OnRightPickTrigger: number;
  81637. /**
  81638. * On center pick
  81639. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81640. */
  81641. static readonly ACTION_OnCenterPickTrigger: number;
  81642. /**
  81643. * On pick down
  81644. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81645. */
  81646. static readonly ACTION_OnPickDownTrigger: number;
  81647. /**
  81648. * On double pick
  81649. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81650. */
  81651. static readonly ACTION_OnDoublePickTrigger: number;
  81652. /**
  81653. * On pick up
  81654. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81655. */
  81656. static readonly ACTION_OnPickUpTrigger: number;
  81657. /**
  81658. * On pick out.
  81659. * This trigger will only be raised if you also declared a OnPickDown
  81660. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81661. */
  81662. static readonly ACTION_OnPickOutTrigger: number;
  81663. /**
  81664. * On long press
  81665. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81666. */
  81667. static readonly ACTION_OnLongPressTrigger: number;
  81668. /**
  81669. * On pointer over
  81670. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81671. */
  81672. static readonly ACTION_OnPointerOverTrigger: number;
  81673. /**
  81674. * On pointer out
  81675. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81676. */
  81677. static readonly ACTION_OnPointerOutTrigger: number;
  81678. /**
  81679. * On every frame
  81680. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81681. */
  81682. static readonly ACTION_OnEveryFrameTrigger: number;
  81683. /**
  81684. * On intersection enter
  81685. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81686. */
  81687. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81688. /**
  81689. * On intersection exit
  81690. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81691. */
  81692. static readonly ACTION_OnIntersectionExitTrigger: number;
  81693. /**
  81694. * On key down
  81695. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81696. */
  81697. static readonly ACTION_OnKeyDownTrigger: number;
  81698. /**
  81699. * On key up
  81700. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81701. */
  81702. static readonly ACTION_OnKeyUpTrigger: number;
  81703. /**
  81704. * Billboard mode will only apply to Y axis
  81705. */
  81706. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81707. /**
  81708. * Billboard mode will apply to all axes
  81709. */
  81710. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81711. /**
  81712. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81713. */
  81714. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81715. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81716. * Test order :
  81717. * Is the bounding sphere outside the frustum ?
  81718. * If not, are the bounding box vertices outside the frustum ?
  81719. * It not, then the cullable object is in the frustum.
  81720. */
  81721. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81722. /** Culling strategy : Bounding Sphere Only.
  81723. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81724. * It's also less accurate than the standard because some not visible objects can still be selected.
  81725. * Test : is the bounding sphere outside the frustum ?
  81726. * If not, then the cullable object is in the frustum.
  81727. */
  81728. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81729. /** Culling strategy : Optimistic Inclusion.
  81730. * This in an inclusion test first, then the standard exclusion test.
  81731. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81732. * 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.
  81733. * Anyway, it's as accurate as the standard strategy.
  81734. * Test :
  81735. * Is the cullable object bounding sphere center in the frustum ?
  81736. * If not, apply the default culling strategy.
  81737. */
  81738. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81739. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81740. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81741. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81742. * 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.
  81743. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81744. * Test :
  81745. * Is the cullable object bounding sphere center in the frustum ?
  81746. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81747. */
  81748. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81749. /**
  81750. * No logging while loading
  81751. */
  81752. static readonly SCENELOADER_NO_LOGGING: number;
  81753. /**
  81754. * Minimal logging while loading
  81755. */
  81756. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81757. /**
  81758. * Summary logging while loading
  81759. */
  81760. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81761. /**
  81762. * Detailled logging while loading
  81763. */
  81764. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81765. /**
  81766. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81767. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81768. */
  81769. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81770. /**
  81771. * Constant used to retrieve the position texture index in the textures array in the prepass
  81772. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81773. */
  81774. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81775. /**
  81776. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81777. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81778. */
  81779. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81780. /**
  81781. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81782. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81783. */
  81784. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81785. /**
  81786. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81787. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81788. */
  81789. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81790. /**
  81791. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81792. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81793. */
  81794. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81795. /**
  81796. * Constant used to retrieve albedo index in the textures array in the prepass
  81797. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81798. */
  81799. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81800. }
  81801. }
  81802. declare module BABYLON {
  81803. /**
  81804. * This represents the required contract to create a new type of texture loader.
  81805. */
  81806. export interface IInternalTextureLoader {
  81807. /**
  81808. * Defines wether the loader supports cascade loading the different faces.
  81809. */
  81810. supportCascades: boolean;
  81811. /**
  81812. * This returns if the loader support the current file information.
  81813. * @param extension defines the file extension of the file being loaded
  81814. * @param mimeType defines the optional mime type of the file being loaded
  81815. * @returns true if the loader can load the specified file
  81816. */
  81817. canLoad(extension: string, mimeType?: string): boolean;
  81818. /**
  81819. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81820. * @param data contains the texture data
  81821. * @param texture defines the BabylonJS internal texture
  81822. * @param createPolynomials will be true if polynomials have been requested
  81823. * @param onLoad defines the callback to trigger once the texture is ready
  81824. * @param onError defines the callback to trigger in case of error
  81825. */
  81826. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81827. /**
  81828. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81829. * @param data contains the texture data
  81830. * @param texture defines the BabylonJS internal texture
  81831. * @param callback defines the method to call once ready to upload
  81832. */
  81833. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81834. }
  81835. }
  81836. declare module BABYLON {
  81837. /**
  81838. * Class used to store and describe the pipeline context associated with an effect
  81839. */
  81840. export interface IPipelineContext {
  81841. /**
  81842. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81843. */
  81844. isAsync: boolean;
  81845. /**
  81846. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81847. */
  81848. isReady: boolean;
  81849. /** @hidden */
  81850. _getVertexShaderCode(): string | null;
  81851. /** @hidden */
  81852. _getFragmentShaderCode(): string | null;
  81853. /** @hidden */
  81854. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81855. }
  81856. }
  81857. declare module BABYLON {
  81858. /**
  81859. * Class used to store gfx data (like WebGLBuffer)
  81860. */
  81861. export class DataBuffer {
  81862. /**
  81863. * Gets or sets the number of objects referencing this buffer
  81864. */
  81865. references: number;
  81866. /** Gets or sets the size of the underlying buffer */
  81867. capacity: number;
  81868. /**
  81869. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81870. */
  81871. is32Bits: boolean;
  81872. /**
  81873. * Gets the underlying buffer
  81874. */
  81875. get underlyingResource(): any;
  81876. }
  81877. }
  81878. declare module BABYLON {
  81879. /** @hidden */
  81880. export interface IShaderProcessor {
  81881. attributeProcessor?: (attribute: string) => string;
  81882. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81883. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81884. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81885. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81886. lineProcessor?: (line: string, isFragment: boolean) => string;
  81887. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81888. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81889. }
  81890. }
  81891. declare module BABYLON {
  81892. /** @hidden */
  81893. export interface ProcessingOptions {
  81894. defines: string[];
  81895. indexParameters: any;
  81896. isFragment: boolean;
  81897. shouldUseHighPrecisionShader: boolean;
  81898. supportsUniformBuffers: boolean;
  81899. shadersRepository: string;
  81900. includesShadersStore: {
  81901. [key: string]: string;
  81902. };
  81903. processor?: IShaderProcessor;
  81904. version: string;
  81905. platformName: string;
  81906. lookForClosingBracketForUniformBuffer?: boolean;
  81907. }
  81908. }
  81909. declare module BABYLON {
  81910. /** @hidden */
  81911. export class ShaderCodeNode {
  81912. line: string;
  81913. children: ShaderCodeNode[];
  81914. additionalDefineKey?: string;
  81915. additionalDefineValue?: string;
  81916. isValid(preprocessors: {
  81917. [key: string]: string;
  81918. }): boolean;
  81919. process(preprocessors: {
  81920. [key: string]: string;
  81921. }, options: ProcessingOptions): string;
  81922. }
  81923. }
  81924. declare module BABYLON {
  81925. /** @hidden */
  81926. export class ShaderCodeCursor {
  81927. private _lines;
  81928. lineIndex: number;
  81929. get currentLine(): string;
  81930. get canRead(): boolean;
  81931. set lines(value: string[]);
  81932. }
  81933. }
  81934. declare module BABYLON {
  81935. /** @hidden */
  81936. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81937. process(preprocessors: {
  81938. [key: string]: string;
  81939. }, options: ProcessingOptions): string;
  81940. }
  81941. }
  81942. declare module BABYLON {
  81943. /** @hidden */
  81944. export class ShaderDefineExpression {
  81945. isTrue(preprocessors: {
  81946. [key: string]: string;
  81947. }): boolean;
  81948. private static _OperatorPriority;
  81949. private static _Stack;
  81950. static postfixToInfix(postfix: string[]): string;
  81951. static infixToPostfix(infix: string): string[];
  81952. }
  81953. }
  81954. declare module BABYLON {
  81955. /** @hidden */
  81956. export class ShaderCodeTestNode extends ShaderCodeNode {
  81957. testExpression: ShaderDefineExpression;
  81958. isValid(preprocessors: {
  81959. [key: string]: string;
  81960. }): boolean;
  81961. }
  81962. }
  81963. declare module BABYLON {
  81964. /** @hidden */
  81965. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81966. define: string;
  81967. not: boolean;
  81968. constructor(define: string, not?: boolean);
  81969. isTrue(preprocessors: {
  81970. [key: string]: string;
  81971. }): boolean;
  81972. }
  81973. }
  81974. declare module BABYLON {
  81975. /** @hidden */
  81976. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81977. leftOperand: ShaderDefineExpression;
  81978. rightOperand: ShaderDefineExpression;
  81979. isTrue(preprocessors: {
  81980. [key: string]: string;
  81981. }): boolean;
  81982. }
  81983. }
  81984. declare module BABYLON {
  81985. /** @hidden */
  81986. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81987. leftOperand: ShaderDefineExpression;
  81988. rightOperand: ShaderDefineExpression;
  81989. isTrue(preprocessors: {
  81990. [key: string]: string;
  81991. }): boolean;
  81992. }
  81993. }
  81994. declare module BABYLON {
  81995. /** @hidden */
  81996. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81997. define: string;
  81998. operand: string;
  81999. testValue: string;
  82000. constructor(define: string, operand: string, testValue: string);
  82001. isTrue(preprocessors: {
  82002. [key: string]: string;
  82003. }): boolean;
  82004. }
  82005. }
  82006. declare module BABYLON {
  82007. /**
  82008. * Class used to enable access to offline support
  82009. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82010. */
  82011. export interface IOfflineProvider {
  82012. /**
  82013. * Gets a boolean indicating if scene must be saved in the database
  82014. */
  82015. enableSceneOffline: boolean;
  82016. /**
  82017. * Gets a boolean indicating if textures must be saved in the database
  82018. */
  82019. enableTexturesOffline: boolean;
  82020. /**
  82021. * Open the offline support and make it available
  82022. * @param successCallback defines the callback to call on success
  82023. * @param errorCallback defines the callback to call on error
  82024. */
  82025. open(successCallback: () => void, errorCallback: () => void): void;
  82026. /**
  82027. * Loads an image from the offline support
  82028. * @param url defines the url to load from
  82029. * @param image defines the target DOM image
  82030. */
  82031. loadImage(url: string, image: HTMLImageElement): void;
  82032. /**
  82033. * Loads a file from offline support
  82034. * @param url defines the URL to load from
  82035. * @param sceneLoaded defines a callback to call on success
  82036. * @param progressCallBack defines a callback to call when progress changed
  82037. * @param errorCallback defines a callback to call on error
  82038. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82039. */
  82040. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82041. }
  82042. }
  82043. declare module BABYLON {
  82044. /**
  82045. * Class used to help managing file picking and drag'n'drop
  82046. * File Storage
  82047. */
  82048. export class FilesInputStore {
  82049. /**
  82050. * List of files ready to be loaded
  82051. */
  82052. static FilesToLoad: {
  82053. [key: string]: File;
  82054. };
  82055. }
  82056. }
  82057. declare module BABYLON {
  82058. /**
  82059. * Class used to define a retry strategy when error happens while loading assets
  82060. */
  82061. export class RetryStrategy {
  82062. /**
  82063. * Function used to defines an exponential back off strategy
  82064. * @param maxRetries defines the maximum number of retries (3 by default)
  82065. * @param baseInterval defines the interval between retries
  82066. * @returns the strategy function to use
  82067. */
  82068. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82069. }
  82070. }
  82071. declare module BABYLON {
  82072. /**
  82073. * @ignore
  82074. * Application error to support additional information when loading a file
  82075. */
  82076. export abstract class BaseError extends Error {
  82077. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82078. }
  82079. }
  82080. declare module BABYLON {
  82081. /** @ignore */
  82082. export class LoadFileError extends BaseError {
  82083. request?: WebRequest;
  82084. file?: File;
  82085. /**
  82086. * Creates a new LoadFileError
  82087. * @param message defines the message of the error
  82088. * @param request defines the optional web request
  82089. * @param file defines the optional file
  82090. */
  82091. constructor(message: string, object?: WebRequest | File);
  82092. }
  82093. /** @ignore */
  82094. export class RequestFileError extends BaseError {
  82095. request: WebRequest;
  82096. /**
  82097. * Creates a new LoadFileError
  82098. * @param message defines the message of the error
  82099. * @param request defines the optional web request
  82100. */
  82101. constructor(message: string, request: WebRequest);
  82102. }
  82103. /** @ignore */
  82104. export class ReadFileError extends BaseError {
  82105. file: File;
  82106. /**
  82107. * Creates a new ReadFileError
  82108. * @param message defines the message of the error
  82109. * @param file defines the optional file
  82110. */
  82111. constructor(message: string, file: File);
  82112. }
  82113. /**
  82114. * @hidden
  82115. */
  82116. export class FileTools {
  82117. /**
  82118. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82119. */
  82120. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82121. /**
  82122. * Gets or sets the base URL to use to load assets
  82123. */
  82124. static BaseUrl: string;
  82125. /**
  82126. * Default behaviour for cors in the application.
  82127. * It can be a string if the expected behavior is identical in the entire app.
  82128. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82129. */
  82130. static CorsBehavior: string | ((url: string | string[]) => string);
  82131. /**
  82132. * Gets or sets a function used to pre-process url before using them to load assets
  82133. */
  82134. static PreprocessUrl: (url: string) => string;
  82135. /**
  82136. * Removes unwanted characters from an url
  82137. * @param url defines the url to clean
  82138. * @returns the cleaned url
  82139. */
  82140. private static _CleanUrl;
  82141. /**
  82142. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82143. * @param url define the url we are trying
  82144. * @param element define the dom element where to configure the cors policy
  82145. */
  82146. static SetCorsBehavior(url: string | string[], element: {
  82147. crossOrigin: string | null;
  82148. }): void;
  82149. /**
  82150. * Loads an image as an HTMLImageElement.
  82151. * @param input url string, ArrayBuffer, or Blob to load
  82152. * @param onLoad callback called when the image successfully loads
  82153. * @param onError callback called when the image fails to load
  82154. * @param offlineProvider offline provider for caching
  82155. * @param mimeType optional mime type
  82156. * @returns the HTMLImageElement of the loaded image
  82157. */
  82158. 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>;
  82159. /**
  82160. * Reads a file from a File object
  82161. * @param file defines the file to load
  82162. * @param onSuccess defines the callback to call when data is loaded
  82163. * @param onProgress defines the callback to call during loading process
  82164. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82165. * @param onError defines the callback to call when an error occurs
  82166. * @returns a file request object
  82167. */
  82168. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82169. /**
  82170. * Loads a file from a url
  82171. * @param url url to load
  82172. * @param onSuccess callback called when the file successfully loads
  82173. * @param onProgress callback called while file is loading (if the server supports this mode)
  82174. * @param offlineProvider defines the offline provider for caching
  82175. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82176. * @param onError callback called when the file fails to load
  82177. * @returns a file request object
  82178. */
  82179. 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;
  82180. /**
  82181. * Loads a file
  82182. * @param url url to load
  82183. * @param onSuccess callback called when the file successfully loads
  82184. * @param onProgress callback called while file is loading (if the server supports this mode)
  82185. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82186. * @param onError callback called when the file fails to load
  82187. * @param onOpened callback called when the web request is opened
  82188. * @returns a file request object
  82189. */
  82190. 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;
  82191. /**
  82192. * Checks if the loaded document was accessed via `file:`-Protocol.
  82193. * @returns boolean
  82194. */
  82195. static IsFileURL(): boolean;
  82196. }
  82197. }
  82198. declare module BABYLON {
  82199. /** @hidden */
  82200. export class ShaderProcessor {
  82201. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  82202. private static _ProcessPrecision;
  82203. private static _ExtractOperation;
  82204. private static _BuildSubExpression;
  82205. private static _BuildExpression;
  82206. private static _MoveCursorWithinIf;
  82207. private static _MoveCursor;
  82208. private static _EvaluatePreProcessors;
  82209. private static _PreparePreProcessors;
  82210. private static _ProcessShaderConversion;
  82211. private static _ProcessIncludes;
  82212. /**
  82213. * Loads a file from a url
  82214. * @param url url to load
  82215. * @param onSuccess callback called when the file successfully loads
  82216. * @param onProgress callback called while file is loading (if the server supports this mode)
  82217. * @param offlineProvider defines the offline provider for caching
  82218. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82219. * @param onError callback called when the file fails to load
  82220. * @returns a file request object
  82221. * @hidden
  82222. */
  82223. 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;
  82224. }
  82225. }
  82226. declare module BABYLON {
  82227. /**
  82228. * @hidden
  82229. */
  82230. export interface IColor4Like {
  82231. r: float;
  82232. g: float;
  82233. b: float;
  82234. a: float;
  82235. }
  82236. /**
  82237. * @hidden
  82238. */
  82239. export interface IColor3Like {
  82240. r: float;
  82241. g: float;
  82242. b: float;
  82243. }
  82244. /**
  82245. * @hidden
  82246. */
  82247. export interface IVector4Like {
  82248. x: float;
  82249. y: float;
  82250. z: float;
  82251. w: float;
  82252. }
  82253. /**
  82254. * @hidden
  82255. */
  82256. export interface IVector3Like {
  82257. x: float;
  82258. y: float;
  82259. z: float;
  82260. }
  82261. /**
  82262. * @hidden
  82263. */
  82264. export interface IVector2Like {
  82265. x: float;
  82266. y: float;
  82267. }
  82268. /**
  82269. * @hidden
  82270. */
  82271. export interface IMatrixLike {
  82272. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82273. updateFlag: int;
  82274. }
  82275. /**
  82276. * @hidden
  82277. */
  82278. export interface IViewportLike {
  82279. x: float;
  82280. y: float;
  82281. width: float;
  82282. height: float;
  82283. }
  82284. /**
  82285. * @hidden
  82286. */
  82287. export interface IPlaneLike {
  82288. normal: IVector3Like;
  82289. d: float;
  82290. normalize(): void;
  82291. }
  82292. }
  82293. declare module BABYLON {
  82294. /**
  82295. * Interface used to define common properties for effect fallbacks
  82296. */
  82297. export interface IEffectFallbacks {
  82298. /**
  82299. * Removes the defines that should be removed when falling back.
  82300. * @param currentDefines defines the current define statements for the shader.
  82301. * @param effect defines the current effect we try to compile
  82302. * @returns The resulting defines with defines of the current rank removed.
  82303. */
  82304. reduce(currentDefines: string, effect: Effect): string;
  82305. /**
  82306. * Removes the fallback from the bound mesh.
  82307. */
  82308. unBindMesh(): void;
  82309. /**
  82310. * Checks to see if more fallbacks are still availible.
  82311. */
  82312. hasMoreFallbacks: boolean;
  82313. }
  82314. }
  82315. declare module BABYLON {
  82316. /**
  82317. * Class used to evalaute queries containing `and` and `or` operators
  82318. */
  82319. export class AndOrNotEvaluator {
  82320. /**
  82321. * Evaluate a query
  82322. * @param query defines the query to evaluate
  82323. * @param evaluateCallback defines the callback used to filter result
  82324. * @returns true if the query matches
  82325. */
  82326. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82327. private static _HandleParenthesisContent;
  82328. private static _SimplifyNegation;
  82329. }
  82330. }
  82331. declare module BABYLON {
  82332. /**
  82333. * Class used to store custom tags
  82334. */
  82335. export class Tags {
  82336. /**
  82337. * Adds support for tags on the given object
  82338. * @param obj defines the object to use
  82339. */
  82340. static EnableFor(obj: any): void;
  82341. /**
  82342. * Removes tags support
  82343. * @param obj defines the object to use
  82344. */
  82345. static DisableFor(obj: any): void;
  82346. /**
  82347. * Gets a boolean indicating if the given object has tags
  82348. * @param obj defines the object to use
  82349. * @returns a boolean
  82350. */
  82351. static HasTags(obj: any): boolean;
  82352. /**
  82353. * Gets the tags available on a given object
  82354. * @param obj defines the object to use
  82355. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82356. * @returns the tags
  82357. */
  82358. static GetTags(obj: any, asString?: boolean): any;
  82359. /**
  82360. * Adds tags to an object
  82361. * @param obj defines the object to use
  82362. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82363. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82364. */
  82365. static AddTagsTo(obj: any, tagsString: string): void;
  82366. /**
  82367. * @hidden
  82368. */
  82369. static _AddTagTo(obj: any, tag: string): void;
  82370. /**
  82371. * Removes specific tags from a specific object
  82372. * @param obj defines the object to use
  82373. * @param tagsString defines the tags to remove
  82374. */
  82375. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82376. /**
  82377. * @hidden
  82378. */
  82379. static _RemoveTagFrom(obj: any, tag: string): void;
  82380. /**
  82381. * Defines if tags hosted on an object match a given query
  82382. * @param obj defines the object to use
  82383. * @param tagsQuery defines the tag query
  82384. * @returns a boolean
  82385. */
  82386. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82387. }
  82388. }
  82389. declare module BABYLON {
  82390. /**
  82391. * Scalar computation library
  82392. */
  82393. export class Scalar {
  82394. /**
  82395. * Two pi constants convenient for computation.
  82396. */
  82397. static TwoPi: number;
  82398. /**
  82399. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82400. * @param a number
  82401. * @param b number
  82402. * @param epsilon (default = 1.401298E-45)
  82403. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82404. */
  82405. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82406. /**
  82407. * Returns a string : the upper case translation of the number i to hexadecimal.
  82408. * @param i number
  82409. * @returns the upper case translation of the number i to hexadecimal.
  82410. */
  82411. static ToHex(i: number): string;
  82412. /**
  82413. * Returns -1 if value is negative and +1 is value is positive.
  82414. * @param value the value
  82415. * @returns the value itself if it's equal to zero.
  82416. */
  82417. static Sign(value: number): number;
  82418. /**
  82419. * Returns the value itself if it's between min and max.
  82420. * Returns min if the value is lower than min.
  82421. * Returns max if the value is greater than max.
  82422. * @param value the value to clmap
  82423. * @param min the min value to clamp to (default: 0)
  82424. * @param max the max value to clamp to (default: 1)
  82425. * @returns the clamped value
  82426. */
  82427. static Clamp(value: number, min?: number, max?: number): number;
  82428. /**
  82429. * the log2 of value.
  82430. * @param value the value to compute log2 of
  82431. * @returns the log2 of value.
  82432. */
  82433. static Log2(value: number): number;
  82434. /**
  82435. * Loops the value, so that it is never larger than length and never smaller than 0.
  82436. *
  82437. * This is similar to the modulo operator but it works with floating point numbers.
  82438. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82439. * With t = 5 and length = 2.5, the result would be 0.0.
  82440. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82441. * @param value the value
  82442. * @param length the length
  82443. * @returns the looped value
  82444. */
  82445. static Repeat(value: number, length: number): number;
  82446. /**
  82447. * Normalize the value between 0.0 and 1.0 using min and max values
  82448. * @param value value to normalize
  82449. * @param min max to normalize between
  82450. * @param max min to normalize between
  82451. * @returns the normalized value
  82452. */
  82453. static Normalize(value: number, min: number, max: number): number;
  82454. /**
  82455. * Denormalize the value from 0.0 and 1.0 using min and max values
  82456. * @param normalized value to denormalize
  82457. * @param min max to denormalize between
  82458. * @param max min to denormalize between
  82459. * @returns the denormalized value
  82460. */
  82461. static Denormalize(normalized: number, min: number, max: number): number;
  82462. /**
  82463. * Calculates the shortest difference between two given angles given in degrees.
  82464. * @param current current angle in degrees
  82465. * @param target target angle in degrees
  82466. * @returns the delta
  82467. */
  82468. static DeltaAngle(current: number, target: number): number;
  82469. /**
  82470. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82471. * @param tx value
  82472. * @param length length
  82473. * @returns The returned value will move back and forth between 0 and length
  82474. */
  82475. static PingPong(tx: number, length: number): number;
  82476. /**
  82477. * Interpolates between min and max with smoothing at the limits.
  82478. *
  82479. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82480. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82481. * @param from from
  82482. * @param to to
  82483. * @param tx value
  82484. * @returns the smooth stepped value
  82485. */
  82486. static SmoothStep(from: number, to: number, tx: number): number;
  82487. /**
  82488. * Moves a value current towards target.
  82489. *
  82490. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82491. * Negative values of maxDelta pushes the value away from target.
  82492. * @param current current value
  82493. * @param target target value
  82494. * @param maxDelta max distance to move
  82495. * @returns resulting value
  82496. */
  82497. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82498. /**
  82499. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82500. *
  82501. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82502. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82503. * @param current current value
  82504. * @param target target value
  82505. * @param maxDelta max distance to move
  82506. * @returns resulting angle
  82507. */
  82508. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82509. /**
  82510. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82511. * @param start start value
  82512. * @param end target value
  82513. * @param amount amount to lerp between
  82514. * @returns the lerped value
  82515. */
  82516. static Lerp(start: number, end: number, amount: number): number;
  82517. /**
  82518. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82519. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82520. * @param start start value
  82521. * @param end target value
  82522. * @param amount amount to lerp between
  82523. * @returns the lerped value
  82524. */
  82525. static LerpAngle(start: number, end: number, amount: number): number;
  82526. /**
  82527. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82528. * @param a start value
  82529. * @param b target value
  82530. * @param value value between a and b
  82531. * @returns the inverseLerp value
  82532. */
  82533. static InverseLerp(a: number, b: number, value: number): number;
  82534. /**
  82535. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82536. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82537. * @param value1 spline value
  82538. * @param tangent1 spline value
  82539. * @param value2 spline value
  82540. * @param tangent2 spline value
  82541. * @param amount input value
  82542. * @returns hermite result
  82543. */
  82544. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82545. /**
  82546. * Returns a random float number between and min and max values
  82547. * @param min min value of random
  82548. * @param max max value of random
  82549. * @returns random value
  82550. */
  82551. static RandomRange(min: number, max: number): number;
  82552. /**
  82553. * This function returns percentage of a number in a given range.
  82554. *
  82555. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82556. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82557. * @param number to convert to percentage
  82558. * @param min min range
  82559. * @param max max range
  82560. * @returns the percentage
  82561. */
  82562. static RangeToPercent(number: number, min: number, max: number): number;
  82563. /**
  82564. * This function returns number that corresponds to the percentage in a given range.
  82565. *
  82566. * PercentToRange(0.34,0,100) will return 34.
  82567. * @param percent to convert to number
  82568. * @param min min range
  82569. * @param max max range
  82570. * @returns the number
  82571. */
  82572. static PercentToRange(percent: number, min: number, max: number): number;
  82573. /**
  82574. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82575. * @param angle The angle to normalize in radian.
  82576. * @return The converted angle.
  82577. */
  82578. static NormalizeRadians(angle: number): number;
  82579. }
  82580. }
  82581. declare module BABYLON {
  82582. /**
  82583. * Constant used to convert a value to gamma space
  82584. * @ignorenaming
  82585. */
  82586. export const ToGammaSpace: number;
  82587. /**
  82588. * Constant used to convert a value to linear space
  82589. * @ignorenaming
  82590. */
  82591. export const ToLinearSpace = 2.2;
  82592. /**
  82593. * Constant used to define the minimal number value in Babylon.js
  82594. * @ignorenaming
  82595. */
  82596. let Epsilon: number;
  82597. }
  82598. declare module BABYLON {
  82599. /**
  82600. * Class used to represent a viewport on screen
  82601. */
  82602. export class Viewport {
  82603. /** viewport left coordinate */
  82604. x: number;
  82605. /** viewport top coordinate */
  82606. y: number;
  82607. /**viewport width */
  82608. width: number;
  82609. /** viewport height */
  82610. height: number;
  82611. /**
  82612. * Creates a Viewport object located at (x, y) and sized (width, height)
  82613. * @param x defines viewport left coordinate
  82614. * @param y defines viewport top coordinate
  82615. * @param width defines the viewport width
  82616. * @param height defines the viewport height
  82617. */
  82618. constructor(
  82619. /** viewport left coordinate */
  82620. x: number,
  82621. /** viewport top coordinate */
  82622. y: number,
  82623. /**viewport width */
  82624. width: number,
  82625. /** viewport height */
  82626. height: number);
  82627. /**
  82628. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82629. * @param renderWidth defines the rendering width
  82630. * @param renderHeight defines the rendering height
  82631. * @returns a new Viewport
  82632. */
  82633. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82634. /**
  82635. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82636. * @param renderWidth defines the rendering width
  82637. * @param renderHeight defines the rendering height
  82638. * @param ref defines the target viewport
  82639. * @returns the current viewport
  82640. */
  82641. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82642. /**
  82643. * Returns a new Viewport copied from the current one
  82644. * @returns a new Viewport
  82645. */
  82646. clone(): Viewport;
  82647. }
  82648. }
  82649. declare module BABYLON {
  82650. /**
  82651. * Class containing a set of static utilities functions for arrays.
  82652. */
  82653. export class ArrayTools {
  82654. /**
  82655. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82656. * @param size the number of element to construct and put in the array
  82657. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82658. * @returns a new array filled with new objects
  82659. */
  82660. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82661. }
  82662. }
  82663. declare module BABYLON {
  82664. /**
  82665. * Represents a plane by the equation ax + by + cz + d = 0
  82666. */
  82667. export class Plane {
  82668. private static _TmpMatrix;
  82669. /**
  82670. * Normal of the plane (a,b,c)
  82671. */
  82672. normal: Vector3;
  82673. /**
  82674. * d component of the plane
  82675. */
  82676. d: number;
  82677. /**
  82678. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82679. * @param a a component of the plane
  82680. * @param b b component of the plane
  82681. * @param c c component of the plane
  82682. * @param d d component of the plane
  82683. */
  82684. constructor(a: number, b: number, c: number, d: number);
  82685. /**
  82686. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82687. */
  82688. asArray(): number[];
  82689. /**
  82690. * @returns a new plane copied from the current Plane.
  82691. */
  82692. clone(): Plane;
  82693. /**
  82694. * @returns the string "Plane".
  82695. */
  82696. getClassName(): string;
  82697. /**
  82698. * @returns the Plane hash code.
  82699. */
  82700. getHashCode(): number;
  82701. /**
  82702. * Normalize the current Plane in place.
  82703. * @returns the updated Plane.
  82704. */
  82705. normalize(): Plane;
  82706. /**
  82707. * Applies a transformation the plane and returns the result
  82708. * @param transformation the transformation matrix to be applied to the plane
  82709. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82710. */
  82711. transform(transformation: DeepImmutable<Matrix>): Plane;
  82712. /**
  82713. * Compute the dot product between the point and the plane normal
  82714. * @param point point to calculate the dot product with
  82715. * @returns the dot product (float) of the point coordinates and the plane normal.
  82716. */
  82717. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82718. /**
  82719. * Updates the current Plane from the plane defined by the three given points.
  82720. * @param point1 one of the points used to contruct the plane
  82721. * @param point2 one of the points used to contruct the plane
  82722. * @param point3 one of the points used to contruct the plane
  82723. * @returns the updated Plane.
  82724. */
  82725. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82726. /**
  82727. * Checks if the plane is facing a given direction
  82728. * @param direction the direction to check if the plane is facing
  82729. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82730. * @returns True is the vector "direction" is the same side than the plane normal.
  82731. */
  82732. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82733. /**
  82734. * Calculates the distance to a point
  82735. * @param point point to calculate distance to
  82736. * @returns the signed distance (float) from the given point to the Plane.
  82737. */
  82738. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82739. /**
  82740. * Creates a plane from an array
  82741. * @param array the array to create a plane from
  82742. * @returns a new Plane from the given array.
  82743. */
  82744. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82745. /**
  82746. * Creates a plane from three points
  82747. * @param point1 point used to create the plane
  82748. * @param point2 point used to create the plane
  82749. * @param point3 point used to create the plane
  82750. * @returns a new Plane defined by the three given points.
  82751. */
  82752. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82753. /**
  82754. * Creates a plane from an origin point and a normal
  82755. * @param origin origin of the plane to be constructed
  82756. * @param normal normal of the plane to be constructed
  82757. * @returns a new Plane the normal vector to this plane at the given origin point.
  82758. * Note : the vector "normal" is updated because normalized.
  82759. */
  82760. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82761. /**
  82762. * Calculates the distance from a plane and a point
  82763. * @param origin origin of the plane to be constructed
  82764. * @param normal normal of the plane to be constructed
  82765. * @param point point to calculate distance to
  82766. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82767. */
  82768. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82769. }
  82770. }
  82771. declare module BABYLON {
  82772. /** @hidden */
  82773. export class PerformanceConfigurator {
  82774. /** @hidden */
  82775. static MatrixUse64Bits: boolean;
  82776. /** @hidden */
  82777. static MatrixTrackPrecisionChange: boolean;
  82778. /** @hidden */
  82779. static MatrixCurrentType: any;
  82780. /** @hidden */
  82781. static MatrixTrackedMatrices: Array<any> | null;
  82782. /** @hidden */
  82783. static SetMatrixPrecision(use64bits: boolean): void;
  82784. }
  82785. }
  82786. declare module BABYLON {
  82787. /**
  82788. * Class representing a vector containing 2 coordinates
  82789. */
  82790. export class Vector2 {
  82791. /** defines the first coordinate */
  82792. x: number;
  82793. /** defines the second coordinate */
  82794. y: number;
  82795. /**
  82796. * Creates a new Vector2 from the given x and y coordinates
  82797. * @param x defines the first coordinate
  82798. * @param y defines the second coordinate
  82799. */
  82800. constructor(
  82801. /** defines the first coordinate */
  82802. x?: number,
  82803. /** defines the second coordinate */
  82804. y?: number);
  82805. /**
  82806. * Gets a string with the Vector2 coordinates
  82807. * @returns a string with the Vector2 coordinates
  82808. */
  82809. toString(): string;
  82810. /**
  82811. * Gets class name
  82812. * @returns the string "Vector2"
  82813. */
  82814. getClassName(): string;
  82815. /**
  82816. * Gets current vector hash code
  82817. * @returns the Vector2 hash code as a number
  82818. */
  82819. getHashCode(): number;
  82820. /**
  82821. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82822. * @param array defines the source array
  82823. * @param index defines the offset in source array
  82824. * @returns the current Vector2
  82825. */
  82826. toArray(array: FloatArray, index?: number): Vector2;
  82827. /**
  82828. * Update the current vector from an array
  82829. * @param array defines the destination array
  82830. * @param index defines the offset in the destination array
  82831. * @returns the current Vector3
  82832. */
  82833. fromArray(array: FloatArray, index?: number): Vector2;
  82834. /**
  82835. * Copy the current vector to an array
  82836. * @returns a new array with 2 elements: the Vector2 coordinates.
  82837. */
  82838. asArray(): number[];
  82839. /**
  82840. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82841. * @param source defines the source Vector2
  82842. * @returns the current updated Vector2
  82843. */
  82844. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82845. /**
  82846. * Sets the Vector2 coordinates with the given floats
  82847. * @param x defines the first coordinate
  82848. * @param y defines the second coordinate
  82849. * @returns the current updated Vector2
  82850. */
  82851. copyFromFloats(x: number, y: number): Vector2;
  82852. /**
  82853. * Sets the Vector2 coordinates with the given floats
  82854. * @param x defines the first coordinate
  82855. * @param y defines the second coordinate
  82856. * @returns the current updated Vector2
  82857. */
  82858. set(x: number, y: number): Vector2;
  82859. /**
  82860. * Add another vector with the current one
  82861. * @param otherVector defines the other vector
  82862. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82863. */
  82864. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82865. /**
  82866. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82867. * @param otherVector defines the other vector
  82868. * @param result defines the target vector
  82869. * @returns the unmodified current Vector2
  82870. */
  82871. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82872. /**
  82873. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82874. * @param otherVector defines the other vector
  82875. * @returns the current updated Vector2
  82876. */
  82877. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82878. /**
  82879. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82880. * @param otherVector defines the other vector
  82881. * @returns a new Vector2
  82882. */
  82883. addVector3(otherVector: Vector3): Vector2;
  82884. /**
  82885. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82886. * @param otherVector defines the other vector
  82887. * @returns a new Vector2
  82888. */
  82889. subtract(otherVector: Vector2): Vector2;
  82890. /**
  82891. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82892. * @param otherVector defines the other vector
  82893. * @param result defines the target vector
  82894. * @returns the unmodified current Vector2
  82895. */
  82896. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82897. /**
  82898. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82899. * @param otherVector defines the other vector
  82900. * @returns the current updated Vector2
  82901. */
  82902. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82903. /**
  82904. * Multiplies in place the current Vector2 coordinates by the given ones
  82905. * @param otherVector defines the other vector
  82906. * @returns the current updated Vector2
  82907. */
  82908. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82909. /**
  82910. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82911. * @param otherVector defines the other vector
  82912. * @returns a new Vector2
  82913. */
  82914. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82915. /**
  82916. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82917. * @param otherVector defines the other vector
  82918. * @param result defines the target vector
  82919. * @returns the unmodified current Vector2
  82920. */
  82921. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82922. /**
  82923. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82924. * @param x defines the first coordinate
  82925. * @param y defines the second coordinate
  82926. * @returns a new Vector2
  82927. */
  82928. multiplyByFloats(x: number, y: number): Vector2;
  82929. /**
  82930. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82931. * @param otherVector defines the other vector
  82932. * @returns a new Vector2
  82933. */
  82934. divide(otherVector: Vector2): Vector2;
  82935. /**
  82936. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82937. * @param otherVector defines the other vector
  82938. * @param result defines the target vector
  82939. * @returns the unmodified current Vector2
  82940. */
  82941. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82942. /**
  82943. * Divides the current Vector2 coordinates by the given ones
  82944. * @param otherVector defines the other vector
  82945. * @returns the current updated Vector2
  82946. */
  82947. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82948. /**
  82949. * Gets a new Vector2 with current Vector2 negated coordinates
  82950. * @returns a new Vector2
  82951. */
  82952. negate(): Vector2;
  82953. /**
  82954. * Negate this vector in place
  82955. * @returns this
  82956. */
  82957. negateInPlace(): Vector2;
  82958. /**
  82959. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82960. * @param result defines the Vector3 object where to store the result
  82961. * @returns the current Vector2
  82962. */
  82963. negateToRef(result: Vector2): Vector2;
  82964. /**
  82965. * Multiply the Vector2 coordinates by scale
  82966. * @param scale defines the scaling factor
  82967. * @returns the current updated Vector2
  82968. */
  82969. scaleInPlace(scale: number): Vector2;
  82970. /**
  82971. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82972. * @param scale defines the scaling factor
  82973. * @returns a new Vector2
  82974. */
  82975. scale(scale: number): Vector2;
  82976. /**
  82977. * Scale the current Vector2 values by a factor to a given Vector2
  82978. * @param scale defines the scale factor
  82979. * @param result defines the Vector2 object where to store the result
  82980. * @returns the unmodified current Vector2
  82981. */
  82982. scaleToRef(scale: number, result: Vector2): Vector2;
  82983. /**
  82984. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82985. * @param scale defines the scale factor
  82986. * @param result defines the Vector2 object where to store the result
  82987. * @returns the unmodified current Vector2
  82988. */
  82989. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82990. /**
  82991. * Gets a boolean if two vectors are equals
  82992. * @param otherVector defines the other vector
  82993. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82994. */
  82995. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82996. /**
  82997. * Gets a boolean if two vectors are equals (using an epsilon value)
  82998. * @param otherVector defines the other vector
  82999. * @param epsilon defines the minimal distance to consider equality
  83000. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  83001. */
  83002. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  83003. /**
  83004. * Gets a new Vector2 from current Vector2 floored values
  83005. * @returns a new Vector2
  83006. */
  83007. floor(): Vector2;
  83008. /**
  83009. * Gets a new Vector2 from current Vector2 floored values
  83010. * @returns a new Vector2
  83011. */
  83012. fract(): Vector2;
  83013. /**
  83014. * Gets the length of the vector
  83015. * @returns the vector length (float)
  83016. */
  83017. length(): number;
  83018. /**
  83019. * Gets the vector squared length
  83020. * @returns the vector squared length (float)
  83021. */
  83022. lengthSquared(): number;
  83023. /**
  83024. * Normalize the vector
  83025. * @returns the current updated Vector2
  83026. */
  83027. normalize(): Vector2;
  83028. /**
  83029. * Gets a new Vector2 copied from the Vector2
  83030. * @returns a new Vector2
  83031. */
  83032. clone(): Vector2;
  83033. /**
  83034. * Gets a new Vector2(0, 0)
  83035. * @returns a new Vector2
  83036. */
  83037. static Zero(): Vector2;
  83038. /**
  83039. * Gets a new Vector2(1, 1)
  83040. * @returns a new Vector2
  83041. */
  83042. static One(): Vector2;
  83043. /**
  83044. * Gets a new Vector2 set from the given index element of the given array
  83045. * @param array defines the data source
  83046. * @param offset defines the offset in the data source
  83047. * @returns a new Vector2
  83048. */
  83049. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  83050. /**
  83051. * Sets "result" from the given index element of the given array
  83052. * @param array defines the data source
  83053. * @param offset defines the offset in the data source
  83054. * @param result defines the target vector
  83055. */
  83056. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  83057. /**
  83058. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  83059. * @param value1 defines 1st point of control
  83060. * @param value2 defines 2nd point of control
  83061. * @param value3 defines 3rd point of control
  83062. * @param value4 defines 4th point of control
  83063. * @param amount defines the interpolation factor
  83064. * @returns a new Vector2
  83065. */
  83066. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  83067. /**
  83068. * 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".
  83069. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  83070. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  83071. * @param value defines the value to clamp
  83072. * @param min defines the lower limit
  83073. * @param max defines the upper limit
  83074. * @returns a new Vector2
  83075. */
  83076. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  83077. /**
  83078. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  83079. * @param value1 defines the 1st control point
  83080. * @param tangent1 defines the outgoing tangent
  83081. * @param value2 defines the 2nd control point
  83082. * @param tangent2 defines the incoming tangent
  83083. * @param amount defines the interpolation factor
  83084. * @returns a new Vector2
  83085. */
  83086. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83087. /**
  83088. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83089. * @param start defines the start vector
  83090. * @param end defines the end vector
  83091. * @param amount defines the interpolation factor
  83092. * @returns a new Vector2
  83093. */
  83094. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83095. /**
  83096. * Gets the dot product of the vector "left" and the vector "right"
  83097. * @param left defines first vector
  83098. * @param right defines second vector
  83099. * @returns the dot product (float)
  83100. */
  83101. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83102. /**
  83103. * Returns a new Vector2 equal to the normalized given vector
  83104. * @param vector defines the vector to normalize
  83105. * @returns a new Vector2
  83106. */
  83107. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83108. /**
  83109. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83110. * @param left defines 1st vector
  83111. * @param right defines 2nd vector
  83112. * @returns a new Vector2
  83113. */
  83114. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83115. /**
  83116. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83117. * @param left defines 1st vector
  83118. * @param right defines 2nd vector
  83119. * @returns a new Vector2
  83120. */
  83121. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83122. /**
  83123. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83124. * @param vector defines the vector to transform
  83125. * @param transformation defines the matrix to apply
  83126. * @returns a new Vector2
  83127. */
  83128. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83129. /**
  83130. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83131. * @param vector defines the vector to transform
  83132. * @param transformation defines the matrix to apply
  83133. * @param result defines the target vector
  83134. */
  83135. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83136. /**
  83137. * Determines if a given vector is included in a triangle
  83138. * @param p defines the vector to test
  83139. * @param p0 defines 1st triangle point
  83140. * @param p1 defines 2nd triangle point
  83141. * @param p2 defines 3rd triangle point
  83142. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83143. */
  83144. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83145. /**
  83146. * Gets the distance between the vectors "value1" and "value2"
  83147. * @param value1 defines first vector
  83148. * @param value2 defines second vector
  83149. * @returns the distance between vectors
  83150. */
  83151. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83152. /**
  83153. * Returns the squared distance between the vectors "value1" and "value2"
  83154. * @param value1 defines first vector
  83155. * @param value2 defines second vector
  83156. * @returns the squared distance between vectors
  83157. */
  83158. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83159. /**
  83160. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83161. * @param value1 defines first vector
  83162. * @param value2 defines second vector
  83163. * @returns a new Vector2
  83164. */
  83165. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83166. /**
  83167. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83168. * @param p defines the middle point
  83169. * @param segA defines one point of the segment
  83170. * @param segB defines the other point of the segment
  83171. * @returns the shortest distance
  83172. */
  83173. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83174. }
  83175. /**
  83176. * Class used to store (x,y,z) vector representation
  83177. * A Vector3 is the main object used in 3D geometry
  83178. * It can represent etiher the coordinates of a point the space, either a direction
  83179. * Reminder: js uses a left handed forward facing system
  83180. */
  83181. export class Vector3 {
  83182. private static _UpReadOnly;
  83183. private static _ZeroReadOnly;
  83184. /** @hidden */
  83185. _x: number;
  83186. /** @hidden */
  83187. _y: number;
  83188. /** @hidden */
  83189. _z: number;
  83190. /** @hidden */
  83191. _isDirty: boolean;
  83192. /** Gets or sets the x coordinate */
  83193. get x(): number;
  83194. set x(value: number);
  83195. /** Gets or sets the y coordinate */
  83196. get y(): number;
  83197. set y(value: number);
  83198. /** Gets or sets the z coordinate */
  83199. get z(): number;
  83200. set z(value: number);
  83201. /**
  83202. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83203. * @param x defines the first coordinates (on X axis)
  83204. * @param y defines the second coordinates (on Y axis)
  83205. * @param z defines the third coordinates (on Z axis)
  83206. */
  83207. constructor(x?: number, y?: number, z?: number);
  83208. /**
  83209. * Creates a string representation of the Vector3
  83210. * @returns a string with the Vector3 coordinates.
  83211. */
  83212. toString(): string;
  83213. /**
  83214. * Gets the class name
  83215. * @returns the string "Vector3"
  83216. */
  83217. getClassName(): string;
  83218. /**
  83219. * Creates the Vector3 hash code
  83220. * @returns a number which tends to be unique between Vector3 instances
  83221. */
  83222. getHashCode(): number;
  83223. /**
  83224. * Creates an array containing three elements : the coordinates of the Vector3
  83225. * @returns a new array of numbers
  83226. */
  83227. asArray(): number[];
  83228. /**
  83229. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83230. * @param array defines the destination array
  83231. * @param index defines the offset in the destination array
  83232. * @returns the current Vector3
  83233. */
  83234. toArray(array: FloatArray, index?: number): Vector3;
  83235. /**
  83236. * Update the current vector from an array
  83237. * @param array defines the destination array
  83238. * @param index defines the offset in the destination array
  83239. * @returns the current Vector3
  83240. */
  83241. fromArray(array: FloatArray, index?: number): Vector3;
  83242. /**
  83243. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83244. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83245. */
  83246. toQuaternion(): Quaternion;
  83247. /**
  83248. * Adds the given vector to the current Vector3
  83249. * @param otherVector defines the second operand
  83250. * @returns the current updated Vector3
  83251. */
  83252. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83253. /**
  83254. * Adds the given coordinates to the current Vector3
  83255. * @param x defines the x coordinate of the operand
  83256. * @param y defines the y coordinate of the operand
  83257. * @param z defines the z coordinate of the operand
  83258. * @returns the current updated Vector3
  83259. */
  83260. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83261. /**
  83262. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83263. * @param otherVector defines the second operand
  83264. * @returns the resulting Vector3
  83265. */
  83266. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83267. /**
  83268. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83269. * @param otherVector defines the second operand
  83270. * @param result defines the Vector3 object where to store the result
  83271. * @returns the current Vector3
  83272. */
  83273. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83274. /**
  83275. * Subtract the given vector from the current Vector3
  83276. * @param otherVector defines the second operand
  83277. * @returns the current updated Vector3
  83278. */
  83279. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83280. /**
  83281. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83282. * @param otherVector defines the second operand
  83283. * @returns the resulting Vector3
  83284. */
  83285. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83286. /**
  83287. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83288. * @param otherVector defines the second operand
  83289. * @param result defines the Vector3 object where to store the result
  83290. * @returns the current Vector3
  83291. */
  83292. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83293. /**
  83294. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83295. * @param x defines the x coordinate of the operand
  83296. * @param y defines the y coordinate of the operand
  83297. * @param z defines the z coordinate of the operand
  83298. * @returns the resulting Vector3
  83299. */
  83300. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83301. /**
  83302. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83303. * @param x defines the x coordinate of the operand
  83304. * @param y defines the y coordinate of the operand
  83305. * @param z defines the z coordinate of the operand
  83306. * @param result defines the Vector3 object where to store the result
  83307. * @returns the current Vector3
  83308. */
  83309. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83310. /**
  83311. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83312. * @returns a new Vector3
  83313. */
  83314. negate(): Vector3;
  83315. /**
  83316. * Negate this vector in place
  83317. * @returns this
  83318. */
  83319. negateInPlace(): Vector3;
  83320. /**
  83321. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83322. * @param result defines the Vector3 object where to store the result
  83323. * @returns the current Vector3
  83324. */
  83325. negateToRef(result: Vector3): Vector3;
  83326. /**
  83327. * Multiplies the Vector3 coordinates by the float "scale"
  83328. * @param scale defines the multiplier factor
  83329. * @returns the current updated Vector3
  83330. */
  83331. scaleInPlace(scale: number): Vector3;
  83332. /**
  83333. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83334. * @param scale defines the multiplier factor
  83335. * @returns a new Vector3
  83336. */
  83337. scale(scale: number): Vector3;
  83338. /**
  83339. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83340. * @param scale defines the multiplier factor
  83341. * @param result defines the Vector3 object where to store the result
  83342. * @returns the current Vector3
  83343. */
  83344. scaleToRef(scale: number, result: Vector3): Vector3;
  83345. /**
  83346. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83347. * @param scale defines the scale factor
  83348. * @param result defines the Vector3 object where to store the result
  83349. * @returns the unmodified current Vector3
  83350. */
  83351. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83352. /**
  83353. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83354. * @param origin defines the origin of the projection ray
  83355. * @param plane defines the plane to project to
  83356. * @returns the projected vector3
  83357. */
  83358. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83359. /**
  83360. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83361. * @param origin defines the origin of the projection ray
  83362. * @param plane defines the plane to project to
  83363. * @param result defines the Vector3 where to store the result
  83364. */
  83365. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83366. /**
  83367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83368. * @param otherVector defines the second operand
  83369. * @returns true if both vectors are equals
  83370. */
  83371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83372. /**
  83373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83374. * @param otherVector defines the second operand
  83375. * @param epsilon defines the minimal distance to define values as equals
  83376. * @returns true if both vectors are distant less than epsilon
  83377. */
  83378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83379. /**
  83380. * Returns true if the current Vector3 coordinates equals the given floats
  83381. * @param x defines the x coordinate of the operand
  83382. * @param y defines the y coordinate of the operand
  83383. * @param z defines the z coordinate of the operand
  83384. * @returns true if both vectors are equals
  83385. */
  83386. equalsToFloats(x: number, y: number, z: number): boolean;
  83387. /**
  83388. * Multiplies the current Vector3 coordinates by the given ones
  83389. * @param otherVector defines the second operand
  83390. * @returns the current updated Vector3
  83391. */
  83392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83393. /**
  83394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83395. * @param otherVector defines the second operand
  83396. * @returns the new Vector3
  83397. */
  83398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83399. /**
  83400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83401. * @param otherVector defines the second operand
  83402. * @param result defines the Vector3 object where to store the result
  83403. * @returns the current Vector3
  83404. */
  83405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83406. /**
  83407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83408. * @param x defines the x coordinate of the operand
  83409. * @param y defines the y coordinate of the operand
  83410. * @param z defines the z coordinate of the operand
  83411. * @returns the new Vector3
  83412. */
  83413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83414. /**
  83415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83416. * @param otherVector defines the second operand
  83417. * @returns the new Vector3
  83418. */
  83419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83420. /**
  83421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83422. * @param otherVector defines the second operand
  83423. * @param result defines the Vector3 object where to store the result
  83424. * @returns the current Vector3
  83425. */
  83426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83427. /**
  83428. * Divides the current Vector3 coordinates by the given ones.
  83429. * @param otherVector defines the second operand
  83430. * @returns the current updated Vector3
  83431. */
  83432. divideInPlace(otherVector: Vector3): Vector3;
  83433. /**
  83434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83435. * @param other defines the second operand
  83436. * @returns the current updated Vector3
  83437. */
  83438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83439. /**
  83440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83441. * @param other defines the second operand
  83442. * @returns the current updated Vector3
  83443. */
  83444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83445. /**
  83446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83447. * @param x defines the x coordinate of the operand
  83448. * @param y defines the y coordinate of the operand
  83449. * @param z defines the z coordinate of the operand
  83450. * @returns the current updated Vector3
  83451. */
  83452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83453. /**
  83454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83455. * @param x defines the x coordinate of the operand
  83456. * @param y defines the y coordinate of the operand
  83457. * @param z defines the z coordinate of the operand
  83458. * @returns the current updated Vector3
  83459. */
  83460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83461. /**
  83462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83463. * Check if is non uniform within a certain amount of decimal places to account for this
  83464. * @param epsilon the amount the values can differ
  83465. * @returns if the the vector is non uniform to a certain number of decimal places
  83466. */
  83467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83468. /**
  83469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83470. */
  83471. get isNonUniform(): boolean;
  83472. /**
  83473. * Gets a new Vector3 from current Vector3 floored values
  83474. * @returns a new Vector3
  83475. */
  83476. floor(): Vector3;
  83477. /**
  83478. * Gets a new Vector3 from current Vector3 floored values
  83479. * @returns a new Vector3
  83480. */
  83481. fract(): Vector3;
  83482. /**
  83483. * Gets the length of the Vector3
  83484. * @returns the length of the Vector3
  83485. */
  83486. length(): number;
  83487. /**
  83488. * Gets the squared length of the Vector3
  83489. * @returns squared length of the Vector3
  83490. */
  83491. lengthSquared(): number;
  83492. /**
  83493. * Normalize the current Vector3.
  83494. * Please note that this is an in place operation.
  83495. * @returns the current updated Vector3
  83496. */
  83497. normalize(): Vector3;
  83498. /**
  83499. * Reorders the x y z properties of the vector in place
  83500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83501. * @returns the current updated vector
  83502. */
  83503. reorderInPlace(order: string): this;
  83504. /**
  83505. * Rotates the vector around 0,0,0 by a quaternion
  83506. * @param quaternion the rotation quaternion
  83507. * @param result vector to store the result
  83508. * @returns the resulting vector
  83509. */
  83510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83511. /**
  83512. * Rotates a vector around a given point
  83513. * @param quaternion the rotation quaternion
  83514. * @param point the point to rotate around
  83515. * @param result vector to store the result
  83516. * @returns the resulting vector
  83517. */
  83518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83519. /**
  83520. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83521. * The cross product is then orthogonal to both current and "other"
  83522. * @param other defines the right operand
  83523. * @returns the cross product
  83524. */
  83525. cross(other: Vector3): Vector3;
  83526. /**
  83527. * Normalize the current Vector3 with the given input length.
  83528. * Please note that this is an in place operation.
  83529. * @param len the length of the vector
  83530. * @returns the current updated Vector3
  83531. */
  83532. normalizeFromLength(len: number): Vector3;
  83533. /**
  83534. * Normalize the current Vector3 to a new vector
  83535. * @returns the new Vector3
  83536. */
  83537. normalizeToNew(): Vector3;
  83538. /**
  83539. * Normalize the current Vector3 to the reference
  83540. * @param reference define the Vector3 to update
  83541. * @returns the updated Vector3
  83542. */
  83543. normalizeToRef(reference: Vector3): Vector3;
  83544. /**
  83545. * Creates a new Vector3 copied from the current Vector3
  83546. * @returns the new Vector3
  83547. */
  83548. clone(): Vector3;
  83549. /**
  83550. * Copies the given vector coordinates to the current Vector3 ones
  83551. * @param source defines the source Vector3
  83552. * @returns the current updated Vector3
  83553. */
  83554. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83555. /**
  83556. * Copies the given floats to the current Vector3 coordinates
  83557. * @param x defines the x coordinate of the operand
  83558. * @param y defines the y coordinate of the operand
  83559. * @param z defines the z coordinate of the operand
  83560. * @returns the current updated Vector3
  83561. */
  83562. copyFromFloats(x: number, y: number, z: number): Vector3;
  83563. /**
  83564. * Copies the given floats to the current Vector3 coordinates
  83565. * @param x defines the x coordinate of the operand
  83566. * @param y defines the y coordinate of the operand
  83567. * @param z defines the z coordinate of the operand
  83568. * @returns the current updated Vector3
  83569. */
  83570. set(x: number, y: number, z: number): Vector3;
  83571. /**
  83572. * Copies the given float to the current Vector3 coordinates
  83573. * @param v defines the x, y and z coordinates of the operand
  83574. * @returns the current updated Vector3
  83575. */
  83576. setAll(v: number): Vector3;
  83577. /**
  83578. * Get the clip factor between two vectors
  83579. * @param vector0 defines the first operand
  83580. * @param vector1 defines the second operand
  83581. * @param axis defines the axis to use
  83582. * @param size defines the size along the axis
  83583. * @returns the clip factor
  83584. */
  83585. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83586. /**
  83587. * Get angle between two vectors
  83588. * @param vector0 angle between vector0 and vector1
  83589. * @param vector1 angle between vector0 and vector1
  83590. * @param normal direction of the normal
  83591. * @return the angle between vector0 and vector1
  83592. */
  83593. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83594. /**
  83595. * Returns a new Vector3 set from the index "offset" of the given array
  83596. * @param array defines the source array
  83597. * @param offset defines the offset in the source array
  83598. * @returns the new Vector3
  83599. */
  83600. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83601. /**
  83602. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83603. * @param array defines the source array
  83604. * @param offset defines the offset in the source array
  83605. * @returns the new Vector3
  83606. * @deprecated Please use FromArray instead.
  83607. */
  83608. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83609. /**
  83610. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83611. * @param array defines the source array
  83612. * @param offset defines the offset in the source array
  83613. * @param result defines the Vector3 where to store the result
  83614. */
  83615. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83616. /**
  83617. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83618. * @param array defines the source array
  83619. * @param offset defines the offset in the source array
  83620. * @param result defines the Vector3 where to store the result
  83621. * @deprecated Please use FromArrayToRef instead.
  83622. */
  83623. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83624. /**
  83625. * Sets the given vector "result" with the given floats.
  83626. * @param x defines the x coordinate of the source
  83627. * @param y defines the y coordinate of the source
  83628. * @param z defines the z coordinate of the source
  83629. * @param result defines the Vector3 where to store the result
  83630. */
  83631. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83632. /**
  83633. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83634. * @returns a new empty Vector3
  83635. */
  83636. static Zero(): Vector3;
  83637. /**
  83638. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83639. * @returns a new unit Vector3
  83640. */
  83641. static One(): Vector3;
  83642. /**
  83643. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83644. * @returns a new up Vector3
  83645. */
  83646. static Up(): Vector3;
  83647. /**
  83648. * Gets a up Vector3 that must not be updated
  83649. */
  83650. static get UpReadOnly(): DeepImmutable<Vector3>;
  83651. /**
  83652. * Gets a zero Vector3 that must not be updated
  83653. */
  83654. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83655. /**
  83656. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83657. * @returns a new down Vector3
  83658. */
  83659. static Down(): Vector3;
  83660. /**
  83661. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83662. * @param rightHandedSystem is the scene right-handed (negative z)
  83663. * @returns a new forward Vector3
  83664. */
  83665. static Forward(rightHandedSystem?: boolean): Vector3;
  83666. /**
  83667. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83668. * @param rightHandedSystem is the scene right-handed (negative-z)
  83669. * @returns a new forward Vector3
  83670. */
  83671. static Backward(rightHandedSystem?: boolean): Vector3;
  83672. /**
  83673. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83674. * @returns a new right Vector3
  83675. */
  83676. static Right(): Vector3;
  83677. /**
  83678. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83679. * @returns a new left Vector3
  83680. */
  83681. static Left(): Vector3;
  83682. /**
  83683. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83684. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83685. * @param vector defines the Vector3 to transform
  83686. * @param transformation defines the transformation matrix
  83687. * @returns the transformed Vector3
  83688. */
  83689. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83690. /**
  83691. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83692. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83693. * @param vector defines the Vector3 to transform
  83694. * @param transformation defines the transformation matrix
  83695. * @param result defines the Vector3 where to store the result
  83696. */
  83697. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83698. /**
  83699. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83700. * This method computes tranformed coordinates only, not transformed direction vectors
  83701. * @param x define the x coordinate of the source vector
  83702. * @param y define the y coordinate of the source vector
  83703. * @param z define the z coordinate of the source vector
  83704. * @param transformation defines the transformation matrix
  83705. * @param result defines the Vector3 where to store the result
  83706. */
  83707. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83708. /**
  83709. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83710. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83711. * @param vector defines the Vector3 to transform
  83712. * @param transformation defines the transformation matrix
  83713. * @returns the new Vector3
  83714. */
  83715. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83716. /**
  83717. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83718. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83719. * @param vector defines the Vector3 to transform
  83720. * @param transformation defines the transformation matrix
  83721. * @param result defines the Vector3 where to store the result
  83722. */
  83723. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83724. /**
  83725. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83726. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83727. * @param x define the x coordinate of the source vector
  83728. * @param y define the y coordinate of the source vector
  83729. * @param z define the z coordinate of the source vector
  83730. * @param transformation defines the transformation matrix
  83731. * @param result defines the Vector3 where to store the result
  83732. */
  83733. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83734. /**
  83735. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83736. * @param value1 defines the first control point
  83737. * @param value2 defines the second control point
  83738. * @param value3 defines the third control point
  83739. * @param value4 defines the fourth control point
  83740. * @param amount defines the amount on the spline to use
  83741. * @returns the new Vector3
  83742. */
  83743. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83744. /**
  83745. * 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"
  83746. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83747. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83748. * @param value defines the current value
  83749. * @param min defines the lower range value
  83750. * @param max defines the upper range value
  83751. * @returns the new Vector3
  83752. */
  83753. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83754. /**
  83755. * 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"
  83756. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83757. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83758. * @param value defines the current value
  83759. * @param min defines the lower range value
  83760. * @param max defines the upper range value
  83761. * @param result defines the Vector3 where to store the result
  83762. */
  83763. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83764. /**
  83765. * Checks if a given vector is inside a specific range
  83766. * @param v defines the vector to test
  83767. * @param min defines the minimum range
  83768. * @param max defines the maximum range
  83769. */
  83770. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83771. /**
  83772. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83773. * @param value1 defines the first control point
  83774. * @param tangent1 defines the first tangent vector
  83775. * @param value2 defines the second control point
  83776. * @param tangent2 defines the second tangent vector
  83777. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83778. * @returns the new Vector3
  83779. */
  83780. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83781. /**
  83782. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83783. * @param start defines the start value
  83784. * @param end defines the end value
  83785. * @param amount max defines amount between both (between 0 and 1)
  83786. * @returns the new Vector3
  83787. */
  83788. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83789. /**
  83790. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83791. * @param start defines the start value
  83792. * @param end defines the end value
  83793. * @param amount max defines amount between both (between 0 and 1)
  83794. * @param result defines the Vector3 where to store the result
  83795. */
  83796. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83797. /**
  83798. * Returns the dot product (float) between the vectors "left" and "right"
  83799. * @param left defines the left operand
  83800. * @param right defines the right operand
  83801. * @returns the dot product
  83802. */
  83803. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83804. /**
  83805. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83806. * The cross product is then orthogonal to both "left" and "right"
  83807. * @param left defines the left operand
  83808. * @param right defines the right operand
  83809. * @returns the cross product
  83810. */
  83811. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83812. /**
  83813. * Sets the given vector "result" with the cross product of "left" and "right"
  83814. * The cross product is then orthogonal to both "left" and "right"
  83815. * @param left defines the left operand
  83816. * @param right defines the right operand
  83817. * @param result defines the Vector3 where to store the result
  83818. */
  83819. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83820. /**
  83821. * Returns a new Vector3 as the normalization of the given vector
  83822. * @param vector defines the Vector3 to normalize
  83823. * @returns the new Vector3
  83824. */
  83825. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83826. /**
  83827. * Sets the given vector "result" with the normalization of the given first vector
  83828. * @param vector defines the Vector3 to normalize
  83829. * @param result defines the Vector3 where to store the result
  83830. */
  83831. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83832. /**
  83833. * Project a Vector3 onto screen space
  83834. * @param vector defines the Vector3 to project
  83835. * @param world defines the world matrix to use
  83836. * @param transform defines the transform (view x projection) matrix to use
  83837. * @param viewport defines the screen viewport to use
  83838. * @returns the new Vector3
  83839. */
  83840. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83841. /** @hidden */
  83842. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83843. /**
  83844. * Unproject from screen space to object space
  83845. * @param source defines the screen space Vector3 to use
  83846. * @param viewportWidth defines the current width of the viewport
  83847. * @param viewportHeight defines the current height of the viewport
  83848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83849. * @param transform defines the transform (view x projection) matrix to use
  83850. * @returns the new Vector3
  83851. */
  83852. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83853. /**
  83854. * Unproject from screen space to object space
  83855. * @param source defines the screen space Vector3 to use
  83856. * @param viewportWidth defines the current width of the viewport
  83857. * @param viewportHeight defines the current height of the viewport
  83858. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83859. * @param view defines the view matrix to use
  83860. * @param projection defines the projection matrix to use
  83861. * @returns the new Vector3
  83862. */
  83863. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83864. /**
  83865. * Unproject from screen space to object space
  83866. * @param source defines the screen space Vector3 to use
  83867. * @param viewportWidth defines the current width of the viewport
  83868. * @param viewportHeight defines the current height of the viewport
  83869. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83870. * @param view defines the view matrix to use
  83871. * @param projection defines the projection matrix to use
  83872. * @param result defines the Vector3 where to store the result
  83873. */
  83874. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83875. /**
  83876. * Unproject from screen space to object space
  83877. * @param sourceX defines the screen space x coordinate to use
  83878. * @param sourceY defines the screen space y coordinate to use
  83879. * @param sourceZ defines the screen space z coordinate to use
  83880. * @param viewportWidth defines the current width of the viewport
  83881. * @param viewportHeight defines the current height of the viewport
  83882. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83883. * @param view defines the view matrix to use
  83884. * @param projection defines the projection matrix to use
  83885. * @param result defines the Vector3 where to store the result
  83886. */
  83887. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83888. /**
  83889. * Gets the minimal coordinate values between two Vector3
  83890. * @param left defines the first operand
  83891. * @param right defines the second operand
  83892. * @returns the new Vector3
  83893. */
  83894. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83895. /**
  83896. * Gets the maximal coordinate values between two Vector3
  83897. * @param left defines the first operand
  83898. * @param right defines the second operand
  83899. * @returns the new Vector3
  83900. */
  83901. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83902. /**
  83903. * Returns the distance between the vectors "value1" and "value2"
  83904. * @param value1 defines the first operand
  83905. * @param value2 defines the second operand
  83906. * @returns the distance
  83907. */
  83908. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83909. /**
  83910. * Returns the squared distance between the vectors "value1" and "value2"
  83911. * @param value1 defines the first operand
  83912. * @param value2 defines the second operand
  83913. * @returns the squared distance
  83914. */
  83915. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83916. /**
  83917. * Returns a new Vector3 located at the center between "value1" and "value2"
  83918. * @param value1 defines the first operand
  83919. * @param value2 defines the second operand
  83920. * @returns the new Vector3
  83921. */
  83922. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83923. /**
  83924. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83925. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83926. * to something in order to rotate it from its local system to the given target system
  83927. * Note: axis1, axis2 and axis3 are normalized during this operation
  83928. * @param axis1 defines the first axis
  83929. * @param axis2 defines the second axis
  83930. * @param axis3 defines the third axis
  83931. * @returns a new Vector3
  83932. */
  83933. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83934. /**
  83935. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83936. * @param axis1 defines the first axis
  83937. * @param axis2 defines the second axis
  83938. * @param axis3 defines the third axis
  83939. * @param ref defines the Vector3 where to store the result
  83940. */
  83941. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83942. }
  83943. /**
  83944. * Vector4 class created for EulerAngle class conversion to Quaternion
  83945. */
  83946. export class Vector4 {
  83947. /** x value of the vector */
  83948. x: number;
  83949. /** y value of the vector */
  83950. y: number;
  83951. /** z value of the vector */
  83952. z: number;
  83953. /** w value of the vector */
  83954. w: number;
  83955. /**
  83956. * Creates a Vector4 object from the given floats.
  83957. * @param x x value of the vector
  83958. * @param y y value of the vector
  83959. * @param z z value of the vector
  83960. * @param w w value of the vector
  83961. */
  83962. constructor(
  83963. /** x value of the vector */
  83964. x: number,
  83965. /** y value of the vector */
  83966. y: number,
  83967. /** z value of the vector */
  83968. z: number,
  83969. /** w value of the vector */
  83970. w: number);
  83971. /**
  83972. * Returns the string with the Vector4 coordinates.
  83973. * @returns a string containing all the vector values
  83974. */
  83975. toString(): string;
  83976. /**
  83977. * Returns the string "Vector4".
  83978. * @returns "Vector4"
  83979. */
  83980. getClassName(): string;
  83981. /**
  83982. * Returns the Vector4 hash code.
  83983. * @returns a unique hash code
  83984. */
  83985. getHashCode(): number;
  83986. /**
  83987. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83988. * @returns the resulting array
  83989. */
  83990. asArray(): number[];
  83991. /**
  83992. * Populates the given array from the given index with the Vector4 coordinates.
  83993. * @param array array to populate
  83994. * @param index index of the array to start at (default: 0)
  83995. * @returns the Vector4.
  83996. */
  83997. toArray(array: FloatArray, index?: number): Vector4;
  83998. /**
  83999. * Update the current vector from an array
  84000. * @param array defines the destination array
  84001. * @param index defines the offset in the destination array
  84002. * @returns the current Vector3
  84003. */
  84004. fromArray(array: FloatArray, index?: number): Vector4;
  84005. /**
  84006. * Adds the given vector to the current Vector4.
  84007. * @param otherVector the vector to add
  84008. * @returns the updated Vector4.
  84009. */
  84010. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84011. /**
  84012. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  84013. * @param otherVector the vector to add
  84014. * @returns the resulting vector
  84015. */
  84016. add(otherVector: DeepImmutable<Vector4>): Vector4;
  84017. /**
  84018. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  84019. * @param otherVector the vector to add
  84020. * @param result the vector to store the result
  84021. * @returns the current Vector4.
  84022. */
  84023. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84024. /**
  84025. * Subtract in place the given vector from the current Vector4.
  84026. * @param otherVector the vector to subtract
  84027. * @returns the updated Vector4.
  84028. */
  84029. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84030. /**
  84031. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  84032. * @param otherVector the vector to add
  84033. * @returns the new vector with the result
  84034. */
  84035. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  84036. /**
  84037. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  84038. * @param otherVector the vector to subtract
  84039. * @param result the vector to store the result
  84040. * @returns the current Vector4.
  84041. */
  84042. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84043. /**
  84044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84045. */
  84046. /**
  84047. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84048. * @param x value to subtract
  84049. * @param y value to subtract
  84050. * @param z value to subtract
  84051. * @param w value to subtract
  84052. * @returns new vector containing the result
  84053. */
  84054. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84055. /**
  84056. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84057. * @param x value to subtract
  84058. * @param y value to subtract
  84059. * @param z value to subtract
  84060. * @param w value to subtract
  84061. * @param result the vector to store the result in
  84062. * @returns the current Vector4.
  84063. */
  84064. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  84065. /**
  84066. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  84067. * @returns a new vector with the negated values
  84068. */
  84069. negate(): Vector4;
  84070. /**
  84071. * Negate this vector in place
  84072. * @returns this
  84073. */
  84074. negateInPlace(): Vector4;
  84075. /**
  84076. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  84077. * @param result defines the Vector3 object where to store the result
  84078. * @returns the current Vector4
  84079. */
  84080. negateToRef(result: Vector4): Vector4;
  84081. /**
  84082. * Multiplies the current Vector4 coordinates by scale (float).
  84083. * @param scale the number to scale with
  84084. * @returns the updated Vector4.
  84085. */
  84086. scaleInPlace(scale: number): Vector4;
  84087. /**
  84088. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84089. * @param scale the number to scale with
  84090. * @returns a new vector with the result
  84091. */
  84092. scale(scale: number): Vector4;
  84093. /**
  84094. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84095. * @param scale the number to scale with
  84096. * @param result a vector to store the result in
  84097. * @returns the current Vector4.
  84098. */
  84099. scaleToRef(scale: number, result: Vector4): Vector4;
  84100. /**
  84101. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84102. * @param scale defines the scale factor
  84103. * @param result defines the Vector4 object where to store the result
  84104. * @returns the unmodified current Vector4
  84105. */
  84106. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84107. /**
  84108. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84109. * @param otherVector the vector to compare against
  84110. * @returns true if they are equal
  84111. */
  84112. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84113. /**
  84114. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84115. * @param otherVector vector to compare against
  84116. * @param epsilon (Default: very small number)
  84117. * @returns true if they are equal
  84118. */
  84119. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84120. /**
  84121. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84122. * @param x x value to compare against
  84123. * @param y y value to compare against
  84124. * @param z z value to compare against
  84125. * @param w w value to compare against
  84126. * @returns true if equal
  84127. */
  84128. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84129. /**
  84130. * Multiplies in place the current Vector4 by the given one.
  84131. * @param otherVector vector to multiple with
  84132. * @returns the updated Vector4.
  84133. */
  84134. multiplyInPlace(otherVector: Vector4): Vector4;
  84135. /**
  84136. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84137. * @param otherVector vector to multiple with
  84138. * @returns resulting new vector
  84139. */
  84140. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84141. /**
  84142. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84143. * @param otherVector vector to multiple with
  84144. * @param result vector to store the result
  84145. * @returns the current Vector4.
  84146. */
  84147. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84148. /**
  84149. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84150. * @param x x value multiply with
  84151. * @param y y value multiply with
  84152. * @param z z value multiply with
  84153. * @param w w value multiply with
  84154. * @returns resulting new vector
  84155. */
  84156. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84157. /**
  84158. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84159. * @param otherVector vector to devide with
  84160. * @returns resulting new vector
  84161. */
  84162. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84163. /**
  84164. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84165. * @param otherVector vector to devide with
  84166. * @param result vector to store the result
  84167. * @returns the current Vector4.
  84168. */
  84169. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84170. /**
  84171. * Divides the current Vector3 coordinates by the given ones.
  84172. * @param otherVector vector to devide with
  84173. * @returns the updated Vector3.
  84174. */
  84175. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84176. /**
  84177. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84178. * @param other defines the second operand
  84179. * @returns the current updated Vector4
  84180. */
  84181. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84182. /**
  84183. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84184. * @param other defines the second operand
  84185. * @returns the current updated Vector4
  84186. */
  84187. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84188. /**
  84189. * Gets a new Vector4 from current Vector4 floored values
  84190. * @returns a new Vector4
  84191. */
  84192. floor(): Vector4;
  84193. /**
  84194. * Gets a new Vector4 from current Vector3 floored values
  84195. * @returns a new Vector4
  84196. */
  84197. fract(): Vector4;
  84198. /**
  84199. * Returns the Vector4 length (float).
  84200. * @returns the length
  84201. */
  84202. length(): number;
  84203. /**
  84204. * Returns the Vector4 squared length (float).
  84205. * @returns the length squared
  84206. */
  84207. lengthSquared(): number;
  84208. /**
  84209. * Normalizes in place the Vector4.
  84210. * @returns the updated Vector4.
  84211. */
  84212. normalize(): Vector4;
  84213. /**
  84214. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84215. * @returns this converted to a new vector3
  84216. */
  84217. toVector3(): Vector3;
  84218. /**
  84219. * Returns a new Vector4 copied from the current one.
  84220. * @returns the new cloned vector
  84221. */
  84222. clone(): Vector4;
  84223. /**
  84224. * Updates the current Vector4 with the given one coordinates.
  84225. * @param source the source vector to copy from
  84226. * @returns the updated Vector4.
  84227. */
  84228. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84229. /**
  84230. * Updates the current Vector4 coordinates with the given floats.
  84231. * @param x float to copy from
  84232. * @param y float to copy from
  84233. * @param z float to copy from
  84234. * @param w float to copy from
  84235. * @returns the updated Vector4.
  84236. */
  84237. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84238. /**
  84239. * Updates the current Vector4 coordinates with the given floats.
  84240. * @param x float to set from
  84241. * @param y float to set from
  84242. * @param z float to set from
  84243. * @param w float to set from
  84244. * @returns the updated Vector4.
  84245. */
  84246. set(x: number, y: number, z: number, w: number): Vector4;
  84247. /**
  84248. * Copies the given float to the current Vector3 coordinates
  84249. * @param v defines the x, y, z and w coordinates of the operand
  84250. * @returns the current updated Vector3
  84251. */
  84252. setAll(v: number): Vector4;
  84253. /**
  84254. * Returns a new Vector4 set from the starting index of the given array.
  84255. * @param array the array to pull values from
  84256. * @param offset the offset into the array to start at
  84257. * @returns the new vector
  84258. */
  84259. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84260. /**
  84261. * Updates the given vector "result" from the starting index of the given array.
  84262. * @param array the array to pull values from
  84263. * @param offset the offset into the array to start at
  84264. * @param result the vector to store the result in
  84265. */
  84266. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84267. /**
  84268. * Updates the given vector "result" from the starting index of the given Float32Array.
  84269. * @param array the array to pull values from
  84270. * @param offset the offset into the array to start at
  84271. * @param result the vector to store the result in
  84272. */
  84273. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84274. /**
  84275. * Updates the given vector "result" coordinates from the given floats.
  84276. * @param x float to set from
  84277. * @param y float to set from
  84278. * @param z float to set from
  84279. * @param w float to set from
  84280. * @param result the vector to the floats in
  84281. */
  84282. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84283. /**
  84284. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84285. * @returns the new vector
  84286. */
  84287. static Zero(): Vector4;
  84288. /**
  84289. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84290. * @returns the new vector
  84291. */
  84292. static One(): Vector4;
  84293. /**
  84294. * Returns a new normalized Vector4 from the given one.
  84295. * @param vector the vector to normalize
  84296. * @returns the vector
  84297. */
  84298. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84299. /**
  84300. * Updates the given vector "result" from the normalization of the given one.
  84301. * @param vector the vector to normalize
  84302. * @param result the vector to store the result in
  84303. */
  84304. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84305. /**
  84306. * Returns a vector with the minimum values from the left and right vectors
  84307. * @param left left vector to minimize
  84308. * @param right right vector to minimize
  84309. * @returns a new vector with the minimum of the left and right vector values
  84310. */
  84311. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84312. /**
  84313. * Returns a vector with the maximum values from the left and right vectors
  84314. * @param left left vector to maximize
  84315. * @param right right vector to maximize
  84316. * @returns a new vector with the maximum of the left and right vector values
  84317. */
  84318. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84319. /**
  84320. * Returns the distance (float) between the vectors "value1" and "value2".
  84321. * @param value1 value to calulate the distance between
  84322. * @param value2 value to calulate the distance between
  84323. * @return the distance between the two vectors
  84324. */
  84325. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84326. /**
  84327. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84328. * @param value1 value to calulate the distance between
  84329. * @param value2 value to calulate the distance between
  84330. * @return the distance between the two vectors squared
  84331. */
  84332. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84333. /**
  84334. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84335. * @param value1 value to calulate the center between
  84336. * @param value2 value to calulate the center between
  84337. * @return the center between the two vectors
  84338. */
  84339. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84340. /**
  84341. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84342. * This methods computes transformed normalized direction vectors only.
  84343. * @param vector the vector to transform
  84344. * @param transformation the transformation matrix to apply
  84345. * @returns the new vector
  84346. */
  84347. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84348. /**
  84349. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84350. * This methods computes transformed normalized direction vectors only.
  84351. * @param vector the vector to transform
  84352. * @param transformation the transformation matrix to apply
  84353. * @param result the vector to store the result in
  84354. */
  84355. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84356. /**
  84357. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84358. * This methods computes transformed normalized direction vectors only.
  84359. * @param x value to transform
  84360. * @param y value to transform
  84361. * @param z value to transform
  84362. * @param w value to transform
  84363. * @param transformation the transformation matrix to apply
  84364. * @param result the vector to store the results in
  84365. */
  84366. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84367. /**
  84368. * Creates a new Vector4 from a Vector3
  84369. * @param source defines the source data
  84370. * @param w defines the 4th component (default is 0)
  84371. * @returns a new Vector4
  84372. */
  84373. static FromVector3(source: Vector3, w?: number): Vector4;
  84374. }
  84375. /**
  84376. * Class used to store quaternion data
  84377. * @see https://en.wikipedia.org/wiki/Quaternion
  84378. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84379. */
  84380. export class Quaternion {
  84381. /** @hidden */
  84382. _x: number;
  84383. /** @hidden */
  84384. _y: number;
  84385. /** @hidden */
  84386. _z: number;
  84387. /** @hidden */
  84388. _w: number;
  84389. /** @hidden */
  84390. _isDirty: boolean;
  84391. /** Gets or sets the x coordinate */
  84392. get x(): number;
  84393. set x(value: number);
  84394. /** Gets or sets the y coordinate */
  84395. get y(): number;
  84396. set y(value: number);
  84397. /** Gets or sets the z coordinate */
  84398. get z(): number;
  84399. set z(value: number);
  84400. /** Gets or sets the w coordinate */
  84401. get w(): number;
  84402. set w(value: number);
  84403. /**
  84404. * Creates a new Quaternion from the given floats
  84405. * @param x defines the first component (0 by default)
  84406. * @param y defines the second component (0 by default)
  84407. * @param z defines the third component (0 by default)
  84408. * @param w defines the fourth component (1.0 by default)
  84409. */
  84410. constructor(x?: number, y?: number, z?: number, w?: number);
  84411. /**
  84412. * Gets a string representation for the current quaternion
  84413. * @returns a string with the Quaternion coordinates
  84414. */
  84415. toString(): string;
  84416. /**
  84417. * Gets the class name of the quaternion
  84418. * @returns the string "Quaternion"
  84419. */
  84420. getClassName(): string;
  84421. /**
  84422. * Gets a hash code for this quaternion
  84423. * @returns the quaternion hash code
  84424. */
  84425. getHashCode(): number;
  84426. /**
  84427. * Copy the quaternion to an array
  84428. * @returns a new array populated with 4 elements from the quaternion coordinates
  84429. */
  84430. asArray(): number[];
  84431. /**
  84432. * Check if two quaternions are equals
  84433. * @param otherQuaternion defines the second operand
  84434. * @return true if the current quaternion and the given one coordinates are strictly equals
  84435. */
  84436. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84437. /**
  84438. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84439. * @param otherQuaternion defines the other quaternion
  84440. * @param epsilon defines the minimal distance to consider equality
  84441. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84442. */
  84443. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84444. /**
  84445. * Clone the current quaternion
  84446. * @returns a new quaternion copied from the current one
  84447. */
  84448. clone(): Quaternion;
  84449. /**
  84450. * Copy a quaternion to the current one
  84451. * @param other defines the other quaternion
  84452. * @returns the updated current quaternion
  84453. */
  84454. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84455. /**
  84456. * Updates the current quaternion with the given float coordinates
  84457. * @param x defines the x coordinate
  84458. * @param y defines the y coordinate
  84459. * @param z defines the z coordinate
  84460. * @param w defines the w coordinate
  84461. * @returns the updated current quaternion
  84462. */
  84463. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84464. /**
  84465. * Updates the current quaternion from the given float coordinates
  84466. * @param x defines the x coordinate
  84467. * @param y defines the y coordinate
  84468. * @param z defines the z coordinate
  84469. * @param w defines the w coordinate
  84470. * @returns the updated current quaternion
  84471. */
  84472. set(x: number, y: number, z: number, w: number): Quaternion;
  84473. /**
  84474. * Adds two quaternions
  84475. * @param other defines the second operand
  84476. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84477. */
  84478. add(other: DeepImmutable<Quaternion>): Quaternion;
  84479. /**
  84480. * Add a quaternion to the current one
  84481. * @param other defines the quaternion to add
  84482. * @returns the current quaternion
  84483. */
  84484. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84485. /**
  84486. * Subtract two quaternions
  84487. * @param other defines the second operand
  84488. * @returns a new quaternion as the subtraction result of the given one from the current one
  84489. */
  84490. subtract(other: Quaternion): Quaternion;
  84491. /**
  84492. * Multiplies the current quaternion by a scale factor
  84493. * @param value defines the scale factor
  84494. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84495. */
  84496. scale(value: number): Quaternion;
  84497. /**
  84498. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84499. * @param scale defines the scale factor
  84500. * @param result defines the Quaternion object where to store the result
  84501. * @returns the unmodified current quaternion
  84502. */
  84503. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84504. /**
  84505. * Multiplies in place the current quaternion by a scale factor
  84506. * @param value defines the scale factor
  84507. * @returns the current modified quaternion
  84508. */
  84509. scaleInPlace(value: number): Quaternion;
  84510. /**
  84511. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84512. * @param scale defines the scale factor
  84513. * @param result defines the Quaternion object where to store the result
  84514. * @returns the unmodified current quaternion
  84515. */
  84516. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84517. /**
  84518. * Multiplies two quaternions
  84519. * @param q1 defines the second operand
  84520. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84521. */
  84522. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84523. /**
  84524. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84525. * @param q1 defines the second operand
  84526. * @param result defines the target quaternion
  84527. * @returns the current quaternion
  84528. */
  84529. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84530. /**
  84531. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84532. * @param q1 defines the second operand
  84533. * @returns the currentupdated quaternion
  84534. */
  84535. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84536. /**
  84537. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84538. * @param ref defines the target quaternion
  84539. * @returns the current quaternion
  84540. */
  84541. conjugateToRef(ref: Quaternion): Quaternion;
  84542. /**
  84543. * Conjugates in place (1-q) the current quaternion
  84544. * @returns the current updated quaternion
  84545. */
  84546. conjugateInPlace(): Quaternion;
  84547. /**
  84548. * Conjugates in place (1-q) the current quaternion
  84549. * @returns a new quaternion
  84550. */
  84551. conjugate(): Quaternion;
  84552. /**
  84553. * Gets length of current quaternion
  84554. * @returns the quaternion length (float)
  84555. */
  84556. length(): number;
  84557. /**
  84558. * Normalize in place the current quaternion
  84559. * @returns the current updated quaternion
  84560. */
  84561. normalize(): Quaternion;
  84562. /**
  84563. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84564. * @param order is a reserved parameter and is ignored for now
  84565. * @returns a new Vector3 containing the Euler angles
  84566. */
  84567. toEulerAngles(order?: string): Vector3;
  84568. /**
  84569. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84570. * @param result defines the vector which will be filled with the Euler angles
  84571. * @returns the current unchanged quaternion
  84572. */
  84573. toEulerAnglesToRef(result: Vector3): Quaternion;
  84574. /**
  84575. * Updates the given rotation matrix with the current quaternion values
  84576. * @param result defines the target matrix
  84577. * @returns the current unchanged quaternion
  84578. */
  84579. toRotationMatrix(result: Matrix): Quaternion;
  84580. /**
  84581. * Updates the current quaternion from the given rotation matrix values
  84582. * @param matrix defines the source matrix
  84583. * @returns the current updated quaternion
  84584. */
  84585. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84586. /**
  84587. * Creates a new quaternion from a rotation matrix
  84588. * @param matrix defines the source matrix
  84589. * @returns a new quaternion created from the given rotation matrix values
  84590. */
  84591. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84592. /**
  84593. * Updates the given quaternion with the given rotation matrix values
  84594. * @param matrix defines the source matrix
  84595. * @param result defines the target quaternion
  84596. */
  84597. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84598. /**
  84599. * Returns the dot product (float) between the quaternions "left" and "right"
  84600. * @param left defines the left operand
  84601. * @param right defines the right operand
  84602. * @returns the dot product
  84603. */
  84604. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84605. /**
  84606. * Checks if the two quaternions are close to each other
  84607. * @param quat0 defines the first quaternion to check
  84608. * @param quat1 defines the second quaternion to check
  84609. * @returns true if the two quaternions are close to each other
  84610. */
  84611. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84612. /**
  84613. * Creates an empty quaternion
  84614. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84615. */
  84616. static Zero(): Quaternion;
  84617. /**
  84618. * Inverse a given quaternion
  84619. * @param q defines the source quaternion
  84620. * @returns a new quaternion as the inverted current quaternion
  84621. */
  84622. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84623. /**
  84624. * Inverse a given quaternion
  84625. * @param q defines the source quaternion
  84626. * @param result the quaternion the result will be stored in
  84627. * @returns the result quaternion
  84628. */
  84629. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84630. /**
  84631. * Creates an identity quaternion
  84632. * @returns the identity quaternion
  84633. */
  84634. static Identity(): Quaternion;
  84635. /**
  84636. * Gets a boolean indicating if the given quaternion is identity
  84637. * @param quaternion defines the quaternion to check
  84638. * @returns true if the quaternion is identity
  84639. */
  84640. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84641. /**
  84642. * Creates a quaternion from a rotation around an axis
  84643. * @param axis defines the axis to use
  84644. * @param angle defines the angle to use
  84645. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84646. */
  84647. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84648. /**
  84649. * Creates a rotation around an axis and stores it into the given quaternion
  84650. * @param axis defines the axis to use
  84651. * @param angle defines the angle to use
  84652. * @param result defines the target quaternion
  84653. * @returns the target quaternion
  84654. */
  84655. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84656. /**
  84657. * Creates a new quaternion from data stored into an array
  84658. * @param array defines the data source
  84659. * @param offset defines the offset in the source array where the data starts
  84660. * @returns a new quaternion
  84661. */
  84662. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84663. /**
  84664. * Updates the given quaternion "result" from the starting index of the given array.
  84665. * @param array the array to pull values from
  84666. * @param offset the offset into the array to start at
  84667. * @param result the quaternion to store the result in
  84668. */
  84669. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84670. /**
  84671. * Create a quaternion from Euler rotation angles
  84672. * @param x Pitch
  84673. * @param y Yaw
  84674. * @param z Roll
  84675. * @returns the new Quaternion
  84676. */
  84677. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84678. /**
  84679. * Updates a quaternion from Euler rotation angles
  84680. * @param x Pitch
  84681. * @param y Yaw
  84682. * @param z Roll
  84683. * @param result the quaternion to store the result
  84684. * @returns the updated quaternion
  84685. */
  84686. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84687. /**
  84688. * Create a quaternion from Euler rotation vector
  84689. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84690. * @returns the new Quaternion
  84691. */
  84692. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84693. /**
  84694. * Updates a quaternion from Euler rotation vector
  84695. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84696. * @param result the quaternion to store the result
  84697. * @returns the updated quaternion
  84698. */
  84699. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84700. /**
  84701. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84702. * @param yaw defines the rotation around Y axis
  84703. * @param pitch defines the rotation around X axis
  84704. * @param roll defines the rotation around Z axis
  84705. * @returns the new quaternion
  84706. */
  84707. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84708. /**
  84709. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84710. * @param yaw defines the rotation around Y axis
  84711. * @param pitch defines the rotation around X axis
  84712. * @param roll defines the rotation around Z axis
  84713. * @param result defines the target quaternion
  84714. */
  84715. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84716. /**
  84717. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84718. * @param alpha defines the rotation around first axis
  84719. * @param beta defines the rotation around second axis
  84720. * @param gamma defines the rotation around third axis
  84721. * @returns the new quaternion
  84722. */
  84723. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84724. /**
  84725. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84726. * @param alpha defines the rotation around first axis
  84727. * @param beta defines the rotation around second axis
  84728. * @param gamma defines the rotation around third axis
  84729. * @param result defines the target quaternion
  84730. */
  84731. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84732. /**
  84733. * 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)
  84734. * @param axis1 defines the first axis
  84735. * @param axis2 defines the second axis
  84736. * @param axis3 defines the third axis
  84737. * @returns the new quaternion
  84738. */
  84739. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84740. /**
  84741. * 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
  84742. * @param axis1 defines the first axis
  84743. * @param axis2 defines the second axis
  84744. * @param axis3 defines the third axis
  84745. * @param ref defines the target quaternion
  84746. */
  84747. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84748. /**
  84749. * Interpolates between two quaternions
  84750. * @param left defines first quaternion
  84751. * @param right defines second quaternion
  84752. * @param amount defines the gradient to use
  84753. * @returns the new interpolated quaternion
  84754. */
  84755. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84756. /**
  84757. * Interpolates between two quaternions and stores it into a target quaternion
  84758. * @param left defines first quaternion
  84759. * @param right defines second quaternion
  84760. * @param amount defines the gradient to use
  84761. * @param result defines the target quaternion
  84762. */
  84763. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84764. /**
  84765. * Interpolate between two quaternions using Hermite interpolation
  84766. * @param value1 defines first quaternion
  84767. * @param tangent1 defines the incoming tangent
  84768. * @param value2 defines second quaternion
  84769. * @param tangent2 defines the outgoing tangent
  84770. * @param amount defines the target quaternion
  84771. * @returns the new interpolated quaternion
  84772. */
  84773. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84774. }
  84775. /**
  84776. * Class used to store matrix data (4x4)
  84777. */
  84778. export class Matrix {
  84779. /**
  84780. * Gets the precision of matrix computations
  84781. */
  84782. static get Use64Bits(): boolean;
  84783. private static _updateFlagSeed;
  84784. private static _identityReadOnly;
  84785. private _isIdentity;
  84786. private _isIdentityDirty;
  84787. private _isIdentity3x2;
  84788. private _isIdentity3x2Dirty;
  84789. /**
  84790. * Gets the update flag of the matrix which is an unique number for the matrix.
  84791. * It will be incremented every time the matrix data change.
  84792. * You can use it to speed the comparison between two versions of the same matrix.
  84793. */
  84794. updateFlag: number;
  84795. private readonly _m;
  84796. /**
  84797. * Gets the internal data of the matrix
  84798. */
  84799. get m(): DeepImmutable<Float32Array | Array<number>>;
  84800. /** @hidden */
  84801. _markAsUpdated(): void;
  84802. /** @hidden */
  84803. private _updateIdentityStatus;
  84804. /**
  84805. * Creates an empty matrix (filled with zeros)
  84806. */
  84807. constructor();
  84808. /**
  84809. * Check if the current matrix is identity
  84810. * @returns true is the matrix is the identity matrix
  84811. */
  84812. isIdentity(): boolean;
  84813. /**
  84814. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84815. * @returns true is the matrix is the identity matrix
  84816. */
  84817. isIdentityAs3x2(): boolean;
  84818. /**
  84819. * Gets the determinant of the matrix
  84820. * @returns the matrix determinant
  84821. */
  84822. determinant(): number;
  84823. /**
  84824. * Returns the matrix as a Float32Array or Array<number>
  84825. * @returns the matrix underlying array
  84826. */
  84827. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84828. /**
  84829. * Returns the matrix as a Float32Array or Array<number>
  84830. * @returns the matrix underlying array.
  84831. */
  84832. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84833. /**
  84834. * Inverts the current matrix in place
  84835. * @returns the current inverted matrix
  84836. */
  84837. invert(): Matrix;
  84838. /**
  84839. * Sets all the matrix elements to zero
  84840. * @returns the current matrix
  84841. */
  84842. reset(): Matrix;
  84843. /**
  84844. * Adds the current matrix with a second one
  84845. * @param other defines the matrix to add
  84846. * @returns a new matrix as the addition of the current matrix and the given one
  84847. */
  84848. add(other: DeepImmutable<Matrix>): Matrix;
  84849. /**
  84850. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84851. * @param other defines the matrix to add
  84852. * @param result defines the target matrix
  84853. * @returns the current matrix
  84854. */
  84855. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84856. /**
  84857. * Adds in place the given matrix to the current matrix
  84858. * @param other defines the second operand
  84859. * @returns the current updated matrix
  84860. */
  84861. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84862. /**
  84863. * Sets the given matrix to the current inverted Matrix
  84864. * @param other defines the target matrix
  84865. * @returns the unmodified current matrix
  84866. */
  84867. invertToRef(other: Matrix): Matrix;
  84868. /**
  84869. * add a value at the specified position in the current Matrix
  84870. * @param index the index of the value within the matrix. between 0 and 15.
  84871. * @param value the value to be added
  84872. * @returns the current updated matrix
  84873. */
  84874. addAtIndex(index: number, value: number): Matrix;
  84875. /**
  84876. * mutiply the specified position in the current Matrix by a value
  84877. * @param index the index of the value within the matrix. between 0 and 15.
  84878. * @param value the value to be added
  84879. * @returns the current updated matrix
  84880. */
  84881. multiplyAtIndex(index: number, value: number): Matrix;
  84882. /**
  84883. * Inserts the translation vector (using 3 floats) in the current matrix
  84884. * @param x defines the 1st component of the translation
  84885. * @param y defines the 2nd component of the translation
  84886. * @param z defines the 3rd component of the translation
  84887. * @returns the current updated matrix
  84888. */
  84889. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84890. /**
  84891. * Adds the translation vector (using 3 floats) in the current matrix
  84892. * @param x defines the 1st component of the translation
  84893. * @param y defines the 2nd component of the translation
  84894. * @param z defines the 3rd component of the translation
  84895. * @returns the current updated matrix
  84896. */
  84897. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84898. /**
  84899. * Inserts the translation vector in the current matrix
  84900. * @param vector3 defines the translation to insert
  84901. * @returns the current updated matrix
  84902. */
  84903. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84904. /**
  84905. * Gets the translation value of the current matrix
  84906. * @returns a new Vector3 as the extracted translation from the matrix
  84907. */
  84908. getTranslation(): Vector3;
  84909. /**
  84910. * Fill a Vector3 with the extracted translation from the matrix
  84911. * @param result defines the Vector3 where to store the translation
  84912. * @returns the current matrix
  84913. */
  84914. getTranslationToRef(result: Vector3): Matrix;
  84915. /**
  84916. * Remove rotation and scaling part from the matrix
  84917. * @returns the updated matrix
  84918. */
  84919. removeRotationAndScaling(): Matrix;
  84920. /**
  84921. * Multiply two matrices
  84922. * @param other defines the second operand
  84923. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84924. */
  84925. multiply(other: DeepImmutable<Matrix>): Matrix;
  84926. /**
  84927. * Copy the current matrix from the given one
  84928. * @param other defines the source matrix
  84929. * @returns the current updated matrix
  84930. */
  84931. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84932. /**
  84933. * Populates the given array from the starting index with the current matrix values
  84934. * @param array defines the target array
  84935. * @param offset defines the offset in the target array where to start storing values
  84936. * @returns the current matrix
  84937. */
  84938. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84939. /**
  84940. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84941. * @param other defines the second operand
  84942. * @param result defines the matrix where to store the multiplication
  84943. * @returns the current matrix
  84944. */
  84945. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84946. /**
  84947. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84948. * @param other defines the second operand
  84949. * @param result defines the array where to store the multiplication
  84950. * @param offset defines the offset in the target array where to start storing values
  84951. * @returns the current matrix
  84952. */
  84953. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84954. /**
  84955. * Check equality between this matrix and a second one
  84956. * @param value defines the second matrix to compare
  84957. * @returns true is the current matrix and the given one values are strictly equal
  84958. */
  84959. equals(value: DeepImmutable<Matrix>): boolean;
  84960. /**
  84961. * Clone the current matrix
  84962. * @returns a new matrix from the current matrix
  84963. */
  84964. clone(): Matrix;
  84965. /**
  84966. * Returns the name of the current matrix class
  84967. * @returns the string "Matrix"
  84968. */
  84969. getClassName(): string;
  84970. /**
  84971. * Gets the hash code of the current matrix
  84972. * @returns the hash code
  84973. */
  84974. getHashCode(): number;
  84975. /**
  84976. * Decomposes the current Matrix into a translation, rotation and scaling components
  84977. * @param scale defines the scale vector3 given as a reference to update
  84978. * @param rotation defines the rotation quaternion given as a reference to update
  84979. * @param translation defines the translation vector3 given as a reference to update
  84980. * @returns true if operation was successful
  84981. */
  84982. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84983. /**
  84984. * Gets specific row of the matrix
  84985. * @param index defines the number of the row to get
  84986. * @returns the index-th row of the current matrix as a new Vector4
  84987. */
  84988. getRow(index: number): Nullable<Vector4>;
  84989. /**
  84990. * Sets the index-th row of the current matrix to the vector4 values
  84991. * @param index defines the number of the row to set
  84992. * @param row defines the target vector4
  84993. * @returns the updated current matrix
  84994. */
  84995. setRow(index: number, row: Vector4): Matrix;
  84996. /**
  84997. * Compute the transpose of the matrix
  84998. * @returns the new transposed matrix
  84999. */
  85000. transpose(): Matrix;
  85001. /**
  85002. * Compute the transpose of the matrix and store it in a given matrix
  85003. * @param result defines the target matrix
  85004. * @returns the current matrix
  85005. */
  85006. transposeToRef(result: Matrix): Matrix;
  85007. /**
  85008. * Sets the index-th row of the current matrix with the given 4 x float values
  85009. * @param index defines the row index
  85010. * @param x defines the x component to set
  85011. * @param y defines the y component to set
  85012. * @param z defines the z component to set
  85013. * @param w defines the w component to set
  85014. * @returns the updated current matrix
  85015. */
  85016. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  85017. /**
  85018. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  85019. * @param scale defines the scale factor
  85020. * @returns a new matrix
  85021. */
  85022. scale(scale: number): Matrix;
  85023. /**
  85024. * Scale the current matrix values by a factor to a given result matrix
  85025. * @param scale defines the scale factor
  85026. * @param result defines the matrix to store the result
  85027. * @returns the current matrix
  85028. */
  85029. scaleToRef(scale: number, result: Matrix): Matrix;
  85030. /**
  85031. * Scale the current matrix values by a factor and add the result to a given matrix
  85032. * @param scale defines the scale factor
  85033. * @param result defines the Matrix to store the result
  85034. * @returns the current matrix
  85035. */
  85036. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  85037. /**
  85038. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  85039. * @param ref matrix to store the result
  85040. */
  85041. toNormalMatrix(ref: Matrix): void;
  85042. /**
  85043. * Gets only rotation part of the current matrix
  85044. * @returns a new matrix sets to the extracted rotation matrix from the current one
  85045. */
  85046. getRotationMatrix(): Matrix;
  85047. /**
  85048. * Extracts the rotation matrix from the current one and sets it as the given "result"
  85049. * @param result defines the target matrix to store data to
  85050. * @returns the current matrix
  85051. */
  85052. getRotationMatrixToRef(result: Matrix): Matrix;
  85053. /**
  85054. * Toggles model matrix from being right handed to left handed in place and vice versa
  85055. */
  85056. toggleModelMatrixHandInPlace(): void;
  85057. /**
  85058. * Toggles projection matrix from being right handed to left handed in place and vice versa
  85059. */
  85060. toggleProjectionMatrixHandInPlace(): void;
  85061. /**
  85062. * Creates a matrix from an array
  85063. * @param array defines the source array
  85064. * @param offset defines an offset in the source array
  85065. * @returns a new Matrix set from the starting index of the given array
  85066. */
  85067. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  85068. /**
  85069. * Copy the content of an array into a given matrix
  85070. * @param array defines the source array
  85071. * @param offset defines an offset in the source array
  85072. * @param result defines the target matrix
  85073. */
  85074. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  85075. /**
  85076. * Stores an array into a matrix after having multiplied each component by a given factor
  85077. * @param array defines the source array
  85078. * @param offset defines the offset in the source array
  85079. * @param scale defines the scaling factor
  85080. * @param result defines the target matrix
  85081. */
  85082. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  85083. /**
  85084. * Gets an identity matrix that must not be updated
  85085. */
  85086. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85087. /**
  85088. * Stores a list of values (16) inside a given matrix
  85089. * @param initialM11 defines 1st value of 1st row
  85090. * @param initialM12 defines 2nd value of 1st row
  85091. * @param initialM13 defines 3rd value of 1st row
  85092. * @param initialM14 defines 4th value of 1st row
  85093. * @param initialM21 defines 1st value of 2nd row
  85094. * @param initialM22 defines 2nd value of 2nd row
  85095. * @param initialM23 defines 3rd value of 2nd row
  85096. * @param initialM24 defines 4th value of 2nd row
  85097. * @param initialM31 defines 1st value of 3rd row
  85098. * @param initialM32 defines 2nd value of 3rd row
  85099. * @param initialM33 defines 3rd value of 3rd row
  85100. * @param initialM34 defines 4th value of 3rd row
  85101. * @param initialM41 defines 1st value of 4th row
  85102. * @param initialM42 defines 2nd value of 4th row
  85103. * @param initialM43 defines 3rd value of 4th row
  85104. * @param initialM44 defines 4th value of 4th row
  85105. * @param result defines the target matrix
  85106. */
  85107. 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;
  85108. /**
  85109. * Creates new matrix from a list of values (16)
  85110. * @param initialM11 defines 1st value of 1st row
  85111. * @param initialM12 defines 2nd value of 1st row
  85112. * @param initialM13 defines 3rd value of 1st row
  85113. * @param initialM14 defines 4th value of 1st row
  85114. * @param initialM21 defines 1st value of 2nd row
  85115. * @param initialM22 defines 2nd value of 2nd row
  85116. * @param initialM23 defines 3rd value of 2nd row
  85117. * @param initialM24 defines 4th value of 2nd row
  85118. * @param initialM31 defines 1st value of 3rd row
  85119. * @param initialM32 defines 2nd value of 3rd row
  85120. * @param initialM33 defines 3rd value of 3rd row
  85121. * @param initialM34 defines 4th value of 3rd row
  85122. * @param initialM41 defines 1st value of 4th row
  85123. * @param initialM42 defines 2nd value of 4th row
  85124. * @param initialM43 defines 3rd value of 4th row
  85125. * @param initialM44 defines 4th value of 4th row
  85126. * @returns the new matrix
  85127. */
  85128. 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;
  85129. /**
  85130. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85131. * @param scale defines the scale vector3
  85132. * @param rotation defines the rotation quaternion
  85133. * @param translation defines the translation vector3
  85134. * @returns a new matrix
  85135. */
  85136. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85137. /**
  85138. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85139. * @param scale defines the scale vector3
  85140. * @param rotation defines the rotation quaternion
  85141. * @param translation defines the translation vector3
  85142. * @param result defines the target matrix
  85143. */
  85144. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85145. /**
  85146. * Creates a new identity matrix
  85147. * @returns a new identity matrix
  85148. */
  85149. static Identity(): Matrix;
  85150. /**
  85151. * Creates a new identity matrix and stores the result in a given matrix
  85152. * @param result defines the target matrix
  85153. */
  85154. static IdentityToRef(result: Matrix): void;
  85155. /**
  85156. * Creates a new zero matrix
  85157. * @returns a new zero matrix
  85158. */
  85159. static Zero(): Matrix;
  85160. /**
  85161. * Creates a new rotation matrix for "angle" radians around the X axis
  85162. * @param angle defines the angle (in radians) to use
  85163. * @return the new matrix
  85164. */
  85165. static RotationX(angle: number): Matrix;
  85166. /**
  85167. * Creates a new matrix as the invert of a given matrix
  85168. * @param source defines the source matrix
  85169. * @returns the new matrix
  85170. */
  85171. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85172. /**
  85173. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85174. * @param angle defines the angle (in radians) to use
  85175. * @param result defines the target matrix
  85176. */
  85177. static RotationXToRef(angle: number, result: Matrix): void;
  85178. /**
  85179. * Creates a new rotation matrix for "angle" radians around the Y axis
  85180. * @param angle defines the angle (in radians) to use
  85181. * @return the new matrix
  85182. */
  85183. static RotationY(angle: number): Matrix;
  85184. /**
  85185. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85186. * @param angle defines the angle (in radians) to use
  85187. * @param result defines the target matrix
  85188. */
  85189. static RotationYToRef(angle: number, result: Matrix): void;
  85190. /**
  85191. * Creates a new rotation matrix for "angle" radians around the Z axis
  85192. * @param angle defines the angle (in radians) to use
  85193. * @return the new matrix
  85194. */
  85195. static RotationZ(angle: number): Matrix;
  85196. /**
  85197. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85198. * @param angle defines the angle (in radians) to use
  85199. * @param result defines the target matrix
  85200. */
  85201. static RotationZToRef(angle: number, result: Matrix): void;
  85202. /**
  85203. * Creates a new rotation matrix for "angle" radians around the given axis
  85204. * @param axis defines the axis to use
  85205. * @param angle defines the angle (in radians) to use
  85206. * @return the new matrix
  85207. */
  85208. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85209. /**
  85210. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85211. * @param axis defines the axis to use
  85212. * @param angle defines the angle (in radians) to use
  85213. * @param result defines the target matrix
  85214. */
  85215. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85216. /**
  85217. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85218. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85219. * @param from defines the vector to align
  85220. * @param to defines the vector to align to
  85221. * @param result defines the target matrix
  85222. */
  85223. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85224. /**
  85225. * Creates a rotation matrix
  85226. * @param yaw defines the yaw angle in radians (Y axis)
  85227. * @param pitch defines the pitch angle in radians (X axis)
  85228. * @param roll defines the roll angle in radians (Z axis)
  85229. * @returns the new rotation matrix
  85230. */
  85231. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85232. /**
  85233. * Creates a rotation matrix and stores it in a given matrix
  85234. * @param yaw defines the yaw angle in radians (Y axis)
  85235. * @param pitch defines the pitch angle in radians (X axis)
  85236. * @param roll defines the roll angle in radians (Z axis)
  85237. * @param result defines the target matrix
  85238. */
  85239. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85240. /**
  85241. * Creates a scaling matrix
  85242. * @param x defines the scale factor on X axis
  85243. * @param y defines the scale factor on Y axis
  85244. * @param z defines the scale factor on Z axis
  85245. * @returns the new matrix
  85246. */
  85247. static Scaling(x: number, y: number, z: number): Matrix;
  85248. /**
  85249. * Creates a scaling matrix and stores it in a given matrix
  85250. * @param x defines the scale factor on X axis
  85251. * @param y defines the scale factor on Y axis
  85252. * @param z defines the scale factor on Z axis
  85253. * @param result defines the target matrix
  85254. */
  85255. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85256. /**
  85257. * Creates a translation matrix
  85258. * @param x defines the translation on X axis
  85259. * @param y defines the translation on Y axis
  85260. * @param z defines the translationon Z axis
  85261. * @returns the new matrix
  85262. */
  85263. static Translation(x: number, y: number, z: number): Matrix;
  85264. /**
  85265. * Creates a translation matrix and stores it in a given matrix
  85266. * @param x defines the translation on X axis
  85267. * @param y defines the translation on Y axis
  85268. * @param z defines the translationon Z axis
  85269. * @param result defines the target matrix
  85270. */
  85271. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85272. /**
  85273. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85274. * @param startValue defines the start value
  85275. * @param endValue defines the end value
  85276. * @param gradient defines the gradient factor
  85277. * @returns the new matrix
  85278. */
  85279. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85280. /**
  85281. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85282. * @param startValue defines the start value
  85283. * @param endValue defines the end value
  85284. * @param gradient defines the gradient factor
  85285. * @param result defines the Matrix object where to store data
  85286. */
  85287. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85288. /**
  85289. * Builds a new matrix whose values are computed by:
  85290. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85291. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85292. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85293. * @param startValue defines the first matrix
  85294. * @param endValue defines the second matrix
  85295. * @param gradient defines the gradient between the two matrices
  85296. * @returns the new matrix
  85297. */
  85298. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85299. /**
  85300. * Update a matrix to values which are computed by:
  85301. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85302. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85303. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85304. * @param startValue defines the first matrix
  85305. * @param endValue defines the second matrix
  85306. * @param gradient defines the gradient between the two matrices
  85307. * @param result defines the target matrix
  85308. */
  85309. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85310. /**
  85311. * 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"
  85312. * This function works in left handed mode
  85313. * @param eye defines the final position of the entity
  85314. * @param target defines where the entity should look at
  85315. * @param up defines the up vector for the entity
  85316. * @returns the new matrix
  85317. */
  85318. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85319. /**
  85320. * 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".
  85321. * This function works in left handed mode
  85322. * @param eye defines the final position of the entity
  85323. * @param target defines where the entity should look at
  85324. * @param up defines the up vector for the entity
  85325. * @param result defines the target matrix
  85326. */
  85327. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85328. /**
  85329. * 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"
  85330. * This function works in right handed mode
  85331. * @param eye defines the final position of the entity
  85332. * @param target defines where the entity should look at
  85333. * @param up defines the up vector for the entity
  85334. * @returns the new matrix
  85335. */
  85336. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85337. /**
  85338. * 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".
  85339. * This function works in right handed mode
  85340. * @param eye defines the final position of the entity
  85341. * @param target defines where the entity should look at
  85342. * @param up defines the up vector for the entity
  85343. * @param result defines the target matrix
  85344. */
  85345. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85346. /**
  85347. * Create a left-handed orthographic projection matrix
  85348. * @param width defines the viewport width
  85349. * @param height defines the viewport height
  85350. * @param znear defines the near clip plane
  85351. * @param zfar defines the far clip plane
  85352. * @returns a new matrix as a left-handed orthographic projection matrix
  85353. */
  85354. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85355. /**
  85356. * Store a left-handed orthographic projection to a given matrix
  85357. * @param width defines the viewport width
  85358. * @param height defines the viewport height
  85359. * @param znear defines the near clip plane
  85360. * @param zfar defines the far clip plane
  85361. * @param result defines the target matrix
  85362. */
  85363. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85364. /**
  85365. * Create a left-handed orthographic projection matrix
  85366. * @param left defines the viewport left coordinate
  85367. * @param right defines the viewport right coordinate
  85368. * @param bottom defines the viewport bottom coordinate
  85369. * @param top defines the viewport top coordinate
  85370. * @param znear defines the near clip plane
  85371. * @param zfar defines the far clip plane
  85372. * @returns a new matrix as a left-handed orthographic projection matrix
  85373. */
  85374. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85375. /**
  85376. * Stores a left-handed orthographic projection into a given matrix
  85377. * @param left defines the viewport left coordinate
  85378. * @param right defines the viewport right coordinate
  85379. * @param bottom defines the viewport bottom coordinate
  85380. * @param top defines the viewport top coordinate
  85381. * @param znear defines the near clip plane
  85382. * @param zfar defines the far clip plane
  85383. * @param result defines the target matrix
  85384. */
  85385. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85386. /**
  85387. * Creates a right-handed orthographic projection matrix
  85388. * @param left defines the viewport left coordinate
  85389. * @param right defines the viewport right coordinate
  85390. * @param bottom defines the viewport bottom coordinate
  85391. * @param top defines the viewport top coordinate
  85392. * @param znear defines the near clip plane
  85393. * @param zfar defines the far clip plane
  85394. * @returns a new matrix as a right-handed orthographic projection matrix
  85395. */
  85396. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85397. /**
  85398. * Stores a right-handed orthographic projection into a given matrix
  85399. * @param left defines the viewport left coordinate
  85400. * @param right defines the viewport right coordinate
  85401. * @param bottom defines the viewport bottom coordinate
  85402. * @param top defines the viewport top coordinate
  85403. * @param znear defines the near clip plane
  85404. * @param zfar defines the far clip plane
  85405. * @param result defines the target matrix
  85406. */
  85407. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85408. /**
  85409. * Creates a left-handed perspective projection matrix
  85410. * @param width defines the viewport width
  85411. * @param height defines the viewport height
  85412. * @param znear defines the near clip plane
  85413. * @param zfar defines the far clip plane
  85414. * @returns a new matrix as a left-handed perspective projection matrix
  85415. */
  85416. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85417. /**
  85418. * Creates a left-handed perspective projection matrix
  85419. * @param fov defines the horizontal field of view
  85420. * @param aspect defines the aspect ratio
  85421. * @param znear defines the near clip plane
  85422. * @param zfar defines the far clip plane
  85423. * @returns a new matrix as a left-handed perspective projection matrix
  85424. */
  85425. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85426. /**
  85427. * Stores a left-handed perspective projection into a given matrix
  85428. * @param fov defines the horizontal field of view
  85429. * @param aspect defines the aspect ratio
  85430. * @param znear defines the near clip plane
  85431. * @param zfar defines the far clip plane
  85432. * @param result defines the target matrix
  85433. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85434. */
  85435. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85436. /**
  85437. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85438. * @param fov defines the horizontal field of view
  85439. * @param aspect defines the aspect ratio
  85440. * @param znear defines the near clip plane
  85441. * @param zfar not used as infinity is used as far clip
  85442. * @param result defines the target matrix
  85443. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85444. */
  85445. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85446. /**
  85447. * Creates a right-handed perspective projection matrix
  85448. * @param fov defines the horizontal field of view
  85449. * @param aspect defines the aspect ratio
  85450. * @param znear defines the near clip plane
  85451. * @param zfar defines the far clip plane
  85452. * @returns a new matrix as a right-handed perspective projection matrix
  85453. */
  85454. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85455. /**
  85456. * Stores a right-handed perspective projection into a given matrix
  85457. * @param fov defines the horizontal field of view
  85458. * @param aspect defines the aspect ratio
  85459. * @param znear defines the near clip plane
  85460. * @param zfar defines the far clip plane
  85461. * @param result defines the target matrix
  85462. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85463. */
  85464. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85465. /**
  85466. * Stores a right-handed perspective projection into a given matrix
  85467. * @param fov defines the horizontal field of view
  85468. * @param aspect defines the aspect ratio
  85469. * @param znear defines the near clip plane
  85470. * @param zfar not used as infinity is used as far clip
  85471. * @param result defines the target matrix
  85472. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85473. */
  85474. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85475. /**
  85476. * Stores a perspective projection for WebVR info a given matrix
  85477. * @param fov defines the field of view
  85478. * @param znear defines the near clip plane
  85479. * @param zfar defines the far clip plane
  85480. * @param result defines the target matrix
  85481. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85482. */
  85483. static PerspectiveFovWebVRToRef(fov: {
  85484. upDegrees: number;
  85485. downDegrees: number;
  85486. leftDegrees: number;
  85487. rightDegrees: number;
  85488. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85489. /**
  85490. * Computes a complete transformation matrix
  85491. * @param viewport defines the viewport to use
  85492. * @param world defines the world matrix
  85493. * @param view defines the view matrix
  85494. * @param projection defines the projection matrix
  85495. * @param zmin defines the near clip plane
  85496. * @param zmax defines the far clip plane
  85497. * @returns the transformation matrix
  85498. */
  85499. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85500. /**
  85501. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85502. * @param matrix defines the matrix to use
  85503. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85504. */
  85505. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85506. /**
  85507. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85508. * @param matrix defines the matrix to use
  85509. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85510. */
  85511. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85512. /**
  85513. * Compute the transpose of a given matrix
  85514. * @param matrix defines the matrix to transpose
  85515. * @returns the new matrix
  85516. */
  85517. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85518. /**
  85519. * Compute the transpose of a matrix and store it in a target matrix
  85520. * @param matrix defines the matrix to transpose
  85521. * @param result defines the target matrix
  85522. */
  85523. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85524. /**
  85525. * Computes a reflection matrix from a plane
  85526. * @param plane defines the reflection plane
  85527. * @returns a new matrix
  85528. */
  85529. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85530. /**
  85531. * Computes a reflection matrix from a plane
  85532. * @param plane defines the reflection plane
  85533. * @param result defines the target matrix
  85534. */
  85535. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85536. /**
  85537. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85538. * @param xaxis defines the value of the 1st axis
  85539. * @param yaxis defines the value of the 2nd axis
  85540. * @param zaxis defines the value of the 3rd axis
  85541. * @param result defines the target matrix
  85542. */
  85543. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85544. /**
  85545. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85546. * @param quat defines the quaternion to use
  85547. * @param result defines the target matrix
  85548. */
  85549. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85550. }
  85551. /**
  85552. * @hidden
  85553. */
  85554. export class TmpVectors {
  85555. static Vector2: Vector2[];
  85556. static Vector3: Vector3[];
  85557. static Vector4: Vector4[];
  85558. static Quaternion: Quaternion[];
  85559. static Matrix: Matrix[];
  85560. }
  85561. }
  85562. declare module BABYLON {
  85563. /**
  85564. * Defines potential orientation for back face culling
  85565. */
  85566. export enum Orientation {
  85567. /**
  85568. * Clockwise
  85569. */
  85570. CW = 0,
  85571. /** Counter clockwise */
  85572. CCW = 1
  85573. }
  85574. /** Class used to represent a Bezier curve */
  85575. export class BezierCurve {
  85576. /**
  85577. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85578. * @param t defines the time
  85579. * @param x1 defines the left coordinate on X axis
  85580. * @param y1 defines the left coordinate on Y axis
  85581. * @param x2 defines the right coordinate on X axis
  85582. * @param y2 defines the right coordinate on Y axis
  85583. * @returns the interpolated value
  85584. */
  85585. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85586. }
  85587. /**
  85588. * Defines angle representation
  85589. */
  85590. export class Angle {
  85591. private _radians;
  85592. /**
  85593. * Creates an Angle object of "radians" radians (float).
  85594. * @param radians the angle in radians
  85595. */
  85596. constructor(radians: number);
  85597. /**
  85598. * Get value in degrees
  85599. * @returns the Angle value in degrees (float)
  85600. */
  85601. degrees(): number;
  85602. /**
  85603. * Get value in radians
  85604. * @returns the Angle value in radians (float)
  85605. */
  85606. radians(): number;
  85607. /**
  85608. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85609. * @param a defines first point as the origin
  85610. * @param b defines point
  85611. * @returns a new Angle
  85612. */
  85613. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85614. /**
  85615. * Gets a new Angle object from the given float in radians
  85616. * @param radians defines the angle value in radians
  85617. * @returns a new Angle
  85618. */
  85619. static FromRadians(radians: number): Angle;
  85620. /**
  85621. * Gets a new Angle object from the given float in degrees
  85622. * @param degrees defines the angle value in degrees
  85623. * @returns a new Angle
  85624. */
  85625. static FromDegrees(degrees: number): Angle;
  85626. }
  85627. /**
  85628. * This represents an arc in a 2d space.
  85629. */
  85630. export class Arc2 {
  85631. /** Defines the start point of the arc */
  85632. startPoint: Vector2;
  85633. /** Defines the mid point of the arc */
  85634. midPoint: Vector2;
  85635. /** Defines the end point of the arc */
  85636. endPoint: Vector2;
  85637. /**
  85638. * Defines the center point of the arc.
  85639. */
  85640. centerPoint: Vector2;
  85641. /**
  85642. * Defines the radius of the arc.
  85643. */
  85644. radius: number;
  85645. /**
  85646. * Defines the angle of the arc (from mid point to end point).
  85647. */
  85648. angle: Angle;
  85649. /**
  85650. * Defines the start angle of the arc (from start point to middle point).
  85651. */
  85652. startAngle: Angle;
  85653. /**
  85654. * Defines the orientation of the arc (clock wise/counter clock wise).
  85655. */
  85656. orientation: Orientation;
  85657. /**
  85658. * Creates an Arc object from the three given points : start, middle and end.
  85659. * @param startPoint Defines the start point of the arc
  85660. * @param midPoint Defines the midlle point of the arc
  85661. * @param endPoint Defines the end point of the arc
  85662. */
  85663. constructor(
  85664. /** Defines the start point of the arc */
  85665. startPoint: Vector2,
  85666. /** Defines the mid point of the arc */
  85667. midPoint: Vector2,
  85668. /** Defines the end point of the arc */
  85669. endPoint: Vector2);
  85670. }
  85671. /**
  85672. * Represents a 2D path made up of multiple 2D points
  85673. */
  85674. export class Path2 {
  85675. private _points;
  85676. private _length;
  85677. /**
  85678. * If the path start and end point are the same
  85679. */
  85680. closed: boolean;
  85681. /**
  85682. * Creates a Path2 object from the starting 2D coordinates x and y.
  85683. * @param x the starting points x value
  85684. * @param y the starting points y value
  85685. */
  85686. constructor(x: number, y: number);
  85687. /**
  85688. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85689. * @param x the added points x value
  85690. * @param y the added points y value
  85691. * @returns the updated Path2.
  85692. */
  85693. addLineTo(x: number, y: number): Path2;
  85694. /**
  85695. * 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.
  85696. * @param midX middle point x value
  85697. * @param midY middle point y value
  85698. * @param endX end point x value
  85699. * @param endY end point y value
  85700. * @param numberOfSegments (default: 36)
  85701. * @returns the updated Path2.
  85702. */
  85703. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85704. /**
  85705. * Closes the Path2.
  85706. * @returns the Path2.
  85707. */
  85708. close(): Path2;
  85709. /**
  85710. * Gets the sum of the distance between each sequential point in the path
  85711. * @returns the Path2 total length (float).
  85712. */
  85713. length(): number;
  85714. /**
  85715. * Gets the points which construct the path
  85716. * @returns the Path2 internal array of points.
  85717. */
  85718. getPoints(): Vector2[];
  85719. /**
  85720. * Retreives the point at the distance aways from the starting point
  85721. * @param normalizedLengthPosition the length along the path to retreive the point from
  85722. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85723. */
  85724. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85725. /**
  85726. * Creates a new path starting from an x and y position
  85727. * @param x starting x value
  85728. * @param y starting y value
  85729. * @returns a new Path2 starting at the coordinates (x, y).
  85730. */
  85731. static StartingAt(x: number, y: number): Path2;
  85732. }
  85733. /**
  85734. * Represents a 3D path made up of multiple 3D points
  85735. */
  85736. export class Path3D {
  85737. /**
  85738. * an array of Vector3, the curve axis of the Path3D
  85739. */
  85740. path: Vector3[];
  85741. private _curve;
  85742. private _distances;
  85743. private _tangents;
  85744. private _normals;
  85745. private _binormals;
  85746. private _raw;
  85747. private _alignTangentsWithPath;
  85748. private readonly _pointAtData;
  85749. /**
  85750. * new Path3D(path, normal, raw)
  85751. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85752. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85753. * @param path an array of Vector3, the curve axis of the Path3D
  85754. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85755. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85756. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85757. */
  85758. constructor(
  85759. /**
  85760. * an array of Vector3, the curve axis of the Path3D
  85761. */
  85762. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85763. /**
  85764. * Returns the Path3D array of successive Vector3 designing its curve.
  85765. * @returns the Path3D array of successive Vector3 designing its curve.
  85766. */
  85767. getCurve(): Vector3[];
  85768. /**
  85769. * Returns the Path3D array of successive Vector3 designing its curve.
  85770. * @returns the Path3D array of successive Vector3 designing its curve.
  85771. */
  85772. getPoints(): Vector3[];
  85773. /**
  85774. * @returns the computed length (float) of the path.
  85775. */
  85776. length(): number;
  85777. /**
  85778. * Returns an array populated with tangent vectors on each Path3D curve point.
  85779. * @returns an array populated with tangent vectors on each Path3D curve point.
  85780. */
  85781. getTangents(): Vector3[];
  85782. /**
  85783. * Returns an array populated with normal vectors on each Path3D curve point.
  85784. * @returns an array populated with normal vectors on each Path3D curve point.
  85785. */
  85786. getNormals(): Vector3[];
  85787. /**
  85788. * Returns an array populated with binormal vectors on each Path3D curve point.
  85789. * @returns an array populated with binormal vectors on each Path3D curve point.
  85790. */
  85791. getBinormals(): Vector3[];
  85792. /**
  85793. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85794. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85795. */
  85796. getDistances(): number[];
  85797. /**
  85798. * Returns an interpolated point along this path
  85799. * @param position the position of the point along this path, from 0.0 to 1.0
  85800. * @returns a new Vector3 as the point
  85801. */
  85802. getPointAt(position: number): Vector3;
  85803. /**
  85804. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85805. * @param position the position of the point along this path, from 0.0 to 1.0
  85806. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85807. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85808. */
  85809. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85810. /**
  85811. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85812. * @param position the position of the point along this path, from 0.0 to 1.0
  85813. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85814. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85815. */
  85816. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85817. /**
  85818. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85819. * @param position the position of the point along this path, from 0.0 to 1.0
  85820. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85821. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85822. */
  85823. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85824. /**
  85825. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85826. * @param position the position of the point along this path, from 0.0 to 1.0
  85827. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85828. */
  85829. getDistanceAt(position: number): number;
  85830. /**
  85831. * Returns the array index of the previous point of an interpolated point along this path
  85832. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85833. * @returns the array index
  85834. */
  85835. getPreviousPointIndexAt(position: number): number;
  85836. /**
  85837. * 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)
  85838. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85839. * @returns the sub position
  85840. */
  85841. getSubPositionAt(position: number): number;
  85842. /**
  85843. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85844. * @param target the vector of which to get the closest position to
  85845. * @returns the position of the closest virtual point on this path to the target vector
  85846. */
  85847. getClosestPositionTo(target: Vector3): number;
  85848. /**
  85849. * Returns a sub path (slice) of this path
  85850. * @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
  85851. * @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
  85852. * @returns a sub path (slice) of this path
  85853. */
  85854. slice(start?: number, end?: number): Path3D;
  85855. /**
  85856. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85857. * @param path path which all values are copied into the curves points
  85858. * @param firstNormal which should be projected onto the curve
  85859. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85860. * @returns the same object updated.
  85861. */
  85862. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85863. private _compute;
  85864. private _getFirstNonNullVector;
  85865. private _getLastNonNullVector;
  85866. private _normalVector;
  85867. /**
  85868. * Updates the point at data for an interpolated point along this curve
  85869. * @param position the position of the point along this curve, from 0.0 to 1.0
  85870. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85871. * @returns the (updated) point at data
  85872. */
  85873. private _updatePointAtData;
  85874. /**
  85875. * Updates the point at data from the specified parameters
  85876. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85877. * @param point the interpolated point
  85878. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85879. */
  85880. private _setPointAtData;
  85881. /**
  85882. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85883. */
  85884. private _updateInterpolationMatrix;
  85885. }
  85886. /**
  85887. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85888. * A Curve3 is designed from a series of successive Vector3.
  85889. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85890. */
  85891. export class Curve3 {
  85892. private _points;
  85893. private _length;
  85894. /**
  85895. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85896. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85897. * @param v1 (Vector3) the control point
  85898. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85899. * @param nbPoints (integer) the wanted number of points in the curve
  85900. * @returns the created Curve3
  85901. */
  85902. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85903. /**
  85904. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85905. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85906. * @param v1 (Vector3) the first control point
  85907. * @param v2 (Vector3) the second control point
  85908. * @param v3 (Vector3) the end point of the Cubic Bezier
  85909. * @param nbPoints (integer) the wanted number of points in the curve
  85910. * @returns the created Curve3
  85911. */
  85912. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85913. /**
  85914. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85915. * @param p1 (Vector3) the origin point of the Hermite Spline
  85916. * @param t1 (Vector3) the tangent vector at the origin point
  85917. * @param p2 (Vector3) the end point of the Hermite Spline
  85918. * @param t2 (Vector3) the tangent vector at the end point
  85919. * @param nbPoints (integer) the wanted number of points in the curve
  85920. * @returns the created Curve3
  85921. */
  85922. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85923. /**
  85924. * Returns a Curve3 object along a CatmullRom Spline curve :
  85925. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85926. * @param nbPoints (integer) the wanted number of points between each curve control points
  85927. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85928. * @returns the created Curve3
  85929. */
  85930. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85931. /**
  85932. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85933. * A Curve3 is designed from a series of successive Vector3.
  85934. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85935. * @param points points which make up the curve
  85936. */
  85937. constructor(points: Vector3[]);
  85938. /**
  85939. * @returns the Curve3 stored array of successive Vector3
  85940. */
  85941. getPoints(): Vector3[];
  85942. /**
  85943. * @returns the computed length (float) of the curve.
  85944. */
  85945. length(): number;
  85946. /**
  85947. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85948. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85949. * curveA and curveB keep unchanged.
  85950. * @param curve the curve to continue from this curve
  85951. * @returns the newly constructed curve
  85952. */
  85953. continue(curve: DeepImmutable<Curve3>): Curve3;
  85954. private _computeLength;
  85955. }
  85956. }
  85957. declare module BABYLON {
  85958. /**
  85959. * This represents the main contract an easing function should follow.
  85960. * Easing functions are used throughout the animation system.
  85961. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85962. */
  85963. export interface IEasingFunction {
  85964. /**
  85965. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85966. * of the easing function.
  85967. * The link below provides some of the most common examples of easing functions.
  85968. * @see https://easings.net/
  85969. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85970. * @returns the corresponding value on the curve defined by the easing function
  85971. */
  85972. ease(gradient: number): number;
  85973. }
  85974. /**
  85975. * Base class used for every default easing function.
  85976. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85977. */
  85978. export class EasingFunction implements IEasingFunction {
  85979. /**
  85980. * Interpolation follows the mathematical formula associated with the easing function.
  85981. */
  85982. static readonly EASINGMODE_EASEIN: number;
  85983. /**
  85984. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85985. */
  85986. static readonly EASINGMODE_EASEOUT: number;
  85987. /**
  85988. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85989. */
  85990. static readonly EASINGMODE_EASEINOUT: number;
  85991. private _easingMode;
  85992. /**
  85993. * Sets the easing mode of the current function.
  85994. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85995. */
  85996. setEasingMode(easingMode: number): void;
  85997. /**
  85998. * Gets the current easing mode.
  85999. * @returns the easing mode
  86000. */
  86001. getEasingMode(): number;
  86002. /**
  86003. * @hidden
  86004. */
  86005. easeInCore(gradient: number): number;
  86006. /**
  86007. * Given an input gradient between 0 and 1, this returns the corresponding value
  86008. * of the easing function.
  86009. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86010. * @returns the corresponding value on the curve defined by the easing function
  86011. */
  86012. ease(gradient: number): number;
  86013. }
  86014. /**
  86015. * Easing function with a circle shape (see link below).
  86016. * @see https://easings.net/#easeInCirc
  86017. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86018. */
  86019. export class CircleEase extends EasingFunction implements IEasingFunction {
  86020. /** @hidden */
  86021. easeInCore(gradient: number): number;
  86022. }
  86023. /**
  86024. * Easing function with a ease back shape (see link below).
  86025. * @see https://easings.net/#easeInBack
  86026. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86027. */
  86028. export class BackEase extends EasingFunction implements IEasingFunction {
  86029. /** Defines the amplitude of the function */
  86030. amplitude: number;
  86031. /**
  86032. * Instantiates a back ease easing
  86033. * @see https://easings.net/#easeInBack
  86034. * @param amplitude Defines the amplitude of the function
  86035. */
  86036. constructor(
  86037. /** Defines the amplitude of the function */
  86038. amplitude?: number);
  86039. /** @hidden */
  86040. easeInCore(gradient: number): number;
  86041. }
  86042. /**
  86043. * Easing function with a bouncing shape (see link below).
  86044. * @see https://easings.net/#easeInBounce
  86045. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86046. */
  86047. export class BounceEase extends EasingFunction implements IEasingFunction {
  86048. /** Defines the number of bounces */
  86049. bounces: number;
  86050. /** Defines the amplitude of the bounce */
  86051. bounciness: number;
  86052. /**
  86053. * Instantiates a bounce easing
  86054. * @see https://easings.net/#easeInBounce
  86055. * @param bounces Defines the number of bounces
  86056. * @param bounciness Defines the amplitude of the bounce
  86057. */
  86058. constructor(
  86059. /** Defines the number of bounces */
  86060. bounces?: number,
  86061. /** Defines the amplitude of the bounce */
  86062. bounciness?: number);
  86063. /** @hidden */
  86064. easeInCore(gradient: number): number;
  86065. }
  86066. /**
  86067. * Easing function with a power of 3 shape (see link below).
  86068. * @see https://easings.net/#easeInCubic
  86069. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86070. */
  86071. export class CubicEase extends EasingFunction implements IEasingFunction {
  86072. /** @hidden */
  86073. easeInCore(gradient: number): number;
  86074. }
  86075. /**
  86076. * Easing function with an elastic shape (see link below).
  86077. * @see https://easings.net/#easeInElastic
  86078. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86079. */
  86080. export class ElasticEase extends EasingFunction implements IEasingFunction {
  86081. /** Defines the number of oscillations*/
  86082. oscillations: number;
  86083. /** Defines the amplitude of the oscillations*/
  86084. springiness: number;
  86085. /**
  86086. * Instantiates an elastic easing function
  86087. * @see https://easings.net/#easeInElastic
  86088. * @param oscillations Defines the number of oscillations
  86089. * @param springiness Defines the amplitude of the oscillations
  86090. */
  86091. constructor(
  86092. /** Defines the number of oscillations*/
  86093. oscillations?: number,
  86094. /** Defines the amplitude of the oscillations*/
  86095. springiness?: number);
  86096. /** @hidden */
  86097. easeInCore(gradient: number): number;
  86098. }
  86099. /**
  86100. * Easing function with an exponential shape (see link below).
  86101. * @see https://easings.net/#easeInExpo
  86102. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86103. */
  86104. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86105. /** Defines the exponent of the function */
  86106. exponent: number;
  86107. /**
  86108. * Instantiates an exponential easing function
  86109. * @see https://easings.net/#easeInExpo
  86110. * @param exponent Defines the exponent of the function
  86111. */
  86112. constructor(
  86113. /** Defines the exponent of the function */
  86114. exponent?: number);
  86115. /** @hidden */
  86116. easeInCore(gradient: number): number;
  86117. }
  86118. /**
  86119. * Easing function with a power shape (see link below).
  86120. * @see https://easings.net/#easeInQuad
  86121. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86122. */
  86123. export class PowerEase extends EasingFunction implements IEasingFunction {
  86124. /** Defines the power of the function */
  86125. power: number;
  86126. /**
  86127. * Instantiates an power base easing function
  86128. * @see https://easings.net/#easeInQuad
  86129. * @param power Defines the power of the function
  86130. */
  86131. constructor(
  86132. /** Defines the power of the function */
  86133. power?: number);
  86134. /** @hidden */
  86135. easeInCore(gradient: number): number;
  86136. }
  86137. /**
  86138. * Easing function with a power of 2 shape (see link below).
  86139. * @see https://easings.net/#easeInQuad
  86140. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86141. */
  86142. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86143. /** @hidden */
  86144. easeInCore(gradient: number): number;
  86145. }
  86146. /**
  86147. * Easing function with a power of 4 shape (see link below).
  86148. * @see https://easings.net/#easeInQuart
  86149. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86150. */
  86151. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86152. /** @hidden */
  86153. easeInCore(gradient: number): number;
  86154. }
  86155. /**
  86156. * Easing function with a power of 5 shape (see link below).
  86157. * @see https://easings.net/#easeInQuint
  86158. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86159. */
  86160. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86161. /** @hidden */
  86162. easeInCore(gradient: number): number;
  86163. }
  86164. /**
  86165. * Easing function with a sin shape (see link below).
  86166. * @see https://easings.net/#easeInSine
  86167. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86168. */
  86169. export class SineEase extends EasingFunction implements IEasingFunction {
  86170. /** @hidden */
  86171. easeInCore(gradient: number): number;
  86172. }
  86173. /**
  86174. * Easing function with a bezier shape (see link below).
  86175. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86176. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86177. */
  86178. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86179. /** Defines the x component of the start tangent in the bezier curve */
  86180. x1: number;
  86181. /** Defines the y component of the start tangent in the bezier curve */
  86182. y1: number;
  86183. /** Defines the x component of the end tangent in the bezier curve */
  86184. x2: number;
  86185. /** Defines the y component of the end tangent in the bezier curve */
  86186. y2: number;
  86187. /**
  86188. * Instantiates a bezier function
  86189. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86190. * @param x1 Defines the x component of the start tangent in the bezier curve
  86191. * @param y1 Defines the y component of the start tangent in the bezier curve
  86192. * @param x2 Defines the x component of the end tangent in the bezier curve
  86193. * @param y2 Defines the y component of the end tangent in the bezier curve
  86194. */
  86195. constructor(
  86196. /** Defines the x component of the start tangent in the bezier curve */
  86197. x1?: number,
  86198. /** Defines the y component of the start tangent in the bezier curve */
  86199. y1?: number,
  86200. /** Defines the x component of the end tangent in the bezier curve */
  86201. x2?: number,
  86202. /** Defines the y component of the end tangent in the bezier curve */
  86203. y2?: number);
  86204. /** @hidden */
  86205. easeInCore(gradient: number): number;
  86206. }
  86207. }
  86208. declare module BABYLON {
  86209. /**
  86210. * Class used to hold a RBG color
  86211. */
  86212. export class Color3 {
  86213. /**
  86214. * Defines the red component (between 0 and 1, default is 0)
  86215. */
  86216. r: number;
  86217. /**
  86218. * Defines the green component (between 0 and 1, default is 0)
  86219. */
  86220. g: number;
  86221. /**
  86222. * Defines the blue component (between 0 and 1, default is 0)
  86223. */
  86224. b: number;
  86225. /**
  86226. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86227. * @param r defines the red component (between 0 and 1, default is 0)
  86228. * @param g defines the green component (between 0 and 1, default is 0)
  86229. * @param b defines the blue component (between 0 and 1, default is 0)
  86230. */
  86231. constructor(
  86232. /**
  86233. * Defines the red component (between 0 and 1, default is 0)
  86234. */
  86235. r?: number,
  86236. /**
  86237. * Defines the green component (between 0 and 1, default is 0)
  86238. */
  86239. g?: number,
  86240. /**
  86241. * Defines the blue component (between 0 and 1, default is 0)
  86242. */
  86243. b?: number);
  86244. /**
  86245. * Creates a string with the Color3 current values
  86246. * @returns the string representation of the Color3 object
  86247. */
  86248. toString(): string;
  86249. /**
  86250. * Returns the string "Color3"
  86251. * @returns "Color3"
  86252. */
  86253. getClassName(): string;
  86254. /**
  86255. * Compute the Color3 hash code
  86256. * @returns an unique number that can be used to hash Color3 objects
  86257. */
  86258. getHashCode(): number;
  86259. /**
  86260. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86261. * @param array defines the array where to store the r,g,b components
  86262. * @param index defines an optional index in the target array to define where to start storing values
  86263. * @returns the current Color3 object
  86264. */
  86265. toArray(array: FloatArray, index?: number): Color3;
  86266. /**
  86267. * Update the current color with values stored in an array from the starting index of the given array
  86268. * @param array defines the source array
  86269. * @param offset defines an offset in the source array
  86270. * @returns the current Color3 object
  86271. */
  86272. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86273. /**
  86274. * Returns a new Color4 object from the current Color3 and the given alpha
  86275. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86276. * @returns a new Color4 object
  86277. */
  86278. toColor4(alpha?: number): Color4;
  86279. /**
  86280. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86281. * @returns the new array
  86282. */
  86283. asArray(): number[];
  86284. /**
  86285. * Returns the luminance value
  86286. * @returns a float value
  86287. */
  86288. toLuminance(): number;
  86289. /**
  86290. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86291. * @param otherColor defines the second operand
  86292. * @returns the new Color3 object
  86293. */
  86294. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86295. /**
  86296. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86297. * @param otherColor defines the second operand
  86298. * @param result defines the Color3 object where to store the result
  86299. * @returns the current Color3
  86300. */
  86301. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86302. /**
  86303. * Determines equality between Color3 objects
  86304. * @param otherColor defines the second operand
  86305. * @returns true if the rgb values are equal to the given ones
  86306. */
  86307. equals(otherColor: DeepImmutable<Color3>): boolean;
  86308. /**
  86309. * Determines equality between the current Color3 object and a set of r,b,g values
  86310. * @param r defines the red component to check
  86311. * @param g defines the green component to check
  86312. * @param b defines the blue component to check
  86313. * @returns true if the rgb values are equal to the given ones
  86314. */
  86315. equalsFloats(r: number, g: number, b: number): boolean;
  86316. /**
  86317. * Multiplies in place each rgb value by scale
  86318. * @param scale defines the scaling factor
  86319. * @returns the updated Color3
  86320. */
  86321. scale(scale: number): Color3;
  86322. /**
  86323. * Multiplies the rgb values by scale and stores the result into "result"
  86324. * @param scale defines the scaling factor
  86325. * @param result defines the Color3 object where to store the result
  86326. * @returns the unmodified current Color3
  86327. */
  86328. scaleToRef(scale: number, result: Color3): Color3;
  86329. /**
  86330. * Scale the current Color3 values by a factor and add the result to a given Color3
  86331. * @param scale defines the scale factor
  86332. * @param result defines color to store the result into
  86333. * @returns the unmodified current Color3
  86334. */
  86335. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86336. /**
  86337. * Clamps the rgb values by the min and max values and stores the result into "result"
  86338. * @param min defines minimum clamping value (default is 0)
  86339. * @param max defines maximum clamping value (default is 1)
  86340. * @param result defines color to store the result into
  86341. * @returns the original Color3
  86342. */
  86343. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86344. /**
  86345. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86346. * @param otherColor defines the second operand
  86347. * @returns the new Color3
  86348. */
  86349. add(otherColor: DeepImmutable<Color3>): Color3;
  86350. /**
  86351. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86352. * @param otherColor defines the second operand
  86353. * @param result defines Color3 object to store the result into
  86354. * @returns the unmodified current Color3
  86355. */
  86356. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86357. /**
  86358. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86359. * @param otherColor defines the second operand
  86360. * @returns the new Color3
  86361. */
  86362. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86363. /**
  86364. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86365. * @param otherColor defines the second operand
  86366. * @param result defines Color3 object to store the result into
  86367. * @returns the unmodified current Color3
  86368. */
  86369. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86370. /**
  86371. * Copy the current object
  86372. * @returns a new Color3 copied the current one
  86373. */
  86374. clone(): Color3;
  86375. /**
  86376. * Copies the rgb values from the source in the current Color3
  86377. * @param source defines the source Color3 object
  86378. * @returns the updated Color3 object
  86379. */
  86380. copyFrom(source: DeepImmutable<Color3>): Color3;
  86381. /**
  86382. * Updates the Color3 rgb values from the given floats
  86383. * @param r defines the red component to read from
  86384. * @param g defines the green component to read from
  86385. * @param b defines the blue component to read from
  86386. * @returns the current Color3 object
  86387. */
  86388. copyFromFloats(r: number, g: number, b: number): Color3;
  86389. /**
  86390. * Updates the Color3 rgb values from the given floats
  86391. * @param r defines the red component to read from
  86392. * @param g defines the green component to read from
  86393. * @param b defines the blue component to read from
  86394. * @returns the current Color3 object
  86395. */
  86396. set(r: number, g: number, b: number): Color3;
  86397. /**
  86398. * Compute the Color3 hexadecimal code as a string
  86399. * @returns a string containing the hexadecimal representation of the Color3 object
  86400. */
  86401. toHexString(): string;
  86402. /**
  86403. * Computes a new Color3 converted from the current one to linear space
  86404. * @returns a new Color3 object
  86405. */
  86406. toLinearSpace(): Color3;
  86407. /**
  86408. * Converts current color in rgb space to HSV values
  86409. * @returns a new color3 representing the HSV values
  86410. */
  86411. toHSV(): Color3;
  86412. /**
  86413. * Converts current color in rgb space to HSV values
  86414. * @param result defines the Color3 where to store the HSV values
  86415. */
  86416. toHSVToRef(result: Color3): void;
  86417. /**
  86418. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86419. * @param convertedColor defines the Color3 object where to store the linear space version
  86420. * @returns the unmodified Color3
  86421. */
  86422. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86423. /**
  86424. * Computes a new Color3 converted from the current one to gamma space
  86425. * @returns a new Color3 object
  86426. */
  86427. toGammaSpace(): Color3;
  86428. /**
  86429. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86430. * @param convertedColor defines the Color3 object where to store the gamma space version
  86431. * @returns the unmodified Color3
  86432. */
  86433. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86434. private static _BlackReadOnly;
  86435. /**
  86436. * Convert Hue, saturation and value to a Color3 (RGB)
  86437. * @param hue defines the hue
  86438. * @param saturation defines the saturation
  86439. * @param value defines the value
  86440. * @param result defines the Color3 where to store the RGB values
  86441. */
  86442. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86443. /**
  86444. * Creates a new Color3 from the string containing valid hexadecimal values
  86445. * @param hex defines a string containing valid hexadecimal values
  86446. * @returns a new Color3 object
  86447. */
  86448. static FromHexString(hex: string): Color3;
  86449. /**
  86450. * Creates a new Color3 from the starting index of the given array
  86451. * @param array defines the source array
  86452. * @param offset defines an offset in the source array
  86453. * @returns a new Color3 object
  86454. */
  86455. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86456. /**
  86457. * Creates a new Color3 from the starting index element of the given array
  86458. * @param array defines the source array to read from
  86459. * @param offset defines the offset in the source array
  86460. * @param result defines the target Color3 object
  86461. */
  86462. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86463. /**
  86464. * Creates a new Color3 from integer values (< 256)
  86465. * @param r defines the red component to read from (value between 0 and 255)
  86466. * @param g defines the green component to read from (value between 0 and 255)
  86467. * @param b defines the blue component to read from (value between 0 and 255)
  86468. * @returns a new Color3 object
  86469. */
  86470. static FromInts(r: number, g: number, b: number): Color3;
  86471. /**
  86472. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86473. * @param start defines the start Color3 value
  86474. * @param end defines the end Color3 value
  86475. * @param amount defines the gradient value between start and end
  86476. * @returns a new Color3 object
  86477. */
  86478. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86479. /**
  86480. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86481. * @param left defines the start value
  86482. * @param right defines the end value
  86483. * @param amount defines the gradient factor
  86484. * @param result defines the Color3 object where to store the result
  86485. */
  86486. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86487. /**
  86488. * Returns a Color3 value containing a red color
  86489. * @returns a new Color3 object
  86490. */
  86491. static Red(): Color3;
  86492. /**
  86493. * Returns a Color3 value containing a green color
  86494. * @returns a new Color3 object
  86495. */
  86496. static Green(): Color3;
  86497. /**
  86498. * Returns a Color3 value containing a blue color
  86499. * @returns a new Color3 object
  86500. */
  86501. static Blue(): Color3;
  86502. /**
  86503. * Returns a Color3 value containing a black color
  86504. * @returns a new Color3 object
  86505. */
  86506. static Black(): Color3;
  86507. /**
  86508. * Gets a Color3 value containing a black color that must not be updated
  86509. */
  86510. static get BlackReadOnly(): DeepImmutable<Color3>;
  86511. /**
  86512. * Returns a Color3 value containing a white color
  86513. * @returns a new Color3 object
  86514. */
  86515. static White(): Color3;
  86516. /**
  86517. * Returns a Color3 value containing a purple color
  86518. * @returns a new Color3 object
  86519. */
  86520. static Purple(): Color3;
  86521. /**
  86522. * Returns a Color3 value containing a magenta color
  86523. * @returns a new Color3 object
  86524. */
  86525. static Magenta(): Color3;
  86526. /**
  86527. * Returns a Color3 value containing a yellow color
  86528. * @returns a new Color3 object
  86529. */
  86530. static Yellow(): Color3;
  86531. /**
  86532. * Returns a Color3 value containing a gray color
  86533. * @returns a new Color3 object
  86534. */
  86535. static Gray(): Color3;
  86536. /**
  86537. * Returns a Color3 value containing a teal color
  86538. * @returns a new Color3 object
  86539. */
  86540. static Teal(): Color3;
  86541. /**
  86542. * Returns a Color3 value containing a random color
  86543. * @returns a new Color3 object
  86544. */
  86545. static Random(): Color3;
  86546. }
  86547. /**
  86548. * Class used to hold a RBGA color
  86549. */
  86550. export class Color4 {
  86551. /**
  86552. * Defines the red component (between 0 and 1, default is 0)
  86553. */
  86554. r: number;
  86555. /**
  86556. * Defines the green component (between 0 and 1, default is 0)
  86557. */
  86558. g: number;
  86559. /**
  86560. * Defines the blue component (between 0 and 1, default is 0)
  86561. */
  86562. b: number;
  86563. /**
  86564. * Defines the alpha component (between 0 and 1, default is 1)
  86565. */
  86566. a: number;
  86567. /**
  86568. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86569. * @param r defines the red component (between 0 and 1, default is 0)
  86570. * @param g defines the green component (between 0 and 1, default is 0)
  86571. * @param b defines the blue component (between 0 and 1, default is 0)
  86572. * @param a defines the alpha component (between 0 and 1, default is 1)
  86573. */
  86574. constructor(
  86575. /**
  86576. * Defines the red component (between 0 and 1, default is 0)
  86577. */
  86578. r?: number,
  86579. /**
  86580. * Defines the green component (between 0 and 1, default is 0)
  86581. */
  86582. g?: number,
  86583. /**
  86584. * Defines the blue component (between 0 and 1, default is 0)
  86585. */
  86586. b?: number,
  86587. /**
  86588. * Defines the alpha component (between 0 and 1, default is 1)
  86589. */
  86590. a?: number);
  86591. /**
  86592. * Adds in place the given Color4 values to the current Color4 object
  86593. * @param right defines the second operand
  86594. * @returns the current updated Color4 object
  86595. */
  86596. addInPlace(right: DeepImmutable<Color4>): Color4;
  86597. /**
  86598. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86599. * @returns the new array
  86600. */
  86601. asArray(): number[];
  86602. /**
  86603. * Stores from the starting index in the given array the Color4 successive values
  86604. * @param array defines the array where to store the r,g,b components
  86605. * @param index defines an optional index in the target array to define where to start storing values
  86606. * @returns the current Color4 object
  86607. */
  86608. toArray(array: number[], index?: number): Color4;
  86609. /**
  86610. * Update the current color with values stored in an array from the starting index of the given array
  86611. * @param array defines the source array
  86612. * @param offset defines an offset in the source array
  86613. * @returns the current Color4 object
  86614. */
  86615. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86616. /**
  86617. * Determines equality between Color4 objects
  86618. * @param otherColor defines the second operand
  86619. * @returns true if the rgba values are equal to the given ones
  86620. */
  86621. equals(otherColor: DeepImmutable<Color4>): boolean;
  86622. /**
  86623. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86624. * @param right defines the second operand
  86625. * @returns a new Color4 object
  86626. */
  86627. add(right: DeepImmutable<Color4>): Color4;
  86628. /**
  86629. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86630. * @param right defines the second operand
  86631. * @returns a new Color4 object
  86632. */
  86633. subtract(right: DeepImmutable<Color4>): Color4;
  86634. /**
  86635. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86636. * @param right defines the second operand
  86637. * @param result defines the Color4 object where to store the result
  86638. * @returns the current Color4 object
  86639. */
  86640. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86641. /**
  86642. * Creates a new Color4 with the current Color4 values multiplied by scale
  86643. * @param scale defines the scaling factor to apply
  86644. * @returns a new Color4 object
  86645. */
  86646. scale(scale: number): Color4;
  86647. /**
  86648. * Multiplies the current Color4 values by scale and stores the result in "result"
  86649. * @param scale defines the scaling factor to apply
  86650. * @param result defines the Color4 object where to store the result
  86651. * @returns the current unmodified Color4
  86652. */
  86653. scaleToRef(scale: number, result: Color4): Color4;
  86654. /**
  86655. * Scale the current Color4 values by a factor and add the result to a given Color4
  86656. * @param scale defines the scale factor
  86657. * @param result defines the Color4 object where to store the result
  86658. * @returns the unmodified current Color4
  86659. */
  86660. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86661. /**
  86662. * Clamps the rgb values by the min and max values and stores the result into "result"
  86663. * @param min defines minimum clamping value (default is 0)
  86664. * @param max defines maximum clamping value (default is 1)
  86665. * @param result defines color to store the result into.
  86666. * @returns the cuurent Color4
  86667. */
  86668. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86669. /**
  86670. * Multipy an Color4 value by another and return a new Color4 object
  86671. * @param color defines the Color4 value to multiply by
  86672. * @returns a new Color4 object
  86673. */
  86674. multiply(color: Color4): Color4;
  86675. /**
  86676. * Multipy a Color4 value by another and push the result in a reference value
  86677. * @param color defines the Color4 value to multiply by
  86678. * @param result defines the Color4 to fill the result in
  86679. * @returns the result Color4
  86680. */
  86681. multiplyToRef(color: Color4, result: Color4): Color4;
  86682. /**
  86683. * Creates a string with the Color4 current values
  86684. * @returns the string representation of the Color4 object
  86685. */
  86686. toString(): string;
  86687. /**
  86688. * Returns the string "Color4"
  86689. * @returns "Color4"
  86690. */
  86691. getClassName(): string;
  86692. /**
  86693. * Compute the Color4 hash code
  86694. * @returns an unique number that can be used to hash Color4 objects
  86695. */
  86696. getHashCode(): number;
  86697. /**
  86698. * Creates a new Color4 copied from the current one
  86699. * @returns a new Color4 object
  86700. */
  86701. clone(): Color4;
  86702. /**
  86703. * Copies the given Color4 values into the current one
  86704. * @param source defines the source Color4 object
  86705. * @returns the current updated Color4 object
  86706. */
  86707. copyFrom(source: Color4): Color4;
  86708. /**
  86709. * Copies the given float values into the current one
  86710. * @param r defines the red component to read from
  86711. * @param g defines the green component to read from
  86712. * @param b defines the blue component to read from
  86713. * @param a defines the alpha component to read from
  86714. * @returns the current updated Color4 object
  86715. */
  86716. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86717. /**
  86718. * Copies the given float values into the current one
  86719. * @param r defines the red component to read from
  86720. * @param g defines the green component to read from
  86721. * @param b defines the blue component to read from
  86722. * @param a defines the alpha component to read from
  86723. * @returns the current updated Color4 object
  86724. */
  86725. set(r: number, g: number, b: number, a: number): Color4;
  86726. /**
  86727. * Compute the Color4 hexadecimal code as a string
  86728. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86729. * @returns a string containing the hexadecimal representation of the Color4 object
  86730. */
  86731. toHexString(returnAsColor3?: boolean): string;
  86732. /**
  86733. * Computes a new Color4 converted from the current one to linear space
  86734. * @returns a new Color4 object
  86735. */
  86736. toLinearSpace(): Color4;
  86737. /**
  86738. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86739. * @param convertedColor defines the Color4 object where to store the linear space version
  86740. * @returns the unmodified Color4
  86741. */
  86742. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86743. /**
  86744. * Computes a new Color4 converted from the current one to gamma space
  86745. * @returns a new Color4 object
  86746. */
  86747. toGammaSpace(): Color4;
  86748. /**
  86749. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86750. * @param convertedColor defines the Color4 object where to store the gamma space version
  86751. * @returns the unmodified Color4
  86752. */
  86753. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86754. /**
  86755. * Creates a new Color4 from the string containing valid hexadecimal values
  86756. * @param hex defines a string containing valid hexadecimal values
  86757. * @returns a new Color4 object
  86758. */
  86759. static FromHexString(hex: string): Color4;
  86760. /**
  86761. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86762. * @param left defines the start value
  86763. * @param right defines the end value
  86764. * @param amount defines the gradient factor
  86765. * @returns a new Color4 object
  86766. */
  86767. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86768. /**
  86769. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86770. * @param left defines the start value
  86771. * @param right defines the end value
  86772. * @param amount defines the gradient factor
  86773. * @param result defines the Color4 object where to store data
  86774. */
  86775. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86776. /**
  86777. * Creates a new Color4 from a Color3 and an alpha value
  86778. * @param color3 defines the source Color3 to read from
  86779. * @param alpha defines the alpha component (1.0 by default)
  86780. * @returns a new Color4 object
  86781. */
  86782. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86783. /**
  86784. * Creates a new Color4 from the starting index element of the given array
  86785. * @param array defines the source array to read from
  86786. * @param offset defines the offset in the source array
  86787. * @returns a new Color4 object
  86788. */
  86789. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86790. /**
  86791. * Creates a new Color4 from the starting index element of the given array
  86792. * @param array defines the source array to read from
  86793. * @param offset defines the offset in the source array
  86794. * @param result defines the target Color4 object
  86795. */
  86796. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86797. /**
  86798. * Creates a new Color3 from integer values (< 256)
  86799. * @param r defines the red component to read from (value between 0 and 255)
  86800. * @param g defines the green component to read from (value between 0 and 255)
  86801. * @param b defines the blue component to read from (value between 0 and 255)
  86802. * @param a defines the alpha component to read from (value between 0 and 255)
  86803. * @returns a new Color3 object
  86804. */
  86805. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86806. /**
  86807. * Check the content of a given array and convert it to an array containing RGBA data
  86808. * If the original array was already containing count * 4 values then it is returned directly
  86809. * @param colors defines the array to check
  86810. * @param count defines the number of RGBA data to expect
  86811. * @returns an array containing count * 4 values (RGBA)
  86812. */
  86813. static CheckColors4(colors: number[], count: number): number[];
  86814. }
  86815. /**
  86816. * @hidden
  86817. */
  86818. export class TmpColors {
  86819. static Color3: Color3[];
  86820. static Color4: Color4[];
  86821. }
  86822. }
  86823. declare module BABYLON {
  86824. /**
  86825. * Defines an interface which represents an animation key frame
  86826. */
  86827. export interface IAnimationKey {
  86828. /**
  86829. * Frame of the key frame
  86830. */
  86831. frame: number;
  86832. /**
  86833. * Value at the specifies key frame
  86834. */
  86835. value: any;
  86836. /**
  86837. * The input tangent for the cubic hermite spline
  86838. */
  86839. inTangent?: any;
  86840. /**
  86841. * The output tangent for the cubic hermite spline
  86842. */
  86843. outTangent?: any;
  86844. /**
  86845. * The animation interpolation type
  86846. */
  86847. interpolation?: AnimationKeyInterpolation;
  86848. }
  86849. /**
  86850. * Enum for the animation key frame interpolation type
  86851. */
  86852. export enum AnimationKeyInterpolation {
  86853. /**
  86854. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86855. */
  86856. STEP = 1
  86857. }
  86858. }
  86859. declare module BABYLON {
  86860. /**
  86861. * Represents the range of an animation
  86862. */
  86863. export class AnimationRange {
  86864. /**The name of the animation range**/
  86865. name: string;
  86866. /**The starting frame of the animation */
  86867. from: number;
  86868. /**The ending frame of the animation*/
  86869. to: number;
  86870. /**
  86871. * Initializes the range of an animation
  86872. * @param name The name of the animation range
  86873. * @param from The starting frame of the animation
  86874. * @param to The ending frame of the animation
  86875. */
  86876. constructor(
  86877. /**The name of the animation range**/
  86878. name: string,
  86879. /**The starting frame of the animation */
  86880. from: number,
  86881. /**The ending frame of the animation*/
  86882. to: number);
  86883. /**
  86884. * Makes a copy of the animation range
  86885. * @returns A copy of the animation range
  86886. */
  86887. clone(): AnimationRange;
  86888. }
  86889. }
  86890. declare module BABYLON {
  86891. /**
  86892. * Composed of a frame, and an action function
  86893. */
  86894. export class AnimationEvent {
  86895. /** The frame for which the event is triggered **/
  86896. frame: number;
  86897. /** The event to perform when triggered **/
  86898. action: (currentFrame: number) => void;
  86899. /** Specifies if the event should be triggered only once**/
  86900. onlyOnce?: boolean | undefined;
  86901. /**
  86902. * Specifies if the animation event is done
  86903. */
  86904. isDone: boolean;
  86905. /**
  86906. * Initializes the animation event
  86907. * @param frame The frame for which the event is triggered
  86908. * @param action The event to perform when triggered
  86909. * @param onlyOnce Specifies if the event should be triggered only once
  86910. */
  86911. constructor(
  86912. /** The frame for which the event is triggered **/
  86913. frame: number,
  86914. /** The event to perform when triggered **/
  86915. action: (currentFrame: number) => void,
  86916. /** Specifies if the event should be triggered only once**/
  86917. onlyOnce?: boolean | undefined);
  86918. /** @hidden */
  86919. _clone(): AnimationEvent;
  86920. }
  86921. }
  86922. declare module BABYLON {
  86923. /**
  86924. * Interface used to define a behavior
  86925. */
  86926. export interface Behavior<T> {
  86927. /** gets or sets behavior's name */
  86928. name: string;
  86929. /**
  86930. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86931. */
  86932. init(): void;
  86933. /**
  86934. * Called when the behavior is attached to a target
  86935. * @param target defines the target where the behavior is attached to
  86936. */
  86937. attach(target: T): void;
  86938. /**
  86939. * Called when the behavior is detached from its target
  86940. */
  86941. detach(): void;
  86942. }
  86943. /**
  86944. * Interface implemented by classes supporting behaviors
  86945. */
  86946. export interface IBehaviorAware<T> {
  86947. /**
  86948. * Attach a behavior
  86949. * @param behavior defines the behavior to attach
  86950. * @returns the current host
  86951. */
  86952. addBehavior(behavior: Behavior<T>): T;
  86953. /**
  86954. * Remove a behavior from the current object
  86955. * @param behavior defines the behavior to detach
  86956. * @returns the current host
  86957. */
  86958. removeBehavior(behavior: Behavior<T>): T;
  86959. /**
  86960. * Gets a behavior using its name to search
  86961. * @param name defines the name to search
  86962. * @returns the behavior or null if not found
  86963. */
  86964. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86965. }
  86966. }
  86967. declare module BABYLON {
  86968. /**
  86969. * Defines an array and its length.
  86970. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86971. */
  86972. export interface ISmartArrayLike<T> {
  86973. /**
  86974. * The data of the array.
  86975. */
  86976. data: Array<T>;
  86977. /**
  86978. * The active length of the array.
  86979. */
  86980. length: number;
  86981. }
  86982. /**
  86983. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86984. */
  86985. export class SmartArray<T> implements ISmartArrayLike<T> {
  86986. /**
  86987. * The full set of data from the array.
  86988. */
  86989. data: Array<T>;
  86990. /**
  86991. * The active length of the array.
  86992. */
  86993. length: number;
  86994. protected _id: number;
  86995. /**
  86996. * Instantiates a Smart Array.
  86997. * @param capacity defines the default capacity of the array.
  86998. */
  86999. constructor(capacity: number);
  87000. /**
  87001. * Pushes a value at the end of the active data.
  87002. * @param value defines the object to push in the array.
  87003. */
  87004. push(value: T): void;
  87005. /**
  87006. * Iterates over the active data and apply the lambda to them.
  87007. * @param func defines the action to apply on each value.
  87008. */
  87009. forEach(func: (content: T) => void): void;
  87010. /**
  87011. * Sorts the full sets of data.
  87012. * @param compareFn defines the comparison function to apply.
  87013. */
  87014. sort(compareFn: (a: T, b: T) => number): void;
  87015. /**
  87016. * Resets the active data to an empty array.
  87017. */
  87018. reset(): void;
  87019. /**
  87020. * Releases all the data from the array as well as the array.
  87021. */
  87022. dispose(): void;
  87023. /**
  87024. * Concats the active data with a given array.
  87025. * @param array defines the data to concatenate with.
  87026. */
  87027. concat(array: any): void;
  87028. /**
  87029. * Returns the position of a value in the active data.
  87030. * @param value defines the value to find the index for
  87031. * @returns the index if found in the active data otherwise -1
  87032. */
  87033. indexOf(value: T): number;
  87034. /**
  87035. * Returns whether an element is part of the active data.
  87036. * @param value defines the value to look for
  87037. * @returns true if found in the active data otherwise false
  87038. */
  87039. contains(value: T): boolean;
  87040. private static _GlobalId;
  87041. }
  87042. /**
  87043. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87044. * The data in this array can only be present once
  87045. */
  87046. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87047. private _duplicateId;
  87048. /**
  87049. * Pushes a value at the end of the active data.
  87050. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87051. * @param value defines the object to push in the array.
  87052. */
  87053. push(value: T): void;
  87054. /**
  87055. * Pushes a value at the end of the active data.
  87056. * If the data is already present, it won t be added again
  87057. * @param value defines the object to push in the array.
  87058. * @returns true if added false if it was already present
  87059. */
  87060. pushNoDuplicate(value: T): boolean;
  87061. /**
  87062. * Resets the active data to an empty array.
  87063. */
  87064. reset(): void;
  87065. /**
  87066. * Concats the active data with a given array.
  87067. * This ensures no dupplicate will be present in the result.
  87068. * @param array defines the data to concatenate with.
  87069. */
  87070. concatWithNoDuplicate(array: any): void;
  87071. }
  87072. }
  87073. declare module BABYLON {
  87074. /**
  87075. * @ignore
  87076. * This is a list of all the different input types that are available in the application.
  87077. * Fo instance: ArcRotateCameraGamepadInput...
  87078. */
  87079. export var CameraInputTypes: {};
  87080. /**
  87081. * This is the contract to implement in order to create a new input class.
  87082. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  87083. */
  87084. export interface ICameraInput<TCamera extends Camera> {
  87085. /**
  87086. * Defines the camera the input is attached to.
  87087. */
  87088. camera: Nullable<TCamera>;
  87089. /**
  87090. * Gets the class name of the current intput.
  87091. * @returns the class name
  87092. */
  87093. getClassName(): string;
  87094. /**
  87095. * Get the friendly name associated with the input class.
  87096. * @returns the input friendly name
  87097. */
  87098. getSimpleName(): string;
  87099. /**
  87100. * Attach the input controls to a specific dom element to get the input from.
  87101. * @param element Defines the element the controls should be listened from
  87102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87103. */
  87104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87105. /**
  87106. * Detach the current controls from the specified dom element.
  87107. * @param element Defines the element to stop listening the inputs from
  87108. */
  87109. detachControl(element: Nullable<HTMLElement>): void;
  87110. /**
  87111. * Update the current camera state depending on the inputs that have been used this frame.
  87112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87113. */
  87114. checkInputs?: () => void;
  87115. }
  87116. /**
  87117. * Represents a map of input types to input instance or input index to input instance.
  87118. */
  87119. export interface CameraInputsMap<TCamera extends Camera> {
  87120. /**
  87121. * Accessor to the input by input type.
  87122. */
  87123. [name: string]: ICameraInput<TCamera>;
  87124. /**
  87125. * Accessor to the input by input index.
  87126. */
  87127. [idx: number]: ICameraInput<TCamera>;
  87128. }
  87129. /**
  87130. * This represents the input manager used within a camera.
  87131. * It helps dealing with all the different kind of input attached to a camera.
  87132. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87133. */
  87134. export class CameraInputsManager<TCamera extends Camera> {
  87135. /**
  87136. * Defines the list of inputs attahed to the camera.
  87137. */
  87138. attached: CameraInputsMap<TCamera>;
  87139. /**
  87140. * Defines the dom element the camera is collecting inputs from.
  87141. * This is null if the controls have not been attached.
  87142. */
  87143. attachedElement: Nullable<HTMLElement>;
  87144. /**
  87145. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87146. */
  87147. noPreventDefault: boolean;
  87148. /**
  87149. * Defined the camera the input manager belongs to.
  87150. */
  87151. camera: TCamera;
  87152. /**
  87153. * Update the current camera state depending on the inputs that have been used this frame.
  87154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87155. */
  87156. checkInputs: () => void;
  87157. /**
  87158. * Instantiate a new Camera Input Manager.
  87159. * @param camera Defines the camera the input manager blongs to
  87160. */
  87161. constructor(camera: TCamera);
  87162. /**
  87163. * Add an input method to a camera
  87164. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87165. * @param input camera input method
  87166. */
  87167. add(input: ICameraInput<TCamera>): void;
  87168. /**
  87169. * Remove a specific input method from a camera
  87170. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87171. * @param inputToRemove camera input method
  87172. */
  87173. remove(inputToRemove: ICameraInput<TCamera>): void;
  87174. /**
  87175. * Remove a specific input type from a camera
  87176. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87177. * @param inputType the type of the input to remove
  87178. */
  87179. removeByType(inputType: string): void;
  87180. private _addCheckInputs;
  87181. /**
  87182. * Attach the input controls to the currently attached dom element to listen the events from.
  87183. * @param input Defines the input to attach
  87184. */
  87185. attachInput(input: ICameraInput<TCamera>): void;
  87186. /**
  87187. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87188. * @param element Defines the dom element to collect the events from
  87189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87190. */
  87191. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  87192. /**
  87193. * Detach the current manager inputs controls from a specific dom element.
  87194. * @param element Defines the dom element to collect the events from
  87195. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87196. */
  87197. detachElement(element: HTMLElement, disconnect?: boolean): void;
  87198. /**
  87199. * Rebuild the dynamic inputCheck function from the current list of
  87200. * defined inputs in the manager.
  87201. */
  87202. rebuildInputCheck(): void;
  87203. /**
  87204. * Remove all attached input methods from a camera
  87205. */
  87206. clear(): void;
  87207. /**
  87208. * Serialize the current input manager attached to a camera.
  87209. * This ensures than once parsed,
  87210. * the input associated to the camera will be identical to the current ones
  87211. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87212. */
  87213. serialize(serializedCamera: any): void;
  87214. /**
  87215. * Parses an input manager serialized JSON to restore the previous list of inputs
  87216. * and states associated to a camera.
  87217. * @param parsedCamera Defines the JSON to parse
  87218. */
  87219. parse(parsedCamera: any): void;
  87220. }
  87221. }
  87222. declare module BABYLON {
  87223. /**
  87224. * Class used to store data that will be store in GPU memory
  87225. */
  87226. export class Buffer {
  87227. private _engine;
  87228. private _buffer;
  87229. /** @hidden */
  87230. _data: Nullable<DataArray>;
  87231. private _updatable;
  87232. private _instanced;
  87233. private _divisor;
  87234. /**
  87235. * Gets the byte stride.
  87236. */
  87237. readonly byteStride: number;
  87238. /**
  87239. * Constructor
  87240. * @param engine the engine
  87241. * @param data the data to use for this buffer
  87242. * @param updatable whether the data is updatable
  87243. * @param stride the stride (optional)
  87244. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87245. * @param instanced whether the buffer is instanced (optional)
  87246. * @param useBytes set to true if the stride in in bytes (optional)
  87247. * @param divisor sets an optional divisor for instances (1 by default)
  87248. */
  87249. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87250. /**
  87251. * Create a new VertexBuffer based on the current buffer
  87252. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87253. * @param offset defines offset in the buffer (0 by default)
  87254. * @param size defines the size in floats of attributes (position is 3 for instance)
  87255. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87256. * @param instanced defines if the vertex buffer contains indexed data
  87257. * @param useBytes defines if the offset and stride are in bytes *
  87258. * @param divisor sets an optional divisor for instances (1 by default)
  87259. * @returns the new vertex buffer
  87260. */
  87261. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87262. /**
  87263. * Gets a boolean indicating if the Buffer is updatable?
  87264. * @returns true if the buffer is updatable
  87265. */
  87266. isUpdatable(): boolean;
  87267. /**
  87268. * Gets current buffer's data
  87269. * @returns a DataArray or null
  87270. */
  87271. getData(): Nullable<DataArray>;
  87272. /**
  87273. * Gets underlying native buffer
  87274. * @returns underlying native buffer
  87275. */
  87276. getBuffer(): Nullable<DataBuffer>;
  87277. /**
  87278. * Gets the stride in float32 units (i.e. byte stride / 4).
  87279. * May not be an integer if the byte stride is not divisible by 4.
  87280. * @returns the stride in float32 units
  87281. * @deprecated Please use byteStride instead.
  87282. */
  87283. getStrideSize(): number;
  87284. /**
  87285. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87286. * @param data defines the data to store
  87287. */
  87288. create(data?: Nullable<DataArray>): void;
  87289. /** @hidden */
  87290. _rebuild(): void;
  87291. /**
  87292. * Update current buffer data
  87293. * @param data defines the data to store
  87294. */
  87295. update(data: DataArray): void;
  87296. /**
  87297. * Updates the data directly.
  87298. * @param data the new data
  87299. * @param offset the new offset
  87300. * @param vertexCount the vertex count (optional)
  87301. * @param useBytes set to true if the offset is in bytes
  87302. */
  87303. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87304. /**
  87305. * Release all resources
  87306. */
  87307. dispose(): void;
  87308. }
  87309. /**
  87310. * Specialized buffer used to store vertex data
  87311. */
  87312. export class VertexBuffer {
  87313. /** @hidden */
  87314. _buffer: Buffer;
  87315. private _kind;
  87316. private _size;
  87317. private _ownsBuffer;
  87318. private _instanced;
  87319. private _instanceDivisor;
  87320. /**
  87321. * The byte type.
  87322. */
  87323. static readonly BYTE: number;
  87324. /**
  87325. * The unsigned byte type.
  87326. */
  87327. static readonly UNSIGNED_BYTE: number;
  87328. /**
  87329. * The short type.
  87330. */
  87331. static readonly SHORT: number;
  87332. /**
  87333. * The unsigned short type.
  87334. */
  87335. static readonly UNSIGNED_SHORT: number;
  87336. /**
  87337. * The integer type.
  87338. */
  87339. static readonly INT: number;
  87340. /**
  87341. * The unsigned integer type.
  87342. */
  87343. static readonly UNSIGNED_INT: number;
  87344. /**
  87345. * The float type.
  87346. */
  87347. static readonly FLOAT: number;
  87348. /**
  87349. * Gets or sets the instance divisor when in instanced mode
  87350. */
  87351. get instanceDivisor(): number;
  87352. set instanceDivisor(value: number);
  87353. /**
  87354. * Gets the byte stride.
  87355. */
  87356. readonly byteStride: number;
  87357. /**
  87358. * Gets the byte offset.
  87359. */
  87360. readonly byteOffset: number;
  87361. /**
  87362. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87363. */
  87364. readonly normalized: boolean;
  87365. /**
  87366. * Gets the data type of each component in the array.
  87367. */
  87368. readonly type: number;
  87369. /**
  87370. * Constructor
  87371. * @param engine the engine
  87372. * @param data the data to use for this vertex buffer
  87373. * @param kind the vertex buffer kind
  87374. * @param updatable whether the data is updatable
  87375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87376. * @param stride the stride (optional)
  87377. * @param instanced whether the buffer is instanced (optional)
  87378. * @param offset the offset of the data (optional)
  87379. * @param size the number of components (optional)
  87380. * @param type the type of the component (optional)
  87381. * @param normalized whether the data contains normalized data (optional)
  87382. * @param useBytes set to true if stride and offset are in bytes (optional)
  87383. * @param divisor defines the instance divisor to use (1 by default)
  87384. */
  87385. 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);
  87386. /** @hidden */
  87387. _rebuild(): void;
  87388. /**
  87389. * Returns the kind of the VertexBuffer (string)
  87390. * @returns a string
  87391. */
  87392. getKind(): string;
  87393. /**
  87394. * Gets a boolean indicating if the VertexBuffer is updatable?
  87395. * @returns true if the buffer is updatable
  87396. */
  87397. isUpdatable(): boolean;
  87398. /**
  87399. * Gets current buffer's data
  87400. * @returns a DataArray or null
  87401. */
  87402. getData(): Nullable<DataArray>;
  87403. /**
  87404. * Gets underlying native buffer
  87405. * @returns underlying native buffer
  87406. */
  87407. getBuffer(): Nullable<DataBuffer>;
  87408. /**
  87409. * Gets the stride in float32 units (i.e. byte stride / 4).
  87410. * May not be an integer if the byte stride is not divisible by 4.
  87411. * @returns the stride in float32 units
  87412. * @deprecated Please use byteStride instead.
  87413. */
  87414. getStrideSize(): number;
  87415. /**
  87416. * Returns the offset as a multiple of the type byte length.
  87417. * @returns the offset in bytes
  87418. * @deprecated Please use byteOffset instead.
  87419. */
  87420. getOffset(): number;
  87421. /**
  87422. * Returns the number of components per vertex attribute (integer)
  87423. * @returns the size in float
  87424. */
  87425. getSize(): number;
  87426. /**
  87427. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87428. * @returns true if this buffer is instanced
  87429. */
  87430. getIsInstanced(): boolean;
  87431. /**
  87432. * Returns the instancing divisor, zero for non-instanced (integer).
  87433. * @returns a number
  87434. */
  87435. getInstanceDivisor(): number;
  87436. /**
  87437. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87438. * @param data defines the data to store
  87439. */
  87440. create(data?: DataArray): void;
  87441. /**
  87442. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87443. * This function will create a new buffer if the current one is not updatable
  87444. * @param data defines the data to store
  87445. */
  87446. update(data: DataArray): void;
  87447. /**
  87448. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87449. * Returns the directly updated WebGLBuffer.
  87450. * @param data the new data
  87451. * @param offset the new offset
  87452. * @param useBytes set to true if the offset is in bytes
  87453. */
  87454. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87455. /**
  87456. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87457. */
  87458. dispose(): void;
  87459. /**
  87460. * Enumerates each value of this vertex buffer as numbers.
  87461. * @param count the number of values to enumerate
  87462. * @param callback the callback function called for each value
  87463. */
  87464. forEach(count: number, callback: (value: number, index: number) => void): void;
  87465. /**
  87466. * Positions
  87467. */
  87468. static readonly PositionKind: string;
  87469. /**
  87470. * Normals
  87471. */
  87472. static readonly NormalKind: string;
  87473. /**
  87474. * Tangents
  87475. */
  87476. static readonly TangentKind: string;
  87477. /**
  87478. * Texture coordinates
  87479. */
  87480. static readonly UVKind: string;
  87481. /**
  87482. * Texture coordinates 2
  87483. */
  87484. static readonly UV2Kind: string;
  87485. /**
  87486. * Texture coordinates 3
  87487. */
  87488. static readonly UV3Kind: string;
  87489. /**
  87490. * Texture coordinates 4
  87491. */
  87492. static readonly UV4Kind: string;
  87493. /**
  87494. * Texture coordinates 5
  87495. */
  87496. static readonly UV5Kind: string;
  87497. /**
  87498. * Texture coordinates 6
  87499. */
  87500. static readonly UV6Kind: string;
  87501. /**
  87502. * Colors
  87503. */
  87504. static readonly ColorKind: string;
  87505. /**
  87506. * Matrix indices (for bones)
  87507. */
  87508. static readonly MatricesIndicesKind: string;
  87509. /**
  87510. * Matrix weights (for bones)
  87511. */
  87512. static readonly MatricesWeightsKind: string;
  87513. /**
  87514. * Additional matrix indices (for bones)
  87515. */
  87516. static readonly MatricesIndicesExtraKind: string;
  87517. /**
  87518. * Additional matrix weights (for bones)
  87519. */
  87520. static readonly MatricesWeightsExtraKind: string;
  87521. /**
  87522. * Deduces the stride given a kind.
  87523. * @param kind The kind string to deduce
  87524. * @returns The deduced stride
  87525. */
  87526. static DeduceStride(kind: string): number;
  87527. /**
  87528. * Gets the byte length of the given type.
  87529. * @param type the type
  87530. * @returns the number of bytes
  87531. */
  87532. static GetTypeByteLength(type: number): number;
  87533. /**
  87534. * Enumerates each value of the given parameters as numbers.
  87535. * @param data the data to enumerate
  87536. * @param byteOffset the byte offset of the data
  87537. * @param byteStride the byte stride of the data
  87538. * @param componentCount the number of components per element
  87539. * @param componentType the type of the component
  87540. * @param count the number of values to enumerate
  87541. * @param normalized whether the data is normalized
  87542. * @param callback the callback function called for each value
  87543. */
  87544. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87545. private static _GetFloatValue;
  87546. }
  87547. }
  87548. declare module BABYLON {
  87549. /**
  87550. * The options Interface for creating a Capsule Mesh
  87551. */
  87552. export interface ICreateCapsuleOptions {
  87553. /** The Orientation of the capsule. Default : Vector3.Up() */
  87554. orientation?: Vector3;
  87555. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87556. subdivisions: number;
  87557. /** Number of cylindrical segments on the capsule. */
  87558. tessellation: number;
  87559. /** Height or Length of the capsule. */
  87560. height: number;
  87561. /** Radius of the capsule. */
  87562. radius: number;
  87563. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87564. capSubdivisions: number;
  87565. /** Overwrite for the top radius. */
  87566. radiusTop?: number;
  87567. /** Overwrite for the bottom radius. */
  87568. radiusBottom?: number;
  87569. /** Overwrite for the top capSubdivisions. */
  87570. topCapSubdivisions?: number;
  87571. /** Overwrite for the bottom capSubdivisions. */
  87572. bottomCapSubdivisions?: number;
  87573. }
  87574. /**
  87575. * Class containing static functions to help procedurally build meshes
  87576. */
  87577. export class CapsuleBuilder {
  87578. /**
  87579. * Creates a capsule or a pill mesh
  87580. * @param name defines the name of the mesh
  87581. * @param options The constructors options.
  87582. * @param scene The scene the mesh is scoped to.
  87583. * @returns Capsule Mesh
  87584. */
  87585. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87586. }
  87587. }
  87588. declare module BABYLON {
  87589. /**
  87590. * @hidden
  87591. */
  87592. export class IntersectionInfo {
  87593. bu: Nullable<number>;
  87594. bv: Nullable<number>;
  87595. distance: number;
  87596. faceId: number;
  87597. subMeshId: number;
  87598. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87599. }
  87600. }
  87601. declare module BABYLON {
  87602. /**
  87603. * Class used to store bounding sphere information
  87604. */
  87605. export class BoundingSphere {
  87606. /**
  87607. * Gets the center of the bounding sphere in local space
  87608. */
  87609. readonly center: Vector3;
  87610. /**
  87611. * Radius of the bounding sphere in local space
  87612. */
  87613. radius: number;
  87614. /**
  87615. * Gets the center of the bounding sphere in world space
  87616. */
  87617. readonly centerWorld: Vector3;
  87618. /**
  87619. * Radius of the bounding sphere in world space
  87620. */
  87621. radiusWorld: number;
  87622. /**
  87623. * Gets the minimum vector in local space
  87624. */
  87625. readonly minimum: Vector3;
  87626. /**
  87627. * Gets the maximum vector in local space
  87628. */
  87629. readonly maximum: Vector3;
  87630. private _worldMatrix;
  87631. private static readonly TmpVector3;
  87632. /**
  87633. * Creates a new bounding sphere
  87634. * @param min defines the minimum vector (in local space)
  87635. * @param max defines the maximum vector (in local space)
  87636. * @param worldMatrix defines the new world matrix
  87637. */
  87638. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87639. /**
  87640. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87641. * @param min defines the new minimum vector (in local space)
  87642. * @param max defines the new maximum vector (in local space)
  87643. * @param worldMatrix defines the new world matrix
  87644. */
  87645. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87646. /**
  87647. * Scale the current bounding sphere by applying a scale factor
  87648. * @param factor defines the scale factor to apply
  87649. * @returns the current bounding box
  87650. */
  87651. scale(factor: number): BoundingSphere;
  87652. /**
  87653. * Gets the world matrix of the bounding box
  87654. * @returns a matrix
  87655. */
  87656. getWorldMatrix(): DeepImmutable<Matrix>;
  87657. /** @hidden */
  87658. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87659. /**
  87660. * Tests if the bounding sphere is intersecting the frustum planes
  87661. * @param frustumPlanes defines the frustum planes to test
  87662. * @returns true if there is an intersection
  87663. */
  87664. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87665. /**
  87666. * Tests if the bounding sphere center is in between the frustum planes.
  87667. * Used for optimistic fast inclusion.
  87668. * @param frustumPlanes defines the frustum planes to test
  87669. * @returns true if the sphere center is in between the frustum planes
  87670. */
  87671. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87672. /**
  87673. * Tests if a point is inside the bounding sphere
  87674. * @param point defines the point to test
  87675. * @returns true if the point is inside the bounding sphere
  87676. */
  87677. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87678. /**
  87679. * Checks if two sphere intersct
  87680. * @param sphere0 sphere 0
  87681. * @param sphere1 sphere 1
  87682. * @returns true if the speres intersect
  87683. */
  87684. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87685. }
  87686. }
  87687. declare module BABYLON {
  87688. /**
  87689. * Class used to store bounding box information
  87690. */
  87691. export class BoundingBox implements ICullable {
  87692. /**
  87693. * Gets the 8 vectors representing the bounding box in local space
  87694. */
  87695. readonly vectors: Vector3[];
  87696. /**
  87697. * Gets the center of the bounding box in local space
  87698. */
  87699. readonly center: Vector3;
  87700. /**
  87701. * Gets the center of the bounding box in world space
  87702. */
  87703. readonly centerWorld: Vector3;
  87704. /**
  87705. * Gets the extend size in local space
  87706. */
  87707. readonly extendSize: Vector3;
  87708. /**
  87709. * Gets the extend size in world space
  87710. */
  87711. readonly extendSizeWorld: Vector3;
  87712. /**
  87713. * Gets the OBB (object bounding box) directions
  87714. */
  87715. readonly directions: Vector3[];
  87716. /**
  87717. * Gets the 8 vectors representing the bounding box in world space
  87718. */
  87719. readonly vectorsWorld: Vector3[];
  87720. /**
  87721. * Gets the minimum vector in world space
  87722. */
  87723. readonly minimumWorld: Vector3;
  87724. /**
  87725. * Gets the maximum vector in world space
  87726. */
  87727. readonly maximumWorld: Vector3;
  87728. /**
  87729. * Gets the minimum vector in local space
  87730. */
  87731. readonly minimum: Vector3;
  87732. /**
  87733. * Gets the maximum vector in local space
  87734. */
  87735. readonly maximum: Vector3;
  87736. private _worldMatrix;
  87737. private static readonly TmpVector3;
  87738. /**
  87739. * @hidden
  87740. */
  87741. _tag: number;
  87742. /**
  87743. * Creates a new bounding box
  87744. * @param min defines the minimum vector (in local space)
  87745. * @param max defines the maximum vector (in local space)
  87746. * @param worldMatrix defines the new world matrix
  87747. */
  87748. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87749. /**
  87750. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87751. * @param min defines the new minimum vector (in local space)
  87752. * @param max defines the new maximum vector (in local space)
  87753. * @param worldMatrix defines the new world matrix
  87754. */
  87755. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87756. /**
  87757. * Scale the current bounding box by applying a scale factor
  87758. * @param factor defines the scale factor to apply
  87759. * @returns the current bounding box
  87760. */
  87761. scale(factor: number): BoundingBox;
  87762. /**
  87763. * Gets the world matrix of the bounding box
  87764. * @returns a matrix
  87765. */
  87766. getWorldMatrix(): DeepImmutable<Matrix>;
  87767. /** @hidden */
  87768. _update(world: DeepImmutable<Matrix>): void;
  87769. /**
  87770. * Tests if the bounding box is intersecting the frustum planes
  87771. * @param frustumPlanes defines the frustum planes to test
  87772. * @returns true if there is an intersection
  87773. */
  87774. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87775. /**
  87776. * Tests if the bounding box is entirely inside the frustum planes
  87777. * @param frustumPlanes defines the frustum planes to test
  87778. * @returns true if there is an inclusion
  87779. */
  87780. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87781. /**
  87782. * Tests if a point is inside the bounding box
  87783. * @param point defines the point to test
  87784. * @returns true if the point is inside the bounding box
  87785. */
  87786. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87787. /**
  87788. * Tests if the bounding box intersects with a bounding sphere
  87789. * @param sphere defines the sphere to test
  87790. * @returns true if there is an intersection
  87791. */
  87792. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87793. /**
  87794. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87795. * @param min defines the min vector to use
  87796. * @param max defines the max vector to use
  87797. * @returns true if there is an intersection
  87798. */
  87799. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87800. /**
  87801. * Tests if two bounding boxes are intersections
  87802. * @param box0 defines the first box to test
  87803. * @param box1 defines the second box to test
  87804. * @returns true if there is an intersection
  87805. */
  87806. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87807. /**
  87808. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87809. * @param minPoint defines the minimum vector of the bounding box
  87810. * @param maxPoint defines the maximum vector of the bounding box
  87811. * @param sphereCenter defines the sphere center
  87812. * @param sphereRadius defines the sphere radius
  87813. * @returns true if there is an intersection
  87814. */
  87815. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87816. /**
  87817. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87818. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87819. * @param frustumPlanes defines the frustum planes to test
  87820. * @return true if there is an inclusion
  87821. */
  87822. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87823. /**
  87824. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87825. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87826. * @param frustumPlanes defines the frustum planes to test
  87827. * @return true if there is an intersection
  87828. */
  87829. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87830. }
  87831. }
  87832. declare module BABYLON {
  87833. /** @hidden */
  87834. export class Collider {
  87835. /** Define if a collision was found */
  87836. collisionFound: boolean;
  87837. /**
  87838. * Define last intersection point in local space
  87839. */
  87840. intersectionPoint: Vector3;
  87841. /**
  87842. * Define last collided mesh
  87843. */
  87844. collidedMesh: Nullable<AbstractMesh>;
  87845. private _collisionPoint;
  87846. private _planeIntersectionPoint;
  87847. private _tempVector;
  87848. private _tempVector2;
  87849. private _tempVector3;
  87850. private _tempVector4;
  87851. private _edge;
  87852. private _baseToVertex;
  87853. private _destinationPoint;
  87854. private _slidePlaneNormal;
  87855. private _displacementVector;
  87856. /** @hidden */
  87857. _radius: Vector3;
  87858. /** @hidden */
  87859. _retry: number;
  87860. private _velocity;
  87861. private _basePoint;
  87862. private _epsilon;
  87863. /** @hidden */
  87864. _velocityWorldLength: number;
  87865. /** @hidden */
  87866. _basePointWorld: Vector3;
  87867. private _velocityWorld;
  87868. private _normalizedVelocity;
  87869. /** @hidden */
  87870. _initialVelocity: Vector3;
  87871. /** @hidden */
  87872. _initialPosition: Vector3;
  87873. private _nearestDistance;
  87874. private _collisionMask;
  87875. get collisionMask(): number;
  87876. set collisionMask(mask: number);
  87877. /**
  87878. * Gets the plane normal used to compute the sliding response (in local space)
  87879. */
  87880. get slidePlaneNormal(): Vector3;
  87881. /** @hidden */
  87882. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87883. /** @hidden */
  87884. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87885. /** @hidden */
  87886. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87887. /** @hidden */
  87888. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87889. /** @hidden */
  87890. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87891. /** @hidden */
  87892. _getResponse(pos: Vector3, vel: Vector3): void;
  87893. }
  87894. }
  87895. declare module BABYLON {
  87896. /**
  87897. * Interface for cullable objects
  87898. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87899. */
  87900. export interface ICullable {
  87901. /**
  87902. * Checks if the object or part of the object is in the frustum
  87903. * @param frustumPlanes Camera near/planes
  87904. * @returns true if the object is in frustum otherwise false
  87905. */
  87906. isInFrustum(frustumPlanes: Plane[]): boolean;
  87907. /**
  87908. * Checks if a cullable object (mesh...) is in the camera frustum
  87909. * Unlike isInFrustum this cheks the full bounding box
  87910. * @param frustumPlanes Camera near/planes
  87911. * @returns true if the object is in frustum otherwise false
  87912. */
  87913. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87914. }
  87915. /**
  87916. * Info for a bounding data of a mesh
  87917. */
  87918. export class BoundingInfo implements ICullable {
  87919. /**
  87920. * Bounding box for the mesh
  87921. */
  87922. readonly boundingBox: BoundingBox;
  87923. /**
  87924. * Bounding sphere for the mesh
  87925. */
  87926. readonly boundingSphere: BoundingSphere;
  87927. private _isLocked;
  87928. private static readonly TmpVector3;
  87929. /**
  87930. * Constructs bounding info
  87931. * @param minimum min vector of the bounding box/sphere
  87932. * @param maximum max vector of the bounding box/sphere
  87933. * @param worldMatrix defines the new world matrix
  87934. */
  87935. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87936. /**
  87937. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87938. * @param min defines the new minimum vector (in local space)
  87939. * @param max defines the new maximum vector (in local space)
  87940. * @param worldMatrix defines the new world matrix
  87941. */
  87942. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87943. /**
  87944. * min vector of the bounding box/sphere
  87945. */
  87946. get minimum(): Vector3;
  87947. /**
  87948. * max vector of the bounding box/sphere
  87949. */
  87950. get maximum(): Vector3;
  87951. /**
  87952. * If the info is locked and won't be updated to avoid perf overhead
  87953. */
  87954. get isLocked(): boolean;
  87955. set isLocked(value: boolean);
  87956. /**
  87957. * Updates the bounding sphere and box
  87958. * @param world world matrix to be used to update
  87959. */
  87960. update(world: DeepImmutable<Matrix>): void;
  87961. /**
  87962. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87963. * @param center New center of the bounding info
  87964. * @param extend New extend of the bounding info
  87965. * @returns the current bounding info
  87966. */
  87967. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87968. /**
  87969. * Scale the current bounding info by applying a scale factor
  87970. * @param factor defines the scale factor to apply
  87971. * @returns the current bounding info
  87972. */
  87973. scale(factor: number): BoundingInfo;
  87974. /**
  87975. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87976. * @param frustumPlanes defines the frustum to test
  87977. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87978. * @returns true if the bounding info is in the frustum planes
  87979. */
  87980. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87981. /**
  87982. * Gets the world distance between the min and max points of the bounding box
  87983. */
  87984. get diagonalLength(): number;
  87985. /**
  87986. * Checks if a cullable object (mesh...) is in the camera frustum
  87987. * Unlike isInFrustum this cheks the full bounding box
  87988. * @param frustumPlanes Camera near/planes
  87989. * @returns true if the object is in frustum otherwise false
  87990. */
  87991. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87992. /** @hidden */
  87993. _checkCollision(collider: Collider): boolean;
  87994. /**
  87995. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87996. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87997. * @param point the point to check intersection with
  87998. * @returns if the point intersects
  87999. */
  88000. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88001. /**
  88002. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88003. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88004. * @param boundingInfo the bounding info to check intersection with
  88005. * @param precise if the intersection should be done using OBB
  88006. * @returns if the bounding info intersects
  88007. */
  88008. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88009. }
  88010. }
  88011. declare module BABYLON {
  88012. /**
  88013. * Extracts minimum and maximum values from a list of indexed positions
  88014. * @param positions defines the positions to use
  88015. * @param indices defines the indices to the positions
  88016. * @param indexStart defines the start index
  88017. * @param indexCount defines the end index
  88018. * @param bias defines bias value to add to the result
  88019. * @return minimum and maximum values
  88020. */
  88021. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88022. minimum: Vector3;
  88023. maximum: Vector3;
  88024. };
  88025. /**
  88026. * Extracts minimum and maximum values from a list of positions
  88027. * @param positions defines the positions to use
  88028. * @param start defines the start index in the positions array
  88029. * @param count defines the number of positions to handle
  88030. * @param bias defines bias value to add to the result
  88031. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88032. * @return minimum and maximum values
  88033. */
  88034. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88035. minimum: Vector3;
  88036. maximum: Vector3;
  88037. };
  88038. }
  88039. declare module BABYLON {
  88040. /** @hidden */
  88041. export class WebGLDataBuffer extends DataBuffer {
  88042. private _buffer;
  88043. constructor(resource: WebGLBuffer);
  88044. get underlyingResource(): any;
  88045. }
  88046. }
  88047. declare module BABYLON {
  88048. /** @hidden */
  88049. export class WebGLPipelineContext implements IPipelineContext {
  88050. engine: ThinEngine;
  88051. program: Nullable<WebGLProgram>;
  88052. context?: WebGLRenderingContext;
  88053. vertexShader?: WebGLShader;
  88054. fragmentShader?: WebGLShader;
  88055. isParallelCompiled: boolean;
  88056. onCompiled?: () => void;
  88057. transformFeedback?: WebGLTransformFeedback | null;
  88058. vertexCompilationError: Nullable<string>;
  88059. fragmentCompilationError: Nullable<string>;
  88060. programLinkError: Nullable<string>;
  88061. programValidationError: Nullable<string>;
  88062. get isAsync(): boolean;
  88063. get isReady(): boolean;
  88064. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  88065. _getVertexShaderCode(): string | null;
  88066. _getFragmentShaderCode(): string | null;
  88067. }
  88068. }
  88069. declare module BABYLON {
  88070. interface ThinEngine {
  88071. /**
  88072. * Create an uniform buffer
  88073. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88074. * @param elements defines the content of the uniform buffer
  88075. * @returns the webGL uniform buffer
  88076. */
  88077. createUniformBuffer(elements: FloatArray): DataBuffer;
  88078. /**
  88079. * Create a dynamic uniform buffer
  88080. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88081. * @param elements defines the content of the uniform buffer
  88082. * @returns the webGL uniform buffer
  88083. */
  88084. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88085. /**
  88086. * Update an existing uniform buffer
  88087. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88088. * @param uniformBuffer defines the target uniform buffer
  88089. * @param elements defines the content to update
  88090. * @param offset defines the offset in the uniform buffer where update should start
  88091. * @param count defines the size of the data to update
  88092. */
  88093. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88094. /**
  88095. * Bind an uniform buffer to the current webGL context
  88096. * @param buffer defines the buffer to bind
  88097. */
  88098. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88099. /**
  88100. * Bind a buffer to the current webGL context at a given location
  88101. * @param buffer defines the buffer to bind
  88102. * @param location defines the index where to bind the buffer
  88103. */
  88104. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88105. /**
  88106. * Bind a specific block at a given index in a specific shader program
  88107. * @param pipelineContext defines the pipeline context to use
  88108. * @param blockName defines the block name
  88109. * @param index defines the index where to bind the block
  88110. */
  88111. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88112. }
  88113. }
  88114. declare module BABYLON {
  88115. /**
  88116. * Uniform buffer objects.
  88117. *
  88118. * Handles blocks of uniform on the GPU.
  88119. *
  88120. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88121. *
  88122. * For more information, please refer to :
  88123. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88124. */
  88125. export class UniformBuffer {
  88126. private _engine;
  88127. private _buffer;
  88128. private _data;
  88129. private _bufferData;
  88130. private _dynamic?;
  88131. private _uniformLocations;
  88132. private _uniformSizes;
  88133. private _uniformLocationPointer;
  88134. private _needSync;
  88135. private _noUBO;
  88136. private _currentEffect;
  88137. /** @hidden */
  88138. _alreadyBound: boolean;
  88139. private static _MAX_UNIFORM_SIZE;
  88140. private static _tempBuffer;
  88141. /**
  88142. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88143. * This is dynamic to allow compat with webgl 1 and 2.
  88144. * You will need to pass the name of the uniform as well as the value.
  88145. */
  88146. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88147. /**
  88148. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88149. * This is dynamic to allow compat with webgl 1 and 2.
  88150. * You will need to pass the name of the uniform as well as the value.
  88151. */
  88152. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88153. /**
  88154. * Lambda to Update a single float in a uniform buffer.
  88155. * This is dynamic to allow compat with webgl 1 and 2.
  88156. * You will need to pass the name of the uniform as well as the value.
  88157. */
  88158. updateFloat: (name: string, x: number) => void;
  88159. /**
  88160. * Lambda to Update a vec2 of float in a uniform buffer.
  88161. * This is dynamic to allow compat with webgl 1 and 2.
  88162. * You will need to pass the name of the uniform as well as the value.
  88163. */
  88164. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88165. /**
  88166. * Lambda to Update a vec3 of float in a uniform buffer.
  88167. * This is dynamic to allow compat with webgl 1 and 2.
  88168. * You will need to pass the name of the uniform as well as the value.
  88169. */
  88170. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88171. /**
  88172. * Lambda to Update a vec4 of float in a uniform buffer.
  88173. * This is dynamic to allow compat with webgl 1 and 2.
  88174. * You will need to pass the name of the uniform as well as the value.
  88175. */
  88176. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88177. /**
  88178. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88179. * This is dynamic to allow compat with webgl 1 and 2.
  88180. * You will need to pass the name of the uniform as well as the value.
  88181. */
  88182. updateMatrix: (name: string, mat: Matrix) => void;
  88183. /**
  88184. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88185. * This is dynamic to allow compat with webgl 1 and 2.
  88186. * You will need to pass the name of the uniform as well as the value.
  88187. */
  88188. updateVector3: (name: string, vector: Vector3) => void;
  88189. /**
  88190. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88191. * This is dynamic to allow compat with webgl 1 and 2.
  88192. * You will need to pass the name of the uniform as well as the value.
  88193. */
  88194. updateVector4: (name: string, vector: Vector4) => void;
  88195. /**
  88196. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88197. * This is dynamic to allow compat with webgl 1 and 2.
  88198. * You will need to pass the name of the uniform as well as the value.
  88199. */
  88200. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88201. /**
  88202. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88203. * This is dynamic to allow compat with webgl 1 and 2.
  88204. * You will need to pass the name of the uniform as well as the value.
  88205. */
  88206. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88207. /**
  88208. * Instantiates a new Uniform buffer objects.
  88209. *
  88210. * Handles blocks of uniform on the GPU.
  88211. *
  88212. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88213. *
  88214. * For more information, please refer to :
  88215. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88216. * @param engine Define the engine the buffer is associated with
  88217. * @param data Define the data contained in the buffer
  88218. * @param dynamic Define if the buffer is updatable
  88219. */
  88220. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88221. /**
  88222. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88223. * or just falling back on setUniformXXX calls.
  88224. */
  88225. get useUbo(): boolean;
  88226. /**
  88227. * Indicates if the WebGL underlying uniform buffer is in sync
  88228. * with the javascript cache data.
  88229. */
  88230. get isSync(): boolean;
  88231. /**
  88232. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88233. * Also, a dynamic UniformBuffer will disable cache verification and always
  88234. * update the underlying WebGL uniform buffer to the GPU.
  88235. * @returns if Dynamic, otherwise false
  88236. */
  88237. isDynamic(): boolean;
  88238. /**
  88239. * The data cache on JS side.
  88240. * @returns the underlying data as a float array
  88241. */
  88242. getData(): Float32Array;
  88243. /**
  88244. * The underlying WebGL Uniform buffer.
  88245. * @returns the webgl buffer
  88246. */
  88247. getBuffer(): Nullable<DataBuffer>;
  88248. /**
  88249. * std140 layout specifies how to align data within an UBO structure.
  88250. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88251. * for specs.
  88252. */
  88253. private _fillAlignment;
  88254. /**
  88255. * Adds an uniform in the buffer.
  88256. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88257. * for the layout to be correct !
  88258. * @param name Name of the uniform, as used in the uniform block in the shader.
  88259. * @param size Data size, or data directly.
  88260. */
  88261. addUniform(name: string, size: number | number[]): void;
  88262. /**
  88263. * Adds a Matrix 4x4 to the uniform buffer.
  88264. * @param name Name of the uniform, as used in the uniform block in the shader.
  88265. * @param mat A 4x4 matrix.
  88266. */
  88267. addMatrix(name: string, mat: Matrix): void;
  88268. /**
  88269. * Adds a vec2 to the uniform buffer.
  88270. * @param name Name of the uniform, as used in the uniform block in the shader.
  88271. * @param x Define the x component value of the vec2
  88272. * @param y Define the y component value of the vec2
  88273. */
  88274. addFloat2(name: string, x: number, y: number): void;
  88275. /**
  88276. * Adds a vec3 to the uniform buffer.
  88277. * @param name Name of the uniform, as used in the uniform block in the shader.
  88278. * @param x Define the x component value of the vec3
  88279. * @param y Define the y component value of the vec3
  88280. * @param z Define the z component value of the vec3
  88281. */
  88282. addFloat3(name: string, x: number, y: number, z: number): void;
  88283. /**
  88284. * Adds a vec3 to the uniform buffer.
  88285. * @param name Name of the uniform, as used in the uniform block in the shader.
  88286. * @param color Define the vec3 from a Color
  88287. */
  88288. addColor3(name: string, color: Color3): void;
  88289. /**
  88290. * Adds a vec4 to the uniform buffer.
  88291. * @param name Name of the uniform, as used in the uniform block in the shader.
  88292. * @param color Define the rgb components from a Color
  88293. * @param alpha Define the a component of the vec4
  88294. */
  88295. addColor4(name: string, color: Color3, alpha: number): void;
  88296. /**
  88297. * Adds a vec3 to the uniform buffer.
  88298. * @param name Name of the uniform, as used in the uniform block in the shader.
  88299. * @param vector Define the vec3 components from a Vector
  88300. */
  88301. addVector3(name: string, vector: Vector3): void;
  88302. /**
  88303. * Adds a Matrix 3x3 to the uniform buffer.
  88304. * @param name Name of the uniform, as used in the uniform block in the shader.
  88305. */
  88306. addMatrix3x3(name: string): void;
  88307. /**
  88308. * Adds a Matrix 2x2 to the uniform buffer.
  88309. * @param name Name of the uniform, as used in the uniform block in the shader.
  88310. */
  88311. addMatrix2x2(name: string): void;
  88312. /**
  88313. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88314. */
  88315. create(): void;
  88316. /** @hidden */
  88317. _rebuild(): void;
  88318. /**
  88319. * Updates the WebGL Uniform Buffer on the GPU.
  88320. * If the `dynamic` flag is set to true, no cache comparison is done.
  88321. * Otherwise, the buffer will be updated only if the cache differs.
  88322. */
  88323. update(): void;
  88324. /**
  88325. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88326. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88327. * @param data Define the flattened data
  88328. * @param size Define the size of the data.
  88329. */
  88330. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88331. private _valueCache;
  88332. private _cacheMatrix;
  88333. private _updateMatrix3x3ForUniform;
  88334. private _updateMatrix3x3ForEffect;
  88335. private _updateMatrix2x2ForEffect;
  88336. private _updateMatrix2x2ForUniform;
  88337. private _updateFloatForEffect;
  88338. private _updateFloatForUniform;
  88339. private _updateFloat2ForEffect;
  88340. private _updateFloat2ForUniform;
  88341. private _updateFloat3ForEffect;
  88342. private _updateFloat3ForUniform;
  88343. private _updateFloat4ForEffect;
  88344. private _updateFloat4ForUniform;
  88345. private _updateMatrixForEffect;
  88346. private _updateMatrixForUniform;
  88347. private _updateVector3ForEffect;
  88348. private _updateVector3ForUniform;
  88349. private _updateVector4ForEffect;
  88350. private _updateVector4ForUniform;
  88351. private _updateColor3ForEffect;
  88352. private _updateColor3ForUniform;
  88353. private _updateColor4ForEffect;
  88354. private _updateColor4ForUniform;
  88355. /**
  88356. * Sets a sampler uniform on the effect.
  88357. * @param name Define the name of the sampler.
  88358. * @param texture Define the texture to set in the sampler
  88359. */
  88360. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88361. /**
  88362. * Directly updates the value of the uniform in the cache AND on the GPU.
  88363. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88364. * @param data Define the flattened data
  88365. */
  88366. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88367. /**
  88368. * Binds this uniform buffer to an effect.
  88369. * @param effect Define the effect to bind the buffer to
  88370. * @param name Name of the uniform block in the shader.
  88371. */
  88372. bindToEffect(effect: Effect, name: string): void;
  88373. /**
  88374. * Disposes the uniform buffer.
  88375. */
  88376. dispose(): void;
  88377. }
  88378. }
  88379. declare module BABYLON {
  88380. /**
  88381. * Enum that determines the text-wrapping mode to use.
  88382. */
  88383. export enum InspectableType {
  88384. /**
  88385. * Checkbox for booleans
  88386. */
  88387. Checkbox = 0,
  88388. /**
  88389. * Sliders for numbers
  88390. */
  88391. Slider = 1,
  88392. /**
  88393. * Vector3
  88394. */
  88395. Vector3 = 2,
  88396. /**
  88397. * Quaternions
  88398. */
  88399. Quaternion = 3,
  88400. /**
  88401. * Color3
  88402. */
  88403. Color3 = 4,
  88404. /**
  88405. * String
  88406. */
  88407. String = 5
  88408. }
  88409. /**
  88410. * Interface used to define custom inspectable properties.
  88411. * This interface is used by the inspector to display custom property grids
  88412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88413. */
  88414. export interface IInspectable {
  88415. /**
  88416. * Gets the label to display
  88417. */
  88418. label: string;
  88419. /**
  88420. * Gets the name of the property to edit
  88421. */
  88422. propertyName: string;
  88423. /**
  88424. * Gets the type of the editor to use
  88425. */
  88426. type: InspectableType;
  88427. /**
  88428. * Gets the minimum value of the property when using in "slider" mode
  88429. */
  88430. min?: number;
  88431. /**
  88432. * Gets the maximum value of the property when using in "slider" mode
  88433. */
  88434. max?: number;
  88435. /**
  88436. * Gets the setp to use when using in "slider" mode
  88437. */
  88438. step?: number;
  88439. }
  88440. }
  88441. declare module BABYLON {
  88442. /**
  88443. * Class used to provide helper for timing
  88444. */
  88445. export class TimingTools {
  88446. /**
  88447. * Polyfill for setImmediate
  88448. * @param action defines the action to execute after the current execution block
  88449. */
  88450. static SetImmediate(action: () => void): void;
  88451. }
  88452. }
  88453. declare module BABYLON {
  88454. /**
  88455. * Class used to enable instatition of objects by class name
  88456. */
  88457. export class InstantiationTools {
  88458. /**
  88459. * Use this object to register external classes like custom textures or material
  88460. * to allow the laoders to instantiate them
  88461. */
  88462. static RegisteredExternalClasses: {
  88463. [key: string]: Object;
  88464. };
  88465. /**
  88466. * Tries to instantiate a new object from a given class name
  88467. * @param className defines the class name to instantiate
  88468. * @returns the new object or null if the system was not able to do the instantiation
  88469. */
  88470. static Instantiate(className: string): any;
  88471. }
  88472. }
  88473. declare module BABYLON {
  88474. /**
  88475. * Define options used to create a depth texture
  88476. */
  88477. export class DepthTextureCreationOptions {
  88478. /** Specifies whether or not a stencil should be allocated in the texture */
  88479. generateStencil?: boolean;
  88480. /** Specifies whether or not bilinear filtering is enable on the texture */
  88481. bilinearFiltering?: boolean;
  88482. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88483. comparisonFunction?: number;
  88484. /** Specifies if the created texture is a cube texture */
  88485. isCube?: boolean;
  88486. }
  88487. }
  88488. declare module BABYLON {
  88489. interface ThinEngine {
  88490. /**
  88491. * Creates a depth stencil cube texture.
  88492. * This is only available in WebGL 2.
  88493. * @param size The size of face edge in the cube texture.
  88494. * @param options The options defining the cube texture.
  88495. * @returns The cube texture
  88496. */
  88497. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88498. /**
  88499. * Creates a cube texture
  88500. * @param rootUrl defines the url where the files to load is located
  88501. * @param scene defines the current scene
  88502. * @param files defines the list of files to load (1 per face)
  88503. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88504. * @param onLoad defines an optional callback raised when the texture is loaded
  88505. * @param onError defines an optional callback raised if there is an issue to load the texture
  88506. * @param format defines the format of the data
  88507. * @param forcedExtension defines the extension to use to pick the right loader
  88508. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88509. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88510. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88511. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88512. * @returns the cube texture as an InternalTexture
  88513. */
  88514. 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;
  88515. /**
  88516. * Creates a cube texture
  88517. * @param rootUrl defines the url where the files to load is located
  88518. * @param scene defines the current scene
  88519. * @param files defines the list of files to load (1 per face)
  88520. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88521. * @param onLoad defines an optional callback raised when the texture is loaded
  88522. * @param onError defines an optional callback raised if there is an issue to load the texture
  88523. * @param format defines the format of the data
  88524. * @param forcedExtension defines the extension to use to pick the right loader
  88525. * @returns the cube texture as an InternalTexture
  88526. */
  88527. 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;
  88528. /**
  88529. * Creates a cube texture
  88530. * @param rootUrl defines the url where the files to load is located
  88531. * @param scene defines the current scene
  88532. * @param files defines the list of files to load (1 per face)
  88533. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88534. * @param onLoad defines an optional callback raised when the texture is loaded
  88535. * @param onError defines an optional callback raised if there is an issue to load the texture
  88536. * @param format defines the format of the data
  88537. * @param forcedExtension defines the extension to use to pick the right loader
  88538. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88539. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88540. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88541. * @returns the cube texture as an InternalTexture
  88542. */
  88543. 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;
  88544. /** @hidden */
  88545. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88546. /** @hidden */
  88547. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88548. /** @hidden */
  88549. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88550. /** @hidden */
  88551. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88552. /**
  88553. * @hidden
  88554. */
  88555. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88556. }
  88557. }
  88558. declare module BABYLON {
  88559. /**
  88560. * Class for creating a cube texture
  88561. */
  88562. export class CubeTexture extends BaseTexture {
  88563. private _delayedOnLoad;
  88564. /**
  88565. * Observable triggered once the texture has been loaded.
  88566. */
  88567. onLoadObservable: Observable<CubeTexture>;
  88568. /**
  88569. * The url of the texture
  88570. */
  88571. url: string;
  88572. /**
  88573. * Gets or sets the center of the bounding box associated with the cube texture.
  88574. * It must define where the camera used to render the texture was set
  88575. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88576. */
  88577. boundingBoxPosition: Vector3;
  88578. private _boundingBoxSize;
  88579. /**
  88580. * Gets or sets the size of the bounding box associated with the cube texture
  88581. * When defined, the cubemap will switch to local mode
  88582. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88583. * @example https://www.babylonjs-playground.com/#RNASML
  88584. */
  88585. set boundingBoxSize(value: Vector3);
  88586. /**
  88587. * Returns the bounding box size
  88588. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88589. */
  88590. get boundingBoxSize(): Vector3;
  88591. protected _rotationY: number;
  88592. /**
  88593. * Sets texture matrix rotation angle around Y axis in radians.
  88594. */
  88595. set rotationY(value: number);
  88596. /**
  88597. * Gets texture matrix rotation angle around Y axis radians.
  88598. */
  88599. get rotationY(): number;
  88600. /**
  88601. * Are mip maps generated for this texture or not.
  88602. */
  88603. get noMipmap(): boolean;
  88604. private _noMipmap;
  88605. private _files;
  88606. protected _forcedExtension: Nullable<string>;
  88607. private _extensions;
  88608. private _textureMatrix;
  88609. private _format;
  88610. private _createPolynomials;
  88611. /**
  88612. * Creates a cube texture from an array of image urls
  88613. * @param files defines an array of image urls
  88614. * @param scene defines the hosting scene
  88615. * @param noMipmap specifies if mip maps are not used
  88616. * @returns a cube texture
  88617. */
  88618. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88619. /**
  88620. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88621. * @param url defines the url of the prefiltered texture
  88622. * @param scene defines the scene the texture is attached to
  88623. * @param forcedExtension defines the extension of the file if different from the url
  88624. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88625. * @return the prefiltered texture
  88626. */
  88627. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88628. /**
  88629. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88630. * as prefiltered data.
  88631. * @param rootUrl defines the url of the texture or the root name of the six images
  88632. * @param null defines the scene or engine the texture is attached to
  88633. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88634. * @param noMipmap defines if mipmaps should be created or not
  88635. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88636. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88637. * @param onError defines a callback triggered in case of error during load
  88638. * @param format defines the internal format to use for the texture once loaded
  88639. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88640. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88641. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88642. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88643. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88644. * @return the cube texture
  88645. */
  88646. 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);
  88647. /**
  88648. * Get the current class name of the texture useful for serialization or dynamic coding.
  88649. * @returns "CubeTexture"
  88650. */
  88651. getClassName(): string;
  88652. /**
  88653. * Update the url (and optional buffer) of this texture if url was null during construction.
  88654. * @param url the url of the texture
  88655. * @param forcedExtension defines the extension to use
  88656. * @param onLoad callback called when the texture is loaded (defaults to null)
  88657. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88658. */
  88659. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88660. /**
  88661. * Delays loading of the cube texture
  88662. * @param forcedExtension defines the extension to use
  88663. */
  88664. delayLoad(forcedExtension?: string): void;
  88665. /**
  88666. * Returns the reflection texture matrix
  88667. * @returns the reflection texture matrix
  88668. */
  88669. getReflectionTextureMatrix(): Matrix;
  88670. /**
  88671. * Sets the reflection texture matrix
  88672. * @param value Reflection texture matrix
  88673. */
  88674. setReflectionTextureMatrix(value: Matrix): void;
  88675. /**
  88676. * Parses text to create a cube texture
  88677. * @param parsedTexture define the serialized text to read from
  88678. * @param scene defines the hosting scene
  88679. * @param rootUrl defines the root url of the cube texture
  88680. * @returns a cube texture
  88681. */
  88682. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88683. /**
  88684. * Makes a clone, or deep copy, of the cube texture
  88685. * @returns a new cube texture
  88686. */
  88687. clone(): CubeTexture;
  88688. }
  88689. }
  88690. declare module BABYLON {
  88691. /**
  88692. * Manages the defines for the Material
  88693. */
  88694. export class MaterialDefines {
  88695. /** @hidden */
  88696. protected _keys: string[];
  88697. private _isDirty;
  88698. /** @hidden */
  88699. _renderId: number;
  88700. /** @hidden */
  88701. _areLightsDirty: boolean;
  88702. /** @hidden */
  88703. _areLightsDisposed: boolean;
  88704. /** @hidden */
  88705. _areAttributesDirty: boolean;
  88706. /** @hidden */
  88707. _areTexturesDirty: boolean;
  88708. /** @hidden */
  88709. _areFresnelDirty: boolean;
  88710. /** @hidden */
  88711. _areMiscDirty: boolean;
  88712. /** @hidden */
  88713. _arePrePassDirty: boolean;
  88714. /** @hidden */
  88715. _areImageProcessingDirty: boolean;
  88716. /** @hidden */
  88717. _normals: boolean;
  88718. /** @hidden */
  88719. _uvs: boolean;
  88720. /** @hidden */
  88721. _needNormals: boolean;
  88722. /** @hidden */
  88723. _needUVs: boolean;
  88724. [id: string]: any;
  88725. /**
  88726. * Specifies if the material needs to be re-calculated
  88727. */
  88728. get isDirty(): boolean;
  88729. /**
  88730. * Marks the material to indicate that it has been re-calculated
  88731. */
  88732. markAsProcessed(): void;
  88733. /**
  88734. * Marks the material to indicate that it needs to be re-calculated
  88735. */
  88736. markAsUnprocessed(): void;
  88737. /**
  88738. * Marks the material to indicate all of its defines need to be re-calculated
  88739. */
  88740. markAllAsDirty(): void;
  88741. /**
  88742. * Marks the material to indicate that image processing needs to be re-calculated
  88743. */
  88744. markAsImageProcessingDirty(): void;
  88745. /**
  88746. * Marks the material to indicate the lights need to be re-calculated
  88747. * @param disposed Defines whether the light is dirty due to dispose or not
  88748. */
  88749. markAsLightDirty(disposed?: boolean): void;
  88750. /**
  88751. * Marks the attribute state as changed
  88752. */
  88753. markAsAttributesDirty(): void;
  88754. /**
  88755. * Marks the texture state as changed
  88756. */
  88757. markAsTexturesDirty(): void;
  88758. /**
  88759. * Marks the fresnel state as changed
  88760. */
  88761. markAsFresnelDirty(): void;
  88762. /**
  88763. * Marks the misc state as changed
  88764. */
  88765. markAsMiscDirty(): void;
  88766. /**
  88767. * Marks the prepass state as changed
  88768. */
  88769. markAsPrePassDirty(): void;
  88770. /**
  88771. * Rebuilds the material defines
  88772. */
  88773. rebuild(): void;
  88774. /**
  88775. * Specifies if two material defines are equal
  88776. * @param other - A material define instance to compare to
  88777. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88778. */
  88779. isEqual(other: MaterialDefines): boolean;
  88780. /**
  88781. * Clones this instance's defines to another instance
  88782. * @param other - material defines to clone values to
  88783. */
  88784. cloneTo(other: MaterialDefines): void;
  88785. /**
  88786. * Resets the material define values
  88787. */
  88788. reset(): void;
  88789. /**
  88790. * Converts the material define values to a string
  88791. * @returns - String of material define information
  88792. */
  88793. toString(): string;
  88794. }
  88795. }
  88796. declare module BABYLON {
  88797. /**
  88798. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88799. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88800. * 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;
  88801. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88802. */
  88803. export class ColorCurves {
  88804. private _dirty;
  88805. private _tempColor;
  88806. private _globalCurve;
  88807. private _highlightsCurve;
  88808. private _midtonesCurve;
  88809. private _shadowsCurve;
  88810. private _positiveCurve;
  88811. private _negativeCurve;
  88812. private _globalHue;
  88813. private _globalDensity;
  88814. private _globalSaturation;
  88815. private _globalExposure;
  88816. /**
  88817. * Gets the global Hue value.
  88818. * 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).
  88819. */
  88820. get globalHue(): number;
  88821. /**
  88822. * Sets the global Hue value.
  88823. * 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).
  88824. */
  88825. set globalHue(value: number);
  88826. /**
  88827. * Gets the global Density value.
  88828. * 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.
  88829. * Values less than zero provide a filter of opposite hue.
  88830. */
  88831. get globalDensity(): number;
  88832. /**
  88833. * Sets the global Density value.
  88834. * 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.
  88835. * Values less than zero provide a filter of opposite hue.
  88836. */
  88837. set globalDensity(value: number);
  88838. /**
  88839. * Gets the global Saturation value.
  88840. * 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.
  88841. */
  88842. get globalSaturation(): number;
  88843. /**
  88844. * Sets the global Saturation value.
  88845. * 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.
  88846. */
  88847. set globalSaturation(value: number);
  88848. /**
  88849. * Gets the global Exposure value.
  88850. * 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.
  88851. */
  88852. get globalExposure(): number;
  88853. /**
  88854. * Sets the global Exposure value.
  88855. * 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.
  88856. */
  88857. set globalExposure(value: number);
  88858. private _highlightsHue;
  88859. private _highlightsDensity;
  88860. private _highlightsSaturation;
  88861. private _highlightsExposure;
  88862. /**
  88863. * Gets the highlights Hue value.
  88864. * 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).
  88865. */
  88866. get highlightsHue(): number;
  88867. /**
  88868. * Sets the highlights Hue value.
  88869. * 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).
  88870. */
  88871. set highlightsHue(value: number);
  88872. /**
  88873. * Gets the highlights Density value.
  88874. * 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.
  88875. * Values less than zero provide a filter of opposite hue.
  88876. */
  88877. get highlightsDensity(): number;
  88878. /**
  88879. * Sets the highlights Density value.
  88880. * 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.
  88881. * Values less than zero provide a filter of opposite hue.
  88882. */
  88883. set highlightsDensity(value: number);
  88884. /**
  88885. * Gets the highlights Saturation value.
  88886. * 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.
  88887. */
  88888. get highlightsSaturation(): number;
  88889. /**
  88890. * Sets the highlights Saturation value.
  88891. * 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.
  88892. */
  88893. set highlightsSaturation(value: number);
  88894. /**
  88895. * Gets the highlights Exposure value.
  88896. * 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.
  88897. */
  88898. get highlightsExposure(): number;
  88899. /**
  88900. * Sets the highlights Exposure value.
  88901. * 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.
  88902. */
  88903. set highlightsExposure(value: number);
  88904. private _midtonesHue;
  88905. private _midtonesDensity;
  88906. private _midtonesSaturation;
  88907. private _midtonesExposure;
  88908. /**
  88909. * Gets the midtones Hue value.
  88910. * 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).
  88911. */
  88912. get midtonesHue(): number;
  88913. /**
  88914. * Sets the midtones Hue value.
  88915. * 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).
  88916. */
  88917. set midtonesHue(value: number);
  88918. /**
  88919. * Gets the midtones Density value.
  88920. * 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.
  88921. * Values less than zero provide a filter of opposite hue.
  88922. */
  88923. get midtonesDensity(): number;
  88924. /**
  88925. * Sets the midtones Density value.
  88926. * 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.
  88927. * Values less than zero provide a filter of opposite hue.
  88928. */
  88929. set midtonesDensity(value: number);
  88930. /**
  88931. * Gets the midtones Saturation value.
  88932. * 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.
  88933. */
  88934. get midtonesSaturation(): number;
  88935. /**
  88936. * Sets the midtones Saturation value.
  88937. * 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.
  88938. */
  88939. set midtonesSaturation(value: number);
  88940. /**
  88941. * Gets the midtones Exposure value.
  88942. * 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.
  88943. */
  88944. get midtonesExposure(): number;
  88945. /**
  88946. * Sets the midtones Exposure value.
  88947. * 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.
  88948. */
  88949. set midtonesExposure(value: number);
  88950. private _shadowsHue;
  88951. private _shadowsDensity;
  88952. private _shadowsSaturation;
  88953. private _shadowsExposure;
  88954. /**
  88955. * Gets the shadows Hue value.
  88956. * 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).
  88957. */
  88958. get shadowsHue(): number;
  88959. /**
  88960. * Sets the shadows Hue value.
  88961. * 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).
  88962. */
  88963. set shadowsHue(value: number);
  88964. /**
  88965. * Gets the shadows Density value.
  88966. * 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.
  88967. * Values less than zero provide a filter of opposite hue.
  88968. */
  88969. get shadowsDensity(): number;
  88970. /**
  88971. * Sets the shadows Density value.
  88972. * 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.
  88973. * Values less than zero provide a filter of opposite hue.
  88974. */
  88975. set shadowsDensity(value: number);
  88976. /**
  88977. * Gets the shadows Saturation value.
  88978. * 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.
  88979. */
  88980. get shadowsSaturation(): number;
  88981. /**
  88982. * Sets the shadows Saturation value.
  88983. * 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.
  88984. */
  88985. set shadowsSaturation(value: number);
  88986. /**
  88987. * Gets the shadows Exposure value.
  88988. * 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.
  88989. */
  88990. get shadowsExposure(): number;
  88991. /**
  88992. * Sets the shadows Exposure value.
  88993. * 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.
  88994. */
  88995. set shadowsExposure(value: number);
  88996. /**
  88997. * Returns the class name
  88998. * @returns The class name
  88999. */
  89000. getClassName(): string;
  89001. /**
  89002. * Binds the color curves to the shader.
  89003. * @param colorCurves The color curve to bind
  89004. * @param effect The effect to bind to
  89005. * @param positiveUniform The positive uniform shader parameter
  89006. * @param neutralUniform The neutral uniform shader parameter
  89007. * @param negativeUniform The negative uniform shader parameter
  89008. */
  89009. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89010. /**
  89011. * Prepare the list of uniforms associated with the ColorCurves effects.
  89012. * @param uniformsList The list of uniforms used in the effect
  89013. */
  89014. static PrepareUniforms(uniformsList: string[]): void;
  89015. /**
  89016. * Returns color grading data based on a hue, density, saturation and exposure value.
  89017. * @param filterHue The hue of the color filter.
  89018. * @param filterDensity The density of the color filter.
  89019. * @param saturation The saturation.
  89020. * @param exposure The exposure.
  89021. * @param result The result data container.
  89022. */
  89023. private getColorGradingDataToRef;
  89024. /**
  89025. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89026. * @param value The input slider value in range [-100,100].
  89027. * @returns Adjusted value.
  89028. */
  89029. private static applyColorGradingSliderNonlinear;
  89030. /**
  89031. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89032. * @param hue The hue (H) input.
  89033. * @param saturation The saturation (S) input.
  89034. * @param brightness The brightness (B) input.
  89035. * @result An RGBA color represented as Vector4.
  89036. */
  89037. private static fromHSBToRef;
  89038. /**
  89039. * Returns a value clamped between min and max
  89040. * @param value The value to clamp
  89041. * @param min The minimum of value
  89042. * @param max The maximum of value
  89043. * @returns The clamped value.
  89044. */
  89045. private static clamp;
  89046. /**
  89047. * Clones the current color curve instance.
  89048. * @return The cloned curves
  89049. */
  89050. clone(): ColorCurves;
  89051. /**
  89052. * Serializes the current color curve instance to a json representation.
  89053. * @return a JSON representation
  89054. */
  89055. serialize(): any;
  89056. /**
  89057. * Parses the color curve from a json representation.
  89058. * @param source the JSON source to parse
  89059. * @return The parsed curves
  89060. */
  89061. static Parse(source: any): ColorCurves;
  89062. }
  89063. }
  89064. declare module BABYLON {
  89065. /**
  89066. * Interface to follow in your material defines to integrate easily the
  89067. * Image proccessing functions.
  89068. * @hidden
  89069. */
  89070. export interface IImageProcessingConfigurationDefines {
  89071. IMAGEPROCESSING: boolean;
  89072. VIGNETTE: boolean;
  89073. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89074. VIGNETTEBLENDMODEOPAQUE: boolean;
  89075. TONEMAPPING: boolean;
  89076. TONEMAPPING_ACES: boolean;
  89077. CONTRAST: boolean;
  89078. EXPOSURE: boolean;
  89079. COLORCURVES: boolean;
  89080. COLORGRADING: boolean;
  89081. COLORGRADING3D: boolean;
  89082. SAMPLER3DGREENDEPTH: boolean;
  89083. SAMPLER3DBGRMAP: boolean;
  89084. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89085. }
  89086. /**
  89087. * @hidden
  89088. */
  89089. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89090. IMAGEPROCESSING: boolean;
  89091. VIGNETTE: boolean;
  89092. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89093. VIGNETTEBLENDMODEOPAQUE: boolean;
  89094. TONEMAPPING: boolean;
  89095. TONEMAPPING_ACES: boolean;
  89096. CONTRAST: boolean;
  89097. COLORCURVES: boolean;
  89098. COLORGRADING: boolean;
  89099. COLORGRADING3D: boolean;
  89100. SAMPLER3DGREENDEPTH: boolean;
  89101. SAMPLER3DBGRMAP: boolean;
  89102. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89103. EXPOSURE: boolean;
  89104. constructor();
  89105. }
  89106. /**
  89107. * This groups together the common properties used for image processing either in direct forward pass
  89108. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89109. * or not.
  89110. */
  89111. export class ImageProcessingConfiguration {
  89112. /**
  89113. * Default tone mapping applied in BabylonJS.
  89114. */
  89115. static readonly TONEMAPPING_STANDARD: number;
  89116. /**
  89117. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89118. * to other engines rendering to increase portability.
  89119. */
  89120. static readonly TONEMAPPING_ACES: number;
  89121. /**
  89122. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89123. */
  89124. colorCurves: Nullable<ColorCurves>;
  89125. private _colorCurvesEnabled;
  89126. /**
  89127. * Gets wether the color curves effect is enabled.
  89128. */
  89129. get colorCurvesEnabled(): boolean;
  89130. /**
  89131. * Sets wether the color curves effect is enabled.
  89132. */
  89133. set colorCurvesEnabled(value: boolean);
  89134. private _colorGradingTexture;
  89135. /**
  89136. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89137. */
  89138. get colorGradingTexture(): Nullable<BaseTexture>;
  89139. /**
  89140. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89141. */
  89142. set colorGradingTexture(value: Nullable<BaseTexture>);
  89143. private _colorGradingEnabled;
  89144. /**
  89145. * Gets wether the color grading effect is enabled.
  89146. */
  89147. get colorGradingEnabled(): boolean;
  89148. /**
  89149. * Sets wether the color grading effect is enabled.
  89150. */
  89151. set colorGradingEnabled(value: boolean);
  89152. private _colorGradingWithGreenDepth;
  89153. /**
  89154. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89155. */
  89156. get colorGradingWithGreenDepth(): boolean;
  89157. /**
  89158. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89159. */
  89160. set colorGradingWithGreenDepth(value: boolean);
  89161. private _colorGradingBGR;
  89162. /**
  89163. * Gets wether the color grading texture contains BGR values.
  89164. */
  89165. get colorGradingBGR(): boolean;
  89166. /**
  89167. * Sets wether the color grading texture contains BGR values.
  89168. */
  89169. set colorGradingBGR(value: boolean);
  89170. /** @hidden */
  89171. _exposure: number;
  89172. /**
  89173. * Gets the Exposure used in the effect.
  89174. */
  89175. get exposure(): number;
  89176. /**
  89177. * Sets the Exposure used in the effect.
  89178. */
  89179. set exposure(value: number);
  89180. private _toneMappingEnabled;
  89181. /**
  89182. * Gets wether the tone mapping effect is enabled.
  89183. */
  89184. get toneMappingEnabled(): boolean;
  89185. /**
  89186. * Sets wether the tone mapping effect is enabled.
  89187. */
  89188. set toneMappingEnabled(value: boolean);
  89189. private _toneMappingType;
  89190. /**
  89191. * Gets the type of tone mapping effect.
  89192. */
  89193. get toneMappingType(): number;
  89194. /**
  89195. * Sets the type of tone mapping effect used in BabylonJS.
  89196. */
  89197. set toneMappingType(value: number);
  89198. protected _contrast: number;
  89199. /**
  89200. * Gets the contrast used in the effect.
  89201. */
  89202. get contrast(): number;
  89203. /**
  89204. * Sets the contrast used in the effect.
  89205. */
  89206. set contrast(value: number);
  89207. /**
  89208. * Vignette stretch size.
  89209. */
  89210. vignetteStretch: number;
  89211. /**
  89212. * Vignette centre X Offset.
  89213. */
  89214. vignetteCentreX: number;
  89215. /**
  89216. * Vignette centre Y Offset.
  89217. */
  89218. vignetteCentreY: number;
  89219. /**
  89220. * Vignette weight or intensity of the vignette effect.
  89221. */
  89222. vignetteWeight: number;
  89223. /**
  89224. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89225. * if vignetteEnabled is set to true.
  89226. */
  89227. vignetteColor: Color4;
  89228. /**
  89229. * Camera field of view used by the Vignette effect.
  89230. */
  89231. vignetteCameraFov: number;
  89232. private _vignetteBlendMode;
  89233. /**
  89234. * Gets the vignette blend mode allowing different kind of effect.
  89235. */
  89236. get vignetteBlendMode(): number;
  89237. /**
  89238. * Sets the vignette blend mode allowing different kind of effect.
  89239. */
  89240. set vignetteBlendMode(value: number);
  89241. private _vignetteEnabled;
  89242. /**
  89243. * Gets wether the vignette effect is enabled.
  89244. */
  89245. get vignetteEnabled(): boolean;
  89246. /**
  89247. * Sets wether the vignette effect is enabled.
  89248. */
  89249. set vignetteEnabled(value: boolean);
  89250. private _applyByPostProcess;
  89251. /**
  89252. * Gets wether the image processing is applied through a post process or not.
  89253. */
  89254. get applyByPostProcess(): boolean;
  89255. /**
  89256. * Sets wether the image processing is applied through a post process or not.
  89257. */
  89258. set applyByPostProcess(value: boolean);
  89259. private _isEnabled;
  89260. /**
  89261. * Gets wether the image processing is enabled or not.
  89262. */
  89263. get isEnabled(): boolean;
  89264. /**
  89265. * Sets wether the image processing is enabled or not.
  89266. */
  89267. set isEnabled(value: boolean);
  89268. /**
  89269. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89270. */
  89271. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89272. /**
  89273. * Method called each time the image processing information changes requires to recompile the effect.
  89274. */
  89275. protected _updateParameters(): void;
  89276. /**
  89277. * Gets the current class name.
  89278. * @return "ImageProcessingConfiguration"
  89279. */
  89280. getClassName(): string;
  89281. /**
  89282. * Prepare the list of uniforms associated with the Image Processing effects.
  89283. * @param uniforms The list of uniforms used in the effect
  89284. * @param defines the list of defines currently in use
  89285. */
  89286. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89287. /**
  89288. * Prepare the list of samplers associated with the Image Processing effects.
  89289. * @param samplersList The list of uniforms used in the effect
  89290. * @param defines the list of defines currently in use
  89291. */
  89292. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89293. /**
  89294. * Prepare the list of defines associated to the shader.
  89295. * @param defines the list of defines to complete
  89296. * @param forPostProcess Define if we are currently in post process mode or not
  89297. */
  89298. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89299. /**
  89300. * Returns true if all the image processing information are ready.
  89301. * @returns True if ready, otherwise, false
  89302. */
  89303. isReady(): boolean;
  89304. /**
  89305. * Binds the image processing to the shader.
  89306. * @param effect The effect to bind to
  89307. * @param overrideAspectRatio Override the aspect ratio of the effect
  89308. */
  89309. bind(effect: Effect, overrideAspectRatio?: number): void;
  89310. /**
  89311. * Clones the current image processing instance.
  89312. * @return The cloned image processing
  89313. */
  89314. clone(): ImageProcessingConfiguration;
  89315. /**
  89316. * Serializes the current image processing instance to a json representation.
  89317. * @return a JSON representation
  89318. */
  89319. serialize(): any;
  89320. /**
  89321. * Parses the image processing from a json representation.
  89322. * @param source the JSON source to parse
  89323. * @return The parsed image processing
  89324. */
  89325. static Parse(source: any): ImageProcessingConfiguration;
  89326. private static _VIGNETTEMODE_MULTIPLY;
  89327. private static _VIGNETTEMODE_OPAQUE;
  89328. /**
  89329. * Used to apply the vignette as a mix with the pixel color.
  89330. */
  89331. static get VIGNETTEMODE_MULTIPLY(): number;
  89332. /**
  89333. * Used to apply the vignette as a replacement of the pixel color.
  89334. */
  89335. static get VIGNETTEMODE_OPAQUE(): number;
  89336. }
  89337. }
  89338. declare module BABYLON {
  89339. /** @hidden */
  89340. export var postprocessVertexShader: {
  89341. name: string;
  89342. shader: string;
  89343. };
  89344. }
  89345. declare module BABYLON {
  89346. /**
  89347. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89348. */
  89349. export type RenderTargetTextureSize = number | {
  89350. width: number;
  89351. height: number;
  89352. layers?: number;
  89353. };
  89354. interface ThinEngine {
  89355. /**
  89356. * Creates a new render target texture
  89357. * @param size defines the size of the texture
  89358. * @param options defines the options used to create the texture
  89359. * @returns a new render target texture stored in an InternalTexture
  89360. */
  89361. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89362. /**
  89363. * Creates a depth stencil texture.
  89364. * This is only available in WebGL 2 or with the depth texture extension available.
  89365. * @param size The size of face edge in the texture.
  89366. * @param options The options defining the texture.
  89367. * @returns The texture
  89368. */
  89369. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89370. /** @hidden */
  89371. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89372. }
  89373. }
  89374. declare module BABYLON {
  89375. /**
  89376. * Defines the kind of connection point for node based material
  89377. */
  89378. export enum NodeMaterialBlockConnectionPointTypes {
  89379. /** Float */
  89380. Float = 1,
  89381. /** Int */
  89382. Int = 2,
  89383. /** Vector2 */
  89384. Vector2 = 4,
  89385. /** Vector3 */
  89386. Vector3 = 8,
  89387. /** Vector4 */
  89388. Vector4 = 16,
  89389. /** Color3 */
  89390. Color3 = 32,
  89391. /** Color4 */
  89392. Color4 = 64,
  89393. /** Matrix */
  89394. Matrix = 128,
  89395. /** Custom object */
  89396. Object = 256,
  89397. /** Detect type based on connection */
  89398. AutoDetect = 1024,
  89399. /** Output type that will be defined by input type */
  89400. BasedOnInput = 2048
  89401. }
  89402. }
  89403. declare module BABYLON {
  89404. /**
  89405. * Enum used to define the target of a block
  89406. */
  89407. export enum NodeMaterialBlockTargets {
  89408. /** Vertex shader */
  89409. Vertex = 1,
  89410. /** Fragment shader */
  89411. Fragment = 2,
  89412. /** Neutral */
  89413. Neutral = 4,
  89414. /** Vertex and Fragment */
  89415. VertexAndFragment = 3
  89416. }
  89417. }
  89418. declare module BABYLON {
  89419. /**
  89420. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89421. */
  89422. export enum NodeMaterialBlockConnectionPointMode {
  89423. /** Value is an uniform */
  89424. Uniform = 0,
  89425. /** Value is a mesh attribute */
  89426. Attribute = 1,
  89427. /** Value is a varying between vertex and fragment shaders */
  89428. Varying = 2,
  89429. /** Mode is undefined */
  89430. Undefined = 3
  89431. }
  89432. }
  89433. declare module BABYLON {
  89434. /**
  89435. * Enum used to define system values e.g. values automatically provided by the system
  89436. */
  89437. export enum NodeMaterialSystemValues {
  89438. /** World */
  89439. World = 1,
  89440. /** View */
  89441. View = 2,
  89442. /** Projection */
  89443. Projection = 3,
  89444. /** ViewProjection */
  89445. ViewProjection = 4,
  89446. /** WorldView */
  89447. WorldView = 5,
  89448. /** WorldViewProjection */
  89449. WorldViewProjection = 6,
  89450. /** CameraPosition */
  89451. CameraPosition = 7,
  89452. /** Fog Color */
  89453. FogColor = 8,
  89454. /** Delta time */
  89455. DeltaTime = 9
  89456. }
  89457. }
  89458. declare module BABYLON {
  89459. /** Defines supported spaces */
  89460. export enum Space {
  89461. /** Local (object) space */
  89462. LOCAL = 0,
  89463. /** World space */
  89464. WORLD = 1,
  89465. /** Bone space */
  89466. BONE = 2
  89467. }
  89468. /** Defines the 3 main axes */
  89469. export class Axis {
  89470. /** X axis */
  89471. static X: Vector3;
  89472. /** Y axis */
  89473. static Y: Vector3;
  89474. /** Z axis */
  89475. static Z: Vector3;
  89476. }
  89477. }
  89478. declare module BABYLON {
  89479. /**
  89480. * Represents a camera frustum
  89481. */
  89482. export class Frustum {
  89483. /**
  89484. * Gets the planes representing the frustum
  89485. * @param transform matrix to be applied to the returned planes
  89486. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89487. */
  89488. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89489. /**
  89490. * Gets the near frustum plane transformed by the transform matrix
  89491. * @param transform transformation matrix to be applied to the resulting frustum plane
  89492. * @param frustumPlane the resuling frustum plane
  89493. */
  89494. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89495. /**
  89496. * Gets the far frustum plane transformed by the transform matrix
  89497. * @param transform transformation matrix to be applied to the resulting frustum plane
  89498. * @param frustumPlane the resuling frustum plane
  89499. */
  89500. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89501. /**
  89502. * Gets the left frustum plane transformed by the transform matrix
  89503. * @param transform transformation matrix to be applied to the resulting frustum plane
  89504. * @param frustumPlane the resuling frustum plane
  89505. */
  89506. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89507. /**
  89508. * Gets the right frustum plane transformed by the transform matrix
  89509. * @param transform transformation matrix to be applied to the resulting frustum plane
  89510. * @param frustumPlane the resuling frustum plane
  89511. */
  89512. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89513. /**
  89514. * Gets the top frustum plane transformed by the transform matrix
  89515. * @param transform transformation matrix to be applied to the resulting frustum plane
  89516. * @param frustumPlane the resuling frustum plane
  89517. */
  89518. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89519. /**
  89520. * Gets the bottom frustum plane transformed by the transform matrix
  89521. * @param transform transformation matrix to be applied to the resulting frustum plane
  89522. * @param frustumPlane the resuling frustum plane
  89523. */
  89524. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89525. /**
  89526. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89527. * @param transform transformation matrix to be applied to the resulting frustum planes
  89528. * @param frustumPlanes the resuling frustum planes
  89529. */
  89530. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89531. }
  89532. }
  89533. declare module BABYLON {
  89534. /**
  89535. * Interface for the size containing width and height
  89536. */
  89537. export interface ISize {
  89538. /**
  89539. * Width
  89540. */
  89541. width: number;
  89542. /**
  89543. * Heighht
  89544. */
  89545. height: number;
  89546. }
  89547. /**
  89548. * Size containing widht and height
  89549. */
  89550. export class Size implements ISize {
  89551. /**
  89552. * Width
  89553. */
  89554. width: number;
  89555. /**
  89556. * Height
  89557. */
  89558. height: number;
  89559. /**
  89560. * Creates a Size object from the given width and height (floats).
  89561. * @param width width of the new size
  89562. * @param height height of the new size
  89563. */
  89564. constructor(width: number, height: number);
  89565. /**
  89566. * Returns a string with the Size width and height
  89567. * @returns a string with the Size width and height
  89568. */
  89569. toString(): string;
  89570. /**
  89571. * "Size"
  89572. * @returns the string "Size"
  89573. */
  89574. getClassName(): string;
  89575. /**
  89576. * Returns the Size hash code.
  89577. * @returns a hash code for a unique width and height
  89578. */
  89579. getHashCode(): number;
  89580. /**
  89581. * Updates the current size from the given one.
  89582. * @param src the given size
  89583. */
  89584. copyFrom(src: Size): void;
  89585. /**
  89586. * Updates in place the current Size from the given floats.
  89587. * @param width width of the new size
  89588. * @param height height of the new size
  89589. * @returns the updated Size.
  89590. */
  89591. copyFromFloats(width: number, height: number): Size;
  89592. /**
  89593. * Updates in place the current Size from the given floats.
  89594. * @param width width to set
  89595. * @param height height to set
  89596. * @returns the updated Size.
  89597. */
  89598. set(width: number, height: number): Size;
  89599. /**
  89600. * Multiplies the width and height by numbers
  89601. * @param w factor to multiple the width by
  89602. * @param h factor to multiple the height by
  89603. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89604. */
  89605. multiplyByFloats(w: number, h: number): Size;
  89606. /**
  89607. * Clones the size
  89608. * @returns a new Size copied from the given one.
  89609. */
  89610. clone(): Size;
  89611. /**
  89612. * True if the current Size and the given one width and height are strictly equal.
  89613. * @param other the other size to compare against
  89614. * @returns True if the current Size and the given one width and height are strictly equal.
  89615. */
  89616. equals(other: Size): boolean;
  89617. /**
  89618. * The surface of the Size : width * height (float).
  89619. */
  89620. get surface(): number;
  89621. /**
  89622. * Create a new size of zero
  89623. * @returns a new Size set to (0.0, 0.0)
  89624. */
  89625. static Zero(): Size;
  89626. /**
  89627. * Sums the width and height of two sizes
  89628. * @param otherSize size to add to this size
  89629. * @returns a new Size set as the addition result of the current Size and the given one.
  89630. */
  89631. add(otherSize: Size): Size;
  89632. /**
  89633. * Subtracts the width and height of two
  89634. * @param otherSize size to subtract to this size
  89635. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89636. */
  89637. subtract(otherSize: Size): Size;
  89638. /**
  89639. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89640. * @param start starting size to lerp between
  89641. * @param end end size to lerp between
  89642. * @param amount amount to lerp between the start and end values
  89643. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89644. */
  89645. static Lerp(start: Size, end: Size, amount: number): Size;
  89646. }
  89647. }
  89648. declare module BABYLON {
  89649. /**
  89650. * Contains position and normal vectors for a vertex
  89651. */
  89652. export class PositionNormalVertex {
  89653. /** the position of the vertex (defaut: 0,0,0) */
  89654. position: Vector3;
  89655. /** the normal of the vertex (defaut: 0,1,0) */
  89656. normal: Vector3;
  89657. /**
  89658. * Creates a PositionNormalVertex
  89659. * @param position the position of the vertex (defaut: 0,0,0)
  89660. * @param normal the normal of the vertex (defaut: 0,1,0)
  89661. */
  89662. constructor(
  89663. /** the position of the vertex (defaut: 0,0,0) */
  89664. position?: Vector3,
  89665. /** the normal of the vertex (defaut: 0,1,0) */
  89666. normal?: Vector3);
  89667. /**
  89668. * Clones the PositionNormalVertex
  89669. * @returns the cloned PositionNormalVertex
  89670. */
  89671. clone(): PositionNormalVertex;
  89672. }
  89673. /**
  89674. * Contains position, normal and uv vectors for a vertex
  89675. */
  89676. export class PositionNormalTextureVertex {
  89677. /** the position of the vertex (defaut: 0,0,0) */
  89678. position: Vector3;
  89679. /** the normal of the vertex (defaut: 0,1,0) */
  89680. normal: Vector3;
  89681. /** the uv of the vertex (default: 0,0) */
  89682. uv: Vector2;
  89683. /**
  89684. * Creates a PositionNormalTextureVertex
  89685. * @param position the position of the vertex (defaut: 0,0,0)
  89686. * @param normal the normal of the vertex (defaut: 0,1,0)
  89687. * @param uv the uv of the vertex (default: 0,0)
  89688. */
  89689. constructor(
  89690. /** the position of the vertex (defaut: 0,0,0) */
  89691. position?: Vector3,
  89692. /** the normal of the vertex (defaut: 0,1,0) */
  89693. normal?: Vector3,
  89694. /** the uv of the vertex (default: 0,0) */
  89695. uv?: Vector2);
  89696. /**
  89697. * Clones the PositionNormalTextureVertex
  89698. * @returns the cloned PositionNormalTextureVertex
  89699. */
  89700. clone(): PositionNormalTextureVertex;
  89701. }
  89702. }
  89703. declare module BABYLON {
  89704. /**
  89705. * Enum defining the type of animations supported by InputBlock
  89706. */
  89707. export enum AnimatedInputBlockTypes {
  89708. /** No animation */
  89709. None = 0,
  89710. /** Time based animation. Will only work for floats */
  89711. Time = 1
  89712. }
  89713. }
  89714. declare module BABYLON {
  89715. /**
  89716. * Interface describing all the common properties and methods a shadow light needs to implement.
  89717. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89718. * as well as binding the different shadow properties to the effects.
  89719. */
  89720. export interface IShadowLight extends Light {
  89721. /**
  89722. * The light id in the scene (used in scene.findLighById for instance)
  89723. */
  89724. id: string;
  89725. /**
  89726. * The position the shdow will be casted from.
  89727. */
  89728. position: Vector3;
  89729. /**
  89730. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89731. */
  89732. direction: Vector3;
  89733. /**
  89734. * The transformed position. Position of the light in world space taking parenting in account.
  89735. */
  89736. transformedPosition: Vector3;
  89737. /**
  89738. * The transformed direction. Direction of the light in world space taking parenting in account.
  89739. */
  89740. transformedDirection: Vector3;
  89741. /**
  89742. * The friendly name of the light in the scene.
  89743. */
  89744. name: string;
  89745. /**
  89746. * Defines the shadow projection clipping minimum z value.
  89747. */
  89748. shadowMinZ: number;
  89749. /**
  89750. * Defines the shadow projection clipping maximum z value.
  89751. */
  89752. shadowMaxZ: number;
  89753. /**
  89754. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89755. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89756. */
  89757. computeTransformedInformation(): boolean;
  89758. /**
  89759. * Gets the scene the light belongs to.
  89760. * @returns The scene
  89761. */
  89762. getScene(): Scene;
  89763. /**
  89764. * Callback defining a custom Projection Matrix Builder.
  89765. * This can be used to override the default projection matrix computation.
  89766. */
  89767. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89768. /**
  89769. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89770. * @param matrix The materix to updated with the projection information
  89771. * @param viewMatrix The transform matrix of the light
  89772. * @param renderList The list of mesh to render in the map
  89773. * @returns The current light
  89774. */
  89775. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89776. /**
  89777. * Gets the current depth scale used in ESM.
  89778. * @returns The scale
  89779. */
  89780. getDepthScale(): number;
  89781. /**
  89782. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89783. * @returns true if a cube texture needs to be use
  89784. */
  89785. needCube(): boolean;
  89786. /**
  89787. * Detects if the projection matrix requires to be recomputed this frame.
  89788. * @returns true if it requires to be recomputed otherwise, false.
  89789. */
  89790. needProjectionMatrixCompute(): boolean;
  89791. /**
  89792. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89793. */
  89794. forceProjectionMatrixCompute(): void;
  89795. /**
  89796. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89797. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89798. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89799. */
  89800. getShadowDirection(faceIndex?: number): Vector3;
  89801. /**
  89802. * Gets the minZ used for shadow according to both the scene and the light.
  89803. * @param activeCamera The camera we are returning the min for
  89804. * @returns the depth min z
  89805. */
  89806. getDepthMinZ(activeCamera: Camera): number;
  89807. /**
  89808. * Gets the maxZ used for shadow according to both the scene and the light.
  89809. * @param activeCamera The camera we are returning the max for
  89810. * @returns the depth max z
  89811. */
  89812. getDepthMaxZ(activeCamera: Camera): number;
  89813. }
  89814. /**
  89815. * Base implementation IShadowLight
  89816. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89817. */
  89818. export abstract class ShadowLight extends Light implements IShadowLight {
  89819. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89820. protected _position: Vector3;
  89821. protected _setPosition(value: Vector3): void;
  89822. /**
  89823. * Sets the position the shadow will be casted from. Also use as the light position for both
  89824. * point and spot lights.
  89825. */
  89826. get position(): Vector3;
  89827. /**
  89828. * Sets the position the shadow will be casted from. Also use as the light position for both
  89829. * point and spot lights.
  89830. */
  89831. set position(value: Vector3);
  89832. protected _direction: Vector3;
  89833. protected _setDirection(value: Vector3): void;
  89834. /**
  89835. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89836. * Also use as the light direction on spot and directional lights.
  89837. */
  89838. get direction(): Vector3;
  89839. /**
  89840. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89841. * Also use as the light direction on spot and directional lights.
  89842. */
  89843. set direction(value: Vector3);
  89844. protected _shadowMinZ: number;
  89845. /**
  89846. * Gets the shadow projection clipping minimum z value.
  89847. */
  89848. get shadowMinZ(): number;
  89849. /**
  89850. * Sets the shadow projection clipping minimum z value.
  89851. */
  89852. set shadowMinZ(value: number);
  89853. protected _shadowMaxZ: number;
  89854. /**
  89855. * Sets the shadow projection clipping maximum z value.
  89856. */
  89857. get shadowMaxZ(): number;
  89858. /**
  89859. * Gets the shadow projection clipping maximum z value.
  89860. */
  89861. set shadowMaxZ(value: number);
  89862. /**
  89863. * Callback defining a custom Projection Matrix Builder.
  89864. * This can be used to override the default projection matrix computation.
  89865. */
  89866. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89867. /**
  89868. * The transformed position. Position of the light in world space taking parenting in account.
  89869. */
  89870. transformedPosition: Vector3;
  89871. /**
  89872. * The transformed direction. Direction of the light in world space taking parenting in account.
  89873. */
  89874. transformedDirection: Vector3;
  89875. private _needProjectionMatrixCompute;
  89876. /**
  89877. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89878. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89879. */
  89880. computeTransformedInformation(): boolean;
  89881. /**
  89882. * Return the depth scale used for the shadow map.
  89883. * @returns the depth scale.
  89884. */
  89885. getDepthScale(): number;
  89886. /**
  89887. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89888. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89889. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89890. */
  89891. getShadowDirection(faceIndex?: number): Vector3;
  89892. /**
  89893. * Returns the ShadowLight absolute position in the World.
  89894. * @returns the position vector in world space
  89895. */
  89896. getAbsolutePosition(): Vector3;
  89897. /**
  89898. * Sets the ShadowLight direction toward the passed target.
  89899. * @param target The point to target in local space
  89900. * @returns the updated ShadowLight direction
  89901. */
  89902. setDirectionToTarget(target: Vector3): Vector3;
  89903. /**
  89904. * Returns the light rotation in euler definition.
  89905. * @returns the x y z rotation in local space.
  89906. */
  89907. getRotation(): Vector3;
  89908. /**
  89909. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89910. * @returns true if a cube texture needs to be use
  89911. */
  89912. needCube(): boolean;
  89913. /**
  89914. * Detects if the projection matrix requires to be recomputed this frame.
  89915. * @returns true if it requires to be recomputed otherwise, false.
  89916. */
  89917. needProjectionMatrixCompute(): boolean;
  89918. /**
  89919. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89920. */
  89921. forceProjectionMatrixCompute(): void;
  89922. /** @hidden */
  89923. _initCache(): void;
  89924. /** @hidden */
  89925. _isSynchronized(): boolean;
  89926. /**
  89927. * Computes the world matrix of the node
  89928. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89929. * @returns the world matrix
  89930. */
  89931. computeWorldMatrix(force?: boolean): Matrix;
  89932. /**
  89933. * Gets the minZ used for shadow according to both the scene and the light.
  89934. * @param activeCamera The camera we are returning the min for
  89935. * @returns the depth min z
  89936. */
  89937. getDepthMinZ(activeCamera: Camera): number;
  89938. /**
  89939. * Gets the maxZ used for shadow according to both the scene and the light.
  89940. * @param activeCamera The camera we are returning the max for
  89941. * @returns the depth max z
  89942. */
  89943. getDepthMaxZ(activeCamera: Camera): number;
  89944. /**
  89945. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89946. * @param matrix The materix to updated with the projection information
  89947. * @param viewMatrix The transform matrix of the light
  89948. * @param renderList The list of mesh to render in the map
  89949. * @returns The current light
  89950. */
  89951. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89952. }
  89953. }
  89954. declare module BABYLON {
  89955. /** @hidden */
  89956. export var packingFunctions: {
  89957. name: string;
  89958. shader: string;
  89959. };
  89960. }
  89961. declare module BABYLON {
  89962. /** @hidden */
  89963. export var bayerDitherFunctions: {
  89964. name: string;
  89965. shader: string;
  89966. };
  89967. }
  89968. declare module BABYLON {
  89969. /** @hidden */
  89970. export var shadowMapFragmentDeclaration: {
  89971. name: string;
  89972. shader: string;
  89973. };
  89974. }
  89975. declare module BABYLON {
  89976. /** @hidden */
  89977. export var clipPlaneFragmentDeclaration: {
  89978. name: string;
  89979. shader: string;
  89980. };
  89981. }
  89982. declare module BABYLON {
  89983. /** @hidden */
  89984. export var clipPlaneFragment: {
  89985. name: string;
  89986. shader: string;
  89987. };
  89988. }
  89989. declare module BABYLON {
  89990. /** @hidden */
  89991. export var shadowMapFragment: {
  89992. name: string;
  89993. shader: string;
  89994. };
  89995. }
  89996. declare module BABYLON {
  89997. /** @hidden */
  89998. export var shadowMapPixelShader: {
  89999. name: string;
  90000. shader: string;
  90001. };
  90002. }
  90003. declare module BABYLON {
  90004. /** @hidden */
  90005. export var bonesDeclaration: {
  90006. name: string;
  90007. shader: string;
  90008. };
  90009. }
  90010. declare module BABYLON {
  90011. /** @hidden */
  90012. export var morphTargetsVertexGlobalDeclaration: {
  90013. name: string;
  90014. shader: string;
  90015. };
  90016. }
  90017. declare module BABYLON {
  90018. /** @hidden */
  90019. export var morphTargetsVertexDeclaration: {
  90020. name: string;
  90021. shader: string;
  90022. };
  90023. }
  90024. declare module BABYLON {
  90025. /** @hidden */
  90026. export var instancesDeclaration: {
  90027. name: string;
  90028. shader: string;
  90029. };
  90030. }
  90031. declare module BABYLON {
  90032. /** @hidden */
  90033. export var helperFunctions: {
  90034. name: string;
  90035. shader: string;
  90036. };
  90037. }
  90038. declare module BABYLON {
  90039. /** @hidden */
  90040. export var shadowMapVertexDeclaration: {
  90041. name: string;
  90042. shader: string;
  90043. };
  90044. }
  90045. declare module BABYLON {
  90046. /** @hidden */
  90047. export var clipPlaneVertexDeclaration: {
  90048. name: string;
  90049. shader: string;
  90050. };
  90051. }
  90052. declare module BABYLON {
  90053. /** @hidden */
  90054. export var morphTargetsVertex: {
  90055. name: string;
  90056. shader: string;
  90057. };
  90058. }
  90059. declare module BABYLON {
  90060. /** @hidden */
  90061. export var instancesVertex: {
  90062. name: string;
  90063. shader: string;
  90064. };
  90065. }
  90066. declare module BABYLON {
  90067. /** @hidden */
  90068. export var bonesVertex: {
  90069. name: string;
  90070. shader: string;
  90071. };
  90072. }
  90073. declare module BABYLON {
  90074. /** @hidden */
  90075. export var shadowMapVertexNormalBias: {
  90076. name: string;
  90077. shader: string;
  90078. };
  90079. }
  90080. declare module BABYLON {
  90081. /** @hidden */
  90082. export var shadowMapVertexMetric: {
  90083. name: string;
  90084. shader: string;
  90085. };
  90086. }
  90087. declare module BABYLON {
  90088. /** @hidden */
  90089. export var clipPlaneVertex: {
  90090. name: string;
  90091. shader: string;
  90092. };
  90093. }
  90094. declare module BABYLON {
  90095. /** @hidden */
  90096. export var shadowMapVertexShader: {
  90097. name: string;
  90098. shader: string;
  90099. };
  90100. }
  90101. declare module BABYLON {
  90102. /** @hidden */
  90103. export var depthBoxBlurPixelShader: {
  90104. name: string;
  90105. shader: string;
  90106. };
  90107. }
  90108. declare module BABYLON {
  90109. /** @hidden */
  90110. export var shadowMapFragmentSoftTransparentShadow: {
  90111. name: string;
  90112. shader: string;
  90113. };
  90114. }
  90115. declare module BABYLON {
  90116. /**
  90117. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90118. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90119. */
  90120. export class EffectFallbacks implements IEffectFallbacks {
  90121. private _defines;
  90122. private _currentRank;
  90123. private _maxRank;
  90124. private _mesh;
  90125. /**
  90126. * Removes the fallback from the bound mesh.
  90127. */
  90128. unBindMesh(): void;
  90129. /**
  90130. * Adds a fallback on the specified property.
  90131. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90132. * @param define The name of the define in the shader
  90133. */
  90134. addFallback(rank: number, define: string): void;
  90135. /**
  90136. * Sets the mesh to use CPU skinning when needing to fallback.
  90137. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90138. * @param mesh The mesh to use the fallbacks.
  90139. */
  90140. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90141. /**
  90142. * Checks to see if more fallbacks are still availible.
  90143. */
  90144. get hasMoreFallbacks(): boolean;
  90145. /**
  90146. * Removes the defines that should be removed when falling back.
  90147. * @param currentDefines defines the current define statements for the shader.
  90148. * @param effect defines the current effect we try to compile
  90149. * @returns The resulting defines with defines of the current rank removed.
  90150. */
  90151. reduce(currentDefines: string, effect: Effect): string;
  90152. }
  90153. }
  90154. declare module BABYLON {
  90155. /**
  90156. * Interface used to define Action
  90157. */
  90158. export interface IAction {
  90159. /**
  90160. * Trigger for the action
  90161. */
  90162. trigger: number;
  90163. /** Options of the trigger */
  90164. triggerOptions: any;
  90165. /**
  90166. * Gets the trigger parameters
  90167. * @returns the trigger parameters
  90168. */
  90169. getTriggerParameter(): any;
  90170. /**
  90171. * Internal only - executes current action event
  90172. * @hidden
  90173. */
  90174. _executeCurrent(evt?: ActionEvent): void;
  90175. /**
  90176. * Serialize placeholder for child classes
  90177. * @param parent of child
  90178. * @returns the serialized object
  90179. */
  90180. serialize(parent: any): any;
  90181. /**
  90182. * Internal only
  90183. * @hidden
  90184. */
  90185. _prepare(): void;
  90186. /**
  90187. * Internal only - manager for action
  90188. * @hidden
  90189. */
  90190. _actionManager: Nullable<AbstractActionManager>;
  90191. /**
  90192. * Adds action to chain of actions, may be a DoNothingAction
  90193. * @param action defines the next action to execute
  90194. * @returns The action passed in
  90195. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90196. */
  90197. then(action: IAction): IAction;
  90198. }
  90199. /**
  90200. * The action to be carried out following a trigger
  90201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90202. */
  90203. export class Action implements IAction {
  90204. /** the trigger, with or without parameters, for the action */
  90205. triggerOptions: any;
  90206. /**
  90207. * Trigger for the action
  90208. */
  90209. trigger: number;
  90210. /**
  90211. * Internal only - manager for action
  90212. * @hidden
  90213. */
  90214. _actionManager: ActionManager;
  90215. private _nextActiveAction;
  90216. private _child;
  90217. private _condition?;
  90218. private _triggerParameter;
  90219. /**
  90220. * An event triggered prior to action being executed.
  90221. */
  90222. onBeforeExecuteObservable: Observable<Action>;
  90223. /**
  90224. * Creates a new Action
  90225. * @param triggerOptions the trigger, with or without parameters, for the action
  90226. * @param condition an optional determinant of action
  90227. */
  90228. constructor(
  90229. /** the trigger, with or without parameters, for the action */
  90230. triggerOptions: any, condition?: Condition);
  90231. /**
  90232. * Internal only
  90233. * @hidden
  90234. */
  90235. _prepare(): void;
  90236. /**
  90237. * Gets the trigger parameters
  90238. * @returns the trigger parameters
  90239. */
  90240. getTriggerParameter(): any;
  90241. /**
  90242. * Internal only - executes current action event
  90243. * @hidden
  90244. */
  90245. _executeCurrent(evt?: ActionEvent): void;
  90246. /**
  90247. * Execute placeholder for child classes
  90248. * @param evt optional action event
  90249. */
  90250. execute(evt?: ActionEvent): void;
  90251. /**
  90252. * Skips to next active action
  90253. */
  90254. skipToNextActiveAction(): void;
  90255. /**
  90256. * Adds action to chain of actions, may be a DoNothingAction
  90257. * @param action defines the next action to execute
  90258. * @returns The action passed in
  90259. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90260. */
  90261. then(action: Action): Action;
  90262. /**
  90263. * Internal only
  90264. * @hidden
  90265. */
  90266. _getProperty(propertyPath: string): string;
  90267. /**
  90268. * Internal only
  90269. * @hidden
  90270. */
  90271. _getEffectiveTarget(target: any, propertyPath: string): any;
  90272. /**
  90273. * Serialize placeholder for child classes
  90274. * @param parent of child
  90275. * @returns the serialized object
  90276. */
  90277. serialize(parent: any): any;
  90278. /**
  90279. * Internal only called by serialize
  90280. * @hidden
  90281. */
  90282. protected _serialize(serializedAction: any, parent?: any): any;
  90283. /**
  90284. * Internal only
  90285. * @hidden
  90286. */
  90287. static _SerializeValueAsString: (value: any) => string;
  90288. /**
  90289. * Internal only
  90290. * @hidden
  90291. */
  90292. static _GetTargetProperty: (target: Scene | Node) => {
  90293. name: string;
  90294. targetType: string;
  90295. value: string;
  90296. };
  90297. }
  90298. }
  90299. declare module BABYLON {
  90300. /**
  90301. * A Condition applied to an Action
  90302. */
  90303. export class Condition {
  90304. /**
  90305. * Internal only - manager for action
  90306. * @hidden
  90307. */
  90308. _actionManager: ActionManager;
  90309. /**
  90310. * Internal only
  90311. * @hidden
  90312. */
  90313. _evaluationId: number;
  90314. /**
  90315. * Internal only
  90316. * @hidden
  90317. */
  90318. _currentResult: boolean;
  90319. /**
  90320. * Creates a new Condition
  90321. * @param actionManager the manager of the action the condition is applied to
  90322. */
  90323. constructor(actionManager: ActionManager);
  90324. /**
  90325. * Check if the current condition is valid
  90326. * @returns a boolean
  90327. */
  90328. isValid(): boolean;
  90329. /**
  90330. * Internal only
  90331. * @hidden
  90332. */
  90333. _getProperty(propertyPath: string): string;
  90334. /**
  90335. * Internal only
  90336. * @hidden
  90337. */
  90338. _getEffectiveTarget(target: any, propertyPath: string): any;
  90339. /**
  90340. * Serialize placeholder for child classes
  90341. * @returns the serialized object
  90342. */
  90343. serialize(): any;
  90344. /**
  90345. * Internal only
  90346. * @hidden
  90347. */
  90348. protected _serialize(serializedCondition: any): any;
  90349. }
  90350. /**
  90351. * Defines specific conditional operators as extensions of Condition
  90352. */
  90353. export class ValueCondition extends Condition {
  90354. /** path to specify the property of the target the conditional operator uses */
  90355. propertyPath: string;
  90356. /** the value compared by the conditional operator against the current value of the property */
  90357. value: any;
  90358. /** the conditional operator, default ValueCondition.IsEqual */
  90359. operator: number;
  90360. /**
  90361. * Internal only
  90362. * @hidden
  90363. */
  90364. private static _IsEqual;
  90365. /**
  90366. * Internal only
  90367. * @hidden
  90368. */
  90369. private static _IsDifferent;
  90370. /**
  90371. * Internal only
  90372. * @hidden
  90373. */
  90374. private static _IsGreater;
  90375. /**
  90376. * Internal only
  90377. * @hidden
  90378. */
  90379. private static _IsLesser;
  90380. /**
  90381. * returns the number for IsEqual
  90382. */
  90383. static get IsEqual(): number;
  90384. /**
  90385. * Returns the number for IsDifferent
  90386. */
  90387. static get IsDifferent(): number;
  90388. /**
  90389. * Returns the number for IsGreater
  90390. */
  90391. static get IsGreater(): number;
  90392. /**
  90393. * Returns the number for IsLesser
  90394. */
  90395. static get IsLesser(): number;
  90396. /**
  90397. * Internal only The action manager for the condition
  90398. * @hidden
  90399. */
  90400. _actionManager: ActionManager;
  90401. /**
  90402. * Internal only
  90403. * @hidden
  90404. */
  90405. private _target;
  90406. /**
  90407. * Internal only
  90408. * @hidden
  90409. */
  90410. private _effectiveTarget;
  90411. /**
  90412. * Internal only
  90413. * @hidden
  90414. */
  90415. private _property;
  90416. /**
  90417. * Creates a new ValueCondition
  90418. * @param actionManager manager for the action the condition applies to
  90419. * @param target for the action
  90420. * @param propertyPath path to specify the property of the target the conditional operator uses
  90421. * @param value the value compared by the conditional operator against the current value of the property
  90422. * @param operator the conditional operator, default ValueCondition.IsEqual
  90423. */
  90424. constructor(actionManager: ActionManager, target: any,
  90425. /** path to specify the property of the target the conditional operator uses */
  90426. propertyPath: string,
  90427. /** the value compared by the conditional operator against the current value of the property */
  90428. value: any,
  90429. /** the conditional operator, default ValueCondition.IsEqual */
  90430. operator?: number);
  90431. /**
  90432. * Compares the given value with the property value for the specified conditional operator
  90433. * @returns the result of the comparison
  90434. */
  90435. isValid(): boolean;
  90436. /**
  90437. * Serialize the ValueCondition into a JSON compatible object
  90438. * @returns serialization object
  90439. */
  90440. serialize(): any;
  90441. /**
  90442. * Gets the name of the conditional operator for the ValueCondition
  90443. * @param operator the conditional operator
  90444. * @returns the name
  90445. */
  90446. static GetOperatorName(operator: number): string;
  90447. }
  90448. /**
  90449. * Defines a predicate condition as an extension of Condition
  90450. */
  90451. export class PredicateCondition extends Condition {
  90452. /** defines the predicate function used to validate the condition */
  90453. predicate: () => boolean;
  90454. /**
  90455. * Internal only - manager for action
  90456. * @hidden
  90457. */
  90458. _actionManager: ActionManager;
  90459. /**
  90460. * Creates a new PredicateCondition
  90461. * @param actionManager manager for the action the condition applies to
  90462. * @param predicate defines the predicate function used to validate the condition
  90463. */
  90464. constructor(actionManager: ActionManager,
  90465. /** defines the predicate function used to validate the condition */
  90466. predicate: () => boolean);
  90467. /**
  90468. * @returns the validity of the predicate condition
  90469. */
  90470. isValid(): boolean;
  90471. }
  90472. /**
  90473. * Defines a state condition as an extension of Condition
  90474. */
  90475. export class StateCondition extends Condition {
  90476. /** Value to compare with target state */
  90477. value: string;
  90478. /**
  90479. * Internal only - manager for action
  90480. * @hidden
  90481. */
  90482. _actionManager: ActionManager;
  90483. /**
  90484. * Internal only
  90485. * @hidden
  90486. */
  90487. private _target;
  90488. /**
  90489. * Creates a new StateCondition
  90490. * @param actionManager manager for the action the condition applies to
  90491. * @param target of the condition
  90492. * @param value to compare with target state
  90493. */
  90494. constructor(actionManager: ActionManager, target: any,
  90495. /** Value to compare with target state */
  90496. value: string);
  90497. /**
  90498. * Gets a boolean indicating if the current condition is met
  90499. * @returns the validity of the state
  90500. */
  90501. isValid(): boolean;
  90502. /**
  90503. * Serialize the StateCondition into a JSON compatible object
  90504. * @returns serialization object
  90505. */
  90506. serialize(): any;
  90507. }
  90508. }
  90509. declare module BABYLON {
  90510. /**
  90511. * This defines an action responsible to toggle a boolean once triggered.
  90512. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90513. */
  90514. export class SwitchBooleanAction extends Action {
  90515. /**
  90516. * The path to the boolean property in the target object
  90517. */
  90518. propertyPath: string;
  90519. private _target;
  90520. private _effectiveTarget;
  90521. private _property;
  90522. /**
  90523. * Instantiate the action
  90524. * @param triggerOptions defines the trigger options
  90525. * @param target defines the object containing the boolean
  90526. * @param propertyPath defines the path to the boolean property in the target object
  90527. * @param condition defines the trigger related conditions
  90528. */
  90529. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90530. /** @hidden */
  90531. _prepare(): void;
  90532. /**
  90533. * Execute the action toggle the boolean value.
  90534. */
  90535. execute(): void;
  90536. /**
  90537. * Serializes the actions and its related information.
  90538. * @param parent defines the object to serialize in
  90539. * @returns the serialized object
  90540. */
  90541. serialize(parent: any): any;
  90542. }
  90543. /**
  90544. * This defines an action responsible to set a the state field of the target
  90545. * to a desired value once triggered.
  90546. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90547. */
  90548. export class SetStateAction extends Action {
  90549. /**
  90550. * The value to store in the state field.
  90551. */
  90552. value: string;
  90553. private _target;
  90554. /**
  90555. * Instantiate the action
  90556. * @param triggerOptions defines the trigger options
  90557. * @param target defines the object containing the state property
  90558. * @param value defines the value to store in the state field
  90559. * @param condition defines the trigger related conditions
  90560. */
  90561. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90562. /**
  90563. * Execute the action and store the value on the target state property.
  90564. */
  90565. execute(): void;
  90566. /**
  90567. * Serializes the actions and its related information.
  90568. * @param parent defines the object to serialize in
  90569. * @returns the serialized object
  90570. */
  90571. serialize(parent: any): any;
  90572. }
  90573. /**
  90574. * This defines an action responsible to set a property of the target
  90575. * to a desired value once triggered.
  90576. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90577. */
  90578. export class SetValueAction extends Action {
  90579. /**
  90580. * The path of the property to set in the target.
  90581. */
  90582. propertyPath: string;
  90583. /**
  90584. * The value to set in the property
  90585. */
  90586. value: any;
  90587. private _target;
  90588. private _effectiveTarget;
  90589. private _property;
  90590. /**
  90591. * Instantiate the action
  90592. * @param triggerOptions defines the trigger options
  90593. * @param target defines the object containing the property
  90594. * @param propertyPath defines the path of the property to set in the target
  90595. * @param value defines the value to set in the property
  90596. * @param condition defines the trigger related conditions
  90597. */
  90598. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90599. /** @hidden */
  90600. _prepare(): void;
  90601. /**
  90602. * Execute the action and set the targetted property to the desired value.
  90603. */
  90604. execute(): void;
  90605. /**
  90606. * Serializes the actions and its related information.
  90607. * @param parent defines the object to serialize in
  90608. * @returns the serialized object
  90609. */
  90610. serialize(parent: any): any;
  90611. }
  90612. /**
  90613. * This defines an action responsible to increment the target value
  90614. * to a desired value once triggered.
  90615. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90616. */
  90617. export class IncrementValueAction extends Action {
  90618. /**
  90619. * The path of the property to increment in the target.
  90620. */
  90621. propertyPath: string;
  90622. /**
  90623. * The value we should increment the property by.
  90624. */
  90625. value: any;
  90626. private _target;
  90627. private _effectiveTarget;
  90628. private _property;
  90629. /**
  90630. * Instantiate the action
  90631. * @param triggerOptions defines the trigger options
  90632. * @param target defines the object containing the property
  90633. * @param propertyPath defines the path of the property to increment in the target
  90634. * @param value defines the value value we should increment the property by
  90635. * @param condition defines the trigger related conditions
  90636. */
  90637. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90638. /** @hidden */
  90639. _prepare(): void;
  90640. /**
  90641. * Execute the action and increment the target of the value amount.
  90642. */
  90643. execute(): void;
  90644. /**
  90645. * Serializes the actions and its related information.
  90646. * @param parent defines the object to serialize in
  90647. * @returns the serialized object
  90648. */
  90649. serialize(parent: any): any;
  90650. }
  90651. /**
  90652. * This defines an action responsible to start an animation once triggered.
  90653. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90654. */
  90655. export class PlayAnimationAction extends Action {
  90656. /**
  90657. * Where the animation should start (animation frame)
  90658. */
  90659. from: number;
  90660. /**
  90661. * Where the animation should stop (animation frame)
  90662. */
  90663. to: number;
  90664. /**
  90665. * Define if the animation should loop or stop after the first play.
  90666. */
  90667. loop?: boolean;
  90668. private _target;
  90669. /**
  90670. * Instantiate the action
  90671. * @param triggerOptions defines the trigger options
  90672. * @param target defines the target animation or animation name
  90673. * @param from defines from where the animation should start (animation frame)
  90674. * @param end defines where the animation should stop (animation frame)
  90675. * @param loop defines if the animation should loop or stop after the first play
  90676. * @param condition defines the trigger related conditions
  90677. */
  90678. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90679. /** @hidden */
  90680. _prepare(): void;
  90681. /**
  90682. * Execute the action and play the animation.
  90683. */
  90684. execute(): void;
  90685. /**
  90686. * Serializes the actions and its related information.
  90687. * @param parent defines the object to serialize in
  90688. * @returns the serialized object
  90689. */
  90690. serialize(parent: any): any;
  90691. }
  90692. /**
  90693. * This defines an action responsible to stop an animation once triggered.
  90694. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90695. */
  90696. export class StopAnimationAction extends Action {
  90697. private _target;
  90698. /**
  90699. * Instantiate the action
  90700. * @param triggerOptions defines the trigger options
  90701. * @param target defines the target animation or animation name
  90702. * @param condition defines the trigger related conditions
  90703. */
  90704. constructor(triggerOptions: any, target: any, condition?: Condition);
  90705. /** @hidden */
  90706. _prepare(): void;
  90707. /**
  90708. * Execute the action and stop the animation.
  90709. */
  90710. execute(): void;
  90711. /**
  90712. * Serializes the actions and its related information.
  90713. * @param parent defines the object to serialize in
  90714. * @returns the serialized object
  90715. */
  90716. serialize(parent: any): any;
  90717. }
  90718. /**
  90719. * This defines an action responsible that does nothing once triggered.
  90720. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90721. */
  90722. export class DoNothingAction extends Action {
  90723. /**
  90724. * Instantiate the action
  90725. * @param triggerOptions defines the trigger options
  90726. * @param condition defines the trigger related conditions
  90727. */
  90728. constructor(triggerOptions?: any, condition?: Condition);
  90729. /**
  90730. * Execute the action and do nothing.
  90731. */
  90732. execute(): void;
  90733. /**
  90734. * Serializes the actions and its related information.
  90735. * @param parent defines the object to serialize in
  90736. * @returns the serialized object
  90737. */
  90738. serialize(parent: any): any;
  90739. }
  90740. /**
  90741. * This defines an action responsible to trigger several actions once triggered.
  90742. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90743. */
  90744. export class CombineAction extends Action {
  90745. /**
  90746. * The list of aggregated animations to run.
  90747. */
  90748. children: Action[];
  90749. /**
  90750. * Instantiate the action
  90751. * @param triggerOptions defines the trigger options
  90752. * @param children defines the list of aggregated animations to run
  90753. * @param condition defines the trigger related conditions
  90754. */
  90755. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90756. /** @hidden */
  90757. _prepare(): void;
  90758. /**
  90759. * Execute the action and executes all the aggregated actions.
  90760. */
  90761. execute(evt: ActionEvent): void;
  90762. /**
  90763. * Serializes the actions and its related information.
  90764. * @param parent defines the object to serialize in
  90765. * @returns the serialized object
  90766. */
  90767. serialize(parent: any): any;
  90768. }
  90769. /**
  90770. * This defines an action responsible to run code (external event) once triggered.
  90771. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90772. */
  90773. export class ExecuteCodeAction extends Action {
  90774. /**
  90775. * The callback function to run.
  90776. */
  90777. func: (evt: ActionEvent) => void;
  90778. /**
  90779. * Instantiate the action
  90780. * @param triggerOptions defines the trigger options
  90781. * @param func defines the callback function to run
  90782. * @param condition defines the trigger related conditions
  90783. */
  90784. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90785. /**
  90786. * Execute the action and run the attached code.
  90787. */
  90788. execute(evt: ActionEvent): void;
  90789. }
  90790. /**
  90791. * This defines an action responsible to set the parent property of the target once triggered.
  90792. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90793. */
  90794. export class SetParentAction extends Action {
  90795. private _parent;
  90796. private _target;
  90797. /**
  90798. * Instantiate the action
  90799. * @param triggerOptions defines the trigger options
  90800. * @param target defines the target containing the parent property
  90801. * @param parent defines from where the animation should start (animation frame)
  90802. * @param condition defines the trigger related conditions
  90803. */
  90804. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90805. /** @hidden */
  90806. _prepare(): void;
  90807. /**
  90808. * Execute the action and set the parent property.
  90809. */
  90810. execute(): void;
  90811. /**
  90812. * Serializes the actions and its related information.
  90813. * @param parent defines the object to serialize in
  90814. * @returns the serialized object
  90815. */
  90816. serialize(parent: any): any;
  90817. }
  90818. }
  90819. declare module BABYLON {
  90820. /**
  90821. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90822. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90823. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90824. */
  90825. export class ActionManager extends AbstractActionManager {
  90826. /**
  90827. * Nothing
  90828. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90829. */
  90830. static readonly NothingTrigger: number;
  90831. /**
  90832. * On pick
  90833. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90834. */
  90835. static readonly OnPickTrigger: number;
  90836. /**
  90837. * On left pick
  90838. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90839. */
  90840. static readonly OnLeftPickTrigger: number;
  90841. /**
  90842. * On right pick
  90843. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90844. */
  90845. static readonly OnRightPickTrigger: number;
  90846. /**
  90847. * On center pick
  90848. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90849. */
  90850. static readonly OnCenterPickTrigger: number;
  90851. /**
  90852. * On pick down
  90853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90854. */
  90855. static readonly OnPickDownTrigger: number;
  90856. /**
  90857. * On double pick
  90858. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90859. */
  90860. static readonly OnDoublePickTrigger: number;
  90861. /**
  90862. * On pick up
  90863. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90864. */
  90865. static readonly OnPickUpTrigger: number;
  90866. /**
  90867. * On pick out.
  90868. * This trigger will only be raised if you also declared a OnPickDown
  90869. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90870. */
  90871. static readonly OnPickOutTrigger: number;
  90872. /**
  90873. * On long press
  90874. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90875. */
  90876. static readonly OnLongPressTrigger: number;
  90877. /**
  90878. * On pointer over
  90879. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90880. */
  90881. static readonly OnPointerOverTrigger: number;
  90882. /**
  90883. * On pointer out
  90884. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90885. */
  90886. static readonly OnPointerOutTrigger: number;
  90887. /**
  90888. * On every frame
  90889. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90890. */
  90891. static readonly OnEveryFrameTrigger: number;
  90892. /**
  90893. * On intersection enter
  90894. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90895. */
  90896. static readonly OnIntersectionEnterTrigger: number;
  90897. /**
  90898. * On intersection exit
  90899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90900. */
  90901. static readonly OnIntersectionExitTrigger: number;
  90902. /**
  90903. * On key down
  90904. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90905. */
  90906. static readonly OnKeyDownTrigger: number;
  90907. /**
  90908. * On key up
  90909. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90910. */
  90911. static readonly OnKeyUpTrigger: number;
  90912. private _scene;
  90913. /**
  90914. * Creates a new action manager
  90915. * @param scene defines the hosting scene
  90916. */
  90917. constructor(scene: Scene);
  90918. /**
  90919. * Releases all associated resources
  90920. */
  90921. dispose(): void;
  90922. /**
  90923. * Gets hosting scene
  90924. * @returns the hosting scene
  90925. */
  90926. getScene(): Scene;
  90927. /**
  90928. * Does this action manager handles actions of any of the given triggers
  90929. * @param triggers defines the triggers to be tested
  90930. * @return a boolean indicating whether one (or more) of the triggers is handled
  90931. */
  90932. hasSpecificTriggers(triggers: number[]): boolean;
  90933. /**
  90934. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90935. * speed.
  90936. * @param triggerA defines the trigger to be tested
  90937. * @param triggerB defines the trigger to be tested
  90938. * @return a boolean indicating whether one (or more) of the triggers is handled
  90939. */
  90940. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90941. /**
  90942. * Does this action manager handles actions of a given trigger
  90943. * @param trigger defines the trigger to be tested
  90944. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90945. * @return whether the trigger is handled
  90946. */
  90947. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90948. /**
  90949. * Does this action manager has pointer triggers
  90950. */
  90951. get hasPointerTriggers(): boolean;
  90952. /**
  90953. * Does this action manager has pick triggers
  90954. */
  90955. get hasPickTriggers(): boolean;
  90956. /**
  90957. * Registers an action to this action manager
  90958. * @param action defines the action to be registered
  90959. * @return the action amended (prepared) after registration
  90960. */
  90961. registerAction(action: IAction): Nullable<IAction>;
  90962. /**
  90963. * Unregisters an action to this action manager
  90964. * @param action defines the action to be unregistered
  90965. * @return a boolean indicating whether the action has been unregistered
  90966. */
  90967. unregisterAction(action: IAction): Boolean;
  90968. /**
  90969. * Process a specific trigger
  90970. * @param trigger defines the trigger to process
  90971. * @param evt defines the event details to be processed
  90972. */
  90973. processTrigger(trigger: number, evt?: IActionEvent): void;
  90974. /** @hidden */
  90975. _getEffectiveTarget(target: any, propertyPath: string): any;
  90976. /** @hidden */
  90977. _getProperty(propertyPath: string): string;
  90978. /**
  90979. * Serialize this manager to a JSON object
  90980. * @param name defines the property name to store this manager
  90981. * @returns a JSON representation of this manager
  90982. */
  90983. serialize(name: string): any;
  90984. /**
  90985. * Creates a new ActionManager from a JSON data
  90986. * @param parsedActions defines the JSON data to read from
  90987. * @param object defines the hosting mesh
  90988. * @param scene defines the hosting scene
  90989. */
  90990. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90991. /**
  90992. * Get a trigger name by index
  90993. * @param trigger defines the trigger index
  90994. * @returns a trigger name
  90995. */
  90996. static GetTriggerName(trigger: number): string;
  90997. }
  90998. }
  90999. declare module BABYLON {
  91000. /**
  91001. * Class used to represent a sprite
  91002. * @see https://doc.babylonjs.com/babylon101/sprites
  91003. */
  91004. export class Sprite implements IAnimatable {
  91005. /** defines the name */
  91006. name: string;
  91007. /** Gets or sets the current world position */
  91008. position: Vector3;
  91009. /** Gets or sets the main color */
  91010. color: Color4;
  91011. /** Gets or sets the width */
  91012. width: number;
  91013. /** Gets or sets the height */
  91014. height: number;
  91015. /** Gets or sets rotation angle */
  91016. angle: number;
  91017. /** Gets or sets the cell index in the sprite sheet */
  91018. cellIndex: number;
  91019. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91020. cellRef: string;
  91021. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91022. invertU: boolean;
  91023. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91024. invertV: boolean;
  91025. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91026. disposeWhenFinishedAnimating: boolean;
  91027. /** Gets the list of attached animations */
  91028. animations: Nullable<Array<Animation>>;
  91029. /** Gets or sets a boolean indicating if the sprite can be picked */
  91030. isPickable: boolean;
  91031. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  91032. useAlphaForPicking: boolean;
  91033. /** @hidden */
  91034. _xOffset: number;
  91035. /** @hidden */
  91036. _yOffset: number;
  91037. /** @hidden */
  91038. _xSize: number;
  91039. /** @hidden */
  91040. _ySize: number;
  91041. /**
  91042. * Gets or sets the associated action manager
  91043. */
  91044. actionManager: Nullable<ActionManager>;
  91045. /**
  91046. * An event triggered when the control has been disposed
  91047. */
  91048. onDisposeObservable: Observable<Sprite>;
  91049. private _animationStarted;
  91050. private _loopAnimation;
  91051. private _fromIndex;
  91052. private _toIndex;
  91053. private _delay;
  91054. private _direction;
  91055. private _manager;
  91056. private _time;
  91057. private _onAnimationEnd;
  91058. /**
  91059. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91060. */
  91061. isVisible: boolean;
  91062. /**
  91063. * Gets or sets the sprite size
  91064. */
  91065. get size(): number;
  91066. set size(value: number);
  91067. /**
  91068. * Returns a boolean indicating if the animation is started
  91069. */
  91070. get animationStarted(): boolean;
  91071. /**
  91072. * Gets or sets the unique id of the sprite
  91073. */
  91074. uniqueId: number;
  91075. /**
  91076. * Gets the manager of this sprite
  91077. */
  91078. get manager(): ISpriteManager;
  91079. /**
  91080. * Creates a new Sprite
  91081. * @param name defines the name
  91082. * @param manager defines the manager
  91083. */
  91084. constructor(
  91085. /** defines the name */
  91086. name: string, manager: ISpriteManager);
  91087. /**
  91088. * Returns the string "Sprite"
  91089. * @returns "Sprite"
  91090. */
  91091. getClassName(): string;
  91092. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91093. get fromIndex(): number;
  91094. set fromIndex(value: number);
  91095. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91096. get toIndex(): number;
  91097. set toIndex(value: number);
  91098. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91099. get loopAnimation(): boolean;
  91100. set loopAnimation(value: boolean);
  91101. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91102. get delay(): number;
  91103. set delay(value: number);
  91104. /**
  91105. * Starts an animation
  91106. * @param from defines the initial key
  91107. * @param to defines the end key
  91108. * @param loop defines if the animation must loop
  91109. * @param delay defines the start delay (in ms)
  91110. * @param onAnimationEnd defines a callback to call when animation ends
  91111. */
  91112. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91113. /** Stops current animation (if any) */
  91114. stopAnimation(): void;
  91115. /** @hidden */
  91116. _animate(deltaTime: number): void;
  91117. /** Release associated resources */
  91118. dispose(): void;
  91119. /**
  91120. * Serializes the sprite to a JSON object
  91121. * @returns the JSON object
  91122. */
  91123. serialize(): any;
  91124. /**
  91125. * Parses a JSON object to create a new sprite
  91126. * @param parsedSprite The JSON object to parse
  91127. * @param manager defines the hosting manager
  91128. * @returns the new sprite
  91129. */
  91130. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91131. }
  91132. }
  91133. declare module BABYLON {
  91134. /**
  91135. * Information about the result of picking within a scene
  91136. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91137. */
  91138. export class PickingInfo {
  91139. /** @hidden */
  91140. _pickingUnavailable: boolean;
  91141. /**
  91142. * If the pick collided with an object
  91143. */
  91144. hit: boolean;
  91145. /**
  91146. * Distance away where the pick collided
  91147. */
  91148. distance: number;
  91149. /**
  91150. * The location of pick collision
  91151. */
  91152. pickedPoint: Nullable<Vector3>;
  91153. /**
  91154. * The mesh corresponding the the pick collision
  91155. */
  91156. pickedMesh: Nullable<AbstractMesh>;
  91157. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91158. bu: number;
  91159. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91160. bv: number;
  91161. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91162. faceId: number;
  91163. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91164. subMeshFaceId: number;
  91165. /** Id of the the submesh that was picked */
  91166. subMeshId: number;
  91167. /** If a sprite was picked, this will be the sprite the pick collided with */
  91168. pickedSprite: Nullable<Sprite>;
  91169. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91170. thinInstanceIndex: number;
  91171. /**
  91172. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91173. */
  91174. originMesh: Nullable<AbstractMesh>;
  91175. /**
  91176. * The ray that was used to perform the picking.
  91177. */
  91178. ray: Nullable<Ray>;
  91179. /**
  91180. * Gets the normal correspodning to the face the pick collided with
  91181. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91182. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91183. * @returns The normal correspodning to the face the pick collided with
  91184. */
  91185. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91186. /**
  91187. * Gets the texture coordinates of where the pick occured
  91188. * @returns the vector containing the coordnates of the texture
  91189. */
  91190. getTextureCoordinates(): Nullable<Vector2>;
  91191. }
  91192. }
  91193. declare module BABYLON {
  91194. /**
  91195. * Class representing a ray with position and direction
  91196. */
  91197. export class Ray {
  91198. /** origin point */
  91199. origin: Vector3;
  91200. /** direction */
  91201. direction: Vector3;
  91202. /** length of the ray */
  91203. length: number;
  91204. private static readonly _TmpVector3;
  91205. private _tmpRay;
  91206. /**
  91207. * Creates a new ray
  91208. * @param origin origin point
  91209. * @param direction direction
  91210. * @param length length of the ray
  91211. */
  91212. constructor(
  91213. /** origin point */
  91214. origin: Vector3,
  91215. /** direction */
  91216. direction: Vector3,
  91217. /** length of the ray */
  91218. length?: number);
  91219. /**
  91220. * Checks if the ray intersects a box
  91221. * This does not account for the ray lenght by design to improve perfs.
  91222. * @param minimum bound of the box
  91223. * @param maximum bound of the box
  91224. * @param intersectionTreshold extra extend to be added to the box in all direction
  91225. * @returns if the box was hit
  91226. */
  91227. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91228. /**
  91229. * Checks if the ray intersects a box
  91230. * This does not account for the ray lenght by design to improve perfs.
  91231. * @param box the bounding box to check
  91232. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91233. * @returns if the box was hit
  91234. */
  91235. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91236. /**
  91237. * If the ray hits a sphere
  91238. * @param sphere the bounding sphere to check
  91239. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91240. * @returns true if it hits the sphere
  91241. */
  91242. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91243. /**
  91244. * If the ray hits a triange
  91245. * @param vertex0 triangle vertex
  91246. * @param vertex1 triangle vertex
  91247. * @param vertex2 triangle vertex
  91248. * @returns intersection information if hit
  91249. */
  91250. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91251. /**
  91252. * Checks if ray intersects a plane
  91253. * @param plane the plane to check
  91254. * @returns the distance away it was hit
  91255. */
  91256. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91257. /**
  91258. * Calculate the intercept of a ray on a given axis
  91259. * @param axis to check 'x' | 'y' | 'z'
  91260. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91261. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91262. */
  91263. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91264. /**
  91265. * Checks if ray intersects a mesh
  91266. * @param mesh the mesh to check
  91267. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91268. * @returns picking info of the intersecton
  91269. */
  91270. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91271. /**
  91272. * Checks if ray intersects a mesh
  91273. * @param meshes the meshes to check
  91274. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91275. * @param results array to store result in
  91276. * @returns Array of picking infos
  91277. */
  91278. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91279. private _comparePickingInfo;
  91280. private static smallnum;
  91281. private static rayl;
  91282. /**
  91283. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91284. * @param sega the first point of the segment to test the intersection against
  91285. * @param segb the second point of the segment to test the intersection against
  91286. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91287. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91288. */
  91289. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91290. /**
  91291. * Update the ray from viewport position
  91292. * @param x position
  91293. * @param y y position
  91294. * @param viewportWidth viewport width
  91295. * @param viewportHeight viewport height
  91296. * @param world world matrix
  91297. * @param view view matrix
  91298. * @param projection projection matrix
  91299. * @returns this ray updated
  91300. */
  91301. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91302. /**
  91303. * Creates a ray with origin and direction of 0,0,0
  91304. * @returns the new ray
  91305. */
  91306. static Zero(): Ray;
  91307. /**
  91308. * Creates a new ray from screen space and viewport
  91309. * @param x position
  91310. * @param y y position
  91311. * @param viewportWidth viewport width
  91312. * @param viewportHeight viewport height
  91313. * @param world world matrix
  91314. * @param view view matrix
  91315. * @param projection projection matrix
  91316. * @returns new ray
  91317. */
  91318. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91319. /**
  91320. * 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
  91321. * transformed to the given world matrix.
  91322. * @param origin The origin point
  91323. * @param end The end point
  91324. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91325. * @returns the new ray
  91326. */
  91327. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91328. /**
  91329. * Transforms a ray by a matrix
  91330. * @param ray ray to transform
  91331. * @param matrix matrix to apply
  91332. * @returns the resulting new ray
  91333. */
  91334. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91335. /**
  91336. * Transforms a ray by a matrix
  91337. * @param ray ray to transform
  91338. * @param matrix matrix to apply
  91339. * @param result ray to store result in
  91340. */
  91341. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91342. /**
  91343. * Unproject a ray from screen space to object space
  91344. * @param sourceX defines the screen space x coordinate to use
  91345. * @param sourceY defines the screen space y coordinate to use
  91346. * @param viewportWidth defines the current width of the viewport
  91347. * @param viewportHeight defines the current height of the viewport
  91348. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91349. * @param view defines the view matrix to use
  91350. * @param projection defines the projection matrix to use
  91351. */
  91352. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91353. }
  91354. /**
  91355. * Type used to define predicate used to select faces when a mesh intersection is detected
  91356. */
  91357. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91358. interface Scene {
  91359. /** @hidden */
  91360. _tempPickingRay: Nullable<Ray>;
  91361. /** @hidden */
  91362. _cachedRayForTransform: Ray;
  91363. /** @hidden */
  91364. _pickWithRayInverseMatrix: Matrix;
  91365. /** @hidden */
  91366. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91367. /** @hidden */
  91368. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91369. /** @hidden */
  91370. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91371. }
  91372. }
  91373. declare module BABYLON {
  91374. /**
  91375. * Groups all the scene component constants in one place to ease maintenance.
  91376. * @hidden
  91377. */
  91378. export class SceneComponentConstants {
  91379. static readonly NAME_EFFECTLAYER: string;
  91380. static readonly NAME_LAYER: string;
  91381. static readonly NAME_LENSFLARESYSTEM: string;
  91382. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91383. static readonly NAME_PARTICLESYSTEM: string;
  91384. static readonly NAME_GAMEPAD: string;
  91385. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91386. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91387. static readonly NAME_PREPASSRENDERER: string;
  91388. static readonly NAME_DEPTHRENDERER: string;
  91389. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91390. static readonly NAME_SPRITE: string;
  91391. static readonly NAME_SUBSURFACE: string;
  91392. static readonly NAME_OUTLINERENDERER: string;
  91393. static readonly NAME_PROCEDURALTEXTURE: string;
  91394. static readonly NAME_SHADOWGENERATOR: string;
  91395. static readonly NAME_OCTREE: string;
  91396. static readonly NAME_PHYSICSENGINE: string;
  91397. static readonly NAME_AUDIO: string;
  91398. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91399. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91400. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91401. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91402. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91403. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91404. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91405. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91406. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91407. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91408. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91409. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91410. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91411. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91412. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91413. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91414. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91415. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91416. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91417. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91418. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91419. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91420. static readonly STEP_AFTERRENDER_AUDIO: number;
  91421. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91422. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91423. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91424. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91425. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91426. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91427. static readonly STEP_POINTERMOVE_SPRITE: number;
  91428. static readonly STEP_POINTERDOWN_SPRITE: number;
  91429. static readonly STEP_POINTERUP_SPRITE: number;
  91430. }
  91431. /**
  91432. * This represents a scene component.
  91433. *
  91434. * This is used to decouple the dependency the scene is having on the different workloads like
  91435. * layers, post processes...
  91436. */
  91437. export interface ISceneComponent {
  91438. /**
  91439. * The name of the component. Each component must have a unique name.
  91440. */
  91441. name: string;
  91442. /**
  91443. * The scene the component belongs to.
  91444. */
  91445. scene: Scene;
  91446. /**
  91447. * Register the component to one instance of a scene.
  91448. */
  91449. register(): void;
  91450. /**
  91451. * Rebuilds the elements related to this component in case of
  91452. * context lost for instance.
  91453. */
  91454. rebuild(): void;
  91455. /**
  91456. * Disposes the component and the associated ressources.
  91457. */
  91458. dispose(): void;
  91459. }
  91460. /**
  91461. * This represents a SERIALIZABLE scene component.
  91462. *
  91463. * This extends Scene Component to add Serialization methods on top.
  91464. */
  91465. export interface ISceneSerializableComponent extends ISceneComponent {
  91466. /**
  91467. * Adds all the elements from the container to the scene
  91468. * @param container the container holding the elements
  91469. */
  91470. addFromContainer(container: AbstractScene): void;
  91471. /**
  91472. * Removes all the elements in the container from the scene
  91473. * @param container contains the elements to remove
  91474. * @param dispose if the removed element should be disposed (default: false)
  91475. */
  91476. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91477. /**
  91478. * Serializes the component data to the specified json object
  91479. * @param serializationObject The object to serialize to
  91480. */
  91481. serialize(serializationObject: any): void;
  91482. }
  91483. /**
  91484. * Strong typing of a Mesh related stage step action
  91485. */
  91486. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91487. /**
  91488. * Strong typing of a Evaluate Sub Mesh related stage step action
  91489. */
  91490. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91491. /**
  91492. * Strong typing of a Active Mesh related stage step action
  91493. */
  91494. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91495. /**
  91496. * Strong typing of a Camera related stage step action
  91497. */
  91498. export type CameraStageAction = (camera: Camera) => void;
  91499. /**
  91500. * Strong typing of a Camera Frame buffer related stage step action
  91501. */
  91502. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91503. /**
  91504. * Strong typing of a Render Target related stage step action
  91505. */
  91506. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91507. /**
  91508. * Strong typing of a RenderingGroup related stage step action
  91509. */
  91510. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91511. /**
  91512. * Strong typing of a Mesh Render related stage step action
  91513. */
  91514. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91515. /**
  91516. * Strong typing of a simple stage step action
  91517. */
  91518. export type SimpleStageAction = () => void;
  91519. /**
  91520. * Strong typing of a render target action.
  91521. */
  91522. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91523. /**
  91524. * Strong typing of a pointer move action.
  91525. */
  91526. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91527. /**
  91528. * Strong typing of a pointer up/down action.
  91529. */
  91530. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91531. /**
  91532. * Representation of a stage in the scene (Basically a list of ordered steps)
  91533. * @hidden
  91534. */
  91535. export class Stage<T extends Function> extends Array<{
  91536. index: number;
  91537. component: ISceneComponent;
  91538. action: T;
  91539. }> {
  91540. /**
  91541. * Hide ctor from the rest of the world.
  91542. * @param items The items to add.
  91543. */
  91544. private constructor();
  91545. /**
  91546. * Creates a new Stage.
  91547. * @returns A new instance of a Stage
  91548. */
  91549. static Create<T extends Function>(): Stage<T>;
  91550. /**
  91551. * Registers a step in an ordered way in the targeted stage.
  91552. * @param index Defines the position to register the step in
  91553. * @param component Defines the component attached to the step
  91554. * @param action Defines the action to launch during the step
  91555. */
  91556. registerStep(index: number, component: ISceneComponent, action: T): void;
  91557. /**
  91558. * Clears all the steps from the stage.
  91559. */
  91560. clear(): void;
  91561. }
  91562. }
  91563. declare module BABYLON {
  91564. interface Scene {
  91565. /** @hidden */
  91566. _pointerOverSprite: Nullable<Sprite>;
  91567. /** @hidden */
  91568. _pickedDownSprite: Nullable<Sprite>;
  91569. /** @hidden */
  91570. _tempSpritePickingRay: Nullable<Ray>;
  91571. /**
  91572. * All of the sprite managers added to this scene
  91573. * @see https://doc.babylonjs.com/babylon101/sprites
  91574. */
  91575. spriteManagers: Array<ISpriteManager>;
  91576. /**
  91577. * An event triggered when sprites rendering is about to start
  91578. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91579. */
  91580. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91581. /**
  91582. * An event triggered when sprites rendering is done
  91583. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91584. */
  91585. onAfterSpritesRenderingObservable: Observable<Scene>;
  91586. /** @hidden */
  91587. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91588. /** Launch a ray to try to pick a sprite in the scene
  91589. * @param x position on screen
  91590. * @param y position on screen
  91591. * @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
  91592. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91593. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91594. * @returns a PickingInfo
  91595. */
  91596. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91597. /** Use the given ray to pick a sprite in the scene
  91598. * @param ray The ray (in world space) to use to pick meshes
  91599. * @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
  91600. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91601. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91602. * @returns a PickingInfo
  91603. */
  91604. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91605. /** @hidden */
  91606. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91607. /** Launch a ray to try to pick sprites in the scene
  91608. * @param x position on screen
  91609. * @param y position on screen
  91610. * @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
  91611. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91612. * @returns a PickingInfo array
  91613. */
  91614. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91615. /** Use the given ray to pick sprites in the scene
  91616. * @param ray The ray (in world space) to use to pick meshes
  91617. * @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
  91618. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91619. * @returns a PickingInfo array
  91620. */
  91621. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91622. /**
  91623. * Force the sprite under the pointer
  91624. * @param sprite defines the sprite to use
  91625. */
  91626. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91627. /**
  91628. * Gets the sprite under the pointer
  91629. * @returns a Sprite or null if no sprite is under the pointer
  91630. */
  91631. getPointerOverSprite(): Nullable<Sprite>;
  91632. }
  91633. /**
  91634. * Defines the sprite scene component responsible to manage sprites
  91635. * in a given scene.
  91636. */
  91637. export class SpriteSceneComponent implements ISceneComponent {
  91638. /**
  91639. * The component name helpfull to identify the component in the list of scene components.
  91640. */
  91641. readonly name: string;
  91642. /**
  91643. * The scene the component belongs to.
  91644. */
  91645. scene: Scene;
  91646. /** @hidden */
  91647. private _spritePredicate;
  91648. /**
  91649. * Creates a new instance of the component for the given scene
  91650. * @param scene Defines the scene to register the component in
  91651. */
  91652. constructor(scene: Scene);
  91653. /**
  91654. * Registers the component in a given scene
  91655. */
  91656. register(): void;
  91657. /**
  91658. * Rebuilds the elements related to this component in case of
  91659. * context lost for instance.
  91660. */
  91661. rebuild(): void;
  91662. /**
  91663. * Disposes the component and the associated ressources.
  91664. */
  91665. dispose(): void;
  91666. private _pickSpriteButKeepRay;
  91667. private _pointerMove;
  91668. private _pointerDown;
  91669. private _pointerUp;
  91670. }
  91671. }
  91672. declare module BABYLON {
  91673. /** @hidden */
  91674. export var fogFragmentDeclaration: {
  91675. name: string;
  91676. shader: string;
  91677. };
  91678. }
  91679. declare module BABYLON {
  91680. /** @hidden */
  91681. export var fogFragment: {
  91682. name: string;
  91683. shader: string;
  91684. };
  91685. }
  91686. declare module BABYLON {
  91687. /** @hidden */
  91688. export var imageProcessingCompatibility: {
  91689. name: string;
  91690. shader: string;
  91691. };
  91692. }
  91693. declare module BABYLON {
  91694. /** @hidden */
  91695. export var spritesPixelShader: {
  91696. name: string;
  91697. shader: string;
  91698. };
  91699. }
  91700. declare module BABYLON {
  91701. /** @hidden */
  91702. export var fogVertexDeclaration: {
  91703. name: string;
  91704. shader: string;
  91705. };
  91706. }
  91707. declare module BABYLON {
  91708. /** @hidden */
  91709. export var spritesVertexShader: {
  91710. name: string;
  91711. shader: string;
  91712. };
  91713. }
  91714. declare module BABYLON {
  91715. /**
  91716. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91717. */
  91718. export interface ISpriteManager extends IDisposable {
  91719. /**
  91720. * Gets manager's name
  91721. */
  91722. name: string;
  91723. /**
  91724. * Restricts the camera to viewing objects with the same layerMask.
  91725. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91726. */
  91727. layerMask: number;
  91728. /**
  91729. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91730. */
  91731. isPickable: boolean;
  91732. /**
  91733. * Gets the hosting scene
  91734. */
  91735. scene: Scene;
  91736. /**
  91737. * Specifies the rendering group id for this mesh (0 by default)
  91738. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91739. */
  91740. renderingGroupId: number;
  91741. /**
  91742. * Defines the list of sprites managed by the manager.
  91743. */
  91744. sprites: Array<Sprite>;
  91745. /**
  91746. * Gets or sets the spritesheet texture
  91747. */
  91748. texture: Texture;
  91749. /** Defines the default width of a cell in the spritesheet */
  91750. cellWidth: number;
  91751. /** Defines the default height of a cell in the spritesheet */
  91752. cellHeight: number;
  91753. /**
  91754. * Tests the intersection of a sprite with a specific ray.
  91755. * @param ray The ray we are sending to test the collision
  91756. * @param camera The camera space we are sending rays in
  91757. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91758. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91759. * @returns picking info or null.
  91760. */
  91761. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91762. /**
  91763. * Intersects the sprites with a ray
  91764. * @param ray defines the ray to intersect with
  91765. * @param camera defines the current active camera
  91766. * @param predicate defines a predicate used to select candidate sprites
  91767. * @returns null if no hit or a PickingInfo array
  91768. */
  91769. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91770. /**
  91771. * Renders the list of sprites on screen.
  91772. */
  91773. render(): void;
  91774. }
  91775. /**
  91776. * Class used to manage multiple sprites on the same spritesheet
  91777. * @see https://doc.babylonjs.com/babylon101/sprites
  91778. */
  91779. export class SpriteManager implements ISpriteManager {
  91780. /** defines the manager's name */
  91781. name: string;
  91782. /** Define the Url to load snippets */
  91783. static SnippetUrl: string;
  91784. /** Snippet ID if the manager was created from the snippet server */
  91785. snippetId: string;
  91786. /** Gets the list of sprites */
  91787. sprites: Sprite[];
  91788. /** Gets or sets the rendering group id (0 by default) */
  91789. renderingGroupId: number;
  91790. /** Gets or sets camera layer mask */
  91791. layerMask: number;
  91792. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91793. fogEnabled: boolean;
  91794. /** Gets or sets a boolean indicating if the sprites are pickable */
  91795. isPickable: boolean;
  91796. /** Defines the default width of a cell in the spritesheet */
  91797. cellWidth: number;
  91798. /** Defines the default height of a cell in the spritesheet */
  91799. cellHeight: number;
  91800. /** Associative array from JSON sprite data file */
  91801. private _cellData;
  91802. /** Array of sprite names from JSON sprite data file */
  91803. private _spriteMap;
  91804. /** True when packed cell data from JSON file is ready*/
  91805. private _packedAndReady;
  91806. private _textureContent;
  91807. private _useInstancing;
  91808. /**
  91809. * An event triggered when the manager is disposed.
  91810. */
  91811. onDisposeObservable: Observable<SpriteManager>;
  91812. private _onDisposeObserver;
  91813. /**
  91814. * Callback called when the manager is disposed
  91815. */
  91816. set onDispose(callback: () => void);
  91817. private _capacity;
  91818. private _fromPacked;
  91819. private _spriteTexture;
  91820. private _epsilon;
  91821. private _scene;
  91822. private _vertexData;
  91823. private _buffer;
  91824. private _vertexBuffers;
  91825. private _spriteBuffer;
  91826. private _indexBuffer;
  91827. private _effectBase;
  91828. private _effectFog;
  91829. private _vertexBufferSize;
  91830. /**
  91831. * Gets or sets the unique id of the sprite
  91832. */
  91833. uniqueId: number;
  91834. /**
  91835. * Gets the array of sprites
  91836. */
  91837. get children(): Sprite[];
  91838. /**
  91839. * Gets the hosting scene
  91840. */
  91841. get scene(): Scene;
  91842. /**
  91843. * Gets the capacity of the manager
  91844. */
  91845. get capacity(): number;
  91846. /**
  91847. * Gets or sets the spritesheet texture
  91848. */
  91849. get texture(): Texture;
  91850. set texture(value: Texture);
  91851. private _blendMode;
  91852. /**
  91853. * Blend mode use to render the particle, it can be any of
  91854. * the static Constants.ALPHA_x properties provided in this class.
  91855. * Default value is Constants.ALPHA_COMBINE
  91856. */
  91857. get blendMode(): number;
  91858. set blendMode(blendMode: number);
  91859. /** Disables writing to the depth buffer when rendering the sprites.
  91860. * It can be handy to disable depth writing when using textures without alpha channel
  91861. * and setting some specific blend modes.
  91862. */
  91863. disableDepthWrite: boolean;
  91864. /**
  91865. * Creates a new sprite manager
  91866. * @param name defines the manager's name
  91867. * @param imgUrl defines the sprite sheet url
  91868. * @param capacity defines the maximum allowed number of sprites
  91869. * @param cellSize defines the size of a sprite cell
  91870. * @param scene defines the hosting scene
  91871. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91872. * @param samplingMode defines the smapling mode to use with spritesheet
  91873. * @param fromPacked set to false; do not alter
  91874. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91875. */
  91876. constructor(
  91877. /** defines the manager's name */
  91878. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91879. /**
  91880. * Returns the string "SpriteManager"
  91881. * @returns "SpriteManager"
  91882. */
  91883. getClassName(): string;
  91884. private _makePacked;
  91885. private _appendSpriteVertex;
  91886. private _checkTextureAlpha;
  91887. /**
  91888. * Intersects the sprites with a ray
  91889. * @param ray defines the ray to intersect with
  91890. * @param camera defines the current active camera
  91891. * @param predicate defines a predicate used to select candidate sprites
  91892. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91893. * @returns null if no hit or a PickingInfo
  91894. */
  91895. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91896. /**
  91897. * Intersects the sprites with a ray
  91898. * @param ray defines the ray to intersect with
  91899. * @param camera defines the current active camera
  91900. * @param predicate defines a predicate used to select candidate sprites
  91901. * @returns null if no hit or a PickingInfo array
  91902. */
  91903. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91904. /**
  91905. * Render all child sprites
  91906. */
  91907. render(): void;
  91908. /**
  91909. * Release associated resources
  91910. */
  91911. dispose(): void;
  91912. /**
  91913. * Serializes the sprite manager to a JSON object
  91914. * @param serializeTexture defines if the texture must be serialized as well
  91915. * @returns the JSON object
  91916. */
  91917. serialize(serializeTexture?: boolean): any;
  91918. /**
  91919. * Parses a JSON object to create a new sprite manager.
  91920. * @param parsedManager The JSON object to parse
  91921. * @param scene The scene to create the sprite managerin
  91922. * @param rootUrl The root url to use to load external dependencies like texture
  91923. * @returns the new sprite manager
  91924. */
  91925. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91926. /**
  91927. * Creates a sprite manager from a snippet saved in a remote file
  91928. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91929. * @param url defines the url to load from
  91930. * @param scene defines the hosting scene
  91931. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91932. * @returns a promise that will resolve to the new sprite manager
  91933. */
  91934. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91935. /**
  91936. * Creates a sprite manager from a snippet saved by the sprite editor
  91937. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91938. * @param scene defines the hosting scene
  91939. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91940. * @returns a promise that will resolve to the new sprite manager
  91941. */
  91942. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91943. }
  91944. }
  91945. declare module BABYLON {
  91946. /** Interface used by value gradients (color, factor, ...) */
  91947. export interface IValueGradient {
  91948. /**
  91949. * Gets or sets the gradient value (between 0 and 1)
  91950. */
  91951. gradient: number;
  91952. }
  91953. /** Class used to store color4 gradient */
  91954. export class ColorGradient implements IValueGradient {
  91955. /**
  91956. * Gets or sets the gradient value (between 0 and 1)
  91957. */
  91958. gradient: number;
  91959. /**
  91960. * Gets or sets first associated color
  91961. */
  91962. color1: Color4;
  91963. /**
  91964. * Gets or sets second associated color
  91965. */
  91966. color2?: Color4 | undefined;
  91967. /**
  91968. * Creates a new color4 gradient
  91969. * @param gradient gets or sets the gradient value (between 0 and 1)
  91970. * @param color1 gets or sets first associated color
  91971. * @param color2 gets or sets first second color
  91972. */
  91973. constructor(
  91974. /**
  91975. * Gets or sets the gradient value (between 0 and 1)
  91976. */
  91977. gradient: number,
  91978. /**
  91979. * Gets or sets first associated color
  91980. */
  91981. color1: Color4,
  91982. /**
  91983. * Gets or sets second associated color
  91984. */
  91985. color2?: Color4 | undefined);
  91986. /**
  91987. * Will get a color picked randomly between color1 and color2.
  91988. * If color2 is undefined then color1 will be used
  91989. * @param result defines the target Color4 to store the result in
  91990. */
  91991. getColorToRef(result: Color4): void;
  91992. }
  91993. /** Class used to store color 3 gradient */
  91994. export class Color3Gradient implements IValueGradient {
  91995. /**
  91996. * Gets or sets the gradient value (between 0 and 1)
  91997. */
  91998. gradient: number;
  91999. /**
  92000. * Gets or sets the associated color
  92001. */
  92002. color: Color3;
  92003. /**
  92004. * Creates a new color3 gradient
  92005. * @param gradient gets or sets the gradient value (between 0 and 1)
  92006. * @param color gets or sets associated color
  92007. */
  92008. constructor(
  92009. /**
  92010. * Gets or sets the gradient value (between 0 and 1)
  92011. */
  92012. gradient: number,
  92013. /**
  92014. * Gets or sets the associated color
  92015. */
  92016. color: Color3);
  92017. }
  92018. /** Class used to store factor gradient */
  92019. export class FactorGradient implements IValueGradient {
  92020. /**
  92021. * Gets or sets the gradient value (between 0 and 1)
  92022. */
  92023. gradient: number;
  92024. /**
  92025. * Gets or sets first associated factor
  92026. */
  92027. factor1: number;
  92028. /**
  92029. * Gets or sets second associated factor
  92030. */
  92031. factor2?: number | undefined;
  92032. /**
  92033. * Creates a new factor gradient
  92034. * @param gradient gets or sets the gradient value (between 0 and 1)
  92035. * @param factor1 gets or sets first associated factor
  92036. * @param factor2 gets or sets second associated factor
  92037. */
  92038. constructor(
  92039. /**
  92040. * Gets or sets the gradient value (between 0 and 1)
  92041. */
  92042. gradient: number,
  92043. /**
  92044. * Gets or sets first associated factor
  92045. */
  92046. factor1: number,
  92047. /**
  92048. * Gets or sets second associated factor
  92049. */
  92050. factor2?: number | undefined);
  92051. /**
  92052. * Will get a number picked randomly between factor1 and factor2.
  92053. * If factor2 is undefined then factor1 will be used
  92054. * @returns the picked number
  92055. */
  92056. getFactor(): number;
  92057. }
  92058. /**
  92059. * Helper used to simplify some generic gradient tasks
  92060. */
  92061. export class GradientHelper {
  92062. /**
  92063. * Gets the current gradient from an array of IValueGradient
  92064. * @param ratio defines the current ratio to get
  92065. * @param gradients defines the array of IValueGradient
  92066. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  92067. */
  92068. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  92069. }
  92070. }
  92071. declare module BABYLON {
  92072. interface ThinEngine {
  92073. /**
  92074. * Creates a raw texture
  92075. * @param data defines the data to store in the texture
  92076. * @param width defines the width of the texture
  92077. * @param height defines the height of the texture
  92078. * @param format defines the format of the data
  92079. * @param generateMipMaps defines if the engine should generate the mip levels
  92080. * @param invertY defines if data must be stored with Y axis inverted
  92081. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92082. * @param compression defines the compression used (null by default)
  92083. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92084. * @returns the raw texture inside an InternalTexture
  92085. */
  92086. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92087. /**
  92088. * Update a raw texture
  92089. * @param texture defines the texture to update
  92090. * @param data defines the data to store in the texture
  92091. * @param format defines the format of the data
  92092. * @param invertY defines if data must be stored with Y axis inverted
  92093. */
  92094. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92095. /**
  92096. * Update a raw texture
  92097. * @param texture defines the texture to update
  92098. * @param data defines the data to store in the texture
  92099. * @param format defines the format of the data
  92100. * @param invertY defines if data must be stored with Y axis inverted
  92101. * @param compression defines the compression used (null by default)
  92102. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92103. */
  92104. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92105. /**
  92106. * Creates a new raw cube texture
  92107. * @param data defines the array of data to use to create each face
  92108. * @param size defines the size of the textures
  92109. * @param format defines the format of the data
  92110. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92111. * @param generateMipMaps defines if the engine should generate the mip levels
  92112. * @param invertY defines if data must be stored with Y axis inverted
  92113. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92114. * @param compression defines the compression used (null by default)
  92115. * @returns the cube texture as an InternalTexture
  92116. */
  92117. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92118. /**
  92119. * Update a raw cube texture
  92120. * @param texture defines the texture to udpdate
  92121. * @param data defines the data to store
  92122. * @param format defines the data format
  92123. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92124. * @param invertY defines if data must be stored with Y axis inverted
  92125. */
  92126. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92127. /**
  92128. * Update a raw cube texture
  92129. * @param texture defines the texture to udpdate
  92130. * @param data defines the data to store
  92131. * @param format defines the data format
  92132. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92133. * @param invertY defines if data must be stored with Y axis inverted
  92134. * @param compression defines the compression used (null by default)
  92135. */
  92136. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92137. /**
  92138. * Update a raw cube texture
  92139. * @param texture defines the texture to udpdate
  92140. * @param data defines the data to store
  92141. * @param format defines the data format
  92142. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92143. * @param invertY defines if data must be stored with Y axis inverted
  92144. * @param compression defines the compression used (null by default)
  92145. * @param level defines which level of the texture to update
  92146. */
  92147. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92148. /**
  92149. * Creates a new raw cube texture from a specified url
  92150. * @param url defines the url where the data is located
  92151. * @param scene defines the current scene
  92152. * @param size defines the size of the textures
  92153. * @param format defines the format of the data
  92154. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92155. * @param noMipmap defines if the engine should avoid generating the mip levels
  92156. * @param callback defines a callback used to extract texture data from loaded data
  92157. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92158. * @param onLoad defines a callback called when texture is loaded
  92159. * @param onError defines a callback called if there is an error
  92160. * @returns the cube texture as an InternalTexture
  92161. */
  92162. 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;
  92163. /**
  92164. * Creates a new raw cube texture from a specified url
  92165. * @param url defines the url where the data is located
  92166. * @param scene defines the current scene
  92167. * @param size defines the size of the textures
  92168. * @param format defines the format of the data
  92169. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92170. * @param noMipmap defines if the engine should avoid generating the mip levels
  92171. * @param callback defines a callback used to extract texture data from loaded data
  92172. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92173. * @param onLoad defines a callback called when texture is loaded
  92174. * @param onError defines a callback called if there is an error
  92175. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92176. * @param invertY defines if data must be stored with Y axis inverted
  92177. * @returns the cube texture as an InternalTexture
  92178. */
  92179. 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;
  92180. /**
  92181. * Creates a new raw 3D texture
  92182. * @param data defines the data used to create the texture
  92183. * @param width defines the width of the texture
  92184. * @param height defines the height of the texture
  92185. * @param depth defines the depth of the texture
  92186. * @param format defines the format of the texture
  92187. * @param generateMipMaps defines if the engine must generate mip levels
  92188. * @param invertY defines if data must be stored with Y axis inverted
  92189. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92190. * @param compression defines the compressed used (can be null)
  92191. * @param textureType defines the compressed used (can be null)
  92192. * @returns a new raw 3D texture (stored in an InternalTexture)
  92193. */
  92194. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92195. /**
  92196. * Update a raw 3D texture
  92197. * @param texture defines the texture to update
  92198. * @param data defines the data to store
  92199. * @param format defines the data format
  92200. * @param invertY defines if data must be stored with Y axis inverted
  92201. */
  92202. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92203. /**
  92204. * Update a raw 3D texture
  92205. * @param texture defines the texture to update
  92206. * @param data defines the data to store
  92207. * @param format defines the data format
  92208. * @param invertY defines if data must be stored with Y axis inverted
  92209. * @param compression defines the used compression (can be null)
  92210. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92211. */
  92212. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92213. /**
  92214. * Creates a new raw 2D array texture
  92215. * @param data defines the data used to create the texture
  92216. * @param width defines the width of the texture
  92217. * @param height defines the height of the texture
  92218. * @param depth defines the number of layers of the texture
  92219. * @param format defines the format of the texture
  92220. * @param generateMipMaps defines if the engine must generate mip levels
  92221. * @param invertY defines if data must be stored with Y axis inverted
  92222. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92223. * @param compression defines the compressed used (can be null)
  92224. * @param textureType defines the compressed used (can be null)
  92225. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92226. */
  92227. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92228. /**
  92229. * Update a raw 2D array texture
  92230. * @param texture defines the texture to update
  92231. * @param data defines the data to store
  92232. * @param format defines the data format
  92233. * @param invertY defines if data must be stored with Y axis inverted
  92234. */
  92235. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92236. /**
  92237. * Update a raw 2D array texture
  92238. * @param texture defines the texture to update
  92239. * @param data defines the data to store
  92240. * @param format defines the data format
  92241. * @param invertY defines if data must be stored with Y axis inverted
  92242. * @param compression defines the used compression (can be null)
  92243. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92244. */
  92245. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92246. }
  92247. }
  92248. declare module BABYLON {
  92249. /**
  92250. * Raw texture can help creating a texture directly from an array of data.
  92251. * This can be super useful if you either get the data from an uncompressed source or
  92252. * if you wish to create your texture pixel by pixel.
  92253. */
  92254. export class RawTexture extends Texture {
  92255. /**
  92256. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92257. */
  92258. format: number;
  92259. /**
  92260. * Instantiates a new RawTexture.
  92261. * Raw texture can help creating a texture directly from an array of data.
  92262. * This can be super useful if you either get the data from an uncompressed source or
  92263. * if you wish to create your texture pixel by pixel.
  92264. * @param data define the array of data to use to create the texture
  92265. * @param width define the width of the texture
  92266. * @param height define the height of the texture
  92267. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92268. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92269. * @param generateMipMaps define whether mip maps should be generated or not
  92270. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92271. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92272. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92273. */
  92274. constructor(data: ArrayBufferView, width: number, height: number,
  92275. /**
  92276. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92277. */
  92278. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92279. /**
  92280. * Updates the texture underlying data.
  92281. * @param data Define the new data of the texture
  92282. */
  92283. update(data: ArrayBufferView): void;
  92284. /**
  92285. * Creates a luminance texture from some data.
  92286. * @param data Define the texture data
  92287. * @param width Define the width of the texture
  92288. * @param height Define the height of the texture
  92289. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92290. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92291. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92292. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92293. * @returns the luminance texture
  92294. */
  92295. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92296. /**
  92297. * Creates a luminance alpha texture from some data.
  92298. * @param data Define the texture data
  92299. * @param width Define the width of the texture
  92300. * @param height Define the height of the texture
  92301. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92302. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92303. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92304. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92305. * @returns the luminance alpha texture
  92306. */
  92307. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92308. /**
  92309. * Creates an alpha texture from some data.
  92310. * @param data Define the texture data
  92311. * @param width Define the width of the texture
  92312. * @param height Define the height of the texture
  92313. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92314. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92315. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92316. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92317. * @returns the alpha texture
  92318. */
  92319. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92320. /**
  92321. * Creates a RGB texture from some data.
  92322. * @param data Define the texture data
  92323. * @param width Define the width of the texture
  92324. * @param height Define the height of the texture
  92325. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92326. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92327. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92328. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92329. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92330. * @returns the RGB alpha texture
  92331. */
  92332. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92333. /**
  92334. * Creates a RGBA texture from some data.
  92335. * @param data Define the texture data
  92336. * @param width Define the width of the texture
  92337. * @param height Define the height of the texture
  92338. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92339. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92340. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92341. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92342. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92343. * @returns the RGBA texture
  92344. */
  92345. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92346. /**
  92347. * Creates a R texture from some data.
  92348. * @param data Define the texture data
  92349. * @param width Define the width of the texture
  92350. * @param height Define the height of the texture
  92351. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92352. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92353. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92354. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92355. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92356. * @returns the R texture
  92357. */
  92358. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92359. }
  92360. }
  92361. declare module BABYLON {
  92362. interface ThinEngine {
  92363. /**
  92364. * Update a dynamic index buffer
  92365. * @param indexBuffer defines the target index buffer
  92366. * @param indices defines the data to update
  92367. * @param offset defines the offset in the target index buffer where update should start
  92368. */
  92369. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92370. /**
  92371. * Updates a dynamic vertex buffer.
  92372. * @param vertexBuffer the vertex buffer to update
  92373. * @param data the data used to update the vertex buffer
  92374. * @param byteOffset the byte offset of the data
  92375. * @param byteLength the byte length of the data
  92376. */
  92377. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92378. }
  92379. }
  92380. declare module BABYLON {
  92381. interface AbstractScene {
  92382. /**
  92383. * The list of procedural textures added to the scene
  92384. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92385. */
  92386. proceduralTextures: Array<ProceduralTexture>;
  92387. }
  92388. /**
  92389. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92390. * in a given scene.
  92391. */
  92392. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92393. /**
  92394. * The component name helpfull to identify the component in the list of scene components.
  92395. */
  92396. readonly name: string;
  92397. /**
  92398. * The scene the component belongs to.
  92399. */
  92400. scene: Scene;
  92401. /**
  92402. * Creates a new instance of the component for the given scene
  92403. * @param scene Defines the scene to register the component in
  92404. */
  92405. constructor(scene: Scene);
  92406. /**
  92407. * Registers the component in a given scene
  92408. */
  92409. register(): void;
  92410. /**
  92411. * Rebuilds the elements related to this component in case of
  92412. * context lost for instance.
  92413. */
  92414. rebuild(): void;
  92415. /**
  92416. * Disposes the component and the associated ressources.
  92417. */
  92418. dispose(): void;
  92419. private _beforeClear;
  92420. }
  92421. }
  92422. declare module BABYLON {
  92423. interface ThinEngine {
  92424. /**
  92425. * Creates a new render target cube texture
  92426. * @param size defines the size of the texture
  92427. * @param options defines the options used to create the texture
  92428. * @returns a new render target cube texture stored in an InternalTexture
  92429. */
  92430. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92431. }
  92432. }
  92433. declare module BABYLON {
  92434. /** @hidden */
  92435. export var proceduralVertexShader: {
  92436. name: string;
  92437. shader: string;
  92438. };
  92439. }
  92440. declare module BABYLON {
  92441. /**
  92442. * 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.
  92443. * This is the base class of any Procedural texture and contains most of the shareable code.
  92444. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92445. */
  92446. export class ProceduralTexture extends Texture {
  92447. /**
  92448. * Define if the texture is enabled or not (disabled texture will not render)
  92449. */
  92450. isEnabled: boolean;
  92451. /**
  92452. * Define if the texture must be cleared before rendering (default is true)
  92453. */
  92454. autoClear: boolean;
  92455. /**
  92456. * Callback called when the texture is generated
  92457. */
  92458. onGenerated: () => void;
  92459. /**
  92460. * Event raised when the texture is generated
  92461. */
  92462. onGeneratedObservable: Observable<ProceduralTexture>;
  92463. /**
  92464. * Event raised before the texture is generated
  92465. */
  92466. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92467. /**
  92468. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92469. */
  92470. nodeMaterialSource: Nullable<NodeMaterial>;
  92471. /** @hidden */
  92472. _generateMipMaps: boolean;
  92473. /** @hidden **/
  92474. _effect: Effect;
  92475. /** @hidden */
  92476. _textures: {
  92477. [key: string]: Texture;
  92478. };
  92479. /** @hidden */
  92480. protected _fallbackTexture: Nullable<Texture>;
  92481. private _size;
  92482. private _currentRefreshId;
  92483. private _frameId;
  92484. private _refreshRate;
  92485. private _vertexBuffers;
  92486. private _indexBuffer;
  92487. private _uniforms;
  92488. private _samplers;
  92489. private _fragment;
  92490. private _floats;
  92491. private _ints;
  92492. private _floatsArrays;
  92493. private _colors3;
  92494. private _colors4;
  92495. private _vectors2;
  92496. private _vectors3;
  92497. private _matrices;
  92498. private _fallbackTextureUsed;
  92499. private _fullEngine;
  92500. private _cachedDefines;
  92501. private _contentUpdateId;
  92502. private _contentData;
  92503. /**
  92504. * Instantiates a new procedural texture.
  92505. * 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.
  92506. * This is the base class of any Procedural texture and contains most of the shareable code.
  92507. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92508. * @param name Define the name of the texture
  92509. * @param size Define the size of the texture to create
  92510. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92511. * @param scene Define the scene the texture belongs to
  92512. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92513. * @param generateMipMaps Define if the texture should creates mip maps or not
  92514. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92515. * @param textureType The FBO internal texture type
  92516. */
  92517. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92518. /**
  92519. * The effect that is created when initializing the post process.
  92520. * @returns The created effect corresponding the the postprocess.
  92521. */
  92522. getEffect(): Effect;
  92523. /**
  92524. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92525. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92526. */
  92527. getContent(): Nullable<ArrayBufferView>;
  92528. private _createIndexBuffer;
  92529. /** @hidden */
  92530. _rebuild(): void;
  92531. /**
  92532. * Resets the texture in order to recreate its associated resources.
  92533. * This can be called in case of context loss
  92534. */
  92535. reset(): void;
  92536. protected _getDefines(): string;
  92537. /**
  92538. * Is the texture ready to be used ? (rendered at least once)
  92539. * @returns true if ready, otherwise, false.
  92540. */
  92541. isReady(): boolean;
  92542. /**
  92543. * Resets the refresh counter of the texture and start bak from scratch.
  92544. * Could be useful to regenerate the texture if it is setup to render only once.
  92545. */
  92546. resetRefreshCounter(): void;
  92547. /**
  92548. * Set the fragment shader to use in order to render the texture.
  92549. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92550. */
  92551. setFragment(fragment: any): void;
  92552. /**
  92553. * Define the refresh rate of the texture or the rendering frequency.
  92554. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92555. */
  92556. get refreshRate(): number;
  92557. set refreshRate(value: number);
  92558. /** @hidden */
  92559. _shouldRender(): boolean;
  92560. /**
  92561. * Get the size the texture is rendering at.
  92562. * @returns the size (on cube texture it is always squared)
  92563. */
  92564. getRenderSize(): RenderTargetTextureSize;
  92565. /**
  92566. * Resize the texture to new value.
  92567. * @param size Define the new size the texture should have
  92568. * @param generateMipMaps Define whether the new texture should create mip maps
  92569. */
  92570. resize(size: number, generateMipMaps: boolean): void;
  92571. private _checkUniform;
  92572. /**
  92573. * Set a texture in the shader program used to render.
  92574. * @param name Define the name of the uniform samplers as defined in the shader
  92575. * @param texture Define the texture to bind to this sampler
  92576. * @return the texture itself allowing "fluent" like uniform updates
  92577. */
  92578. setTexture(name: string, texture: Texture): ProceduralTexture;
  92579. /**
  92580. * Set a float in the shader.
  92581. * @param name Define the name of the uniform as defined in the shader
  92582. * @param value Define the value to give to the uniform
  92583. * @return the texture itself allowing "fluent" like uniform updates
  92584. */
  92585. setFloat(name: string, value: number): ProceduralTexture;
  92586. /**
  92587. * Set a int in the shader.
  92588. * @param name Define the name of the uniform as defined in the shader
  92589. * @param value Define the value to give to the uniform
  92590. * @return the texture itself allowing "fluent" like uniform updates
  92591. */
  92592. setInt(name: string, value: number): ProceduralTexture;
  92593. /**
  92594. * Set an array of floats in the shader.
  92595. * @param name Define the name of the uniform as defined in the shader
  92596. * @param value Define the value to give to the uniform
  92597. * @return the texture itself allowing "fluent" like uniform updates
  92598. */
  92599. setFloats(name: string, value: number[]): ProceduralTexture;
  92600. /**
  92601. * Set a vec3 in the shader from a Color3.
  92602. * @param name Define the name of the uniform as defined in the shader
  92603. * @param value Define the value to give to the uniform
  92604. * @return the texture itself allowing "fluent" like uniform updates
  92605. */
  92606. setColor3(name: string, value: Color3): ProceduralTexture;
  92607. /**
  92608. * Set a vec4 in the shader from a Color4.
  92609. * @param name Define the name of the uniform as defined in the shader
  92610. * @param value Define the value to give to the uniform
  92611. * @return the texture itself allowing "fluent" like uniform updates
  92612. */
  92613. setColor4(name: string, value: Color4): ProceduralTexture;
  92614. /**
  92615. * Set a vec2 in the shader from a Vector2.
  92616. * @param name Define the name of the uniform as defined in the shader
  92617. * @param value Define the value to give to the uniform
  92618. * @return the texture itself allowing "fluent" like uniform updates
  92619. */
  92620. setVector2(name: string, value: Vector2): ProceduralTexture;
  92621. /**
  92622. * Set a vec3 in the shader from a Vector3.
  92623. * @param name Define the name of the uniform as defined in the shader
  92624. * @param value Define the value to give to the uniform
  92625. * @return the texture itself allowing "fluent" like uniform updates
  92626. */
  92627. setVector3(name: string, value: Vector3): ProceduralTexture;
  92628. /**
  92629. * Set a mat4 in the shader from a MAtrix.
  92630. * @param name Define the name of the uniform as defined in the shader
  92631. * @param value Define the value to give to the uniform
  92632. * @return the texture itself allowing "fluent" like uniform updates
  92633. */
  92634. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92635. /**
  92636. * Render the texture to its associated render target.
  92637. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92638. */
  92639. render(useCameraPostProcess?: boolean): void;
  92640. /**
  92641. * Clone the texture.
  92642. * @returns the cloned texture
  92643. */
  92644. clone(): ProceduralTexture;
  92645. /**
  92646. * Dispose the texture and release its asoociated resources.
  92647. */
  92648. dispose(): void;
  92649. }
  92650. }
  92651. declare module BABYLON {
  92652. /**
  92653. * This represents the base class for particle system in Babylon.
  92654. * 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.
  92655. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92656. * @example https://doc.babylonjs.com/babylon101/particles
  92657. */
  92658. export class BaseParticleSystem {
  92659. /**
  92660. * Source color is added to the destination color without alpha affecting the result
  92661. */
  92662. static BLENDMODE_ONEONE: number;
  92663. /**
  92664. * Blend current color and particle color using particle’s alpha
  92665. */
  92666. static BLENDMODE_STANDARD: number;
  92667. /**
  92668. * Add current color and particle color multiplied by particle’s alpha
  92669. */
  92670. static BLENDMODE_ADD: number;
  92671. /**
  92672. * Multiply current color with particle color
  92673. */
  92674. static BLENDMODE_MULTIPLY: number;
  92675. /**
  92676. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92677. */
  92678. static BLENDMODE_MULTIPLYADD: number;
  92679. /**
  92680. * List of animations used by the particle system.
  92681. */
  92682. animations: Animation[];
  92683. /**
  92684. * Gets or sets the unique id of the particle system
  92685. */
  92686. uniqueId: number;
  92687. /**
  92688. * The id of the Particle system.
  92689. */
  92690. id: string;
  92691. /**
  92692. * The friendly name of the Particle system.
  92693. */
  92694. name: string;
  92695. /**
  92696. * Snippet ID if the particle system was created from the snippet server
  92697. */
  92698. snippetId: string;
  92699. /**
  92700. * The rendering group used by the Particle system to chose when to render.
  92701. */
  92702. renderingGroupId: number;
  92703. /**
  92704. * The emitter represents the Mesh or position we are attaching the particle system to.
  92705. */
  92706. emitter: Nullable<AbstractMesh | Vector3>;
  92707. /**
  92708. * The maximum number of particles to emit per frame
  92709. */
  92710. emitRate: number;
  92711. /**
  92712. * If you want to launch only a few particles at once, that can be done, as well.
  92713. */
  92714. manualEmitCount: number;
  92715. /**
  92716. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92717. */
  92718. updateSpeed: number;
  92719. /**
  92720. * The amount of time the particle system is running (depends of the overall update speed).
  92721. */
  92722. targetStopDuration: number;
  92723. /**
  92724. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92725. */
  92726. disposeOnStop: boolean;
  92727. /**
  92728. * Minimum power of emitting particles.
  92729. */
  92730. minEmitPower: number;
  92731. /**
  92732. * Maximum power of emitting particles.
  92733. */
  92734. maxEmitPower: number;
  92735. /**
  92736. * Minimum life time of emitting particles.
  92737. */
  92738. minLifeTime: number;
  92739. /**
  92740. * Maximum life time of emitting particles.
  92741. */
  92742. maxLifeTime: number;
  92743. /**
  92744. * Minimum Size of emitting particles.
  92745. */
  92746. minSize: number;
  92747. /**
  92748. * Maximum Size of emitting particles.
  92749. */
  92750. maxSize: number;
  92751. /**
  92752. * Minimum scale of emitting particles on X axis.
  92753. */
  92754. minScaleX: number;
  92755. /**
  92756. * Maximum scale of emitting particles on X axis.
  92757. */
  92758. maxScaleX: number;
  92759. /**
  92760. * Minimum scale of emitting particles on Y axis.
  92761. */
  92762. minScaleY: number;
  92763. /**
  92764. * Maximum scale of emitting particles on Y axis.
  92765. */
  92766. maxScaleY: number;
  92767. /**
  92768. * Gets or sets the minimal initial rotation in radians.
  92769. */
  92770. minInitialRotation: number;
  92771. /**
  92772. * Gets or sets the maximal initial rotation in radians.
  92773. */
  92774. maxInitialRotation: number;
  92775. /**
  92776. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92777. */
  92778. minAngularSpeed: number;
  92779. /**
  92780. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92781. */
  92782. maxAngularSpeed: number;
  92783. /**
  92784. * The texture used to render each particle. (this can be a spritesheet)
  92785. */
  92786. particleTexture: Nullable<BaseTexture>;
  92787. /**
  92788. * The layer mask we are rendering the particles through.
  92789. */
  92790. layerMask: number;
  92791. /**
  92792. * This can help using your own shader to render the particle system.
  92793. * The according effect will be created
  92794. */
  92795. customShader: any;
  92796. /**
  92797. * By default particle system starts as soon as they are created. This prevents the
  92798. * automatic start to happen and let you decide when to start emitting particles.
  92799. */
  92800. preventAutoStart: boolean;
  92801. private _noiseTexture;
  92802. /**
  92803. * Gets or sets a texture used to add random noise to particle positions
  92804. */
  92805. get noiseTexture(): Nullable<ProceduralTexture>;
  92806. set noiseTexture(value: Nullable<ProceduralTexture>);
  92807. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92808. noiseStrength: Vector3;
  92809. /**
  92810. * Callback triggered when the particle animation is ending.
  92811. */
  92812. onAnimationEnd: Nullable<() => void>;
  92813. /**
  92814. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92815. */
  92816. blendMode: number;
  92817. /**
  92818. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92819. * to override the particles.
  92820. */
  92821. forceDepthWrite: boolean;
  92822. /** 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 */
  92823. preWarmCycles: number;
  92824. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92825. preWarmStepOffset: number;
  92826. /**
  92827. * 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)
  92828. */
  92829. spriteCellChangeSpeed: number;
  92830. /**
  92831. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92832. */
  92833. startSpriteCellID: number;
  92834. /**
  92835. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92836. */
  92837. endSpriteCellID: number;
  92838. /**
  92839. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92840. */
  92841. spriteCellWidth: number;
  92842. /**
  92843. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92844. */
  92845. spriteCellHeight: number;
  92846. /**
  92847. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92848. */
  92849. spriteRandomStartCell: boolean;
  92850. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92851. translationPivot: Vector2;
  92852. /** @hidden */
  92853. protected _isAnimationSheetEnabled: boolean;
  92854. /**
  92855. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92856. */
  92857. beginAnimationOnStart: boolean;
  92858. /**
  92859. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92860. */
  92861. beginAnimationFrom: number;
  92862. /**
  92863. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92864. */
  92865. beginAnimationTo: number;
  92866. /**
  92867. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92868. */
  92869. beginAnimationLoop: boolean;
  92870. /**
  92871. * Gets or sets a world offset applied to all particles
  92872. */
  92873. worldOffset: Vector3;
  92874. /**
  92875. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92876. */
  92877. get isAnimationSheetEnabled(): boolean;
  92878. set isAnimationSheetEnabled(value: boolean);
  92879. /**
  92880. * Get hosting scene
  92881. * @returns the scene
  92882. */
  92883. getScene(): Nullable<Scene>;
  92884. /**
  92885. * You can use gravity if you want to give an orientation to your particles.
  92886. */
  92887. gravity: Vector3;
  92888. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92889. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92890. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92891. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92892. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92893. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92894. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92895. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92896. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92897. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92898. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92899. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92900. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92901. /**
  92902. * Defines the delay in milliseconds before starting the system (0 by default)
  92903. */
  92904. startDelay: number;
  92905. /**
  92906. * Gets the current list of drag gradients.
  92907. * You must use addDragGradient and removeDragGradient to udpate this list
  92908. * @returns the list of drag gradients
  92909. */
  92910. getDragGradients(): Nullable<Array<FactorGradient>>;
  92911. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92912. limitVelocityDamping: number;
  92913. /**
  92914. * Gets the current list of limit velocity gradients.
  92915. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92916. * @returns the list of limit velocity gradients
  92917. */
  92918. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92919. /**
  92920. * Gets the current list of color gradients.
  92921. * You must use addColorGradient and removeColorGradient to udpate this list
  92922. * @returns the list of color gradients
  92923. */
  92924. getColorGradients(): Nullable<Array<ColorGradient>>;
  92925. /**
  92926. * Gets the current list of size gradients.
  92927. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92928. * @returns the list of size gradients
  92929. */
  92930. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92931. /**
  92932. * Gets the current list of color remap gradients.
  92933. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92934. * @returns the list of color remap gradients
  92935. */
  92936. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92937. /**
  92938. * Gets the current list of alpha remap gradients.
  92939. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92940. * @returns the list of alpha remap gradients
  92941. */
  92942. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92943. /**
  92944. * Gets the current list of life time gradients.
  92945. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92946. * @returns the list of life time gradients
  92947. */
  92948. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92949. /**
  92950. * Gets the current list of angular speed gradients.
  92951. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92952. * @returns the list of angular speed gradients
  92953. */
  92954. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92955. /**
  92956. * Gets the current list of velocity gradients.
  92957. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92958. * @returns the list of velocity gradients
  92959. */
  92960. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92961. /**
  92962. * Gets the current list of start size gradients.
  92963. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92964. * @returns the list of start size gradients
  92965. */
  92966. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92967. /**
  92968. * Gets the current list of emit rate gradients.
  92969. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92970. * @returns the list of emit rate gradients
  92971. */
  92972. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92973. /**
  92974. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92975. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92976. */
  92977. get direction1(): Vector3;
  92978. set direction1(value: Vector3);
  92979. /**
  92980. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92981. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92982. */
  92983. get direction2(): Vector3;
  92984. set direction2(value: Vector3);
  92985. /**
  92986. * 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.
  92987. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92988. */
  92989. get minEmitBox(): Vector3;
  92990. set minEmitBox(value: Vector3);
  92991. /**
  92992. * 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.
  92993. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92994. */
  92995. get maxEmitBox(): Vector3;
  92996. set maxEmitBox(value: Vector3);
  92997. /**
  92998. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92999. */
  93000. color1: Color4;
  93001. /**
  93002. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93003. */
  93004. color2: Color4;
  93005. /**
  93006. * Color the particle will have at the end of its lifetime
  93007. */
  93008. colorDead: Color4;
  93009. /**
  93010. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  93011. */
  93012. textureMask: Color4;
  93013. /**
  93014. * The particle emitter type defines the emitter used by the particle system.
  93015. * It can be for example box, sphere, or cone...
  93016. */
  93017. particleEmitterType: IParticleEmitterType;
  93018. /** @hidden */
  93019. _isSubEmitter: boolean;
  93020. /**
  93021. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93022. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93023. */
  93024. billboardMode: number;
  93025. protected _isBillboardBased: boolean;
  93026. /**
  93027. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93028. */
  93029. get isBillboardBased(): boolean;
  93030. set isBillboardBased(value: boolean);
  93031. /**
  93032. * The scene the particle system belongs to.
  93033. */
  93034. protected _scene: Nullable<Scene>;
  93035. /**
  93036. * The engine the particle system belongs to.
  93037. */
  93038. protected _engine: ThinEngine;
  93039. /**
  93040. * Local cache of defines for image processing.
  93041. */
  93042. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  93043. /**
  93044. * Default configuration related to image processing available in the standard Material.
  93045. */
  93046. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  93047. /**
  93048. * Gets the image processing configuration used either in this material.
  93049. */
  93050. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  93051. /**
  93052. * Sets the Default image processing configuration used either in the this material.
  93053. *
  93054. * If sets to null, the scene one is in use.
  93055. */
  93056. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  93057. /**
  93058. * Attaches a new image processing configuration to the Standard Material.
  93059. * @param configuration
  93060. */
  93061. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93062. /** @hidden */
  93063. protected _reset(): void;
  93064. /** @hidden */
  93065. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  93066. /**
  93067. * Instantiates a particle system.
  93068. * 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.
  93069. * @param name The name of the particle system
  93070. */
  93071. constructor(name: string);
  93072. /**
  93073. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93074. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93075. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93076. * @returns the emitter
  93077. */
  93078. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93079. /**
  93080. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93081. * @param radius The radius of the hemisphere to emit from
  93082. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93083. * @returns the emitter
  93084. */
  93085. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  93086. /**
  93087. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93088. * @param radius The radius of the sphere to emit from
  93089. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93090. * @returns the emitter
  93091. */
  93092. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93093. /**
  93094. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93095. * @param radius The radius of the sphere to emit from
  93096. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93097. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93098. * @returns the emitter
  93099. */
  93100. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93101. /**
  93102. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93103. * @param radius The radius of the emission cylinder
  93104. * @param height The height of the emission cylinder
  93105. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93106. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93107. * @returns the emitter
  93108. */
  93109. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93110. /**
  93111. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93112. * @param radius The radius of the cylinder to emit from
  93113. * @param height The height of the emission cylinder
  93114. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93115. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93116. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93117. * @returns the emitter
  93118. */
  93119. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93120. /**
  93121. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93122. * @param radius The radius of the cone to emit from
  93123. * @param angle The base angle of the cone
  93124. * @returns the emitter
  93125. */
  93126. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93127. /**
  93128. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93129. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93130. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93131. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93132. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93133. * @returns the emitter
  93134. */
  93135. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93136. }
  93137. }
  93138. declare module BABYLON {
  93139. /**
  93140. * Type of sub emitter
  93141. */
  93142. export enum SubEmitterType {
  93143. /**
  93144. * Attached to the particle over it's lifetime
  93145. */
  93146. ATTACHED = 0,
  93147. /**
  93148. * Created when the particle dies
  93149. */
  93150. END = 1
  93151. }
  93152. /**
  93153. * Sub emitter class used to emit particles from an existing particle
  93154. */
  93155. export class SubEmitter {
  93156. /**
  93157. * the particle system to be used by the sub emitter
  93158. */
  93159. particleSystem: ParticleSystem;
  93160. /**
  93161. * Type of the submitter (Default: END)
  93162. */
  93163. type: SubEmitterType;
  93164. /**
  93165. * 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)
  93166. * Note: This only is supported when using an emitter of type Mesh
  93167. */
  93168. inheritDirection: boolean;
  93169. /**
  93170. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93171. */
  93172. inheritedVelocityAmount: number;
  93173. /**
  93174. * Creates a sub emitter
  93175. * @param particleSystem the particle system to be used by the sub emitter
  93176. */
  93177. constructor(
  93178. /**
  93179. * the particle system to be used by the sub emitter
  93180. */
  93181. particleSystem: ParticleSystem);
  93182. /**
  93183. * Clones the sub emitter
  93184. * @returns the cloned sub emitter
  93185. */
  93186. clone(): SubEmitter;
  93187. /**
  93188. * Serialize current object to a JSON object
  93189. * @returns the serialized object
  93190. */
  93191. serialize(): any;
  93192. /** @hidden */
  93193. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93194. /**
  93195. * Creates a new SubEmitter from a serialized JSON version
  93196. * @param serializationObject defines the JSON object to read from
  93197. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93198. * @param rootUrl defines the rootUrl for data loading
  93199. * @returns a new SubEmitter
  93200. */
  93201. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93202. /** Release associated resources */
  93203. dispose(): void;
  93204. }
  93205. }
  93206. declare module BABYLON {
  93207. /** @hidden */
  93208. export var imageProcessingDeclaration: {
  93209. name: string;
  93210. shader: string;
  93211. };
  93212. }
  93213. declare module BABYLON {
  93214. /** @hidden */
  93215. export var imageProcessingFunctions: {
  93216. name: string;
  93217. shader: string;
  93218. };
  93219. }
  93220. declare module BABYLON {
  93221. /** @hidden */
  93222. export var particlesPixelShader: {
  93223. name: string;
  93224. shader: string;
  93225. };
  93226. }
  93227. declare module BABYLON {
  93228. /** @hidden */
  93229. export var particlesVertexShader: {
  93230. name: string;
  93231. shader: string;
  93232. };
  93233. }
  93234. declare module BABYLON {
  93235. /**
  93236. * Interface used to define entities containing multiple clip planes
  93237. */
  93238. export interface IClipPlanesHolder {
  93239. /**
  93240. * Gets or sets the active clipplane 1
  93241. */
  93242. clipPlane: Nullable<Plane>;
  93243. /**
  93244. * Gets or sets the active clipplane 2
  93245. */
  93246. clipPlane2: Nullable<Plane>;
  93247. /**
  93248. * Gets or sets the active clipplane 3
  93249. */
  93250. clipPlane3: Nullable<Plane>;
  93251. /**
  93252. * Gets or sets the active clipplane 4
  93253. */
  93254. clipPlane4: Nullable<Plane>;
  93255. /**
  93256. * Gets or sets the active clipplane 5
  93257. */
  93258. clipPlane5: Nullable<Plane>;
  93259. /**
  93260. * Gets or sets the active clipplane 6
  93261. */
  93262. clipPlane6: Nullable<Plane>;
  93263. }
  93264. }
  93265. declare module BABYLON {
  93266. /**
  93267. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93268. *
  93269. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93270. *
  93271. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93272. */
  93273. export class ThinMaterialHelper {
  93274. /**
  93275. * Binds the clip plane information from the holder to the effect.
  93276. * @param effect The effect we are binding the data to
  93277. * @param holder The entity containing the clip plane information
  93278. */
  93279. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93280. }
  93281. }
  93282. declare module BABYLON {
  93283. interface ThinEngine {
  93284. /**
  93285. * Sets alpha constants used by some alpha blending modes
  93286. * @param r defines the red component
  93287. * @param g defines the green component
  93288. * @param b defines the blue component
  93289. * @param a defines the alpha component
  93290. */
  93291. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93292. /**
  93293. * Sets the current alpha mode
  93294. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93295. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93296. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93297. */
  93298. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93299. /**
  93300. * Gets the current alpha mode
  93301. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93302. * @returns the current alpha mode
  93303. */
  93304. getAlphaMode(): number;
  93305. /**
  93306. * Sets the current alpha equation
  93307. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93308. */
  93309. setAlphaEquation(equation: number): void;
  93310. /**
  93311. * Gets the current alpha equation.
  93312. * @returns the current alpha equation
  93313. */
  93314. getAlphaEquation(): number;
  93315. }
  93316. }
  93317. declare module BABYLON {
  93318. /**
  93319. * This represents a particle system in Babylon.
  93320. * 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.
  93321. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93322. * @example https://doc.babylonjs.com/babylon101/particles
  93323. */
  93324. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93325. /**
  93326. * Billboard mode will only apply to Y axis
  93327. */
  93328. static readonly BILLBOARDMODE_Y: number;
  93329. /**
  93330. * Billboard mode will apply to all axes
  93331. */
  93332. static readonly BILLBOARDMODE_ALL: number;
  93333. /**
  93334. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93335. */
  93336. static readonly BILLBOARDMODE_STRETCHED: number;
  93337. /**
  93338. * This function can be defined to provide custom update for active particles.
  93339. * This function will be called instead of regular update (age, position, color, etc.).
  93340. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93341. */
  93342. updateFunction: (particles: Particle[]) => void;
  93343. private _emitterWorldMatrix;
  93344. /**
  93345. * This function can be defined to specify initial direction for every new particle.
  93346. * It by default use the emitterType defined function
  93347. */
  93348. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93349. /**
  93350. * This function can be defined to specify initial position for every new particle.
  93351. * It by default use the emitterType defined function
  93352. */
  93353. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93354. /**
  93355. * @hidden
  93356. */
  93357. _inheritedVelocityOffset: Vector3;
  93358. /**
  93359. * An event triggered when the system is disposed
  93360. */
  93361. onDisposeObservable: Observable<IParticleSystem>;
  93362. /**
  93363. * An event triggered when the system is stopped
  93364. */
  93365. onStoppedObservable: Observable<IParticleSystem>;
  93366. private _onDisposeObserver;
  93367. /**
  93368. * Sets a callback that will be triggered when the system is disposed
  93369. */
  93370. set onDispose(callback: () => void);
  93371. private _particles;
  93372. private _epsilon;
  93373. private _capacity;
  93374. private _stockParticles;
  93375. private _newPartsExcess;
  93376. private _vertexData;
  93377. private _vertexBuffer;
  93378. private _vertexBuffers;
  93379. private _spriteBuffer;
  93380. private _indexBuffer;
  93381. private _effect;
  93382. private _customEffect;
  93383. private _cachedDefines;
  93384. private _scaledColorStep;
  93385. private _colorDiff;
  93386. private _scaledDirection;
  93387. private _scaledGravity;
  93388. private _currentRenderId;
  93389. private _alive;
  93390. private _useInstancing;
  93391. private _started;
  93392. private _stopped;
  93393. private _actualFrame;
  93394. private _scaledUpdateSpeed;
  93395. private _vertexBufferSize;
  93396. /** @hidden */
  93397. _currentEmitRateGradient: Nullable<FactorGradient>;
  93398. /** @hidden */
  93399. _currentEmitRate1: number;
  93400. /** @hidden */
  93401. _currentEmitRate2: number;
  93402. /** @hidden */
  93403. _currentStartSizeGradient: Nullable<FactorGradient>;
  93404. /** @hidden */
  93405. _currentStartSize1: number;
  93406. /** @hidden */
  93407. _currentStartSize2: number;
  93408. private readonly _rawTextureWidth;
  93409. private _rampGradientsTexture;
  93410. private _useRampGradients;
  93411. /** Gets or sets a matrix to use to compute projection */
  93412. defaultProjectionMatrix: Matrix;
  93413. /** Gets or sets a matrix to use to compute view */
  93414. defaultViewMatrix: Matrix;
  93415. /** Gets or sets a boolean indicating that ramp gradients must be used
  93416. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93417. */
  93418. get useRampGradients(): boolean;
  93419. set useRampGradients(value: boolean);
  93420. /**
  93421. * 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.
  93422. * 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: [])
  93423. */
  93424. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93425. private _subEmitters;
  93426. /**
  93427. * @hidden
  93428. * If the particle systems emitter should be disposed when the particle system is disposed
  93429. */
  93430. _disposeEmitterOnDispose: boolean;
  93431. /**
  93432. * The current active Sub-systems, this property is used by the root particle system only.
  93433. */
  93434. activeSubSystems: Array<ParticleSystem>;
  93435. /**
  93436. * Specifies if the particles are updated in emitter local space or world space
  93437. */
  93438. isLocal: boolean;
  93439. private _rootParticleSystem;
  93440. /**
  93441. * Gets the current list of active particles
  93442. */
  93443. get particles(): Particle[];
  93444. /**
  93445. * Gets the number of particles active at the same time.
  93446. * @returns The number of active particles.
  93447. */
  93448. getActiveCount(): number;
  93449. /**
  93450. * Returns the string "ParticleSystem"
  93451. * @returns a string containing the class name
  93452. */
  93453. getClassName(): string;
  93454. /**
  93455. * Gets a boolean indicating that the system is stopping
  93456. * @returns true if the system is currently stopping
  93457. */
  93458. isStopping(): boolean;
  93459. /**
  93460. * Gets the custom effect used to render the particles
  93461. * @param blendMode Blend mode for which the effect should be retrieved
  93462. * @returns The effect
  93463. */
  93464. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93465. /**
  93466. * Sets the custom effect used to render the particles
  93467. * @param effect The effect to set
  93468. * @param blendMode Blend mode for which the effect should be set
  93469. */
  93470. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93471. /** @hidden */
  93472. private _onBeforeDrawParticlesObservable;
  93473. /**
  93474. * Observable that will be called just before the particles are drawn
  93475. */
  93476. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93477. /**
  93478. * Gets the name of the particle vertex shader
  93479. */
  93480. get vertexShaderName(): string;
  93481. /**
  93482. * Instantiates a particle system.
  93483. * 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.
  93484. * @param name The name of the particle system
  93485. * @param capacity The max number of particles alive at the same time
  93486. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93487. * @param customEffect a custom effect used to change the way particles are rendered by default
  93488. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93489. * @param epsilon Offset used to render the particles
  93490. */
  93491. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93492. private _addFactorGradient;
  93493. private _removeFactorGradient;
  93494. /**
  93495. * Adds a new life time gradient
  93496. * @param gradient defines the gradient to use (between 0 and 1)
  93497. * @param factor defines the life time factor to affect to the specified gradient
  93498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93499. * @returns the current particle system
  93500. */
  93501. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93502. /**
  93503. * Remove a specific life time gradient
  93504. * @param gradient defines the gradient to remove
  93505. * @returns the current particle system
  93506. */
  93507. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93508. /**
  93509. * Adds a new size gradient
  93510. * @param gradient defines the gradient to use (between 0 and 1)
  93511. * @param factor defines the size factor to affect to the specified gradient
  93512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93513. * @returns the current particle system
  93514. */
  93515. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93516. /**
  93517. * Remove a specific size gradient
  93518. * @param gradient defines the gradient to remove
  93519. * @returns the current particle system
  93520. */
  93521. removeSizeGradient(gradient: number): IParticleSystem;
  93522. /**
  93523. * Adds a new color remap gradient
  93524. * @param gradient defines the gradient to use (between 0 and 1)
  93525. * @param min defines the color remap minimal range
  93526. * @param max defines the color remap maximal range
  93527. * @returns the current particle system
  93528. */
  93529. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93530. /**
  93531. * Remove a specific color remap gradient
  93532. * @param gradient defines the gradient to remove
  93533. * @returns the current particle system
  93534. */
  93535. removeColorRemapGradient(gradient: number): IParticleSystem;
  93536. /**
  93537. * Adds a new alpha remap gradient
  93538. * @param gradient defines the gradient to use (between 0 and 1)
  93539. * @param min defines the alpha remap minimal range
  93540. * @param max defines the alpha remap maximal range
  93541. * @returns the current particle system
  93542. */
  93543. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93544. /**
  93545. * Remove a specific alpha remap gradient
  93546. * @param gradient defines the gradient to remove
  93547. * @returns the current particle system
  93548. */
  93549. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93550. /**
  93551. * Adds a new angular speed gradient
  93552. * @param gradient defines the gradient to use (between 0 and 1)
  93553. * @param factor defines the angular speed to affect to the specified gradient
  93554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93555. * @returns the current particle system
  93556. */
  93557. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93558. /**
  93559. * Remove a specific angular speed gradient
  93560. * @param gradient defines the gradient to remove
  93561. * @returns the current particle system
  93562. */
  93563. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93564. /**
  93565. * Adds a new velocity gradient
  93566. * @param gradient defines the gradient to use (between 0 and 1)
  93567. * @param factor defines the velocity to affect to the specified gradient
  93568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93569. * @returns the current particle system
  93570. */
  93571. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93572. /**
  93573. * Remove a specific velocity gradient
  93574. * @param gradient defines the gradient to remove
  93575. * @returns the current particle system
  93576. */
  93577. removeVelocityGradient(gradient: number): IParticleSystem;
  93578. /**
  93579. * Adds a new limit velocity gradient
  93580. * @param gradient defines the gradient to use (between 0 and 1)
  93581. * @param factor defines the limit velocity value to affect to the specified gradient
  93582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93583. * @returns the current particle system
  93584. */
  93585. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93586. /**
  93587. * Remove a specific limit velocity gradient
  93588. * @param gradient defines the gradient to remove
  93589. * @returns the current particle system
  93590. */
  93591. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93592. /**
  93593. * Adds a new drag gradient
  93594. * @param gradient defines the gradient to use (between 0 and 1)
  93595. * @param factor defines the drag value to affect to the specified gradient
  93596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93597. * @returns the current particle system
  93598. */
  93599. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93600. /**
  93601. * Remove a specific drag gradient
  93602. * @param gradient defines the gradient to remove
  93603. * @returns the current particle system
  93604. */
  93605. removeDragGradient(gradient: number): IParticleSystem;
  93606. /**
  93607. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93608. * @param gradient defines the gradient to use (between 0 and 1)
  93609. * @param factor defines the emit rate value to affect to the specified gradient
  93610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93611. * @returns the current particle system
  93612. */
  93613. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93614. /**
  93615. * Remove a specific emit rate gradient
  93616. * @param gradient defines the gradient to remove
  93617. * @returns the current particle system
  93618. */
  93619. removeEmitRateGradient(gradient: number): IParticleSystem;
  93620. /**
  93621. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93622. * @param gradient defines the gradient to use (between 0 and 1)
  93623. * @param factor defines the start size value to affect to the specified gradient
  93624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93625. * @returns the current particle system
  93626. */
  93627. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93628. /**
  93629. * Remove a specific start size gradient
  93630. * @param gradient defines the gradient to remove
  93631. * @returns the current particle system
  93632. */
  93633. removeStartSizeGradient(gradient: number): IParticleSystem;
  93634. private _createRampGradientTexture;
  93635. /**
  93636. * Gets the current list of ramp gradients.
  93637. * You must use addRampGradient and removeRampGradient to udpate this list
  93638. * @returns the list of ramp gradients
  93639. */
  93640. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93641. /** Force the system to rebuild all gradients that need to be resync */
  93642. forceRefreshGradients(): void;
  93643. private _syncRampGradientTexture;
  93644. /**
  93645. * Adds a new ramp gradient used to remap particle colors
  93646. * @param gradient defines the gradient to use (between 0 and 1)
  93647. * @param color defines the color to affect to the specified gradient
  93648. * @returns the current particle system
  93649. */
  93650. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93651. /**
  93652. * Remove a specific ramp gradient
  93653. * @param gradient defines the gradient to remove
  93654. * @returns the current particle system
  93655. */
  93656. removeRampGradient(gradient: number): ParticleSystem;
  93657. /**
  93658. * Adds a new color gradient
  93659. * @param gradient defines the gradient to use (between 0 and 1)
  93660. * @param color1 defines the color to affect to the specified gradient
  93661. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93662. * @returns this particle system
  93663. */
  93664. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93665. /**
  93666. * Remove a specific color gradient
  93667. * @param gradient defines the gradient to remove
  93668. * @returns this particle system
  93669. */
  93670. removeColorGradient(gradient: number): IParticleSystem;
  93671. private _fetchR;
  93672. protected _reset(): void;
  93673. private _resetEffect;
  93674. private _createVertexBuffers;
  93675. private _createIndexBuffer;
  93676. /**
  93677. * Gets the maximum number of particles active at the same time.
  93678. * @returns The max number of active particles.
  93679. */
  93680. getCapacity(): number;
  93681. /**
  93682. * Gets whether there are still active particles in the system.
  93683. * @returns True if it is alive, otherwise false.
  93684. */
  93685. isAlive(): boolean;
  93686. /**
  93687. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93688. * @returns True if it has been started, otherwise false.
  93689. */
  93690. isStarted(): boolean;
  93691. private _prepareSubEmitterInternalArray;
  93692. /**
  93693. * Starts the particle system and begins to emit
  93694. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93695. */
  93696. start(delay?: number): void;
  93697. /**
  93698. * Stops the particle system.
  93699. * @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.
  93700. */
  93701. stop(stopSubEmitters?: boolean): void;
  93702. /**
  93703. * Remove all active particles
  93704. */
  93705. reset(): void;
  93706. /**
  93707. * @hidden (for internal use only)
  93708. */
  93709. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93710. /**
  93711. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93712. * Its lifetime will start back at 0.
  93713. */
  93714. recycleParticle: (particle: Particle) => void;
  93715. private _stopSubEmitters;
  93716. private _createParticle;
  93717. private _removeFromRoot;
  93718. private _emitFromParticle;
  93719. private _update;
  93720. /** @hidden */
  93721. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93722. /** @hidden */
  93723. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93724. /**
  93725. * Fill the defines array according to the current settings of the particle system
  93726. * @param defines Array to be updated
  93727. * @param blendMode blend mode to take into account when updating the array
  93728. */
  93729. fillDefines(defines: Array<string>, blendMode: number): void;
  93730. /**
  93731. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93732. * @param uniforms Uniforms array to fill
  93733. * @param attributes Attributes array to fill
  93734. * @param samplers Samplers array to fill
  93735. */
  93736. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93737. /** @hidden */
  93738. private _getEffect;
  93739. /**
  93740. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93741. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93742. */
  93743. animate(preWarmOnly?: boolean): void;
  93744. private _appendParticleVertices;
  93745. /**
  93746. * Rebuilds the particle system.
  93747. */
  93748. rebuild(): void;
  93749. /**
  93750. * Is this system ready to be used/rendered
  93751. * @return true if the system is ready
  93752. */
  93753. isReady(): boolean;
  93754. private _render;
  93755. /**
  93756. * Renders the particle system in its current state.
  93757. * @returns the current number of particles
  93758. */
  93759. render(): number;
  93760. /**
  93761. * Disposes the particle system and free the associated resources
  93762. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93763. */
  93764. dispose(disposeTexture?: boolean): void;
  93765. /**
  93766. * Clones the particle system.
  93767. * @param name The name of the cloned object
  93768. * @param newEmitter The new emitter to use
  93769. * @returns the cloned particle system
  93770. */
  93771. clone(name: string, newEmitter: any): ParticleSystem;
  93772. /**
  93773. * Serializes the particle system to a JSON object
  93774. * @param serializeTexture defines if the texture must be serialized as well
  93775. * @returns the JSON object
  93776. */
  93777. serialize(serializeTexture?: boolean): any;
  93778. /** @hidden */
  93779. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93780. /** @hidden */
  93781. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93782. /**
  93783. * Parses a JSON object to create a particle system.
  93784. * @param parsedParticleSystem The JSON object to parse
  93785. * @param sceneOrEngine The scene or the engine to create the particle system in
  93786. * @param rootUrl The root url to use to load external dependencies like texture
  93787. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93788. * @returns the Parsed particle system
  93789. */
  93790. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93791. }
  93792. }
  93793. declare module BABYLON {
  93794. /**
  93795. * A particle represents one of the element emitted by a particle system.
  93796. * This is mainly define by its coordinates, direction, velocity and age.
  93797. */
  93798. export class Particle {
  93799. /**
  93800. * The particle system the particle belongs to.
  93801. */
  93802. particleSystem: ParticleSystem;
  93803. private static _Count;
  93804. /**
  93805. * Unique ID of the particle
  93806. */
  93807. id: number;
  93808. /**
  93809. * The world position of the particle in the scene.
  93810. */
  93811. position: Vector3;
  93812. /**
  93813. * The world direction of the particle in the scene.
  93814. */
  93815. direction: Vector3;
  93816. /**
  93817. * The color of the particle.
  93818. */
  93819. color: Color4;
  93820. /**
  93821. * The color change of the particle per step.
  93822. */
  93823. colorStep: Color4;
  93824. /**
  93825. * Defines how long will the life of the particle be.
  93826. */
  93827. lifeTime: number;
  93828. /**
  93829. * The current age of the particle.
  93830. */
  93831. age: number;
  93832. /**
  93833. * The current size of the particle.
  93834. */
  93835. size: number;
  93836. /**
  93837. * The current scale of the particle.
  93838. */
  93839. scale: Vector2;
  93840. /**
  93841. * The current angle of the particle.
  93842. */
  93843. angle: number;
  93844. /**
  93845. * Defines how fast is the angle changing.
  93846. */
  93847. angularSpeed: number;
  93848. /**
  93849. * Defines the cell index used by the particle to be rendered from a sprite.
  93850. */
  93851. cellIndex: number;
  93852. /**
  93853. * The information required to support color remapping
  93854. */
  93855. remapData: Vector4;
  93856. /** @hidden */
  93857. _randomCellOffset?: number;
  93858. /** @hidden */
  93859. _initialDirection: Nullable<Vector3>;
  93860. /** @hidden */
  93861. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93862. /** @hidden */
  93863. _initialStartSpriteCellID: number;
  93864. /** @hidden */
  93865. _initialEndSpriteCellID: number;
  93866. /** @hidden */
  93867. _currentColorGradient: Nullable<ColorGradient>;
  93868. /** @hidden */
  93869. _currentColor1: Color4;
  93870. /** @hidden */
  93871. _currentColor2: Color4;
  93872. /** @hidden */
  93873. _currentSizeGradient: Nullable<FactorGradient>;
  93874. /** @hidden */
  93875. _currentSize1: number;
  93876. /** @hidden */
  93877. _currentSize2: number;
  93878. /** @hidden */
  93879. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93880. /** @hidden */
  93881. _currentAngularSpeed1: number;
  93882. /** @hidden */
  93883. _currentAngularSpeed2: number;
  93884. /** @hidden */
  93885. _currentVelocityGradient: Nullable<FactorGradient>;
  93886. /** @hidden */
  93887. _currentVelocity1: number;
  93888. /** @hidden */
  93889. _currentVelocity2: number;
  93890. /** @hidden */
  93891. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93892. /** @hidden */
  93893. _currentLimitVelocity1: number;
  93894. /** @hidden */
  93895. _currentLimitVelocity2: number;
  93896. /** @hidden */
  93897. _currentDragGradient: Nullable<FactorGradient>;
  93898. /** @hidden */
  93899. _currentDrag1: number;
  93900. /** @hidden */
  93901. _currentDrag2: number;
  93902. /** @hidden */
  93903. _randomNoiseCoordinates1: Vector3;
  93904. /** @hidden */
  93905. _randomNoiseCoordinates2: Vector3;
  93906. /** @hidden */
  93907. _localPosition?: Vector3;
  93908. /**
  93909. * Creates a new instance Particle
  93910. * @param particleSystem the particle system the particle belongs to
  93911. */
  93912. constructor(
  93913. /**
  93914. * The particle system the particle belongs to.
  93915. */
  93916. particleSystem: ParticleSystem);
  93917. private updateCellInfoFromSystem;
  93918. /**
  93919. * Defines how the sprite cell index is updated for the particle
  93920. */
  93921. updateCellIndex(): void;
  93922. /** @hidden */
  93923. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93924. /** @hidden */
  93925. _inheritParticleInfoToSubEmitters(): void;
  93926. /** @hidden */
  93927. _reset(): void;
  93928. /**
  93929. * Copy the properties of particle to another one.
  93930. * @param other the particle to copy the information to.
  93931. */
  93932. copyTo(other: Particle): void;
  93933. }
  93934. }
  93935. declare module BABYLON {
  93936. /**
  93937. * Particle emitter represents a volume emitting particles.
  93938. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93939. */
  93940. export interface IParticleEmitterType {
  93941. /**
  93942. * Called by the particle System when the direction is computed for the created particle.
  93943. * @param worldMatrix is the world matrix of the particle system
  93944. * @param directionToUpdate is the direction vector to update with the result
  93945. * @param particle is the particle we are computed the direction for
  93946. * @param isLocal defines if the direction should be set in local space
  93947. */
  93948. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93949. /**
  93950. * Called by the particle System when the position is computed for the created particle.
  93951. * @param worldMatrix is the world matrix of the particle system
  93952. * @param positionToUpdate is the position vector to update with the result
  93953. * @param particle is the particle we are computed the position for
  93954. * @param isLocal defines if the position should be set in local space
  93955. */
  93956. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93957. /**
  93958. * Clones the current emitter and returns a copy of it
  93959. * @returns the new emitter
  93960. */
  93961. clone(): IParticleEmitterType;
  93962. /**
  93963. * Called by the GPUParticleSystem to setup the update shader
  93964. * @param effect defines the update shader
  93965. */
  93966. applyToShader(effect: Effect): void;
  93967. /**
  93968. * Returns a string to use to update the GPU particles update shader
  93969. * @returns the effect defines string
  93970. */
  93971. getEffectDefines(): string;
  93972. /**
  93973. * Returns a string representing the class name
  93974. * @returns a string containing the class name
  93975. */
  93976. getClassName(): string;
  93977. /**
  93978. * Serializes the particle system to a JSON object.
  93979. * @returns the JSON object
  93980. */
  93981. serialize(): any;
  93982. /**
  93983. * Parse properties from a JSON object
  93984. * @param serializationObject defines the JSON object
  93985. * @param scene defines the hosting scene
  93986. */
  93987. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93988. }
  93989. }
  93990. declare module BABYLON {
  93991. /**
  93992. * Particle emitter emitting particles from the inside of a box.
  93993. * It emits the particles randomly between 2 given directions.
  93994. */
  93995. export class BoxParticleEmitter implements IParticleEmitterType {
  93996. /**
  93997. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93998. */
  93999. direction1: Vector3;
  94000. /**
  94001. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94002. */
  94003. direction2: Vector3;
  94004. /**
  94005. * 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.
  94006. */
  94007. minEmitBox: Vector3;
  94008. /**
  94009. * 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.
  94010. */
  94011. maxEmitBox: Vector3;
  94012. /**
  94013. * Creates a new instance BoxParticleEmitter
  94014. */
  94015. constructor();
  94016. /**
  94017. * Called by the particle System when the direction is computed for the created particle.
  94018. * @param worldMatrix is the world matrix of the particle system
  94019. * @param directionToUpdate is the direction vector to update with the result
  94020. * @param particle is the particle we are computed the direction for
  94021. * @param isLocal defines if the direction should be set in local space
  94022. */
  94023. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94024. /**
  94025. * Called by the particle System when the position is computed for the created particle.
  94026. * @param worldMatrix is the world matrix of the particle system
  94027. * @param positionToUpdate is the position vector to update with the result
  94028. * @param particle is the particle we are computed the position for
  94029. * @param isLocal defines if the position should be set in local space
  94030. */
  94031. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94032. /**
  94033. * Clones the current emitter and returns a copy of it
  94034. * @returns the new emitter
  94035. */
  94036. clone(): BoxParticleEmitter;
  94037. /**
  94038. * Called by the GPUParticleSystem to setup the update shader
  94039. * @param effect defines the update shader
  94040. */
  94041. applyToShader(effect: Effect): void;
  94042. /**
  94043. * Returns a string to use to update the GPU particles update shader
  94044. * @returns a string containng the defines string
  94045. */
  94046. getEffectDefines(): string;
  94047. /**
  94048. * Returns the string "BoxParticleEmitter"
  94049. * @returns a string containing the class name
  94050. */
  94051. getClassName(): string;
  94052. /**
  94053. * Serializes the particle system to a JSON object.
  94054. * @returns the JSON object
  94055. */
  94056. serialize(): any;
  94057. /**
  94058. * Parse properties from a JSON object
  94059. * @param serializationObject defines the JSON object
  94060. */
  94061. parse(serializationObject: any): void;
  94062. }
  94063. }
  94064. declare module BABYLON {
  94065. /**
  94066. * Particle emitter emitting particles from the inside of a cone.
  94067. * It emits the particles alongside the cone volume from the base to the particle.
  94068. * The emission direction might be randomized.
  94069. */
  94070. export class ConeParticleEmitter implements IParticleEmitterType {
  94071. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94072. directionRandomizer: number;
  94073. private _radius;
  94074. private _angle;
  94075. private _height;
  94076. /**
  94077. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  94078. */
  94079. radiusRange: number;
  94080. /**
  94081. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  94082. */
  94083. heightRange: number;
  94084. /**
  94085. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  94086. */
  94087. emitFromSpawnPointOnly: boolean;
  94088. /**
  94089. * Gets or sets the radius of the emission cone
  94090. */
  94091. get radius(): number;
  94092. set radius(value: number);
  94093. /**
  94094. * Gets or sets the angle of the emission cone
  94095. */
  94096. get angle(): number;
  94097. set angle(value: number);
  94098. private _buildHeight;
  94099. /**
  94100. * Creates a new instance ConeParticleEmitter
  94101. * @param radius the radius of the emission cone (1 by default)
  94102. * @param angle the cone base angle (PI by default)
  94103. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94104. */
  94105. constructor(radius?: number, angle?: number,
  94106. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94107. directionRandomizer?: number);
  94108. /**
  94109. * Called by the particle System when the direction is computed for the created particle.
  94110. * @param worldMatrix is the world matrix of the particle system
  94111. * @param directionToUpdate is the direction vector to update with the result
  94112. * @param particle is the particle we are computed the direction for
  94113. * @param isLocal defines if the direction should be set in local space
  94114. */
  94115. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94116. /**
  94117. * Called by the particle System when the position is computed for the created particle.
  94118. * @param worldMatrix is the world matrix of the particle system
  94119. * @param positionToUpdate is the position vector to update with the result
  94120. * @param particle is the particle we are computed the position for
  94121. * @param isLocal defines if the position should be set in local space
  94122. */
  94123. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94124. /**
  94125. * Clones the current emitter and returns a copy of it
  94126. * @returns the new emitter
  94127. */
  94128. clone(): ConeParticleEmitter;
  94129. /**
  94130. * Called by the GPUParticleSystem to setup the update shader
  94131. * @param effect defines the update shader
  94132. */
  94133. applyToShader(effect: Effect): void;
  94134. /**
  94135. * Returns a string to use to update the GPU particles update shader
  94136. * @returns a string containng the defines string
  94137. */
  94138. getEffectDefines(): string;
  94139. /**
  94140. * Returns the string "ConeParticleEmitter"
  94141. * @returns a string containing the class name
  94142. */
  94143. getClassName(): string;
  94144. /**
  94145. * Serializes the particle system to a JSON object.
  94146. * @returns the JSON object
  94147. */
  94148. serialize(): any;
  94149. /**
  94150. * Parse properties from a JSON object
  94151. * @param serializationObject defines the JSON object
  94152. */
  94153. parse(serializationObject: any): void;
  94154. }
  94155. }
  94156. declare module BABYLON {
  94157. /**
  94158. * Particle emitter emitting particles from the inside of a cylinder.
  94159. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94160. */
  94161. export class CylinderParticleEmitter implements IParticleEmitterType {
  94162. /**
  94163. * The radius of the emission cylinder.
  94164. */
  94165. radius: number;
  94166. /**
  94167. * The height of the emission cylinder.
  94168. */
  94169. height: number;
  94170. /**
  94171. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94172. */
  94173. radiusRange: number;
  94174. /**
  94175. * How much to randomize the particle direction [0-1].
  94176. */
  94177. directionRandomizer: number;
  94178. /**
  94179. * Creates a new instance CylinderParticleEmitter
  94180. * @param radius the radius of the emission cylinder (1 by default)
  94181. * @param height the height of the emission cylinder (1 by default)
  94182. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94183. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94184. */
  94185. constructor(
  94186. /**
  94187. * The radius of the emission cylinder.
  94188. */
  94189. radius?: number,
  94190. /**
  94191. * The height of the emission cylinder.
  94192. */
  94193. height?: number,
  94194. /**
  94195. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94196. */
  94197. radiusRange?: number,
  94198. /**
  94199. * How much to randomize the particle direction [0-1].
  94200. */
  94201. directionRandomizer?: number);
  94202. /**
  94203. * Called by the particle System when the direction is computed for the created particle.
  94204. * @param worldMatrix is the world matrix of the particle system
  94205. * @param directionToUpdate is the direction vector to update with the result
  94206. * @param particle is the particle we are computed the direction for
  94207. * @param isLocal defines if the direction should be set in local space
  94208. */
  94209. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94210. /**
  94211. * Called by the particle System when the position is computed for the created particle.
  94212. * @param worldMatrix is the world matrix of the particle system
  94213. * @param positionToUpdate is the position vector to update with the result
  94214. * @param particle is the particle we are computed the position for
  94215. * @param isLocal defines if the position should be set in local space
  94216. */
  94217. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94218. /**
  94219. * Clones the current emitter and returns a copy of it
  94220. * @returns the new emitter
  94221. */
  94222. clone(): CylinderParticleEmitter;
  94223. /**
  94224. * Called by the GPUParticleSystem to setup the update shader
  94225. * @param effect defines the update shader
  94226. */
  94227. applyToShader(effect: Effect): void;
  94228. /**
  94229. * Returns a string to use to update the GPU particles update shader
  94230. * @returns a string containng the defines string
  94231. */
  94232. getEffectDefines(): string;
  94233. /**
  94234. * Returns the string "CylinderParticleEmitter"
  94235. * @returns a string containing the class name
  94236. */
  94237. getClassName(): string;
  94238. /**
  94239. * Serializes the particle system to a JSON object.
  94240. * @returns the JSON object
  94241. */
  94242. serialize(): any;
  94243. /**
  94244. * Parse properties from a JSON object
  94245. * @param serializationObject defines the JSON object
  94246. */
  94247. parse(serializationObject: any): void;
  94248. }
  94249. /**
  94250. * Particle emitter emitting particles from the inside of a cylinder.
  94251. * It emits the particles randomly between two vectors.
  94252. */
  94253. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94254. /**
  94255. * The min limit of the emission direction.
  94256. */
  94257. direction1: Vector3;
  94258. /**
  94259. * The max limit of the emission direction.
  94260. */
  94261. direction2: Vector3;
  94262. /**
  94263. * Creates a new instance CylinderDirectedParticleEmitter
  94264. * @param radius the radius of the emission cylinder (1 by default)
  94265. * @param height the height of the emission cylinder (1 by default)
  94266. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94267. * @param direction1 the min limit of the emission direction (up vector by default)
  94268. * @param direction2 the max limit of the emission direction (up vector by default)
  94269. */
  94270. constructor(radius?: number, height?: number, radiusRange?: number,
  94271. /**
  94272. * The min limit of the emission direction.
  94273. */
  94274. direction1?: Vector3,
  94275. /**
  94276. * The max limit of the emission direction.
  94277. */
  94278. direction2?: Vector3);
  94279. /**
  94280. * Called by the particle System when the direction is computed for the created particle.
  94281. * @param worldMatrix is the world matrix of the particle system
  94282. * @param directionToUpdate is the direction vector to update with the result
  94283. * @param particle is the particle we are computed the direction for
  94284. */
  94285. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94286. /**
  94287. * Clones the current emitter and returns a copy of it
  94288. * @returns the new emitter
  94289. */
  94290. clone(): CylinderDirectedParticleEmitter;
  94291. /**
  94292. * Called by the GPUParticleSystem to setup the update shader
  94293. * @param effect defines the update shader
  94294. */
  94295. applyToShader(effect: Effect): void;
  94296. /**
  94297. * Returns a string to use to update the GPU particles update shader
  94298. * @returns a string containng the defines string
  94299. */
  94300. getEffectDefines(): string;
  94301. /**
  94302. * Returns the string "CylinderDirectedParticleEmitter"
  94303. * @returns a string containing the class name
  94304. */
  94305. getClassName(): string;
  94306. /**
  94307. * Serializes the particle system to a JSON object.
  94308. * @returns the JSON object
  94309. */
  94310. serialize(): any;
  94311. /**
  94312. * Parse properties from a JSON object
  94313. * @param serializationObject defines the JSON object
  94314. */
  94315. parse(serializationObject: any): void;
  94316. }
  94317. }
  94318. declare module BABYLON {
  94319. /**
  94320. * Particle emitter emitting particles from the inside of a hemisphere.
  94321. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94322. */
  94323. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94324. /**
  94325. * The radius of the emission hemisphere.
  94326. */
  94327. radius: number;
  94328. /**
  94329. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94330. */
  94331. radiusRange: number;
  94332. /**
  94333. * How much to randomize the particle direction [0-1].
  94334. */
  94335. directionRandomizer: number;
  94336. /**
  94337. * Creates a new instance HemisphericParticleEmitter
  94338. * @param radius the radius of the emission hemisphere (1 by default)
  94339. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94340. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94341. */
  94342. constructor(
  94343. /**
  94344. * The radius of the emission hemisphere.
  94345. */
  94346. radius?: number,
  94347. /**
  94348. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94349. */
  94350. radiusRange?: number,
  94351. /**
  94352. * How much to randomize the particle direction [0-1].
  94353. */
  94354. directionRandomizer?: number);
  94355. /**
  94356. * Called by the particle System when the direction is computed for the created particle.
  94357. * @param worldMatrix is the world matrix of the particle system
  94358. * @param directionToUpdate is the direction vector to update with the result
  94359. * @param particle is the particle we are computed the direction for
  94360. * @param isLocal defines if the direction should be set in local space
  94361. */
  94362. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94363. /**
  94364. * Called by the particle System when the position is computed for the created particle.
  94365. * @param worldMatrix is the world matrix of the particle system
  94366. * @param positionToUpdate is the position vector to update with the result
  94367. * @param particle is the particle we are computed the position for
  94368. * @param isLocal defines if the position should be set in local space
  94369. */
  94370. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94371. /**
  94372. * Clones the current emitter and returns a copy of it
  94373. * @returns the new emitter
  94374. */
  94375. clone(): HemisphericParticleEmitter;
  94376. /**
  94377. * Called by the GPUParticleSystem to setup the update shader
  94378. * @param effect defines the update shader
  94379. */
  94380. applyToShader(effect: Effect): void;
  94381. /**
  94382. * Returns a string to use to update the GPU particles update shader
  94383. * @returns a string containng the defines string
  94384. */
  94385. getEffectDefines(): string;
  94386. /**
  94387. * Returns the string "HemisphericParticleEmitter"
  94388. * @returns a string containing the class name
  94389. */
  94390. getClassName(): string;
  94391. /**
  94392. * Serializes the particle system to a JSON object.
  94393. * @returns the JSON object
  94394. */
  94395. serialize(): any;
  94396. /**
  94397. * Parse properties from a JSON object
  94398. * @param serializationObject defines the JSON object
  94399. */
  94400. parse(serializationObject: any): void;
  94401. }
  94402. }
  94403. declare module BABYLON {
  94404. /**
  94405. * Particle emitter emitting particles from a point.
  94406. * It emits the particles randomly between 2 given directions.
  94407. */
  94408. export class PointParticleEmitter implements IParticleEmitterType {
  94409. /**
  94410. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94411. */
  94412. direction1: Vector3;
  94413. /**
  94414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94415. */
  94416. direction2: Vector3;
  94417. /**
  94418. * Creates a new instance PointParticleEmitter
  94419. */
  94420. constructor();
  94421. /**
  94422. * Called by the particle System when the direction is computed for the created particle.
  94423. * @param worldMatrix is the world matrix of the particle system
  94424. * @param directionToUpdate is the direction vector to update with the result
  94425. * @param particle is the particle we are computed the direction for
  94426. * @param isLocal defines if the direction should be set in local space
  94427. */
  94428. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94429. /**
  94430. * Called by the particle System when the position is computed for the created particle.
  94431. * @param worldMatrix is the world matrix of the particle system
  94432. * @param positionToUpdate is the position vector to update with the result
  94433. * @param particle is the particle we are computed the position for
  94434. * @param isLocal defines if the position should be set in local space
  94435. */
  94436. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94437. /**
  94438. * Clones the current emitter and returns a copy of it
  94439. * @returns the new emitter
  94440. */
  94441. clone(): PointParticleEmitter;
  94442. /**
  94443. * Called by the GPUParticleSystem to setup the update shader
  94444. * @param effect defines the update shader
  94445. */
  94446. applyToShader(effect: Effect): void;
  94447. /**
  94448. * Returns a string to use to update the GPU particles update shader
  94449. * @returns a string containng the defines string
  94450. */
  94451. getEffectDefines(): string;
  94452. /**
  94453. * Returns the string "PointParticleEmitter"
  94454. * @returns a string containing the class name
  94455. */
  94456. getClassName(): string;
  94457. /**
  94458. * Serializes the particle system to a JSON object.
  94459. * @returns the JSON object
  94460. */
  94461. serialize(): any;
  94462. /**
  94463. * Parse properties from a JSON object
  94464. * @param serializationObject defines the JSON object
  94465. */
  94466. parse(serializationObject: any): void;
  94467. }
  94468. }
  94469. declare module BABYLON {
  94470. /**
  94471. * Particle emitter emitting particles from the inside of a sphere.
  94472. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94473. */
  94474. export class SphereParticleEmitter implements IParticleEmitterType {
  94475. /**
  94476. * The radius of the emission sphere.
  94477. */
  94478. radius: number;
  94479. /**
  94480. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94481. */
  94482. radiusRange: number;
  94483. /**
  94484. * How much to randomize the particle direction [0-1].
  94485. */
  94486. directionRandomizer: number;
  94487. /**
  94488. * Creates a new instance SphereParticleEmitter
  94489. * @param radius the radius of the emission sphere (1 by default)
  94490. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94491. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94492. */
  94493. constructor(
  94494. /**
  94495. * The radius of the emission sphere.
  94496. */
  94497. radius?: number,
  94498. /**
  94499. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94500. */
  94501. radiusRange?: number,
  94502. /**
  94503. * How much to randomize the particle direction [0-1].
  94504. */
  94505. directionRandomizer?: number);
  94506. /**
  94507. * Called by the particle System when the direction is computed for the created particle.
  94508. * @param worldMatrix is the world matrix of the particle system
  94509. * @param directionToUpdate is the direction vector to update with the result
  94510. * @param particle is the particle we are computed the direction for
  94511. * @param isLocal defines if the direction should be set in local space
  94512. */
  94513. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94514. /**
  94515. * Called by the particle System when the position is computed for the created particle.
  94516. * @param worldMatrix is the world matrix of the particle system
  94517. * @param positionToUpdate is the position vector to update with the result
  94518. * @param particle is the particle we are computed the position for
  94519. * @param isLocal defines if the position should be set in local space
  94520. */
  94521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94522. /**
  94523. * Clones the current emitter and returns a copy of it
  94524. * @returns the new emitter
  94525. */
  94526. clone(): SphereParticleEmitter;
  94527. /**
  94528. * Called by the GPUParticleSystem to setup the update shader
  94529. * @param effect defines the update shader
  94530. */
  94531. applyToShader(effect: Effect): void;
  94532. /**
  94533. * Returns a string to use to update the GPU particles update shader
  94534. * @returns a string containng the defines string
  94535. */
  94536. getEffectDefines(): string;
  94537. /**
  94538. * Returns the string "SphereParticleEmitter"
  94539. * @returns a string containing the class name
  94540. */
  94541. getClassName(): string;
  94542. /**
  94543. * Serializes the particle system to a JSON object.
  94544. * @returns the JSON object
  94545. */
  94546. serialize(): any;
  94547. /**
  94548. * Parse properties from a JSON object
  94549. * @param serializationObject defines the JSON object
  94550. */
  94551. parse(serializationObject: any): void;
  94552. }
  94553. /**
  94554. * Particle emitter emitting particles from the inside of a sphere.
  94555. * It emits the particles randomly between two vectors.
  94556. */
  94557. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94558. /**
  94559. * The min limit of the emission direction.
  94560. */
  94561. direction1: Vector3;
  94562. /**
  94563. * The max limit of the emission direction.
  94564. */
  94565. direction2: Vector3;
  94566. /**
  94567. * Creates a new instance SphereDirectedParticleEmitter
  94568. * @param radius the radius of the emission sphere (1 by default)
  94569. * @param direction1 the min limit of the emission direction (up vector by default)
  94570. * @param direction2 the max limit of the emission direction (up vector by default)
  94571. */
  94572. constructor(radius?: number,
  94573. /**
  94574. * The min limit of the emission direction.
  94575. */
  94576. direction1?: Vector3,
  94577. /**
  94578. * The max limit of the emission direction.
  94579. */
  94580. direction2?: Vector3);
  94581. /**
  94582. * Called by the particle System when the direction is computed for the created particle.
  94583. * @param worldMatrix is the world matrix of the particle system
  94584. * @param directionToUpdate is the direction vector to update with the result
  94585. * @param particle is the particle we are computed the direction for
  94586. */
  94587. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94588. /**
  94589. * Clones the current emitter and returns a copy of it
  94590. * @returns the new emitter
  94591. */
  94592. clone(): SphereDirectedParticleEmitter;
  94593. /**
  94594. * Called by the GPUParticleSystem to setup the update shader
  94595. * @param effect defines the update shader
  94596. */
  94597. applyToShader(effect: Effect): void;
  94598. /**
  94599. * Returns a string to use to update the GPU particles update shader
  94600. * @returns a string containng the defines string
  94601. */
  94602. getEffectDefines(): string;
  94603. /**
  94604. * Returns the string "SphereDirectedParticleEmitter"
  94605. * @returns a string containing the class name
  94606. */
  94607. getClassName(): string;
  94608. /**
  94609. * Serializes the particle system to a JSON object.
  94610. * @returns the JSON object
  94611. */
  94612. serialize(): any;
  94613. /**
  94614. * Parse properties from a JSON object
  94615. * @param serializationObject defines the JSON object
  94616. */
  94617. parse(serializationObject: any): void;
  94618. }
  94619. }
  94620. declare module BABYLON {
  94621. /**
  94622. * Particle emitter emitting particles from a custom list of positions.
  94623. */
  94624. export class CustomParticleEmitter implements IParticleEmitterType {
  94625. /**
  94626. * Gets or sets the position generator that will create the inital position of each particle.
  94627. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94628. */
  94629. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94630. /**
  94631. * Gets or sets the destination generator that will create the final destination of each particle.
  94632. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94633. */
  94634. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94635. /**
  94636. * Creates a new instance CustomParticleEmitter
  94637. */
  94638. constructor();
  94639. /**
  94640. * Called by the particle System when the direction is computed for the created particle.
  94641. * @param worldMatrix is the world matrix of the particle system
  94642. * @param directionToUpdate is the direction vector to update with the result
  94643. * @param particle is the particle we are computed the direction for
  94644. * @param isLocal defines if the direction should be set in local space
  94645. */
  94646. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94647. /**
  94648. * Called by the particle System when the position is computed for the created particle.
  94649. * @param worldMatrix is the world matrix of the particle system
  94650. * @param positionToUpdate is the position vector to update with the result
  94651. * @param particle is the particle we are computed the position for
  94652. * @param isLocal defines if the position should be set in local space
  94653. */
  94654. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94655. /**
  94656. * Clones the current emitter and returns a copy of it
  94657. * @returns the new emitter
  94658. */
  94659. clone(): CustomParticleEmitter;
  94660. /**
  94661. * Called by the GPUParticleSystem to setup the update shader
  94662. * @param effect defines the update shader
  94663. */
  94664. applyToShader(effect: Effect): void;
  94665. /**
  94666. * Returns a string to use to update the GPU particles update shader
  94667. * @returns a string containng the defines string
  94668. */
  94669. getEffectDefines(): string;
  94670. /**
  94671. * Returns the string "PointParticleEmitter"
  94672. * @returns a string containing the class name
  94673. */
  94674. getClassName(): string;
  94675. /**
  94676. * Serializes the particle system to a JSON object.
  94677. * @returns the JSON object
  94678. */
  94679. serialize(): any;
  94680. /**
  94681. * Parse properties from a JSON object
  94682. * @param serializationObject defines the JSON object
  94683. */
  94684. parse(serializationObject: any): void;
  94685. }
  94686. }
  94687. declare module BABYLON {
  94688. /**
  94689. * Particle emitter emitting particles from the inside of a box.
  94690. * It emits the particles randomly between 2 given directions.
  94691. */
  94692. export class MeshParticleEmitter implements IParticleEmitterType {
  94693. private _indices;
  94694. private _positions;
  94695. private _normals;
  94696. private _storedNormal;
  94697. private _mesh;
  94698. /**
  94699. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94700. */
  94701. direction1: Vector3;
  94702. /**
  94703. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94704. */
  94705. direction2: Vector3;
  94706. /**
  94707. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94708. */
  94709. useMeshNormalsForDirection: boolean;
  94710. /** Defines the mesh to use as source */
  94711. get mesh(): Nullable<AbstractMesh>;
  94712. set mesh(value: Nullable<AbstractMesh>);
  94713. /**
  94714. * Creates a new instance MeshParticleEmitter
  94715. * @param mesh defines the mesh to use as source
  94716. */
  94717. constructor(mesh?: Nullable<AbstractMesh>);
  94718. /**
  94719. * Called by the particle System when the direction is computed for the created particle.
  94720. * @param worldMatrix is the world matrix of the particle system
  94721. * @param directionToUpdate is the direction vector to update with the result
  94722. * @param particle is the particle we are computed the direction for
  94723. * @param isLocal defines if the direction should be set in local space
  94724. */
  94725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94726. /**
  94727. * Called by the particle System when the position is computed for the created particle.
  94728. * @param worldMatrix is the world matrix of the particle system
  94729. * @param positionToUpdate is the position vector to update with the result
  94730. * @param particle is the particle we are computed the position for
  94731. * @param isLocal defines if the position should be set in local space
  94732. */
  94733. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94734. /**
  94735. * Clones the current emitter and returns a copy of it
  94736. * @returns the new emitter
  94737. */
  94738. clone(): MeshParticleEmitter;
  94739. /**
  94740. * Called by the GPUParticleSystem to setup the update shader
  94741. * @param effect defines the update shader
  94742. */
  94743. applyToShader(effect: Effect): void;
  94744. /**
  94745. * Returns a string to use to update the GPU particles update shader
  94746. * @returns a string containng the defines string
  94747. */
  94748. getEffectDefines(): string;
  94749. /**
  94750. * Returns the string "BoxParticleEmitter"
  94751. * @returns a string containing the class name
  94752. */
  94753. getClassName(): string;
  94754. /**
  94755. * Serializes the particle system to a JSON object.
  94756. * @returns the JSON object
  94757. */
  94758. serialize(): any;
  94759. /**
  94760. * Parse properties from a JSON object
  94761. * @param serializationObject defines the JSON object
  94762. * @param scene defines the hosting scene
  94763. */
  94764. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94765. }
  94766. }
  94767. declare module BABYLON {
  94768. /**
  94769. * Interface representing a particle system in Babylon.js.
  94770. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94771. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94772. */
  94773. export interface IParticleSystem {
  94774. /**
  94775. * List of animations used by the particle system.
  94776. */
  94777. animations: Animation[];
  94778. /**
  94779. * The id of the Particle system.
  94780. */
  94781. id: string;
  94782. /**
  94783. * The name of the Particle system.
  94784. */
  94785. name: string;
  94786. /**
  94787. * The emitter represents the Mesh or position we are attaching the particle system to.
  94788. */
  94789. emitter: Nullable<AbstractMesh | Vector3>;
  94790. /**
  94791. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94792. */
  94793. isBillboardBased: boolean;
  94794. /**
  94795. * The rendering group used by the Particle system to chose when to render.
  94796. */
  94797. renderingGroupId: number;
  94798. /**
  94799. * The layer mask we are rendering the particles through.
  94800. */
  94801. layerMask: number;
  94802. /**
  94803. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94804. */
  94805. updateSpeed: number;
  94806. /**
  94807. * The amount of time the particle system is running (depends of the overall update speed).
  94808. */
  94809. targetStopDuration: number;
  94810. /**
  94811. * The texture used to render each particle. (this can be a spritesheet)
  94812. */
  94813. particleTexture: Nullable<BaseTexture>;
  94814. /**
  94815. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94816. */
  94817. blendMode: number;
  94818. /**
  94819. * Minimum life time of emitting particles.
  94820. */
  94821. minLifeTime: number;
  94822. /**
  94823. * Maximum life time of emitting particles.
  94824. */
  94825. maxLifeTime: number;
  94826. /**
  94827. * Minimum Size of emitting particles.
  94828. */
  94829. minSize: number;
  94830. /**
  94831. * Maximum Size of emitting particles.
  94832. */
  94833. maxSize: number;
  94834. /**
  94835. * Minimum scale of emitting particles on X axis.
  94836. */
  94837. minScaleX: number;
  94838. /**
  94839. * Maximum scale of emitting particles on X axis.
  94840. */
  94841. maxScaleX: number;
  94842. /**
  94843. * Minimum scale of emitting particles on Y axis.
  94844. */
  94845. minScaleY: number;
  94846. /**
  94847. * Maximum scale of emitting particles on Y axis.
  94848. */
  94849. maxScaleY: number;
  94850. /**
  94851. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94852. */
  94853. color1: Color4;
  94854. /**
  94855. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94856. */
  94857. color2: Color4;
  94858. /**
  94859. * Color the particle will have at the end of its lifetime.
  94860. */
  94861. colorDead: Color4;
  94862. /**
  94863. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94864. */
  94865. emitRate: number;
  94866. /**
  94867. * You can use gravity if you want to give an orientation to your particles.
  94868. */
  94869. gravity: Vector3;
  94870. /**
  94871. * Minimum power of emitting particles.
  94872. */
  94873. minEmitPower: number;
  94874. /**
  94875. * Maximum power of emitting particles.
  94876. */
  94877. maxEmitPower: number;
  94878. /**
  94879. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94880. */
  94881. minAngularSpeed: number;
  94882. /**
  94883. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94884. */
  94885. maxAngularSpeed: number;
  94886. /**
  94887. * Gets or sets the minimal initial rotation in radians.
  94888. */
  94889. minInitialRotation: number;
  94890. /**
  94891. * Gets or sets the maximal initial rotation in radians.
  94892. */
  94893. maxInitialRotation: number;
  94894. /**
  94895. * The particle emitter type defines the emitter used by the particle system.
  94896. * It can be for example box, sphere, or cone...
  94897. */
  94898. particleEmitterType: Nullable<IParticleEmitterType>;
  94899. /**
  94900. * Defines the delay in milliseconds before starting the system (0 by default)
  94901. */
  94902. startDelay: number;
  94903. /**
  94904. * 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
  94905. */
  94906. preWarmCycles: number;
  94907. /**
  94908. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94909. */
  94910. preWarmStepOffset: number;
  94911. /**
  94912. * 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)
  94913. */
  94914. spriteCellChangeSpeed: number;
  94915. /**
  94916. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94917. */
  94918. startSpriteCellID: number;
  94919. /**
  94920. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94921. */
  94922. endSpriteCellID: number;
  94923. /**
  94924. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94925. */
  94926. spriteCellWidth: number;
  94927. /**
  94928. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94929. */
  94930. spriteCellHeight: number;
  94931. /**
  94932. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94933. */
  94934. spriteRandomStartCell: boolean;
  94935. /**
  94936. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94937. */
  94938. isAnimationSheetEnabled: boolean;
  94939. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94940. translationPivot: Vector2;
  94941. /**
  94942. * Gets or sets a texture used to add random noise to particle positions
  94943. */
  94944. noiseTexture: Nullable<BaseTexture>;
  94945. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94946. noiseStrength: Vector3;
  94947. /**
  94948. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94949. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94950. */
  94951. billboardMode: number;
  94952. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94953. limitVelocityDamping: number;
  94954. /**
  94955. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94956. */
  94957. beginAnimationOnStart: boolean;
  94958. /**
  94959. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94960. */
  94961. beginAnimationFrom: number;
  94962. /**
  94963. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94964. */
  94965. beginAnimationTo: number;
  94966. /**
  94967. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94968. */
  94969. beginAnimationLoop: boolean;
  94970. /**
  94971. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94972. */
  94973. disposeOnStop: boolean;
  94974. /**
  94975. * Specifies if the particles are updated in emitter local space or world space
  94976. */
  94977. isLocal: boolean;
  94978. /** Snippet ID if the particle system was created from the snippet server */
  94979. snippetId: string;
  94980. /** Gets or sets a matrix to use to compute projection */
  94981. defaultProjectionMatrix: Matrix;
  94982. /**
  94983. * Gets the maximum number of particles active at the same time.
  94984. * @returns The max number of active particles.
  94985. */
  94986. getCapacity(): number;
  94987. /**
  94988. * Gets the number of particles active at the same time.
  94989. * @returns The number of active particles.
  94990. */
  94991. getActiveCount(): number;
  94992. /**
  94993. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94994. * @returns True if it has been started, otherwise false.
  94995. */
  94996. isStarted(): boolean;
  94997. /**
  94998. * Animates the particle system for this frame.
  94999. */
  95000. animate(): void;
  95001. /**
  95002. * Renders the particle system in its current state.
  95003. * @returns the current number of particles
  95004. */
  95005. render(): number;
  95006. /**
  95007. * Dispose the particle system and frees its associated resources.
  95008. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  95009. */
  95010. dispose(disposeTexture?: boolean): void;
  95011. /**
  95012. * An event triggered when the system is disposed
  95013. */
  95014. onDisposeObservable: Observable<IParticleSystem>;
  95015. /**
  95016. * An event triggered when the system is stopped
  95017. */
  95018. onStoppedObservable: Observable<IParticleSystem>;
  95019. /**
  95020. * Clones the particle system.
  95021. * @param name The name of the cloned object
  95022. * @param newEmitter The new emitter to use
  95023. * @returns the cloned particle system
  95024. */
  95025. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  95026. /**
  95027. * Serializes the particle system to a JSON object
  95028. * @param serializeTexture defines if the texture must be serialized as well
  95029. * @returns the JSON object
  95030. */
  95031. serialize(serializeTexture: boolean): any;
  95032. /**
  95033. * Rebuild the particle system
  95034. */
  95035. rebuild(): void;
  95036. /** Force the system to rebuild all gradients that need to be resync */
  95037. forceRefreshGradients(): void;
  95038. /**
  95039. * Starts the particle system and begins to emit
  95040. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  95041. */
  95042. start(delay?: number): void;
  95043. /**
  95044. * Stops the particle system.
  95045. */
  95046. stop(): void;
  95047. /**
  95048. * Remove all active particles
  95049. */
  95050. reset(): void;
  95051. /**
  95052. * Gets a boolean indicating that the system is stopping
  95053. * @returns true if the system is currently stopping
  95054. */
  95055. isStopping(): boolean;
  95056. /**
  95057. * Is this system ready to be used/rendered
  95058. * @return true if the system is ready
  95059. */
  95060. isReady(): boolean;
  95061. /**
  95062. * Returns the string "ParticleSystem"
  95063. * @returns a string containing the class name
  95064. */
  95065. getClassName(): string;
  95066. /**
  95067. * Gets the custom effect used to render the particles
  95068. * @param blendMode Blend mode for which the effect should be retrieved
  95069. * @returns The effect
  95070. */
  95071. getCustomEffect(blendMode: number): Nullable<Effect>;
  95072. /**
  95073. * Sets the custom effect used to render the particles
  95074. * @param effect The effect to set
  95075. * @param blendMode Blend mode for which the effect should be set
  95076. */
  95077. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  95078. /**
  95079. * Fill the defines array according to the current settings of the particle system
  95080. * @param defines Array to be updated
  95081. * @param blendMode blend mode to take into account when updating the array
  95082. */
  95083. fillDefines(defines: Array<string>, blendMode: number): void;
  95084. /**
  95085. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  95086. * @param uniforms Uniforms array to fill
  95087. * @param attributes Attributes array to fill
  95088. * @param samplers Samplers array to fill
  95089. */
  95090. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95091. /**
  95092. * Observable that will be called just before the particles are drawn
  95093. */
  95094. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95095. /**
  95096. * Gets the name of the particle vertex shader
  95097. */
  95098. vertexShaderName: string;
  95099. /**
  95100. * Adds a new color gradient
  95101. * @param gradient defines the gradient to use (between 0 and 1)
  95102. * @param color1 defines the color to affect to the specified gradient
  95103. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95104. * @returns the current particle system
  95105. */
  95106. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95107. /**
  95108. * Remove a specific color gradient
  95109. * @param gradient defines the gradient to remove
  95110. * @returns the current particle system
  95111. */
  95112. removeColorGradient(gradient: number): IParticleSystem;
  95113. /**
  95114. * Adds a new size gradient
  95115. * @param gradient defines the gradient to use (between 0 and 1)
  95116. * @param factor defines the size factor to affect to the specified gradient
  95117. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95118. * @returns the current particle system
  95119. */
  95120. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95121. /**
  95122. * Remove a specific size gradient
  95123. * @param gradient defines the gradient to remove
  95124. * @returns the current particle system
  95125. */
  95126. removeSizeGradient(gradient: number): IParticleSystem;
  95127. /**
  95128. * Gets the current list of color gradients.
  95129. * You must use addColorGradient and removeColorGradient to udpate this list
  95130. * @returns the list of color gradients
  95131. */
  95132. getColorGradients(): Nullable<Array<ColorGradient>>;
  95133. /**
  95134. * Gets the current list of size gradients.
  95135. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95136. * @returns the list of size gradients
  95137. */
  95138. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95139. /**
  95140. * Gets the current list of angular speed gradients.
  95141. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95142. * @returns the list of angular speed gradients
  95143. */
  95144. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95145. /**
  95146. * Adds a new angular speed gradient
  95147. * @param gradient defines the gradient to use (between 0 and 1)
  95148. * @param factor defines the angular speed to affect to the specified gradient
  95149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95150. * @returns the current particle system
  95151. */
  95152. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95153. /**
  95154. * Remove a specific angular speed gradient
  95155. * @param gradient defines the gradient to remove
  95156. * @returns the current particle system
  95157. */
  95158. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95159. /**
  95160. * Gets the current list of velocity gradients.
  95161. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95162. * @returns the list of velocity gradients
  95163. */
  95164. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95165. /**
  95166. * Adds a new velocity gradient
  95167. * @param gradient defines the gradient to use (between 0 and 1)
  95168. * @param factor defines the velocity to affect to the specified gradient
  95169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95170. * @returns the current particle system
  95171. */
  95172. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95173. /**
  95174. * Remove a specific velocity gradient
  95175. * @param gradient defines the gradient to remove
  95176. * @returns the current particle system
  95177. */
  95178. removeVelocityGradient(gradient: number): IParticleSystem;
  95179. /**
  95180. * Gets the current list of limit velocity gradients.
  95181. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95182. * @returns the list of limit velocity gradients
  95183. */
  95184. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95185. /**
  95186. * Adds a new limit velocity gradient
  95187. * @param gradient defines the gradient to use (between 0 and 1)
  95188. * @param factor defines the limit velocity to affect to the specified gradient
  95189. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95190. * @returns the current particle system
  95191. */
  95192. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95193. /**
  95194. * Remove a specific limit velocity gradient
  95195. * @param gradient defines the gradient to remove
  95196. * @returns the current particle system
  95197. */
  95198. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95199. /**
  95200. * Adds a new drag gradient
  95201. * @param gradient defines the gradient to use (between 0 and 1)
  95202. * @param factor defines the drag to affect to the specified gradient
  95203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95204. * @returns the current particle system
  95205. */
  95206. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95207. /**
  95208. * Remove a specific drag gradient
  95209. * @param gradient defines the gradient to remove
  95210. * @returns the current particle system
  95211. */
  95212. removeDragGradient(gradient: number): IParticleSystem;
  95213. /**
  95214. * Gets the current list of drag gradients.
  95215. * You must use addDragGradient and removeDragGradient to udpate this list
  95216. * @returns the list of drag gradients
  95217. */
  95218. getDragGradients(): Nullable<Array<FactorGradient>>;
  95219. /**
  95220. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95221. * @param gradient defines the gradient to use (between 0 and 1)
  95222. * @param factor defines the emit rate to affect to the specified gradient
  95223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95224. * @returns the current particle system
  95225. */
  95226. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95227. /**
  95228. * Remove a specific emit rate gradient
  95229. * @param gradient defines the gradient to remove
  95230. * @returns the current particle system
  95231. */
  95232. removeEmitRateGradient(gradient: number): IParticleSystem;
  95233. /**
  95234. * Gets the current list of emit rate gradients.
  95235. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95236. * @returns the list of emit rate gradients
  95237. */
  95238. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95239. /**
  95240. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95241. * @param gradient defines the gradient to use (between 0 and 1)
  95242. * @param factor defines the start size to affect to the specified gradient
  95243. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95244. * @returns the current particle system
  95245. */
  95246. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95247. /**
  95248. * Remove a specific start size gradient
  95249. * @param gradient defines the gradient to remove
  95250. * @returns the current particle system
  95251. */
  95252. removeStartSizeGradient(gradient: number): IParticleSystem;
  95253. /**
  95254. * Gets the current list of start size gradients.
  95255. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95256. * @returns the list of start size gradients
  95257. */
  95258. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95259. /**
  95260. * Adds a new life time gradient
  95261. * @param gradient defines the gradient to use (between 0 and 1)
  95262. * @param factor defines the life time factor to affect to the specified gradient
  95263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95264. * @returns the current particle system
  95265. */
  95266. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95267. /**
  95268. * Remove a specific life time gradient
  95269. * @param gradient defines the gradient to remove
  95270. * @returns the current particle system
  95271. */
  95272. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95273. /**
  95274. * Gets the current list of life time gradients.
  95275. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95276. * @returns the list of life time gradients
  95277. */
  95278. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95279. /**
  95280. * Gets the current list of color gradients.
  95281. * You must use addColorGradient and removeColorGradient to udpate this list
  95282. * @returns the list of color gradients
  95283. */
  95284. getColorGradients(): Nullable<Array<ColorGradient>>;
  95285. /**
  95286. * Adds a new ramp gradient used to remap particle colors
  95287. * @param gradient defines the gradient to use (between 0 and 1)
  95288. * @param color defines the color to affect to the specified gradient
  95289. * @returns the current particle system
  95290. */
  95291. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95292. /**
  95293. * Gets the current list of ramp gradients.
  95294. * You must use addRampGradient and removeRampGradient to udpate this list
  95295. * @returns the list of ramp gradients
  95296. */
  95297. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95298. /** Gets or sets a boolean indicating that ramp gradients must be used
  95299. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95300. */
  95301. useRampGradients: boolean;
  95302. /**
  95303. * Adds a new color remap gradient
  95304. * @param gradient defines the gradient to use (between 0 and 1)
  95305. * @param min defines the color remap minimal range
  95306. * @param max defines the color remap maximal range
  95307. * @returns the current particle system
  95308. */
  95309. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95310. /**
  95311. * Gets the current list of color remap gradients.
  95312. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95313. * @returns the list of color remap gradients
  95314. */
  95315. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95316. /**
  95317. * Adds a new alpha remap gradient
  95318. * @param gradient defines the gradient to use (between 0 and 1)
  95319. * @param min defines the alpha remap minimal range
  95320. * @param max defines the alpha remap maximal range
  95321. * @returns the current particle system
  95322. */
  95323. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95324. /**
  95325. * Gets the current list of alpha remap gradients.
  95326. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95327. * @returns the list of alpha remap gradients
  95328. */
  95329. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95330. /**
  95331. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95332. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95333. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95334. * @returns the emitter
  95335. */
  95336. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95337. /**
  95338. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95339. * @param radius The radius of the hemisphere to emit from
  95340. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95341. * @returns the emitter
  95342. */
  95343. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95344. /**
  95345. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95346. * @param radius The radius of the sphere to emit from
  95347. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95348. * @returns the emitter
  95349. */
  95350. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95351. /**
  95352. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95353. * @param radius The radius of the sphere to emit from
  95354. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95355. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95356. * @returns the emitter
  95357. */
  95358. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95359. /**
  95360. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95361. * @param radius The radius of the emission cylinder
  95362. * @param height The height of the emission cylinder
  95363. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95364. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95365. * @returns the emitter
  95366. */
  95367. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95368. /**
  95369. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95370. * @param radius The radius of the cylinder to emit from
  95371. * @param height The height of the emission cylinder
  95372. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95373. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95374. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95375. * @returns the emitter
  95376. */
  95377. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95378. /**
  95379. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95380. * @param radius The radius of the cone to emit from
  95381. * @param angle The base angle of the cone
  95382. * @returns the emitter
  95383. */
  95384. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95385. /**
  95386. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95387. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95388. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95389. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95390. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95391. * @returns the emitter
  95392. */
  95393. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95394. /**
  95395. * Get hosting scene
  95396. * @returns the scene
  95397. */
  95398. getScene(): Nullable<Scene>;
  95399. }
  95400. }
  95401. declare module BABYLON {
  95402. /**
  95403. * 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.
  95404. * @see https://doc.babylonjs.com/how_to/transformnode
  95405. */
  95406. export class TransformNode extends Node {
  95407. /**
  95408. * Object will not rotate to face the camera
  95409. */
  95410. static BILLBOARDMODE_NONE: number;
  95411. /**
  95412. * Object will rotate to face the camera but only on the x axis
  95413. */
  95414. static BILLBOARDMODE_X: number;
  95415. /**
  95416. * Object will rotate to face the camera but only on the y axis
  95417. */
  95418. static BILLBOARDMODE_Y: number;
  95419. /**
  95420. * Object will rotate to face the camera but only on the z axis
  95421. */
  95422. static BILLBOARDMODE_Z: number;
  95423. /**
  95424. * Object will rotate to face the camera
  95425. */
  95426. static BILLBOARDMODE_ALL: number;
  95427. /**
  95428. * Object will rotate to face the camera's position instead of orientation
  95429. */
  95430. static BILLBOARDMODE_USE_POSITION: number;
  95431. private static _TmpRotation;
  95432. private static _TmpScaling;
  95433. private static _TmpTranslation;
  95434. private _forward;
  95435. private _forwardInverted;
  95436. private _up;
  95437. private _right;
  95438. private _rightInverted;
  95439. private _position;
  95440. private _rotation;
  95441. private _rotationQuaternion;
  95442. protected _scaling: Vector3;
  95443. protected _isDirty: boolean;
  95444. private _transformToBoneReferal;
  95445. private _isAbsoluteSynced;
  95446. private _billboardMode;
  95447. /**
  95448. * Gets or sets the billboard mode. Default is 0.
  95449. *
  95450. * | Value | Type | Description |
  95451. * | --- | --- | --- |
  95452. * | 0 | BILLBOARDMODE_NONE | |
  95453. * | 1 | BILLBOARDMODE_X | |
  95454. * | 2 | BILLBOARDMODE_Y | |
  95455. * | 4 | BILLBOARDMODE_Z | |
  95456. * | 7 | BILLBOARDMODE_ALL | |
  95457. *
  95458. */
  95459. get billboardMode(): number;
  95460. set billboardMode(value: number);
  95461. private _preserveParentRotationForBillboard;
  95462. /**
  95463. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95464. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95465. */
  95466. get preserveParentRotationForBillboard(): boolean;
  95467. set preserveParentRotationForBillboard(value: boolean);
  95468. /**
  95469. * 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
  95470. */
  95471. scalingDeterminant: number;
  95472. private _infiniteDistance;
  95473. /**
  95474. * Gets or sets the distance of the object to max, often used by skybox
  95475. */
  95476. get infiniteDistance(): boolean;
  95477. set infiniteDistance(value: boolean);
  95478. /**
  95479. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95480. * By default the system will update normals to compensate
  95481. */
  95482. ignoreNonUniformScaling: boolean;
  95483. /**
  95484. * 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
  95485. */
  95486. reIntegrateRotationIntoRotationQuaternion: boolean;
  95487. /** @hidden */
  95488. _poseMatrix: Nullable<Matrix>;
  95489. /** @hidden */
  95490. _localMatrix: Matrix;
  95491. private _usePivotMatrix;
  95492. private _absolutePosition;
  95493. private _absoluteScaling;
  95494. private _absoluteRotationQuaternion;
  95495. private _pivotMatrix;
  95496. private _pivotMatrixInverse;
  95497. /** @hidden */
  95498. _postMultiplyPivotMatrix: boolean;
  95499. protected _isWorldMatrixFrozen: boolean;
  95500. /** @hidden */
  95501. _indexInSceneTransformNodesArray: number;
  95502. /**
  95503. * An event triggered after the world matrix is updated
  95504. */
  95505. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95506. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95507. /**
  95508. * Gets a string identifying the name of the class
  95509. * @returns "TransformNode" string
  95510. */
  95511. getClassName(): string;
  95512. /**
  95513. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95514. */
  95515. get position(): Vector3;
  95516. set position(newPosition: Vector3);
  95517. /**
  95518. * 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)).
  95519. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95520. */
  95521. get rotation(): Vector3;
  95522. set rotation(newRotation: Vector3);
  95523. /**
  95524. * 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)).
  95525. */
  95526. get scaling(): Vector3;
  95527. set scaling(newScaling: Vector3);
  95528. /**
  95529. * 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).
  95530. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95531. */
  95532. get rotationQuaternion(): Nullable<Quaternion>;
  95533. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95534. /**
  95535. * The forward direction of that transform in world space.
  95536. */
  95537. get forward(): Vector3;
  95538. /**
  95539. * The up direction of that transform in world space.
  95540. */
  95541. get up(): Vector3;
  95542. /**
  95543. * The right direction of that transform in world space.
  95544. */
  95545. get right(): Vector3;
  95546. /**
  95547. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95548. * @param matrix the matrix to copy the pose from
  95549. * @returns this TransformNode.
  95550. */
  95551. updatePoseMatrix(matrix: Matrix): TransformNode;
  95552. /**
  95553. * Returns the mesh Pose matrix.
  95554. * @returns the pose matrix
  95555. */
  95556. getPoseMatrix(): Matrix;
  95557. /** @hidden */
  95558. _isSynchronized(): boolean;
  95559. /** @hidden */
  95560. _initCache(): void;
  95561. /**
  95562. * Flag the transform node as dirty (Forcing it to update everything)
  95563. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95564. * @returns this transform node
  95565. */
  95566. markAsDirty(property: string): TransformNode;
  95567. /**
  95568. * Returns the current mesh absolute position.
  95569. * Returns a Vector3.
  95570. */
  95571. get absolutePosition(): Vector3;
  95572. /**
  95573. * Returns the current mesh absolute scaling.
  95574. * Returns a Vector3.
  95575. */
  95576. get absoluteScaling(): Vector3;
  95577. /**
  95578. * Returns the current mesh absolute rotation.
  95579. * Returns a Quaternion.
  95580. */
  95581. get absoluteRotationQuaternion(): Quaternion;
  95582. /**
  95583. * Sets a new matrix to apply before all other transformation
  95584. * @param matrix defines the transform matrix
  95585. * @returns the current TransformNode
  95586. */
  95587. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95588. /**
  95589. * Sets a new pivot matrix to the current node
  95590. * @param matrix defines the new pivot matrix to use
  95591. * @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
  95592. * @returns the current TransformNode
  95593. */
  95594. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95595. /**
  95596. * Returns the mesh pivot matrix.
  95597. * Default : Identity.
  95598. * @returns the matrix
  95599. */
  95600. getPivotMatrix(): Matrix;
  95601. /**
  95602. * Instantiate (when possible) or clone that node with its hierarchy
  95603. * @param newParent defines the new parent to use for the instance (or clone)
  95604. * @param options defines options to configure how copy is done
  95605. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95606. * @returns an instance (or a clone) of the current node with its hiearchy
  95607. */
  95608. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95609. doNotInstantiate: boolean;
  95610. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95611. /**
  95612. * Prevents the World matrix to be computed any longer
  95613. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95614. * @returns the TransformNode.
  95615. */
  95616. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95617. /**
  95618. * Allows back the World matrix computation.
  95619. * @returns the TransformNode.
  95620. */
  95621. unfreezeWorldMatrix(): this;
  95622. /**
  95623. * True if the World matrix has been frozen.
  95624. */
  95625. get isWorldMatrixFrozen(): boolean;
  95626. /**
  95627. * Retuns the mesh absolute position in the World.
  95628. * @returns a Vector3.
  95629. */
  95630. getAbsolutePosition(): Vector3;
  95631. /**
  95632. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95633. * @param absolutePosition the absolute position to set
  95634. * @returns the TransformNode.
  95635. */
  95636. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95637. /**
  95638. * Sets the mesh position in its local space.
  95639. * @param vector3 the position to set in localspace
  95640. * @returns the TransformNode.
  95641. */
  95642. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95643. /**
  95644. * Returns the mesh position in the local space from the current World matrix values.
  95645. * @returns a new Vector3.
  95646. */
  95647. getPositionExpressedInLocalSpace(): Vector3;
  95648. /**
  95649. * Translates the mesh along the passed Vector3 in its local space.
  95650. * @param vector3 the distance to translate in localspace
  95651. * @returns the TransformNode.
  95652. */
  95653. locallyTranslate(vector3: Vector3): TransformNode;
  95654. private static _lookAtVectorCache;
  95655. /**
  95656. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95657. * @param targetPoint the position (must be in same space as current mesh) to look at
  95658. * @param yawCor optional yaw (y-axis) correction in radians
  95659. * @param pitchCor optional pitch (x-axis) correction in radians
  95660. * @param rollCor optional roll (z-axis) correction in radians
  95661. * @param space the choosen space of the target
  95662. * @returns the TransformNode.
  95663. */
  95664. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95665. /**
  95666. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95667. * This Vector3 is expressed in the World space.
  95668. * @param localAxis axis to rotate
  95669. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95670. */
  95671. getDirection(localAxis: Vector3): Vector3;
  95672. /**
  95673. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95674. * localAxis is expressed in the mesh local space.
  95675. * result is computed in the Wordl space from the mesh World matrix.
  95676. * @param localAxis axis to rotate
  95677. * @param result the resulting transformnode
  95678. * @returns this TransformNode.
  95679. */
  95680. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95681. /**
  95682. * Sets this transform node rotation to the given local axis.
  95683. * @param localAxis the axis in local space
  95684. * @param yawCor optional yaw (y-axis) correction in radians
  95685. * @param pitchCor optional pitch (x-axis) correction in radians
  95686. * @param rollCor optional roll (z-axis) correction in radians
  95687. * @returns this TransformNode
  95688. */
  95689. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95690. /**
  95691. * Sets a new pivot point to the current node
  95692. * @param point defines the new pivot point to use
  95693. * @param space defines if the point is in world or local space (local by default)
  95694. * @returns the current TransformNode
  95695. */
  95696. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95697. /**
  95698. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95699. * @returns the pivot point
  95700. */
  95701. getPivotPoint(): Vector3;
  95702. /**
  95703. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95704. * @param result the vector3 to store the result
  95705. * @returns this TransformNode.
  95706. */
  95707. getPivotPointToRef(result: Vector3): TransformNode;
  95708. /**
  95709. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95710. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95711. */
  95712. getAbsolutePivotPoint(): Vector3;
  95713. /**
  95714. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95715. * @param result vector3 to store the result
  95716. * @returns this TransformNode.
  95717. */
  95718. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95719. /**
  95720. * Defines the passed node as the parent of the current node.
  95721. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95722. * @see https://doc.babylonjs.com/how_to/parenting
  95723. * @param node the node ot set as the parent
  95724. * @returns this TransformNode.
  95725. */
  95726. setParent(node: Nullable<Node>): TransformNode;
  95727. private _nonUniformScaling;
  95728. /**
  95729. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95730. */
  95731. get nonUniformScaling(): boolean;
  95732. /** @hidden */
  95733. _updateNonUniformScalingState(value: boolean): boolean;
  95734. /**
  95735. * Attach the current TransformNode to another TransformNode associated with a bone
  95736. * @param bone Bone affecting the TransformNode
  95737. * @param affectedTransformNode TransformNode associated with the bone
  95738. * @returns this object
  95739. */
  95740. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95741. /**
  95742. * Detach the transform node if its associated with a bone
  95743. * @returns this object
  95744. */
  95745. detachFromBone(): TransformNode;
  95746. private static _rotationAxisCache;
  95747. /**
  95748. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95749. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95750. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95751. * The passed axis is also normalized.
  95752. * @param axis the axis to rotate around
  95753. * @param amount the amount to rotate in radians
  95754. * @param space Space to rotate in (Default: local)
  95755. * @returns the TransformNode.
  95756. */
  95757. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95758. /**
  95759. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95760. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95761. * The passed axis is also normalized. .
  95762. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95763. * @param point the point to rotate around
  95764. * @param axis the axis to rotate around
  95765. * @param amount the amount to rotate in radians
  95766. * @returns the TransformNode
  95767. */
  95768. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95769. /**
  95770. * Translates the mesh along the axis vector for the passed distance in the given space.
  95771. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95772. * @param axis the axis to translate in
  95773. * @param distance the distance to translate
  95774. * @param space Space to rotate in (Default: local)
  95775. * @returns the TransformNode.
  95776. */
  95777. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95778. /**
  95779. * Adds a rotation step to the mesh current rotation.
  95780. * x, y, z are Euler angles expressed in radians.
  95781. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95782. * This means this rotation is made in the mesh local space only.
  95783. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95784. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95785. * ```javascript
  95786. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95787. * ```
  95788. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95789. * 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.
  95790. * @param x Rotation to add
  95791. * @param y Rotation to add
  95792. * @param z Rotation to add
  95793. * @returns the TransformNode.
  95794. */
  95795. addRotation(x: number, y: number, z: number): TransformNode;
  95796. /**
  95797. * @hidden
  95798. */
  95799. protected _getEffectiveParent(): Nullable<Node>;
  95800. /**
  95801. * Computes the world matrix of the node
  95802. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95803. * @returns the world matrix
  95804. */
  95805. computeWorldMatrix(force?: boolean): Matrix;
  95806. /**
  95807. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95808. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95809. */
  95810. resetLocalMatrix(independentOfChildren?: boolean): void;
  95811. protected _afterComputeWorldMatrix(): void;
  95812. /**
  95813. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95814. * @param func callback function to add
  95815. *
  95816. * @returns the TransformNode.
  95817. */
  95818. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95819. /**
  95820. * Removes a registered callback function.
  95821. * @param func callback function to remove
  95822. * @returns the TransformNode.
  95823. */
  95824. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95825. /**
  95826. * Gets the position of the current mesh in camera space
  95827. * @param camera defines the camera to use
  95828. * @returns a position
  95829. */
  95830. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95831. /**
  95832. * Returns the distance from the mesh to the active camera
  95833. * @param camera defines the camera to use
  95834. * @returns the distance
  95835. */
  95836. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95837. /**
  95838. * Clone the current transform node
  95839. * @param name Name of the new clone
  95840. * @param newParent New parent for the clone
  95841. * @param doNotCloneChildren Do not clone children hierarchy
  95842. * @returns the new transform node
  95843. */
  95844. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95845. /**
  95846. * Serializes the objects information.
  95847. * @param currentSerializationObject defines the object to serialize in
  95848. * @returns the serialized object
  95849. */
  95850. serialize(currentSerializationObject?: any): any;
  95851. /**
  95852. * Returns a new TransformNode object parsed from the source provided.
  95853. * @param parsedTransformNode is the source.
  95854. * @param scene the scne the object belongs to
  95855. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95856. * @returns a new TransformNode object parsed from the source provided.
  95857. */
  95858. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95859. /**
  95860. * Get all child-transformNodes of this node
  95861. * @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
  95862. * @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
  95863. * @returns an array of TransformNode
  95864. */
  95865. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95866. /**
  95867. * Releases resources associated with this transform node.
  95868. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95869. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95870. */
  95871. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95872. /**
  95873. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95874. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95875. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95876. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95877. * @returns the current mesh
  95878. */
  95879. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95880. private _syncAbsoluteScalingAndRotation;
  95881. }
  95882. }
  95883. declare module BABYLON {
  95884. /**
  95885. * Class used to override all child animations of a given target
  95886. */
  95887. export class AnimationPropertiesOverride {
  95888. /**
  95889. * Gets or sets a value indicating if animation blending must be used
  95890. */
  95891. enableBlending: boolean;
  95892. /**
  95893. * Gets or sets the blending speed to use when enableBlending is true
  95894. */
  95895. blendingSpeed: number;
  95896. /**
  95897. * Gets or sets the default loop mode to use
  95898. */
  95899. loopMode: number;
  95900. }
  95901. }
  95902. declare module BABYLON {
  95903. /**
  95904. * Class used to store bone information
  95905. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95906. */
  95907. export class Bone extends Node {
  95908. /**
  95909. * defines the bone name
  95910. */
  95911. name: string;
  95912. private static _tmpVecs;
  95913. private static _tmpQuat;
  95914. private static _tmpMats;
  95915. /**
  95916. * Gets the list of child bones
  95917. */
  95918. children: Bone[];
  95919. /** Gets the animations associated with this bone */
  95920. animations: Animation[];
  95921. /**
  95922. * Gets or sets bone length
  95923. */
  95924. length: number;
  95925. /**
  95926. * @hidden Internal only
  95927. * Set this value to map this bone to a different index in the transform matrices
  95928. * Set this value to -1 to exclude the bone from the transform matrices
  95929. */
  95930. _index: Nullable<number>;
  95931. private _skeleton;
  95932. private _localMatrix;
  95933. private _restPose;
  95934. private _bindPose;
  95935. private _baseMatrix;
  95936. private _absoluteTransform;
  95937. private _invertedAbsoluteTransform;
  95938. private _parent;
  95939. private _scalingDeterminant;
  95940. private _worldTransform;
  95941. private _localScaling;
  95942. private _localRotation;
  95943. private _localPosition;
  95944. private _needToDecompose;
  95945. private _needToCompose;
  95946. /** @hidden */
  95947. _linkedTransformNode: Nullable<TransformNode>;
  95948. /** @hidden */
  95949. _waitingTransformNodeId: Nullable<string>;
  95950. /** @hidden */
  95951. get _matrix(): Matrix;
  95952. /** @hidden */
  95953. set _matrix(value: Matrix);
  95954. /**
  95955. * Create a new bone
  95956. * @param name defines the bone name
  95957. * @param skeleton defines the parent skeleton
  95958. * @param parentBone defines the parent (can be null if the bone is the root)
  95959. * @param localMatrix defines the local matrix
  95960. * @param restPose defines the rest pose matrix
  95961. * @param baseMatrix defines the base matrix
  95962. * @param index defines index of the bone in the hiearchy
  95963. */
  95964. constructor(
  95965. /**
  95966. * defines the bone name
  95967. */
  95968. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95969. /**
  95970. * Gets the current object class name.
  95971. * @return the class name
  95972. */
  95973. getClassName(): string;
  95974. /**
  95975. * Gets the parent skeleton
  95976. * @returns a skeleton
  95977. */
  95978. getSkeleton(): Skeleton;
  95979. /**
  95980. * Gets parent bone
  95981. * @returns a bone or null if the bone is the root of the bone hierarchy
  95982. */
  95983. getParent(): Nullable<Bone>;
  95984. /**
  95985. * Returns an array containing the root bones
  95986. * @returns an array containing the root bones
  95987. */
  95988. getChildren(): Array<Bone>;
  95989. /**
  95990. * Gets the node index in matrix array generated for rendering
  95991. * @returns the node index
  95992. */
  95993. getIndex(): number;
  95994. /**
  95995. * Sets the parent bone
  95996. * @param parent defines the parent (can be null if the bone is the root)
  95997. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95998. */
  95999. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  96000. /**
  96001. * Gets the local matrix
  96002. * @returns a matrix
  96003. */
  96004. getLocalMatrix(): Matrix;
  96005. /**
  96006. * Gets the base matrix (initial matrix which remains unchanged)
  96007. * @returns a matrix
  96008. */
  96009. getBaseMatrix(): Matrix;
  96010. /**
  96011. * Gets the rest pose matrix
  96012. * @returns a matrix
  96013. */
  96014. getRestPose(): Matrix;
  96015. /**
  96016. * Sets the rest pose matrix
  96017. * @param matrix the local-space rest pose to set for this bone
  96018. */
  96019. setRestPose(matrix: Matrix): void;
  96020. /**
  96021. * Gets the bind pose matrix
  96022. * @returns the bind pose matrix
  96023. */
  96024. getBindPose(): Matrix;
  96025. /**
  96026. * Sets the bind pose matrix
  96027. * @param matrix the local-space bind pose to set for this bone
  96028. */
  96029. setBindPose(matrix: Matrix): void;
  96030. /**
  96031. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  96032. */
  96033. getWorldMatrix(): Matrix;
  96034. /**
  96035. * Sets the local matrix to rest pose matrix
  96036. */
  96037. returnToRest(): void;
  96038. /**
  96039. * Gets the inverse of the absolute transform matrix.
  96040. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  96041. * @returns a matrix
  96042. */
  96043. getInvertedAbsoluteTransform(): Matrix;
  96044. /**
  96045. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  96046. * @returns a matrix
  96047. */
  96048. getAbsoluteTransform(): Matrix;
  96049. /**
  96050. * Links with the given transform node.
  96051. * The local matrix of this bone is copied from the transform node every frame.
  96052. * @param transformNode defines the transform node to link to
  96053. */
  96054. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  96055. /**
  96056. * Gets the node used to drive the bone's transformation
  96057. * @returns a transform node or null
  96058. */
  96059. getTransformNode(): Nullable<TransformNode>;
  96060. /** Gets or sets current position (in local space) */
  96061. get position(): Vector3;
  96062. set position(newPosition: Vector3);
  96063. /** Gets or sets current rotation (in local space) */
  96064. get rotation(): Vector3;
  96065. set rotation(newRotation: Vector3);
  96066. /** Gets or sets current rotation quaternion (in local space) */
  96067. get rotationQuaternion(): Quaternion;
  96068. set rotationQuaternion(newRotation: Quaternion);
  96069. /** Gets or sets current scaling (in local space) */
  96070. get scaling(): Vector3;
  96071. set scaling(newScaling: Vector3);
  96072. /**
  96073. * Gets the animation properties override
  96074. */
  96075. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96076. private _decompose;
  96077. private _compose;
  96078. /**
  96079. * Update the base and local matrices
  96080. * @param matrix defines the new base or local matrix
  96081. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96082. * @param updateLocalMatrix defines if the local matrix should be updated
  96083. */
  96084. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  96085. /** @hidden */
  96086. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96087. /**
  96088. * Flag the bone as dirty (Forcing it to update everything)
  96089. */
  96090. markAsDirty(): void;
  96091. /** @hidden */
  96092. _markAsDirtyAndCompose(): void;
  96093. private _markAsDirtyAndDecompose;
  96094. /**
  96095. * Translate the bone in local or world space
  96096. * @param vec The amount to translate the bone
  96097. * @param space The space that the translation is in
  96098. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96099. */
  96100. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96101. /**
  96102. * Set the postion of the bone in local or world space
  96103. * @param position The position to set the bone
  96104. * @param space The space that the position is in
  96105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96106. */
  96107. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96108. /**
  96109. * Set the absolute position of the bone (world space)
  96110. * @param position The position to set the bone
  96111. * @param mesh The mesh that this bone is attached to
  96112. */
  96113. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96114. /**
  96115. * Scale the bone on the x, y and z axes (in local space)
  96116. * @param x The amount to scale the bone on the x axis
  96117. * @param y The amount to scale the bone on the y axis
  96118. * @param z The amount to scale the bone on the z axis
  96119. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96120. */
  96121. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96122. /**
  96123. * Set the bone scaling in local space
  96124. * @param scale defines the scaling vector
  96125. */
  96126. setScale(scale: Vector3): void;
  96127. /**
  96128. * Gets the current scaling in local space
  96129. * @returns the current scaling vector
  96130. */
  96131. getScale(): Vector3;
  96132. /**
  96133. * Gets the current scaling in local space and stores it in a target vector
  96134. * @param result defines the target vector
  96135. */
  96136. getScaleToRef(result: Vector3): void;
  96137. /**
  96138. * Set the yaw, pitch, and roll of the bone in local or world space
  96139. * @param yaw The rotation of the bone on the y axis
  96140. * @param pitch The rotation of the bone on the x axis
  96141. * @param roll The rotation of the bone on the z axis
  96142. * @param space The space that the axes of rotation are in
  96143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96144. */
  96145. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96146. /**
  96147. * Add a rotation to the bone on an axis in local or world space
  96148. * @param axis The axis to rotate the bone on
  96149. * @param amount The amount to rotate the bone
  96150. * @param space The space that the axis is in
  96151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96152. */
  96153. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96154. /**
  96155. * Set the rotation of the bone to a particular axis angle in local or world space
  96156. * @param axis The axis to rotate the bone on
  96157. * @param angle The angle that the bone should be rotated to
  96158. * @param space The space that the axis is in
  96159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96160. */
  96161. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96162. /**
  96163. * Set the euler rotation of the bone in local or world space
  96164. * @param rotation The euler rotation that the bone should be set to
  96165. * @param space The space that the rotation is in
  96166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96167. */
  96168. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96169. /**
  96170. * Set the quaternion rotation of the bone in local or world space
  96171. * @param quat The quaternion rotation that the bone should be set to
  96172. * @param space The space that the rotation is in
  96173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96174. */
  96175. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96176. /**
  96177. * Set the rotation matrix of the bone in local or world space
  96178. * @param rotMat The rotation matrix that the bone should be set to
  96179. * @param space The space that the rotation is in
  96180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96181. */
  96182. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96183. private _rotateWithMatrix;
  96184. private _getNegativeRotationToRef;
  96185. /**
  96186. * Get the position of the bone in local or world space
  96187. * @param space The space that the returned position is in
  96188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96189. * @returns The position of the bone
  96190. */
  96191. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96192. /**
  96193. * Copy the position of the bone to a vector3 in local or world space
  96194. * @param space The space that the returned position is in
  96195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96196. * @param result The vector3 to copy the position to
  96197. */
  96198. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96199. /**
  96200. * Get the absolute position of the bone (world space)
  96201. * @param mesh The mesh that this bone is attached to
  96202. * @returns The absolute position of the bone
  96203. */
  96204. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96205. /**
  96206. * Copy the absolute position of the bone (world space) to the result param
  96207. * @param mesh The mesh that this bone is attached to
  96208. * @param result The vector3 to copy the absolute position to
  96209. */
  96210. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96211. /**
  96212. * Compute the absolute transforms of this bone and its children
  96213. */
  96214. computeAbsoluteTransforms(): void;
  96215. /**
  96216. * Get the world direction from an axis that is in the local space of the bone
  96217. * @param localAxis The local direction that is used to compute the world direction
  96218. * @param mesh The mesh that this bone is attached to
  96219. * @returns The world direction
  96220. */
  96221. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96222. /**
  96223. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96224. * @param localAxis The local direction that is used to compute the world direction
  96225. * @param mesh The mesh that this bone is attached to
  96226. * @param result The vector3 that the world direction will be copied to
  96227. */
  96228. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96229. /**
  96230. * Get the euler rotation of the bone in local or world space
  96231. * @param space The space that the rotation should be in
  96232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96233. * @returns The euler rotation
  96234. */
  96235. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96236. /**
  96237. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96238. * @param space The space that the rotation should be in
  96239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96240. * @param result The vector3 that the rotation should be copied to
  96241. */
  96242. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96243. /**
  96244. * Get the quaternion rotation of the bone in either local or world space
  96245. * @param space The space that the rotation should be in
  96246. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96247. * @returns The quaternion rotation
  96248. */
  96249. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96250. /**
  96251. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96252. * @param space The space that the rotation should be in
  96253. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96254. * @param result The quaternion that the rotation should be copied to
  96255. */
  96256. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96257. /**
  96258. * Get the rotation matrix of the bone in local or world space
  96259. * @param space The space that the rotation should be in
  96260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96261. * @returns The rotation matrix
  96262. */
  96263. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96264. /**
  96265. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96266. * @param space The space that the rotation should be in
  96267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96268. * @param result The quaternion that the rotation should be copied to
  96269. */
  96270. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96271. /**
  96272. * Get the world position of a point that is in the local space of the bone
  96273. * @param position The local position
  96274. * @param mesh The mesh that this bone is attached to
  96275. * @returns The world position
  96276. */
  96277. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96278. /**
  96279. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96280. * @param position The local position
  96281. * @param mesh The mesh that this bone is attached to
  96282. * @param result The vector3 that the world position should be copied to
  96283. */
  96284. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96285. /**
  96286. * Get the local position of a point that is in world space
  96287. * @param position The world position
  96288. * @param mesh The mesh that this bone is attached to
  96289. * @returns The local position
  96290. */
  96291. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96292. /**
  96293. * Get the local position of a point that is in world space and copy it to the result param
  96294. * @param position The world position
  96295. * @param mesh The mesh that this bone is attached to
  96296. * @param result The vector3 that the local position should be copied to
  96297. */
  96298. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96299. /**
  96300. * Set the current local matrix as the restPose for this bone.
  96301. */
  96302. setCurrentPoseAsRest(): void;
  96303. }
  96304. }
  96305. declare module BABYLON {
  96306. /**
  96307. * Defines a runtime animation
  96308. */
  96309. export class RuntimeAnimation {
  96310. private _events;
  96311. /**
  96312. * The current frame of the runtime animation
  96313. */
  96314. private _currentFrame;
  96315. /**
  96316. * The animation used by the runtime animation
  96317. */
  96318. private _animation;
  96319. /**
  96320. * The target of the runtime animation
  96321. */
  96322. private _target;
  96323. /**
  96324. * The initiating animatable
  96325. */
  96326. private _host;
  96327. /**
  96328. * The original value of the runtime animation
  96329. */
  96330. private _originalValue;
  96331. /**
  96332. * The original blend value of the runtime animation
  96333. */
  96334. private _originalBlendValue;
  96335. /**
  96336. * The offsets cache of the runtime animation
  96337. */
  96338. private _offsetsCache;
  96339. /**
  96340. * The high limits cache of the runtime animation
  96341. */
  96342. private _highLimitsCache;
  96343. /**
  96344. * Specifies if the runtime animation has been stopped
  96345. */
  96346. private _stopped;
  96347. /**
  96348. * The blending factor of the runtime animation
  96349. */
  96350. private _blendingFactor;
  96351. /**
  96352. * The BabylonJS scene
  96353. */
  96354. private _scene;
  96355. /**
  96356. * The current value of the runtime animation
  96357. */
  96358. private _currentValue;
  96359. /** @hidden */
  96360. _animationState: _IAnimationState;
  96361. /**
  96362. * The active target of the runtime animation
  96363. */
  96364. private _activeTargets;
  96365. private _currentActiveTarget;
  96366. private _directTarget;
  96367. /**
  96368. * The target path of the runtime animation
  96369. */
  96370. private _targetPath;
  96371. /**
  96372. * The weight of the runtime animation
  96373. */
  96374. private _weight;
  96375. /**
  96376. * The ratio offset of the runtime animation
  96377. */
  96378. private _ratioOffset;
  96379. /**
  96380. * The previous delay of the runtime animation
  96381. */
  96382. private _previousDelay;
  96383. /**
  96384. * The previous ratio of the runtime animation
  96385. */
  96386. private _previousRatio;
  96387. private _enableBlending;
  96388. private _keys;
  96389. private _minFrame;
  96390. private _maxFrame;
  96391. private _minValue;
  96392. private _maxValue;
  96393. private _targetIsArray;
  96394. /**
  96395. * Gets the current frame of the runtime animation
  96396. */
  96397. get currentFrame(): number;
  96398. /**
  96399. * Gets the weight of the runtime animation
  96400. */
  96401. get weight(): number;
  96402. /**
  96403. * Gets the current value of the runtime animation
  96404. */
  96405. get currentValue(): any;
  96406. /**
  96407. * Gets the target path of the runtime animation
  96408. */
  96409. get targetPath(): string;
  96410. /**
  96411. * Gets the actual target of the runtime animation
  96412. */
  96413. get target(): any;
  96414. /**
  96415. * Gets the additive state of the runtime animation
  96416. */
  96417. get isAdditive(): boolean;
  96418. /** @hidden */
  96419. _onLoop: () => void;
  96420. /**
  96421. * Create a new RuntimeAnimation object
  96422. * @param target defines the target of the animation
  96423. * @param animation defines the source animation object
  96424. * @param scene defines the hosting scene
  96425. * @param host defines the initiating Animatable
  96426. */
  96427. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96428. private _preparePath;
  96429. /**
  96430. * Gets the animation from the runtime animation
  96431. */
  96432. get animation(): Animation;
  96433. /**
  96434. * Resets the runtime animation to the beginning
  96435. * @param restoreOriginal defines whether to restore the target property to the original value
  96436. */
  96437. reset(restoreOriginal?: boolean): void;
  96438. /**
  96439. * Specifies if the runtime animation is stopped
  96440. * @returns Boolean specifying if the runtime animation is stopped
  96441. */
  96442. isStopped(): boolean;
  96443. /**
  96444. * Disposes of the runtime animation
  96445. */
  96446. dispose(): void;
  96447. /**
  96448. * Apply the interpolated value to the target
  96449. * @param currentValue defines the value computed by the animation
  96450. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96451. */
  96452. setValue(currentValue: any, weight: number): void;
  96453. private _getOriginalValues;
  96454. private _setValue;
  96455. /**
  96456. * Gets the loop pmode of the runtime animation
  96457. * @returns Loop Mode
  96458. */
  96459. private _getCorrectLoopMode;
  96460. /**
  96461. * Move the current animation to a given frame
  96462. * @param frame defines the frame to move to
  96463. */
  96464. goToFrame(frame: number): void;
  96465. /**
  96466. * @hidden Internal use only
  96467. */
  96468. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96469. /**
  96470. * Execute the current animation
  96471. * @param delay defines the delay to add to the current frame
  96472. * @param from defines the lower bound of the animation range
  96473. * @param to defines the upper bound of the animation range
  96474. * @param loop defines if the current animation must loop
  96475. * @param speedRatio defines the current speed ratio
  96476. * @param weight defines the weight of the animation (default is -1 so no weight)
  96477. * @param onLoop optional callback called when animation loops
  96478. * @returns a boolean indicating if the animation is running
  96479. */
  96480. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96481. }
  96482. }
  96483. declare module BABYLON {
  96484. /**
  96485. * Class used to store an actual running animation
  96486. */
  96487. export class Animatable {
  96488. /** defines the target object */
  96489. target: any;
  96490. /** defines the starting frame number (default is 0) */
  96491. fromFrame: number;
  96492. /** defines the ending frame number (default is 100) */
  96493. toFrame: number;
  96494. /** defines if the animation must loop (default is false) */
  96495. loopAnimation: boolean;
  96496. /** defines a callback to call when animation ends if it is not looping */
  96497. onAnimationEnd?: (() => void) | null | undefined;
  96498. /** defines a callback to call when animation loops */
  96499. onAnimationLoop?: (() => void) | null | undefined;
  96500. /** defines whether the animation should be evaluated additively */
  96501. isAdditive: boolean;
  96502. private _localDelayOffset;
  96503. private _pausedDelay;
  96504. private _runtimeAnimations;
  96505. private _paused;
  96506. private _scene;
  96507. private _speedRatio;
  96508. private _weight;
  96509. private _syncRoot;
  96510. /**
  96511. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96512. * This will only apply for non looping animation (default is true)
  96513. */
  96514. disposeOnEnd: boolean;
  96515. /**
  96516. * Gets a boolean indicating if the animation has started
  96517. */
  96518. animationStarted: boolean;
  96519. /**
  96520. * Observer raised when the animation ends
  96521. */
  96522. onAnimationEndObservable: Observable<Animatable>;
  96523. /**
  96524. * Observer raised when the animation loops
  96525. */
  96526. onAnimationLoopObservable: Observable<Animatable>;
  96527. /**
  96528. * Gets the root Animatable used to synchronize and normalize animations
  96529. */
  96530. get syncRoot(): Nullable<Animatable>;
  96531. /**
  96532. * Gets the current frame of the first RuntimeAnimation
  96533. * Used to synchronize Animatables
  96534. */
  96535. get masterFrame(): number;
  96536. /**
  96537. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96538. */
  96539. get weight(): number;
  96540. set weight(value: number);
  96541. /**
  96542. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96543. */
  96544. get speedRatio(): number;
  96545. set speedRatio(value: number);
  96546. /**
  96547. * Creates a new Animatable
  96548. * @param scene defines the hosting scene
  96549. * @param target defines the target object
  96550. * @param fromFrame defines the starting frame number (default is 0)
  96551. * @param toFrame defines the ending frame number (default is 100)
  96552. * @param loopAnimation defines if the animation must loop (default is false)
  96553. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96554. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96555. * @param animations defines a group of animation to add to the new Animatable
  96556. * @param onAnimationLoop defines a callback to call when animation loops
  96557. * @param isAdditive defines whether the animation should be evaluated additively
  96558. */
  96559. constructor(scene: Scene,
  96560. /** defines the target object */
  96561. target: any,
  96562. /** defines the starting frame number (default is 0) */
  96563. fromFrame?: number,
  96564. /** defines the ending frame number (default is 100) */
  96565. toFrame?: number,
  96566. /** defines if the animation must loop (default is false) */
  96567. loopAnimation?: boolean, speedRatio?: number,
  96568. /** defines a callback to call when animation ends if it is not looping */
  96569. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96570. /** defines a callback to call when animation loops */
  96571. onAnimationLoop?: (() => void) | null | undefined,
  96572. /** defines whether the animation should be evaluated additively */
  96573. isAdditive?: boolean);
  96574. /**
  96575. * Synchronize and normalize current Animatable with a source Animatable
  96576. * This is useful when using animation weights and when animations are not of the same length
  96577. * @param root defines the root Animatable to synchronize with
  96578. * @returns the current Animatable
  96579. */
  96580. syncWith(root: Animatable): Animatable;
  96581. /**
  96582. * Gets the list of runtime animations
  96583. * @returns an array of RuntimeAnimation
  96584. */
  96585. getAnimations(): RuntimeAnimation[];
  96586. /**
  96587. * Adds more animations to the current animatable
  96588. * @param target defines the target of the animations
  96589. * @param animations defines the new animations to add
  96590. */
  96591. appendAnimations(target: any, animations: Animation[]): void;
  96592. /**
  96593. * Gets the source animation for a specific property
  96594. * @param property defines the propertyu to look for
  96595. * @returns null or the source animation for the given property
  96596. */
  96597. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96598. /**
  96599. * Gets the runtime animation for a specific property
  96600. * @param property defines the propertyu to look for
  96601. * @returns null or the runtime animation for the given property
  96602. */
  96603. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96604. /**
  96605. * Resets the animatable to its original state
  96606. */
  96607. reset(): void;
  96608. /**
  96609. * Allows the animatable to blend with current running animations
  96610. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96611. * @param blendingSpeed defines the blending speed to use
  96612. */
  96613. enableBlending(blendingSpeed: number): void;
  96614. /**
  96615. * Disable animation blending
  96616. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96617. */
  96618. disableBlending(): void;
  96619. /**
  96620. * Jump directly to a given frame
  96621. * @param frame defines the frame to jump to
  96622. */
  96623. goToFrame(frame: number): void;
  96624. /**
  96625. * Pause the animation
  96626. */
  96627. pause(): void;
  96628. /**
  96629. * Restart the animation
  96630. */
  96631. restart(): void;
  96632. private _raiseOnAnimationEnd;
  96633. /**
  96634. * Stop and delete the current animation
  96635. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96636. * @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)
  96637. */
  96638. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96639. /**
  96640. * Wait asynchronously for the animation to end
  96641. * @returns a promise which will be fullfilled when the animation ends
  96642. */
  96643. waitAsync(): Promise<Animatable>;
  96644. /** @hidden */
  96645. _animate(delay: number): boolean;
  96646. }
  96647. interface Scene {
  96648. /** @hidden */
  96649. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96650. /** @hidden */
  96651. _processLateAnimationBindingsForMatrices(holder: {
  96652. totalWeight: number;
  96653. totalAdditiveWeight: number;
  96654. animations: RuntimeAnimation[];
  96655. additiveAnimations: RuntimeAnimation[];
  96656. originalValue: Matrix;
  96657. }): any;
  96658. /** @hidden */
  96659. _processLateAnimationBindingsForQuaternions(holder: {
  96660. totalWeight: number;
  96661. totalAdditiveWeight: number;
  96662. animations: RuntimeAnimation[];
  96663. additiveAnimations: RuntimeAnimation[];
  96664. originalValue: Quaternion;
  96665. }, refQuaternion: Quaternion): Quaternion;
  96666. /** @hidden */
  96667. _processLateAnimationBindings(): void;
  96668. /**
  96669. * Will start the animation sequence of a given target
  96670. * @param target defines the target
  96671. * @param from defines from which frame should animation start
  96672. * @param to defines until which frame should animation run.
  96673. * @param weight defines the weight to apply to the animation (1.0 by default)
  96674. * @param loop defines if the animation loops
  96675. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96676. * @param onAnimationEnd defines the function to be executed when the animation ends
  96677. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96678. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96679. * @param onAnimationLoop defines the callback to call when an animation loops
  96680. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96681. * @returns the animatable object created for this animation
  96682. */
  96683. 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;
  96684. /**
  96685. * Will start the animation sequence of a given target
  96686. * @param target defines the target
  96687. * @param from defines from which frame should animation start
  96688. * @param to defines until which frame should animation run.
  96689. * @param loop defines if the animation loops
  96690. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96691. * @param onAnimationEnd defines the function to be executed when the animation ends
  96692. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96693. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96694. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96695. * @param onAnimationLoop defines the callback to call when an animation loops
  96696. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96697. * @returns the animatable object created for this animation
  96698. */
  96699. 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;
  96700. /**
  96701. * Will start the animation sequence of a given target and its hierarchy
  96702. * @param target defines the target
  96703. * @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.
  96704. * @param from defines from which frame should animation start
  96705. * @param to defines until which frame should animation run.
  96706. * @param loop defines if the animation loops
  96707. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96708. * @param onAnimationEnd defines the function to be executed when the animation ends
  96709. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96710. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96711. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96712. * @param onAnimationLoop defines the callback to call when an animation loops
  96713. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96714. * @returns the list of created animatables
  96715. */
  96716. 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[];
  96717. /**
  96718. * Begin a new animation on a given node
  96719. * @param target defines the target where the animation will take place
  96720. * @param animations defines the list of animations to start
  96721. * @param from defines the initial value
  96722. * @param to defines the final value
  96723. * @param loop defines if you want animation to loop (off by default)
  96724. * @param speedRatio defines the speed ratio to apply to all animations
  96725. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96726. * @param onAnimationLoop defines the callback to call when an animation loops
  96727. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96728. * @returns the list of created animatables
  96729. */
  96730. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96731. /**
  96732. * Begin a new animation on a given node and its hierarchy
  96733. * @param target defines the root node where the animation will take place
  96734. * @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.
  96735. * @param animations defines the list of animations to start
  96736. * @param from defines the initial value
  96737. * @param to defines the final value
  96738. * @param loop defines if you want animation to loop (off by default)
  96739. * @param speedRatio defines the speed ratio to apply to all animations
  96740. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96741. * @param onAnimationLoop defines the callback to call when an animation loops
  96742. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96743. * @returns the list of animatables created for all nodes
  96744. */
  96745. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96746. /**
  96747. * Gets the animatable associated with a specific target
  96748. * @param target defines the target of the animatable
  96749. * @returns the required animatable if found
  96750. */
  96751. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96752. /**
  96753. * Gets all animatables associated with a given target
  96754. * @param target defines the target to look animatables for
  96755. * @returns an array of Animatables
  96756. */
  96757. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96758. /**
  96759. * Stops and removes all animations that have been applied to the scene
  96760. */
  96761. stopAllAnimations(): void;
  96762. /**
  96763. * Gets the current delta time used by animation engine
  96764. */
  96765. deltaTime: number;
  96766. }
  96767. interface Bone {
  96768. /**
  96769. * Copy an animation range from another bone
  96770. * @param source defines the source bone
  96771. * @param rangeName defines the range name to copy
  96772. * @param frameOffset defines the frame offset
  96773. * @param rescaleAsRequired defines if rescaling must be applied if required
  96774. * @param skelDimensionsRatio defines the scaling ratio
  96775. * @returns true if operation was successful
  96776. */
  96777. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96778. }
  96779. }
  96780. declare module BABYLON {
  96781. /**
  96782. * Class used to handle skinning animations
  96783. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96784. */
  96785. export class Skeleton implements IAnimatable {
  96786. /** defines the skeleton name */
  96787. name: string;
  96788. /** defines the skeleton Id */
  96789. id: string;
  96790. /**
  96791. * Defines the list of child bones
  96792. */
  96793. bones: Bone[];
  96794. /**
  96795. * Defines an estimate of the dimension of the skeleton at rest
  96796. */
  96797. dimensionsAtRest: Vector3;
  96798. /**
  96799. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96800. */
  96801. needInitialSkinMatrix: boolean;
  96802. /**
  96803. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96804. */
  96805. overrideMesh: Nullable<AbstractMesh>;
  96806. /**
  96807. * Gets the list of animations attached to this skeleton
  96808. */
  96809. animations: Array<Animation>;
  96810. private _scene;
  96811. private _isDirty;
  96812. private _transformMatrices;
  96813. private _transformMatrixTexture;
  96814. private _meshesWithPoseMatrix;
  96815. private _animatables;
  96816. private _identity;
  96817. private _synchronizedWithMesh;
  96818. private _ranges;
  96819. private _lastAbsoluteTransformsUpdateId;
  96820. private _canUseTextureForBones;
  96821. private _uniqueId;
  96822. /** @hidden */
  96823. _numBonesWithLinkedTransformNode: number;
  96824. /** @hidden */
  96825. _hasWaitingData: Nullable<boolean>;
  96826. /** @hidden */
  96827. _waitingOverrideMeshId: Nullable<string>;
  96828. /**
  96829. * Specifies if the skeleton should be serialized
  96830. */
  96831. doNotSerialize: boolean;
  96832. private _useTextureToStoreBoneMatrices;
  96833. /**
  96834. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96835. * Please note that this option is not available if the hardware does not support it
  96836. */
  96837. get useTextureToStoreBoneMatrices(): boolean;
  96838. set useTextureToStoreBoneMatrices(value: boolean);
  96839. private _animationPropertiesOverride;
  96840. /**
  96841. * Gets or sets the animation properties override
  96842. */
  96843. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96844. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96845. /**
  96846. * List of inspectable custom properties (used by the Inspector)
  96847. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96848. */
  96849. inspectableCustomProperties: IInspectable[];
  96850. /**
  96851. * An observable triggered before computing the skeleton's matrices
  96852. */
  96853. onBeforeComputeObservable: Observable<Skeleton>;
  96854. /**
  96855. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96856. */
  96857. get isUsingTextureForMatrices(): boolean;
  96858. /**
  96859. * Gets the unique ID of this skeleton
  96860. */
  96861. get uniqueId(): number;
  96862. /**
  96863. * Creates a new skeleton
  96864. * @param name defines the skeleton name
  96865. * @param id defines the skeleton Id
  96866. * @param scene defines the hosting scene
  96867. */
  96868. constructor(
  96869. /** defines the skeleton name */
  96870. name: string,
  96871. /** defines the skeleton Id */
  96872. id: string, scene: Scene);
  96873. /**
  96874. * Gets the current object class name.
  96875. * @return the class name
  96876. */
  96877. getClassName(): string;
  96878. /**
  96879. * Returns an array containing the root bones
  96880. * @returns an array containing the root bones
  96881. */
  96882. getChildren(): Array<Bone>;
  96883. /**
  96884. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96885. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96886. * @returns a Float32Array containing matrices data
  96887. */
  96888. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96889. /**
  96890. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96891. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96892. * @returns a raw texture containing the data
  96893. */
  96894. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96895. /**
  96896. * Gets the current hosting scene
  96897. * @returns a scene object
  96898. */
  96899. getScene(): Scene;
  96900. /**
  96901. * Gets a string representing the current skeleton data
  96902. * @param fullDetails defines a boolean indicating if we want a verbose version
  96903. * @returns a string representing the current skeleton data
  96904. */
  96905. toString(fullDetails?: boolean): string;
  96906. /**
  96907. * Get bone's index searching by name
  96908. * @param name defines bone's name to search for
  96909. * @return the indice of the bone. Returns -1 if not found
  96910. */
  96911. getBoneIndexByName(name: string): number;
  96912. /**
  96913. * Creater a new animation range
  96914. * @param name defines the name of the range
  96915. * @param from defines the start key
  96916. * @param to defines the end key
  96917. */
  96918. createAnimationRange(name: string, from: number, to: number): void;
  96919. /**
  96920. * Delete a specific animation range
  96921. * @param name defines the name of the range
  96922. * @param deleteFrames defines if frames must be removed as well
  96923. */
  96924. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96925. /**
  96926. * Gets a specific animation range
  96927. * @param name defines the name of the range to look for
  96928. * @returns the requested animation range or null if not found
  96929. */
  96930. getAnimationRange(name: string): Nullable<AnimationRange>;
  96931. /**
  96932. * Gets the list of all animation ranges defined on this skeleton
  96933. * @returns an array
  96934. */
  96935. getAnimationRanges(): Nullable<AnimationRange>[];
  96936. /**
  96937. * Copy animation range from a source skeleton.
  96938. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96939. * @param source defines the source skeleton
  96940. * @param name defines the name of the range to copy
  96941. * @param rescaleAsRequired defines if rescaling must be applied if required
  96942. * @returns true if operation was successful
  96943. */
  96944. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96945. /**
  96946. * Forces the skeleton to go to rest pose
  96947. */
  96948. returnToRest(): void;
  96949. private _getHighestAnimationFrame;
  96950. /**
  96951. * Begin a specific animation range
  96952. * @param name defines the name of the range to start
  96953. * @param loop defines if looping must be turned on (false by default)
  96954. * @param speedRatio defines the speed ratio to apply (1 by default)
  96955. * @param onAnimationEnd defines a callback which will be called when animation will end
  96956. * @returns a new animatable
  96957. */
  96958. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96959. /**
  96960. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96961. * @param skeleton defines the Skeleton containing the animation range to convert
  96962. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96963. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96964. * @returns the original skeleton
  96965. */
  96966. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96967. /** @hidden */
  96968. _markAsDirty(): void;
  96969. /** @hidden */
  96970. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96971. /** @hidden */
  96972. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96973. private _computeTransformMatrices;
  96974. /**
  96975. * Build all resources required to render a skeleton
  96976. */
  96977. prepare(): void;
  96978. /**
  96979. * Gets the list of animatables currently running for this skeleton
  96980. * @returns an array of animatables
  96981. */
  96982. getAnimatables(): IAnimatable[];
  96983. /**
  96984. * Clone the current skeleton
  96985. * @param name defines the name of the new skeleton
  96986. * @param id defines the id of the new skeleton
  96987. * @returns the new skeleton
  96988. */
  96989. clone(name: string, id?: string): Skeleton;
  96990. /**
  96991. * Enable animation blending for this skeleton
  96992. * @param blendingSpeed defines the blending speed to apply
  96993. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96994. */
  96995. enableBlending(blendingSpeed?: number): void;
  96996. /**
  96997. * Releases all resources associated with the current skeleton
  96998. */
  96999. dispose(): void;
  97000. /**
  97001. * Serialize the skeleton in a JSON object
  97002. * @returns a JSON object
  97003. */
  97004. serialize(): any;
  97005. /**
  97006. * Creates a new skeleton from serialized data
  97007. * @param parsedSkeleton defines the serialized data
  97008. * @param scene defines the hosting scene
  97009. * @returns a new skeleton
  97010. */
  97011. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  97012. /**
  97013. * Compute all node absolute transforms
  97014. * @param forceUpdate defines if computation must be done even if cache is up to date
  97015. */
  97016. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  97017. /**
  97018. * Gets the root pose matrix
  97019. * @returns a matrix
  97020. */
  97021. getPoseMatrix(): Nullable<Matrix>;
  97022. /**
  97023. * Sorts bones per internal index
  97024. */
  97025. sortBones(): void;
  97026. private _sortBones;
  97027. /**
  97028. * Set the current local matrix as the restPose for all bones in the skeleton.
  97029. */
  97030. setCurrentPoseAsRest(): void;
  97031. }
  97032. }
  97033. declare module BABYLON {
  97034. /**
  97035. * Creates an instance based on a source mesh.
  97036. */
  97037. export class InstancedMesh extends AbstractMesh {
  97038. private _sourceMesh;
  97039. private _currentLOD;
  97040. /** @hidden */
  97041. _indexInSourceMeshInstanceArray: number;
  97042. constructor(name: string, source: Mesh);
  97043. /**
  97044. * Returns the string "InstancedMesh".
  97045. */
  97046. getClassName(): string;
  97047. /** Gets the list of lights affecting that mesh */
  97048. get lightSources(): Light[];
  97049. _resyncLightSources(): void;
  97050. _resyncLightSource(light: Light): void;
  97051. _removeLightSource(light: Light, dispose: boolean): void;
  97052. /**
  97053. * If the source mesh receives shadows
  97054. */
  97055. get receiveShadows(): boolean;
  97056. /**
  97057. * The material of the source mesh
  97058. */
  97059. get material(): Nullable<Material>;
  97060. /**
  97061. * Visibility of the source mesh
  97062. */
  97063. get visibility(): number;
  97064. /**
  97065. * Skeleton of the source mesh
  97066. */
  97067. get skeleton(): Nullable<Skeleton>;
  97068. /**
  97069. * Rendering ground id of the source mesh
  97070. */
  97071. get renderingGroupId(): number;
  97072. set renderingGroupId(value: number);
  97073. /**
  97074. * Returns the total number of vertices (integer).
  97075. */
  97076. getTotalVertices(): number;
  97077. /**
  97078. * Returns a positive integer : the total number of indices in this mesh geometry.
  97079. * @returns the numner of indices or zero if the mesh has no geometry.
  97080. */
  97081. getTotalIndices(): number;
  97082. /**
  97083. * The source mesh of the instance
  97084. */
  97085. get sourceMesh(): Mesh;
  97086. /**
  97087. * Creates a new InstancedMesh object from the mesh model.
  97088. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97089. * @param name defines the name of the new instance
  97090. * @returns a new InstancedMesh
  97091. */
  97092. createInstance(name: string): InstancedMesh;
  97093. /**
  97094. * Is this node ready to be used/rendered
  97095. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97096. * @return {boolean} is it ready
  97097. */
  97098. isReady(completeCheck?: boolean): boolean;
  97099. /**
  97100. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97101. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97102. * @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.
  97103. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97104. */
  97105. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97106. /**
  97107. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97108. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97109. * The `data` are either a numeric array either a Float32Array.
  97110. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97111. * 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).
  97112. * Note that a new underlying VertexBuffer object is created each call.
  97113. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97114. *
  97115. * Possible `kind` values :
  97116. * - VertexBuffer.PositionKind
  97117. * - VertexBuffer.UVKind
  97118. * - VertexBuffer.UV2Kind
  97119. * - VertexBuffer.UV3Kind
  97120. * - VertexBuffer.UV4Kind
  97121. * - VertexBuffer.UV5Kind
  97122. * - VertexBuffer.UV6Kind
  97123. * - VertexBuffer.ColorKind
  97124. * - VertexBuffer.MatricesIndicesKind
  97125. * - VertexBuffer.MatricesIndicesExtraKind
  97126. * - VertexBuffer.MatricesWeightsKind
  97127. * - VertexBuffer.MatricesWeightsExtraKind
  97128. *
  97129. * Returns the Mesh.
  97130. */
  97131. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97132. /**
  97133. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97134. * If the mesh has no geometry, it is simply returned as it is.
  97135. * The `data` are either a numeric array either a Float32Array.
  97136. * No new underlying VertexBuffer object is created.
  97137. * 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.
  97138. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97139. *
  97140. * Possible `kind` values :
  97141. * - VertexBuffer.PositionKind
  97142. * - VertexBuffer.UVKind
  97143. * - VertexBuffer.UV2Kind
  97144. * - VertexBuffer.UV3Kind
  97145. * - VertexBuffer.UV4Kind
  97146. * - VertexBuffer.UV5Kind
  97147. * - VertexBuffer.UV6Kind
  97148. * - VertexBuffer.ColorKind
  97149. * - VertexBuffer.MatricesIndicesKind
  97150. * - VertexBuffer.MatricesIndicesExtraKind
  97151. * - VertexBuffer.MatricesWeightsKind
  97152. * - VertexBuffer.MatricesWeightsExtraKind
  97153. *
  97154. * Returns the Mesh.
  97155. */
  97156. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97157. /**
  97158. * Sets the mesh indices.
  97159. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97160. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97161. * This method creates a new index buffer each call.
  97162. * Returns the Mesh.
  97163. */
  97164. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97165. /**
  97166. * Boolean : True if the mesh owns the requested kind of data.
  97167. */
  97168. isVerticesDataPresent(kind: string): boolean;
  97169. /**
  97170. * Returns an array of indices (IndicesArray).
  97171. */
  97172. getIndices(): Nullable<IndicesArray>;
  97173. get _positions(): Nullable<Vector3[]>;
  97174. /**
  97175. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97176. * This means the mesh underlying bounding box and sphere are recomputed.
  97177. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97178. * @returns the current mesh
  97179. */
  97180. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97181. /** @hidden */
  97182. _preActivate(): InstancedMesh;
  97183. /** @hidden */
  97184. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97185. /** @hidden */
  97186. _postActivate(): void;
  97187. getWorldMatrix(): Matrix;
  97188. get isAnInstance(): boolean;
  97189. /**
  97190. * Returns the current associated LOD AbstractMesh.
  97191. */
  97192. getLOD(camera: Camera): AbstractMesh;
  97193. /** @hidden */
  97194. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97195. /** @hidden */
  97196. _syncSubMeshes(): InstancedMesh;
  97197. /** @hidden */
  97198. _generatePointsArray(): boolean;
  97199. /** @hidden */
  97200. _updateBoundingInfo(): AbstractMesh;
  97201. /**
  97202. * Creates a new InstancedMesh from the current mesh.
  97203. * - name (string) : the cloned mesh name
  97204. * - newParent (optional Node) : the optional Node to parent the clone to.
  97205. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97206. *
  97207. * Returns the clone.
  97208. */
  97209. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97210. /**
  97211. * Disposes the InstancedMesh.
  97212. * Returns nothing.
  97213. */
  97214. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97215. }
  97216. interface Mesh {
  97217. /**
  97218. * Register a custom buffer that will be instanced
  97219. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97220. * @param kind defines the buffer kind
  97221. * @param stride defines the stride in floats
  97222. */
  97223. registerInstancedBuffer(kind: string, stride: number): void;
  97224. /**
  97225. * true to use the edge renderer for all instances of this mesh
  97226. */
  97227. edgesShareWithInstances: boolean;
  97228. /** @hidden */
  97229. _userInstancedBuffersStorage: {
  97230. data: {
  97231. [key: string]: Float32Array;
  97232. };
  97233. sizes: {
  97234. [key: string]: number;
  97235. };
  97236. vertexBuffers: {
  97237. [key: string]: Nullable<VertexBuffer>;
  97238. };
  97239. strides: {
  97240. [key: string]: number;
  97241. };
  97242. };
  97243. }
  97244. interface AbstractMesh {
  97245. /**
  97246. * Object used to store instanced buffers defined by user
  97247. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97248. */
  97249. instancedBuffers: {
  97250. [key: string]: any;
  97251. };
  97252. }
  97253. }
  97254. declare module BABYLON {
  97255. /**
  97256. * Defines the options associated with the creation of a shader material.
  97257. */
  97258. export interface IShaderMaterialOptions {
  97259. /**
  97260. * Does the material work in alpha blend mode
  97261. */
  97262. needAlphaBlending: boolean;
  97263. /**
  97264. * Does the material work in alpha test mode
  97265. */
  97266. needAlphaTesting: boolean;
  97267. /**
  97268. * The list of attribute names used in the shader
  97269. */
  97270. attributes: string[];
  97271. /**
  97272. * The list of unifrom names used in the shader
  97273. */
  97274. uniforms: string[];
  97275. /**
  97276. * The list of UBO names used in the shader
  97277. */
  97278. uniformBuffers: string[];
  97279. /**
  97280. * The list of sampler names used in the shader
  97281. */
  97282. samplers: string[];
  97283. /**
  97284. * The list of defines used in the shader
  97285. */
  97286. defines: string[];
  97287. }
  97288. /**
  97289. * 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.
  97290. *
  97291. * This returned material effects how the mesh will look based on the code in the shaders.
  97292. *
  97293. * @see https://doc.babylonjs.com/how_to/shader_material
  97294. */
  97295. export class ShaderMaterial extends Material {
  97296. private _shaderPath;
  97297. private _options;
  97298. private _textures;
  97299. private _textureArrays;
  97300. private _floats;
  97301. private _ints;
  97302. private _floatsArrays;
  97303. private _colors3;
  97304. private _colors3Arrays;
  97305. private _colors4;
  97306. private _colors4Arrays;
  97307. private _vectors2;
  97308. private _vectors3;
  97309. private _vectors4;
  97310. private _matrices;
  97311. private _matrixArrays;
  97312. private _matrices3x3;
  97313. private _matrices2x2;
  97314. private _vectors2Arrays;
  97315. private _vectors3Arrays;
  97316. private _vectors4Arrays;
  97317. private _cachedWorldViewMatrix;
  97318. private _cachedWorldViewProjectionMatrix;
  97319. private _renderId;
  97320. private _multiview;
  97321. private _cachedDefines;
  97322. /** Define the Url to load snippets */
  97323. static SnippetUrl: string;
  97324. /** Snippet ID if the material was created from the snippet server */
  97325. snippetId: string;
  97326. /**
  97327. * Instantiate a new shader material.
  97328. * 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.
  97329. * This returned material effects how the mesh will look based on the code in the shaders.
  97330. * @see https://doc.babylonjs.com/how_to/shader_material
  97331. * @param name Define the name of the material in the scene
  97332. * @param scene Define the scene the material belongs to
  97333. * @param shaderPath Defines the route to the shader code in one of three ways:
  97334. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97335. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97336. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97337. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97338. * @param options Define the options used to create the shader
  97339. */
  97340. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97341. /**
  97342. * Gets the shader path used to define the shader code
  97343. * It can be modified to trigger a new compilation
  97344. */
  97345. get shaderPath(): any;
  97346. /**
  97347. * Sets the shader path used to define the shader code
  97348. * It can be modified to trigger a new compilation
  97349. */
  97350. set shaderPath(shaderPath: any);
  97351. /**
  97352. * Gets the options used to compile the shader.
  97353. * They can be modified to trigger a new compilation
  97354. */
  97355. get options(): IShaderMaterialOptions;
  97356. /**
  97357. * Gets the current class name of the material e.g. "ShaderMaterial"
  97358. * Mainly use in serialization.
  97359. * @returns the class name
  97360. */
  97361. getClassName(): string;
  97362. /**
  97363. * Specifies if the material will require alpha blending
  97364. * @returns a boolean specifying if alpha blending is needed
  97365. */
  97366. needAlphaBlending(): boolean;
  97367. /**
  97368. * Specifies if this material should be rendered in alpha test mode
  97369. * @returns a boolean specifying if an alpha test is needed.
  97370. */
  97371. needAlphaTesting(): boolean;
  97372. private _checkUniform;
  97373. /**
  97374. * Set a texture in the shader.
  97375. * @param name Define the name of the uniform samplers as defined in the shader
  97376. * @param texture Define the texture to bind to this sampler
  97377. * @return the material itself allowing "fluent" like uniform updates
  97378. */
  97379. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97380. /**
  97381. * Set a texture array in the shader.
  97382. * @param name Define the name of the uniform sampler array as defined in the shader
  97383. * @param textures Define the list of textures to bind to this sampler
  97384. * @return the material itself allowing "fluent" like uniform updates
  97385. */
  97386. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97387. /**
  97388. * Set a float in the shader.
  97389. * @param name Define the name of the uniform as defined in the shader
  97390. * @param value Define the value to give to the uniform
  97391. * @return the material itself allowing "fluent" like uniform updates
  97392. */
  97393. setFloat(name: string, value: number): ShaderMaterial;
  97394. /**
  97395. * Set a int in the shader.
  97396. * @param name Define the name of the uniform as defined in the shader
  97397. * @param value Define the value to give to the uniform
  97398. * @return the material itself allowing "fluent" like uniform updates
  97399. */
  97400. setInt(name: string, value: number): ShaderMaterial;
  97401. /**
  97402. * Set an array of floats in the shader.
  97403. * @param name Define the name of the uniform as defined in the shader
  97404. * @param value Define the value to give to the uniform
  97405. * @return the material itself allowing "fluent" like uniform updates
  97406. */
  97407. setFloats(name: string, value: number[]): ShaderMaterial;
  97408. /**
  97409. * Set a vec3 in the shader from a Color3.
  97410. * @param name Define the name of the uniform as defined in the shader
  97411. * @param value Define the value to give to the uniform
  97412. * @return the material itself allowing "fluent" like uniform updates
  97413. */
  97414. setColor3(name: string, value: Color3): ShaderMaterial;
  97415. /**
  97416. * Set a vec3 array in the shader from a Color3 array.
  97417. * @param name Define the name of the uniform as defined in the shader
  97418. * @param value Define the value to give to the uniform
  97419. * @return the material itself allowing "fluent" like uniform updates
  97420. */
  97421. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97422. /**
  97423. * Set a vec4 in the shader from a Color4.
  97424. * @param name Define the name of the uniform as defined in the shader
  97425. * @param value Define the value to give to the uniform
  97426. * @return the material itself allowing "fluent" like uniform updates
  97427. */
  97428. setColor4(name: string, value: Color4): ShaderMaterial;
  97429. /**
  97430. * Set a vec4 array in the shader from a Color4 array.
  97431. * @param name Define the name of the uniform as defined in the shader
  97432. * @param value Define the value to give to the uniform
  97433. * @return the material itself allowing "fluent" like uniform updates
  97434. */
  97435. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97436. /**
  97437. * Set a vec2 in the shader from a Vector2.
  97438. * @param name Define the name of the uniform as defined in the shader
  97439. * @param value Define the value to give to the uniform
  97440. * @return the material itself allowing "fluent" like uniform updates
  97441. */
  97442. setVector2(name: string, value: Vector2): ShaderMaterial;
  97443. /**
  97444. * Set a vec3 in the shader from a Vector3.
  97445. * @param name Define the name of the uniform as defined in the shader
  97446. * @param value Define the value to give to the uniform
  97447. * @return the material itself allowing "fluent" like uniform updates
  97448. */
  97449. setVector3(name: string, value: Vector3): ShaderMaterial;
  97450. /**
  97451. * Set a vec4 in the shader from a Vector4.
  97452. * @param name Define the name of the uniform as defined in the shader
  97453. * @param value Define the value to give to the uniform
  97454. * @return the material itself allowing "fluent" like uniform updates
  97455. */
  97456. setVector4(name: string, value: Vector4): ShaderMaterial;
  97457. /**
  97458. * Set a mat4 in the shader from a Matrix.
  97459. * @param name Define the name of the uniform as defined in the shader
  97460. * @param value Define the value to give to the uniform
  97461. * @return the material itself allowing "fluent" like uniform updates
  97462. */
  97463. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97464. /**
  97465. * Set a float32Array in the shader from a matrix array.
  97466. * @param name Define the name of the uniform as defined in the shader
  97467. * @param value Define the value to give to the uniform
  97468. * @return the material itself allowing "fluent" like uniform updates
  97469. */
  97470. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97471. /**
  97472. * Set a mat3 in the shader from a Float32Array.
  97473. * @param name Define the name of the uniform as defined in the shader
  97474. * @param value Define the value to give to the uniform
  97475. * @return the material itself allowing "fluent" like uniform updates
  97476. */
  97477. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97478. /**
  97479. * Set a mat2 in the shader from a Float32Array.
  97480. * @param name Define the name of the uniform as defined in the shader
  97481. * @param value Define the value to give to the uniform
  97482. * @return the material itself allowing "fluent" like uniform updates
  97483. */
  97484. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97485. /**
  97486. * Set a vec2 array in the shader from a number array.
  97487. * @param name Define the name of the uniform as defined in the shader
  97488. * @param value Define the value to give to the uniform
  97489. * @return the material itself allowing "fluent" like uniform updates
  97490. */
  97491. setArray2(name: string, value: number[]): ShaderMaterial;
  97492. /**
  97493. * Set a vec3 array in the shader from a number array.
  97494. * @param name Define the name of the uniform as defined in the shader
  97495. * @param value Define the value to give to the uniform
  97496. * @return the material itself allowing "fluent" like uniform updates
  97497. */
  97498. setArray3(name: string, value: number[]): ShaderMaterial;
  97499. /**
  97500. * Set a vec4 array in the shader from a number array.
  97501. * @param name Define the name of the uniform as defined in the shader
  97502. * @param value Define the value to give to the uniform
  97503. * @return the material itself allowing "fluent" like uniform updates
  97504. */
  97505. setArray4(name: string, value: number[]): ShaderMaterial;
  97506. private _checkCache;
  97507. /**
  97508. * Specifies that the submesh is ready to be used
  97509. * @param mesh defines the mesh to check
  97510. * @param subMesh defines which submesh to check
  97511. * @param useInstances specifies that instances should be used
  97512. * @returns a boolean indicating that the submesh is ready or not
  97513. */
  97514. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97515. /**
  97516. * Checks if the material is ready to render the requested mesh
  97517. * @param mesh Define the mesh to render
  97518. * @param useInstances Define whether or not the material is used with instances
  97519. * @returns true if ready, otherwise false
  97520. */
  97521. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97522. /**
  97523. * Binds the world matrix to the material
  97524. * @param world defines the world transformation matrix
  97525. * @param effectOverride - If provided, use this effect instead of internal effect
  97526. */
  97527. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97528. /**
  97529. * Binds the submesh to this material by preparing the effect and shader to draw
  97530. * @param world defines the world transformation matrix
  97531. * @param mesh defines the mesh containing the submesh
  97532. * @param subMesh defines the submesh to bind the material to
  97533. */
  97534. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97535. /**
  97536. * Binds the material to the mesh
  97537. * @param world defines the world transformation matrix
  97538. * @param mesh defines the mesh to bind the material to
  97539. * @param effectOverride - If provided, use this effect instead of internal effect
  97540. */
  97541. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97542. protected _afterBind(mesh?: Mesh): void;
  97543. /**
  97544. * Gets the active textures from the material
  97545. * @returns an array of textures
  97546. */
  97547. getActiveTextures(): BaseTexture[];
  97548. /**
  97549. * Specifies if the material uses a texture
  97550. * @param texture defines the texture to check against the material
  97551. * @returns a boolean specifying if the material uses the texture
  97552. */
  97553. hasTexture(texture: BaseTexture): boolean;
  97554. /**
  97555. * Makes a duplicate of the material, and gives it a new name
  97556. * @param name defines the new name for the duplicated material
  97557. * @returns the cloned material
  97558. */
  97559. clone(name: string): ShaderMaterial;
  97560. /**
  97561. * Disposes the material
  97562. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97563. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97564. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97565. */
  97566. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97567. /**
  97568. * Serializes this material in a JSON representation
  97569. * @returns the serialized material object
  97570. */
  97571. serialize(): any;
  97572. /**
  97573. * Creates a shader material from parsed shader material data
  97574. * @param source defines the JSON represnetation of the material
  97575. * @param scene defines the hosting scene
  97576. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97577. * @returns a new material
  97578. */
  97579. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97580. /**
  97581. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97582. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97583. * @param url defines the url to load from
  97584. * @param scene defines the hosting scene
  97585. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97586. * @returns a promise that will resolve to the new ShaderMaterial
  97587. */
  97588. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97589. /**
  97590. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97591. * @param snippetId defines the snippet to load
  97592. * @param scene defines the hosting scene
  97593. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97594. * @returns a promise that will resolve to the new ShaderMaterial
  97595. */
  97596. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97597. }
  97598. }
  97599. declare module BABYLON {
  97600. /** @hidden */
  97601. export var colorPixelShader: {
  97602. name: string;
  97603. shader: string;
  97604. };
  97605. }
  97606. declare module BABYLON {
  97607. /** @hidden */
  97608. export var colorVertexShader: {
  97609. name: string;
  97610. shader: string;
  97611. };
  97612. }
  97613. declare module BABYLON {
  97614. /**
  97615. * Line mesh
  97616. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97617. */
  97618. export class LinesMesh extends Mesh {
  97619. /**
  97620. * If vertex color should be applied to the mesh
  97621. */
  97622. readonly useVertexColor?: boolean | undefined;
  97623. /**
  97624. * If vertex alpha should be applied to the mesh
  97625. */
  97626. readonly useVertexAlpha?: boolean | undefined;
  97627. /**
  97628. * Color of the line (Default: White)
  97629. */
  97630. color: Color3;
  97631. /**
  97632. * Alpha of the line (Default: 1)
  97633. */
  97634. alpha: number;
  97635. /**
  97636. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97637. * This margin is expressed in world space coordinates, so its value may vary.
  97638. * Default value is 0.1
  97639. */
  97640. intersectionThreshold: number;
  97641. private _colorShader;
  97642. private color4;
  97643. /**
  97644. * Creates a new LinesMesh
  97645. * @param name defines the name
  97646. * @param scene defines the hosting scene
  97647. * @param parent defines the parent mesh if any
  97648. * @param source defines the optional source LinesMesh used to clone data from
  97649. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97650. * When false, achieved by calling a clone(), also passing False.
  97651. * This will make creation of children, recursive.
  97652. * @param useVertexColor defines if this LinesMesh supports vertex color
  97653. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97654. */
  97655. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97656. /**
  97657. * If vertex color should be applied to the mesh
  97658. */
  97659. useVertexColor?: boolean | undefined,
  97660. /**
  97661. * If vertex alpha should be applied to the mesh
  97662. */
  97663. useVertexAlpha?: boolean | undefined);
  97664. private _addClipPlaneDefine;
  97665. private _removeClipPlaneDefine;
  97666. isReady(): boolean;
  97667. /**
  97668. * Returns the string "LineMesh"
  97669. */
  97670. getClassName(): string;
  97671. /**
  97672. * @hidden
  97673. */
  97674. get material(): Material;
  97675. /**
  97676. * @hidden
  97677. */
  97678. set material(value: Material);
  97679. /**
  97680. * @hidden
  97681. */
  97682. get checkCollisions(): boolean;
  97683. /** @hidden */
  97684. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97685. /** @hidden */
  97686. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97687. /**
  97688. * Disposes of the line mesh
  97689. * @param doNotRecurse If children should be disposed
  97690. */
  97691. dispose(doNotRecurse?: boolean): void;
  97692. /**
  97693. * Returns a new LineMesh object cloned from the current one.
  97694. */
  97695. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97696. /**
  97697. * Creates a new InstancedLinesMesh object from the mesh model.
  97698. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97699. * @param name defines the name of the new instance
  97700. * @returns a new InstancedLinesMesh
  97701. */
  97702. createInstance(name: string): InstancedLinesMesh;
  97703. }
  97704. /**
  97705. * Creates an instance based on a source LinesMesh
  97706. */
  97707. export class InstancedLinesMesh extends InstancedMesh {
  97708. /**
  97709. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97710. * This margin is expressed in world space coordinates, so its value may vary.
  97711. * Initilized with the intersectionThreshold value of the source LinesMesh
  97712. */
  97713. intersectionThreshold: number;
  97714. constructor(name: string, source: LinesMesh);
  97715. /**
  97716. * Returns the string "InstancedLinesMesh".
  97717. */
  97718. getClassName(): string;
  97719. }
  97720. }
  97721. declare module BABYLON {
  97722. /** @hidden */
  97723. export var linePixelShader: {
  97724. name: string;
  97725. shader: string;
  97726. };
  97727. }
  97728. declare module BABYLON {
  97729. /** @hidden */
  97730. export var lineVertexShader: {
  97731. name: string;
  97732. shader: string;
  97733. };
  97734. }
  97735. declare module BABYLON {
  97736. interface Scene {
  97737. /** @hidden */
  97738. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97739. }
  97740. interface AbstractMesh {
  97741. /**
  97742. * Gets the edgesRenderer associated with the mesh
  97743. */
  97744. edgesRenderer: Nullable<EdgesRenderer>;
  97745. }
  97746. interface LinesMesh {
  97747. /**
  97748. * Enables the edge rendering mode on the mesh.
  97749. * This mode makes the mesh edges visible
  97750. * @param epsilon defines the maximal distance between two angles to detect a face
  97751. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97752. * @returns the currentAbstractMesh
  97753. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97754. */
  97755. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97756. }
  97757. interface InstancedLinesMesh {
  97758. /**
  97759. * Enables the edge rendering mode on the mesh.
  97760. * This mode makes the mesh edges visible
  97761. * @param epsilon defines the maximal distance between two angles to detect a face
  97762. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97763. * @returns the current InstancedLinesMesh
  97764. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97765. */
  97766. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97767. }
  97768. /**
  97769. * Defines the minimum contract an Edges renderer should follow.
  97770. */
  97771. export interface IEdgesRenderer extends IDisposable {
  97772. /**
  97773. * Gets or sets a boolean indicating if the edgesRenderer is active
  97774. */
  97775. isEnabled: boolean;
  97776. /**
  97777. * Renders the edges of the attached mesh,
  97778. */
  97779. render(): void;
  97780. /**
  97781. * Checks wether or not the edges renderer is ready to render.
  97782. * @return true if ready, otherwise false.
  97783. */
  97784. isReady(): boolean;
  97785. /**
  97786. * List of instances to render in case the source mesh has instances
  97787. */
  97788. customInstances: SmartArray<Matrix>;
  97789. }
  97790. /**
  97791. * Defines the additional options of the edges renderer
  97792. */
  97793. export interface IEdgesRendererOptions {
  97794. /**
  97795. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97796. * If not defined, the default value is true
  97797. */
  97798. useAlternateEdgeFinder?: boolean;
  97799. /**
  97800. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97801. * If not defined, the default value is true.
  97802. * 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)
  97803. * This option is used only if useAlternateEdgeFinder = true
  97804. */
  97805. useFastVertexMerger?: boolean;
  97806. /**
  97807. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97808. * The default value is 1e-6
  97809. * This option is used only if useAlternateEdgeFinder = true
  97810. */
  97811. epsilonVertexMerge?: number;
  97812. /**
  97813. * 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
  97814. * 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.
  97815. * This option is used only if useAlternateEdgeFinder = true
  97816. */
  97817. applyTessellation?: boolean;
  97818. /**
  97819. * 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
  97820. * The default value is 1e-6
  97821. * This option is used only if useAlternateEdgeFinder = true
  97822. */
  97823. epsilonVertexAligned?: number;
  97824. }
  97825. /**
  97826. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97827. */
  97828. export class EdgesRenderer implements IEdgesRenderer {
  97829. /**
  97830. * Define the size of the edges with an orthographic camera
  97831. */
  97832. edgesWidthScalerForOrthographic: number;
  97833. /**
  97834. * Define the size of the edges with a perspective camera
  97835. */
  97836. edgesWidthScalerForPerspective: number;
  97837. protected _source: AbstractMesh;
  97838. protected _linesPositions: number[];
  97839. protected _linesNormals: number[];
  97840. protected _linesIndices: number[];
  97841. protected _epsilon: number;
  97842. protected _indicesCount: number;
  97843. protected _lineShader: ShaderMaterial;
  97844. protected _ib: DataBuffer;
  97845. protected _buffers: {
  97846. [key: string]: Nullable<VertexBuffer>;
  97847. };
  97848. protected _buffersForInstances: {
  97849. [key: string]: Nullable<VertexBuffer>;
  97850. };
  97851. protected _checkVerticesInsteadOfIndices: boolean;
  97852. protected _options: Nullable<IEdgesRendererOptions>;
  97853. private _meshRebuildObserver;
  97854. private _meshDisposeObserver;
  97855. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97856. isEnabled: boolean;
  97857. /**
  97858. * List of instances to render in case the source mesh has instances
  97859. */
  97860. customInstances: SmartArray<Matrix>;
  97861. private static GetShader;
  97862. /**
  97863. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97864. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97865. * @param source Mesh used to create edges
  97866. * @param epsilon sum of angles in adjacency to check for edge
  97867. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97868. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97869. * @param options The options to apply when generating the edges
  97870. */
  97871. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97872. protected _prepareRessources(): void;
  97873. /** @hidden */
  97874. _rebuild(): void;
  97875. /**
  97876. * Releases the required resources for the edges renderer
  97877. */
  97878. dispose(): void;
  97879. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97880. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97881. /**
  97882. * Checks if the pair of p0 and p1 is en edge
  97883. * @param faceIndex
  97884. * @param edge
  97885. * @param faceNormals
  97886. * @param p0
  97887. * @param p1
  97888. * @private
  97889. */
  97890. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97891. /**
  97892. * push line into the position, normal and index buffer
  97893. * @protected
  97894. */
  97895. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97896. /**
  97897. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97898. */
  97899. private _tessellateTriangle;
  97900. private _generateEdgesLinesAlternate;
  97901. /**
  97902. * Generates lines edges from adjacencjes
  97903. * @private
  97904. */
  97905. _generateEdgesLines(): void;
  97906. /**
  97907. * Checks wether or not the edges renderer is ready to render.
  97908. * @return true if ready, otherwise false.
  97909. */
  97910. isReady(): boolean;
  97911. /**
  97912. * Renders the edges of the attached mesh,
  97913. */
  97914. render(): void;
  97915. }
  97916. /**
  97917. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97918. */
  97919. export class LineEdgesRenderer extends EdgesRenderer {
  97920. /**
  97921. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97922. * @param source LineMesh used to generate edges
  97923. * @param epsilon not important (specified angle for edge detection)
  97924. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97925. */
  97926. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97927. /**
  97928. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97929. */
  97930. _generateEdgesLines(): void;
  97931. }
  97932. }
  97933. declare module BABYLON {
  97934. /**
  97935. * This represents the object necessary to create a rendering group.
  97936. * This is exclusively used and created by the rendering manager.
  97937. * To modify the behavior, you use the available helpers in your scene or meshes.
  97938. * @hidden
  97939. */
  97940. export class RenderingGroup {
  97941. index: number;
  97942. private static _zeroVector;
  97943. private _scene;
  97944. private _opaqueSubMeshes;
  97945. private _transparentSubMeshes;
  97946. private _alphaTestSubMeshes;
  97947. private _depthOnlySubMeshes;
  97948. private _particleSystems;
  97949. private _spriteManagers;
  97950. private _opaqueSortCompareFn;
  97951. private _alphaTestSortCompareFn;
  97952. private _transparentSortCompareFn;
  97953. private _renderOpaque;
  97954. private _renderAlphaTest;
  97955. private _renderTransparent;
  97956. /** @hidden */
  97957. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97958. onBeforeTransparentRendering: () => void;
  97959. /**
  97960. * Set the opaque sort comparison function.
  97961. * If null the sub meshes will be render in the order they were created
  97962. */
  97963. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97964. /**
  97965. * Set the alpha test sort comparison function.
  97966. * If null the sub meshes will be render in the order they were created
  97967. */
  97968. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97969. /**
  97970. * Set the transparent sort comparison function.
  97971. * If null the sub meshes will be render in the order they were created
  97972. */
  97973. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97974. /**
  97975. * Creates a new rendering group.
  97976. * @param index The rendering group index
  97977. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97978. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97979. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97980. */
  97981. 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>);
  97982. /**
  97983. * Render all the sub meshes contained in the group.
  97984. * @param customRenderFunction Used to override the default render behaviour of the group.
  97985. * @returns true if rendered some submeshes.
  97986. */
  97987. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97988. /**
  97989. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97990. * @param subMeshes The submeshes to render
  97991. */
  97992. private renderOpaqueSorted;
  97993. /**
  97994. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97995. * @param subMeshes The submeshes to render
  97996. */
  97997. private renderAlphaTestSorted;
  97998. /**
  97999. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  98000. * @param subMeshes The submeshes to render
  98001. */
  98002. private renderTransparentSorted;
  98003. /**
  98004. * Renders the submeshes in a specified order.
  98005. * @param subMeshes The submeshes to sort before render
  98006. * @param sortCompareFn The comparison function use to sort
  98007. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  98008. * @param transparent Specifies to activate blending if true
  98009. */
  98010. private static renderSorted;
  98011. /**
  98012. * Renders the submeshes in the order they were dispatched (no sort applied).
  98013. * @param subMeshes The submeshes to render
  98014. */
  98015. private static renderUnsorted;
  98016. /**
  98017. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98018. * are rendered back to front if in the same alpha index.
  98019. *
  98020. * @param a The first submesh
  98021. * @param b The second submesh
  98022. * @returns The result of the comparison
  98023. */
  98024. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  98025. /**
  98026. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98027. * are rendered back to front.
  98028. *
  98029. * @param a The first submesh
  98030. * @param b The second submesh
  98031. * @returns The result of the comparison
  98032. */
  98033. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  98034. /**
  98035. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98036. * are rendered front to back (prevent overdraw).
  98037. *
  98038. * @param a The first submesh
  98039. * @param b The second submesh
  98040. * @returns The result of the comparison
  98041. */
  98042. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  98043. /**
  98044. * Resets the different lists of submeshes to prepare a new frame.
  98045. */
  98046. prepare(): void;
  98047. dispose(): void;
  98048. /**
  98049. * Inserts the submesh in its correct queue depending on its material.
  98050. * @param subMesh The submesh to dispatch
  98051. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98052. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98053. */
  98054. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98055. dispatchSprites(spriteManager: ISpriteManager): void;
  98056. dispatchParticles(particleSystem: IParticleSystem): void;
  98057. private _renderParticles;
  98058. private _renderSprites;
  98059. }
  98060. }
  98061. declare module BABYLON {
  98062. /**
  98063. * Interface describing the different options available in the rendering manager
  98064. * regarding Auto Clear between groups.
  98065. */
  98066. export interface IRenderingManagerAutoClearSetup {
  98067. /**
  98068. * Defines whether or not autoclear is enable.
  98069. */
  98070. autoClear: boolean;
  98071. /**
  98072. * Defines whether or not to autoclear the depth buffer.
  98073. */
  98074. depth: boolean;
  98075. /**
  98076. * Defines whether or not to autoclear the stencil buffer.
  98077. */
  98078. stencil: boolean;
  98079. }
  98080. /**
  98081. * This class is used by the onRenderingGroupObservable
  98082. */
  98083. export class RenderingGroupInfo {
  98084. /**
  98085. * The Scene that being rendered
  98086. */
  98087. scene: Scene;
  98088. /**
  98089. * The camera currently used for the rendering pass
  98090. */
  98091. camera: Nullable<Camera>;
  98092. /**
  98093. * The ID of the renderingGroup being processed
  98094. */
  98095. renderingGroupId: number;
  98096. }
  98097. /**
  98098. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98099. * It is enable to manage the different groups as well as the different necessary sort functions.
  98100. * This should not be used directly aside of the few static configurations
  98101. */
  98102. export class RenderingManager {
  98103. /**
  98104. * The max id used for rendering groups (not included)
  98105. */
  98106. static MAX_RENDERINGGROUPS: number;
  98107. /**
  98108. * The min id used for rendering groups (included)
  98109. */
  98110. static MIN_RENDERINGGROUPS: number;
  98111. /**
  98112. * Used to globally prevent autoclearing scenes.
  98113. */
  98114. static AUTOCLEAR: boolean;
  98115. /**
  98116. * @hidden
  98117. */
  98118. _useSceneAutoClearSetup: boolean;
  98119. private _scene;
  98120. private _renderingGroups;
  98121. private _depthStencilBufferAlreadyCleaned;
  98122. private _autoClearDepthStencil;
  98123. private _customOpaqueSortCompareFn;
  98124. private _customAlphaTestSortCompareFn;
  98125. private _customTransparentSortCompareFn;
  98126. private _renderingGroupInfo;
  98127. /**
  98128. * Instantiates a new rendering group for a particular scene
  98129. * @param scene Defines the scene the groups belongs to
  98130. */
  98131. constructor(scene: Scene);
  98132. private _clearDepthStencilBuffer;
  98133. /**
  98134. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98135. * @hidden
  98136. */
  98137. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98138. /**
  98139. * Resets the different information of the group to prepare a new frame
  98140. * @hidden
  98141. */
  98142. reset(): void;
  98143. /**
  98144. * Dispose and release the group and its associated resources.
  98145. * @hidden
  98146. */
  98147. dispose(): void;
  98148. /**
  98149. * Clear the info related to rendering groups preventing retention points during dispose.
  98150. */
  98151. freeRenderingGroups(): void;
  98152. private _prepareRenderingGroup;
  98153. /**
  98154. * Add a sprite manager to the rendering manager in order to render it this frame.
  98155. * @param spriteManager Define the sprite manager to render
  98156. */
  98157. dispatchSprites(spriteManager: ISpriteManager): void;
  98158. /**
  98159. * Add a particle system to the rendering manager in order to render it this frame.
  98160. * @param particleSystem Define the particle system to render
  98161. */
  98162. dispatchParticles(particleSystem: IParticleSystem): void;
  98163. /**
  98164. * Add a submesh to the manager in order to render it this frame
  98165. * @param subMesh The submesh to dispatch
  98166. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98167. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98168. */
  98169. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98170. /**
  98171. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98172. * This allowed control for front to back rendering or reversly depending of the special needs.
  98173. *
  98174. * @param renderingGroupId The rendering group id corresponding to its index
  98175. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98176. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98177. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98178. */
  98179. 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;
  98180. /**
  98181. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98182. *
  98183. * @param renderingGroupId The rendering group id corresponding to its index
  98184. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98185. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98186. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98187. */
  98188. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98189. /**
  98190. * Gets the current auto clear configuration for one rendering group of the rendering
  98191. * manager.
  98192. * @param index the rendering group index to get the information for
  98193. * @returns The auto clear setup for the requested rendering group
  98194. */
  98195. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98196. }
  98197. }
  98198. declare module BABYLON {
  98199. /**
  98200. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98201. */
  98202. export interface ICustomShaderOptions {
  98203. /**
  98204. * Gets or sets the custom shader name to use
  98205. */
  98206. shaderName: string;
  98207. /**
  98208. * The list of attribute names used in the shader
  98209. */
  98210. attributes?: string[];
  98211. /**
  98212. * The list of unifrom names used in the shader
  98213. */
  98214. uniforms?: string[];
  98215. /**
  98216. * The list of sampler names used in the shader
  98217. */
  98218. samplers?: string[];
  98219. /**
  98220. * The list of defines used in the shader
  98221. */
  98222. defines?: string[];
  98223. }
  98224. /**
  98225. * Interface to implement to create a shadow generator compatible with BJS.
  98226. */
  98227. export interface IShadowGenerator {
  98228. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98229. id: string;
  98230. /**
  98231. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98232. * @returns The render target texture if present otherwise, null
  98233. */
  98234. getShadowMap(): Nullable<RenderTargetTexture>;
  98235. /**
  98236. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98237. * @param subMesh The submesh we want to render in the shadow map
  98238. * @param useInstances Defines wether will draw in the map using instances
  98239. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98240. * @returns true if ready otherwise, false
  98241. */
  98242. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98243. /**
  98244. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98245. * @param defines Defines of the material we want to update
  98246. * @param lightIndex Index of the light in the enabled light list of the material
  98247. */
  98248. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98249. /**
  98250. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98251. * defined in the generator but impacting the effect).
  98252. * It implies the unifroms available on the materials are the standard BJS ones.
  98253. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98254. * @param effect The effect we are binfing the information for
  98255. */
  98256. bindShadowLight(lightIndex: string, effect: Effect): void;
  98257. /**
  98258. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98259. * (eq to shadow prjection matrix * light transform matrix)
  98260. * @returns The transform matrix used to create the shadow map
  98261. */
  98262. getTransformMatrix(): Matrix;
  98263. /**
  98264. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98265. * Cube and 2D textures for instance.
  98266. */
  98267. recreateShadowMap(): void;
  98268. /**
  98269. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98270. * @param onCompiled Callback triggered at the and of the effects compilation
  98271. * @param options Sets of optional options forcing the compilation with different modes
  98272. */
  98273. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98274. useInstances: boolean;
  98275. }>): void;
  98276. /**
  98277. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98278. * @param options Sets of optional options forcing the compilation with different modes
  98279. * @returns A promise that resolves when the compilation completes
  98280. */
  98281. forceCompilationAsync(options?: Partial<{
  98282. useInstances: boolean;
  98283. }>): Promise<void>;
  98284. /**
  98285. * Serializes the shadow generator setup to a json object.
  98286. * @returns The serialized JSON object
  98287. */
  98288. serialize(): any;
  98289. /**
  98290. * Disposes the Shadow map and related Textures and effects.
  98291. */
  98292. dispose(): void;
  98293. }
  98294. /**
  98295. * Default implementation IShadowGenerator.
  98296. * This is the main object responsible of generating shadows in the framework.
  98297. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98298. */
  98299. export class ShadowGenerator implements IShadowGenerator {
  98300. /**
  98301. * Name of the shadow generator class
  98302. */
  98303. static CLASSNAME: string;
  98304. /**
  98305. * Shadow generator mode None: no filtering applied.
  98306. */
  98307. static readonly FILTER_NONE: number;
  98308. /**
  98309. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98310. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98311. */
  98312. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98313. /**
  98314. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98315. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98316. */
  98317. static readonly FILTER_POISSONSAMPLING: number;
  98318. /**
  98319. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98320. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98321. */
  98322. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98323. /**
  98324. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98325. * edge artifacts on steep falloff.
  98326. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98327. */
  98328. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98329. /**
  98330. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98331. * edge artifacts on steep falloff.
  98332. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98333. */
  98334. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98335. /**
  98336. * Shadow generator mode PCF: Percentage Closer Filtering
  98337. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98338. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98339. */
  98340. static readonly FILTER_PCF: number;
  98341. /**
  98342. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98343. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98344. * Contact Hardening
  98345. */
  98346. static readonly FILTER_PCSS: number;
  98347. /**
  98348. * Reserved for PCF and PCSS
  98349. * Highest Quality.
  98350. *
  98351. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98352. *
  98353. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98354. */
  98355. static readonly QUALITY_HIGH: number;
  98356. /**
  98357. * Reserved for PCF and PCSS
  98358. * Good tradeoff for quality/perf cross devices
  98359. *
  98360. * Execute PCF on a 3*3 kernel.
  98361. *
  98362. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98363. */
  98364. static readonly QUALITY_MEDIUM: number;
  98365. /**
  98366. * Reserved for PCF and PCSS
  98367. * The lowest quality but the fastest.
  98368. *
  98369. * Execute PCF on a 1*1 kernel.
  98370. *
  98371. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98372. */
  98373. static readonly QUALITY_LOW: number;
  98374. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98375. id: string;
  98376. /** Gets or sets the custom shader name to use */
  98377. customShaderOptions: ICustomShaderOptions;
  98378. /**
  98379. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98380. */
  98381. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98382. /**
  98383. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98384. */
  98385. onAfterShadowMapRenderObservable: Observable<Effect>;
  98386. /**
  98387. * Observable triggered before a mesh is rendered in the shadow map.
  98388. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98389. */
  98390. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98391. /**
  98392. * Observable triggered after a mesh is rendered in the shadow map.
  98393. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98394. */
  98395. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98396. protected _bias: number;
  98397. /**
  98398. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98399. */
  98400. get bias(): number;
  98401. /**
  98402. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98403. */
  98404. set bias(bias: number);
  98405. protected _normalBias: number;
  98406. /**
  98407. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98408. */
  98409. get normalBias(): number;
  98410. /**
  98411. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98412. */
  98413. set normalBias(normalBias: number);
  98414. protected _blurBoxOffset: number;
  98415. /**
  98416. * Gets the blur box offset: offset applied during the blur pass.
  98417. * Only useful if useKernelBlur = false
  98418. */
  98419. get blurBoxOffset(): number;
  98420. /**
  98421. * Sets the blur box offset: offset applied during the blur pass.
  98422. * Only useful if useKernelBlur = false
  98423. */
  98424. set blurBoxOffset(value: number);
  98425. protected _blurScale: number;
  98426. /**
  98427. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98428. * 2 means half of the size.
  98429. */
  98430. get blurScale(): number;
  98431. /**
  98432. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98433. * 2 means half of the size.
  98434. */
  98435. set blurScale(value: number);
  98436. protected _blurKernel: number;
  98437. /**
  98438. * Gets the blur kernel: kernel size of the blur pass.
  98439. * Only useful if useKernelBlur = true
  98440. */
  98441. get blurKernel(): number;
  98442. /**
  98443. * Sets the blur kernel: kernel size of the blur pass.
  98444. * Only useful if useKernelBlur = true
  98445. */
  98446. set blurKernel(value: number);
  98447. protected _useKernelBlur: boolean;
  98448. /**
  98449. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98450. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98451. */
  98452. get useKernelBlur(): boolean;
  98453. /**
  98454. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98455. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98456. */
  98457. set useKernelBlur(value: boolean);
  98458. protected _depthScale: number;
  98459. /**
  98460. * Gets the depth scale used in ESM mode.
  98461. */
  98462. get depthScale(): number;
  98463. /**
  98464. * Sets the depth scale used in ESM mode.
  98465. * This can override the scale stored on the light.
  98466. */
  98467. set depthScale(value: number);
  98468. protected _validateFilter(filter: number): number;
  98469. protected _filter: number;
  98470. /**
  98471. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98472. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98473. */
  98474. get filter(): number;
  98475. /**
  98476. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98477. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98478. */
  98479. set filter(value: number);
  98480. /**
  98481. * Gets if the current filter is set to Poisson Sampling.
  98482. */
  98483. get usePoissonSampling(): boolean;
  98484. /**
  98485. * Sets the current filter to Poisson Sampling.
  98486. */
  98487. set usePoissonSampling(value: boolean);
  98488. /**
  98489. * Gets if the current filter is set to ESM.
  98490. */
  98491. get useExponentialShadowMap(): boolean;
  98492. /**
  98493. * Sets the current filter is to ESM.
  98494. */
  98495. set useExponentialShadowMap(value: boolean);
  98496. /**
  98497. * Gets if the current filter is set to filtered ESM.
  98498. */
  98499. get useBlurExponentialShadowMap(): boolean;
  98500. /**
  98501. * Gets if the current filter is set to filtered ESM.
  98502. */
  98503. set useBlurExponentialShadowMap(value: boolean);
  98504. /**
  98505. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98506. * exponential to prevent steep falloff artifacts).
  98507. */
  98508. get useCloseExponentialShadowMap(): boolean;
  98509. /**
  98510. * Sets the current filter to "close ESM" (using the inverse of the
  98511. * exponential to prevent steep falloff artifacts).
  98512. */
  98513. set useCloseExponentialShadowMap(value: boolean);
  98514. /**
  98515. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98516. * exponential to prevent steep falloff artifacts).
  98517. */
  98518. get useBlurCloseExponentialShadowMap(): boolean;
  98519. /**
  98520. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98521. * exponential to prevent steep falloff artifacts).
  98522. */
  98523. set useBlurCloseExponentialShadowMap(value: boolean);
  98524. /**
  98525. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98526. */
  98527. get usePercentageCloserFiltering(): boolean;
  98528. /**
  98529. * Sets the current filter to "PCF" (percentage closer filtering).
  98530. */
  98531. set usePercentageCloserFiltering(value: boolean);
  98532. protected _filteringQuality: number;
  98533. /**
  98534. * Gets the PCF or PCSS Quality.
  98535. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98536. */
  98537. get filteringQuality(): number;
  98538. /**
  98539. * Sets the PCF or PCSS Quality.
  98540. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98541. */
  98542. set filteringQuality(filteringQuality: number);
  98543. /**
  98544. * Gets if the current filter is set to "PCSS" (contact hardening).
  98545. */
  98546. get useContactHardeningShadow(): boolean;
  98547. /**
  98548. * Sets the current filter to "PCSS" (contact hardening).
  98549. */
  98550. set useContactHardeningShadow(value: boolean);
  98551. protected _contactHardeningLightSizeUVRatio: number;
  98552. /**
  98553. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98554. * Using a ratio helps keeping shape stability independently of the map size.
  98555. *
  98556. * It does not account for the light projection as it was having too much
  98557. * instability during the light setup or during light position changes.
  98558. *
  98559. * Only valid if useContactHardeningShadow is true.
  98560. */
  98561. get contactHardeningLightSizeUVRatio(): number;
  98562. /**
  98563. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98564. * Using a ratio helps keeping shape stability independently of the map size.
  98565. *
  98566. * It does not account for the light projection as it was having too much
  98567. * instability during the light setup or during light position changes.
  98568. *
  98569. * Only valid if useContactHardeningShadow is true.
  98570. */
  98571. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98572. protected _darkness: number;
  98573. /** Gets or sets the actual darkness of a shadow */
  98574. get darkness(): number;
  98575. set darkness(value: number);
  98576. /**
  98577. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98578. * 0 means strongest and 1 would means no shadow.
  98579. * @returns the darkness.
  98580. */
  98581. getDarkness(): number;
  98582. /**
  98583. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98584. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98585. * @returns the shadow generator allowing fluent coding.
  98586. */
  98587. setDarkness(darkness: number): ShadowGenerator;
  98588. protected _transparencyShadow: boolean;
  98589. /** Gets or sets the ability to have transparent shadow */
  98590. get transparencyShadow(): boolean;
  98591. set transparencyShadow(value: boolean);
  98592. /**
  98593. * Sets the ability to have transparent shadow (boolean).
  98594. * @param transparent True if transparent else False
  98595. * @returns the shadow generator allowing fluent coding
  98596. */
  98597. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98598. /**
  98599. * Enables or disables shadows with varying strength based on the transparency
  98600. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98601. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98602. * mesh.visibility * alphaTexture.a
  98603. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98604. */
  98605. enableSoftTransparentShadow: boolean;
  98606. protected _shadowMap: Nullable<RenderTargetTexture>;
  98607. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98608. /**
  98609. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98610. * @returns The render target texture if present otherwise, null
  98611. */
  98612. getShadowMap(): Nullable<RenderTargetTexture>;
  98613. /**
  98614. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98615. * @returns The render target texture if the shadow map is present otherwise, null
  98616. */
  98617. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98618. /**
  98619. * Gets the class name of that object
  98620. * @returns "ShadowGenerator"
  98621. */
  98622. getClassName(): string;
  98623. /**
  98624. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98625. * @param mesh Mesh to add
  98626. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98627. * @returns the Shadow Generator itself
  98628. */
  98629. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98630. /**
  98631. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98632. * @param mesh Mesh to remove
  98633. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98634. * @returns the Shadow Generator itself
  98635. */
  98636. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98637. /**
  98638. * Controls the extent to which the shadows fade out at the edge of the frustum
  98639. */
  98640. frustumEdgeFalloff: number;
  98641. protected _light: IShadowLight;
  98642. /**
  98643. * Returns the associated light object.
  98644. * @returns the light generating the shadow
  98645. */
  98646. getLight(): IShadowLight;
  98647. /**
  98648. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98649. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98650. * It might on the other hand introduce peter panning.
  98651. */
  98652. forceBackFacesOnly: boolean;
  98653. protected _scene: Scene;
  98654. protected _lightDirection: Vector3;
  98655. protected _effect: Effect;
  98656. protected _viewMatrix: Matrix;
  98657. protected _projectionMatrix: Matrix;
  98658. protected _transformMatrix: Matrix;
  98659. protected _cachedPosition: Vector3;
  98660. protected _cachedDirection: Vector3;
  98661. protected _cachedDefines: string;
  98662. protected _currentRenderID: number;
  98663. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98664. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98665. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98666. protected _blurPostProcesses: PostProcess[];
  98667. protected _mapSize: number;
  98668. protected _currentFaceIndex: number;
  98669. protected _currentFaceIndexCache: number;
  98670. protected _textureType: number;
  98671. protected _defaultTextureMatrix: Matrix;
  98672. protected _storedUniqueId: Nullable<number>;
  98673. /** @hidden */
  98674. static _SceneComponentInitialization: (scene: Scene) => void;
  98675. /**
  98676. * Gets or sets the size of the texture what stores the shadows
  98677. */
  98678. get mapSize(): number;
  98679. set mapSize(size: number);
  98680. /**
  98681. * Creates a ShadowGenerator object.
  98682. * A ShadowGenerator is the required tool to use the shadows.
  98683. * Each light casting shadows needs to use its own ShadowGenerator.
  98684. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98685. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98686. * @param light The light object generating the shadows.
  98687. * @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.
  98688. */
  98689. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98690. protected _initializeGenerator(): void;
  98691. protected _createTargetRenderTexture(): void;
  98692. protected _initializeShadowMap(): void;
  98693. protected _initializeBlurRTTAndPostProcesses(): void;
  98694. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98695. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98696. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98697. protected _applyFilterValues(): void;
  98698. /**
  98699. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98700. * @param onCompiled Callback triggered at the and of the effects compilation
  98701. * @param options Sets of optional options forcing the compilation with different modes
  98702. */
  98703. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98704. useInstances: boolean;
  98705. }>): void;
  98706. /**
  98707. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98708. * @param options Sets of optional options forcing the compilation with different modes
  98709. * @returns A promise that resolves when the compilation completes
  98710. */
  98711. forceCompilationAsync(options?: Partial<{
  98712. useInstances: boolean;
  98713. }>): Promise<void>;
  98714. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98715. private _prepareShadowDefines;
  98716. /**
  98717. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98718. * @param subMesh The submesh we want to render in the shadow map
  98719. * @param useInstances Defines wether will draw in the map using instances
  98720. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98721. * @returns true if ready otherwise, false
  98722. */
  98723. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98724. /**
  98725. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98726. * @param defines Defines of the material we want to update
  98727. * @param lightIndex Index of the light in the enabled light list of the material
  98728. */
  98729. prepareDefines(defines: any, lightIndex: number): void;
  98730. /**
  98731. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98732. * defined in the generator but impacting the effect).
  98733. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98734. * @param effect The effect we are binfing the information for
  98735. */
  98736. bindShadowLight(lightIndex: string, effect: Effect): void;
  98737. /**
  98738. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98739. * (eq to shadow prjection matrix * light transform matrix)
  98740. * @returns The transform matrix used to create the shadow map
  98741. */
  98742. getTransformMatrix(): Matrix;
  98743. /**
  98744. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98745. * Cube and 2D textures for instance.
  98746. */
  98747. recreateShadowMap(): void;
  98748. protected _disposeBlurPostProcesses(): void;
  98749. protected _disposeRTTandPostProcesses(): void;
  98750. /**
  98751. * Disposes the ShadowGenerator.
  98752. * Returns nothing.
  98753. */
  98754. dispose(): void;
  98755. /**
  98756. * Serializes the shadow generator setup to a json object.
  98757. * @returns The serialized JSON object
  98758. */
  98759. serialize(): any;
  98760. /**
  98761. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98762. * @param parsedShadowGenerator The JSON object to parse
  98763. * @param scene The scene to create the shadow map for
  98764. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98765. * @returns The parsed shadow generator
  98766. */
  98767. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98768. }
  98769. }
  98770. declare module BABYLON {
  98771. /**
  98772. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98773. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98774. * 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.
  98775. */
  98776. export abstract class Light extends Node {
  98777. /**
  98778. * Falloff Default: light is falling off following the material specification:
  98779. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98780. */
  98781. static readonly FALLOFF_DEFAULT: number;
  98782. /**
  98783. * Falloff Physical: light is falling off following the inverse squared distance law.
  98784. */
  98785. static readonly FALLOFF_PHYSICAL: number;
  98786. /**
  98787. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98788. * to enhance interoperability with other engines.
  98789. */
  98790. static readonly FALLOFF_GLTF: number;
  98791. /**
  98792. * Falloff Standard: light is falling off like in the standard material
  98793. * to enhance interoperability with other materials.
  98794. */
  98795. static readonly FALLOFF_STANDARD: number;
  98796. /**
  98797. * If every light affecting the material is in this lightmapMode,
  98798. * material.lightmapTexture adds or multiplies
  98799. * (depends on material.useLightmapAsShadowmap)
  98800. * after every other light calculations.
  98801. */
  98802. static readonly LIGHTMAP_DEFAULT: number;
  98803. /**
  98804. * material.lightmapTexture as only diffuse lighting from this light
  98805. * adds only specular lighting from this light
  98806. * adds dynamic shadows
  98807. */
  98808. static readonly LIGHTMAP_SPECULAR: number;
  98809. /**
  98810. * material.lightmapTexture as only lighting
  98811. * no light calculation from this light
  98812. * only adds dynamic shadows from this light
  98813. */
  98814. static readonly LIGHTMAP_SHADOWSONLY: number;
  98815. /**
  98816. * Each light type uses the default quantity according to its type:
  98817. * point/spot lights use luminous intensity
  98818. * directional lights use illuminance
  98819. */
  98820. static readonly INTENSITYMODE_AUTOMATIC: number;
  98821. /**
  98822. * lumen (lm)
  98823. */
  98824. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98825. /**
  98826. * candela (lm/sr)
  98827. */
  98828. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98829. /**
  98830. * lux (lm/m^2)
  98831. */
  98832. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98833. /**
  98834. * nit (cd/m^2)
  98835. */
  98836. static readonly INTENSITYMODE_LUMINANCE: number;
  98837. /**
  98838. * Light type const id of the point light.
  98839. */
  98840. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98841. /**
  98842. * Light type const id of the directional light.
  98843. */
  98844. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98845. /**
  98846. * Light type const id of the spot light.
  98847. */
  98848. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98849. /**
  98850. * Light type const id of the hemispheric light.
  98851. */
  98852. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98853. /**
  98854. * Diffuse gives the basic color to an object.
  98855. */
  98856. diffuse: Color3;
  98857. /**
  98858. * Specular produces a highlight color on an object.
  98859. * Note: This is note affecting PBR materials.
  98860. */
  98861. specular: Color3;
  98862. /**
  98863. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98864. * falling off base on range or angle.
  98865. * This can be set to any values in Light.FALLOFF_x.
  98866. *
  98867. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98868. * other types of materials.
  98869. */
  98870. falloffType: number;
  98871. /**
  98872. * Strength of the light.
  98873. * Note: By default it is define in the framework own unit.
  98874. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98875. */
  98876. intensity: number;
  98877. private _range;
  98878. protected _inverseSquaredRange: number;
  98879. /**
  98880. * Defines how far from the source the light is impacting in scene units.
  98881. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98882. */
  98883. get range(): number;
  98884. /**
  98885. * Defines how far from the source the light is impacting in scene units.
  98886. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98887. */
  98888. set range(value: number);
  98889. /**
  98890. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98891. * of light.
  98892. */
  98893. private _photometricScale;
  98894. private _intensityMode;
  98895. /**
  98896. * Gets the photometric scale used to interpret the intensity.
  98897. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98898. */
  98899. get intensityMode(): number;
  98900. /**
  98901. * Sets the photometric scale used to interpret the intensity.
  98902. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98903. */
  98904. set intensityMode(value: number);
  98905. private _radius;
  98906. /**
  98907. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98908. */
  98909. get radius(): number;
  98910. /**
  98911. * sets the light radius used by PBR Materials to simulate soft area lights.
  98912. */
  98913. set radius(value: number);
  98914. private _renderPriority;
  98915. /**
  98916. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98917. * exceeding the number allowed of the materials.
  98918. */
  98919. renderPriority: number;
  98920. private _shadowEnabled;
  98921. /**
  98922. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98923. * the current shadow generator.
  98924. */
  98925. get shadowEnabled(): boolean;
  98926. /**
  98927. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98928. * the current shadow generator.
  98929. */
  98930. set shadowEnabled(value: boolean);
  98931. private _includedOnlyMeshes;
  98932. /**
  98933. * Gets the only meshes impacted by this light.
  98934. */
  98935. get includedOnlyMeshes(): AbstractMesh[];
  98936. /**
  98937. * Sets the only meshes impacted by this light.
  98938. */
  98939. set includedOnlyMeshes(value: AbstractMesh[]);
  98940. private _excludedMeshes;
  98941. /**
  98942. * Gets the meshes not impacted by this light.
  98943. */
  98944. get excludedMeshes(): AbstractMesh[];
  98945. /**
  98946. * Sets the meshes not impacted by this light.
  98947. */
  98948. set excludedMeshes(value: AbstractMesh[]);
  98949. private _excludeWithLayerMask;
  98950. /**
  98951. * Gets the layer id use to find what meshes are not impacted by the light.
  98952. * Inactive if 0
  98953. */
  98954. get excludeWithLayerMask(): number;
  98955. /**
  98956. * Sets the layer id use to find what meshes are not impacted by the light.
  98957. * Inactive if 0
  98958. */
  98959. set excludeWithLayerMask(value: number);
  98960. private _includeOnlyWithLayerMask;
  98961. /**
  98962. * Gets the layer id use to find what meshes are impacted by the light.
  98963. * Inactive if 0
  98964. */
  98965. get includeOnlyWithLayerMask(): number;
  98966. /**
  98967. * Sets the layer id use to find what meshes are impacted by the light.
  98968. * Inactive if 0
  98969. */
  98970. set includeOnlyWithLayerMask(value: number);
  98971. private _lightmapMode;
  98972. /**
  98973. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98974. */
  98975. get lightmapMode(): number;
  98976. /**
  98977. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98978. */
  98979. set lightmapMode(value: number);
  98980. /**
  98981. * Shadow generator associted to the light.
  98982. * @hidden Internal use only.
  98983. */
  98984. _shadowGenerator: Nullable<IShadowGenerator>;
  98985. /**
  98986. * @hidden Internal use only.
  98987. */
  98988. _excludedMeshesIds: string[];
  98989. /**
  98990. * @hidden Internal use only.
  98991. */
  98992. _includedOnlyMeshesIds: string[];
  98993. /**
  98994. * The current light unifom buffer.
  98995. * @hidden Internal use only.
  98996. */
  98997. _uniformBuffer: UniformBuffer;
  98998. /** @hidden */
  98999. _renderId: number;
  99000. /**
  99001. * Creates a Light object in the scene.
  99002. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99003. * @param name The firendly name of the light
  99004. * @param scene The scene the light belongs too
  99005. */
  99006. constructor(name: string, scene: Scene);
  99007. protected abstract _buildUniformLayout(): void;
  99008. /**
  99009. * Sets the passed Effect "effect" with the Light information.
  99010. * @param effect The effect to update
  99011. * @param lightIndex The index of the light in the effect to update
  99012. * @returns The light
  99013. */
  99014. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  99015. /**
  99016. * Sets the passed Effect "effect" with the Light textures.
  99017. * @param effect The effect to update
  99018. * @param lightIndex The index of the light in the effect to update
  99019. * @returns The light
  99020. */
  99021. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  99022. /**
  99023. * Binds the lights information from the scene to the effect for the given mesh.
  99024. * @param lightIndex Light index
  99025. * @param scene The scene where the light belongs to
  99026. * @param effect The effect we are binding the data to
  99027. * @param useSpecular Defines if specular is supported
  99028. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99029. */
  99030. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99031. /**
  99032. * Sets the passed Effect "effect" with the Light information.
  99033. * @param effect The effect to update
  99034. * @param lightDataUniformName The uniform used to store light data (position or direction)
  99035. * @returns The light
  99036. */
  99037. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  99038. /**
  99039. * Returns the string "Light".
  99040. * @returns the class name
  99041. */
  99042. getClassName(): string;
  99043. /** @hidden */
  99044. readonly _isLight: boolean;
  99045. /**
  99046. * Converts the light information to a readable string for debug purpose.
  99047. * @param fullDetails Supports for multiple levels of logging within scene loading
  99048. * @returns the human readable light info
  99049. */
  99050. toString(fullDetails?: boolean): string;
  99051. /** @hidden */
  99052. protected _syncParentEnabledState(): void;
  99053. /**
  99054. * Set the enabled state of this node.
  99055. * @param value - the new enabled state
  99056. */
  99057. setEnabled(value: boolean): void;
  99058. /**
  99059. * Returns the Light associated shadow generator if any.
  99060. * @return the associated shadow generator.
  99061. */
  99062. getShadowGenerator(): Nullable<IShadowGenerator>;
  99063. /**
  99064. * Returns a Vector3, the absolute light position in the World.
  99065. * @returns the world space position of the light
  99066. */
  99067. getAbsolutePosition(): Vector3;
  99068. /**
  99069. * Specifies if the light will affect the passed mesh.
  99070. * @param mesh The mesh to test against the light
  99071. * @return true the mesh is affected otherwise, false.
  99072. */
  99073. canAffectMesh(mesh: AbstractMesh): boolean;
  99074. /**
  99075. * Sort function to order lights for rendering.
  99076. * @param a First Light object to compare to second.
  99077. * @param b Second Light object to compare first.
  99078. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  99079. */
  99080. static CompareLightsPriority(a: Light, b: Light): number;
  99081. /**
  99082. * Releases resources associated with this node.
  99083. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99084. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99085. */
  99086. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99087. /**
  99088. * Returns the light type ID (integer).
  99089. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99090. */
  99091. getTypeID(): number;
  99092. /**
  99093. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99094. * @returns the scaled intensity in intensity mode unit
  99095. */
  99096. getScaledIntensity(): number;
  99097. /**
  99098. * Returns a new Light object, named "name", from the current one.
  99099. * @param name The name of the cloned light
  99100. * @param newParent The parent of this light, if it has one
  99101. * @returns the new created light
  99102. */
  99103. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99104. /**
  99105. * Serializes the current light into a Serialization object.
  99106. * @returns the serialized object.
  99107. */
  99108. serialize(): any;
  99109. /**
  99110. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99111. * This new light is named "name" and added to the passed scene.
  99112. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99113. * @param name The friendly name of the light
  99114. * @param scene The scene the new light will belong to
  99115. * @returns the constructor function
  99116. */
  99117. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99118. /**
  99119. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99120. * @param parsedLight The JSON representation of the light
  99121. * @param scene The scene to create the parsed light in
  99122. * @returns the created light after parsing
  99123. */
  99124. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99125. private _hookArrayForExcluded;
  99126. private _hookArrayForIncludedOnly;
  99127. private _resyncMeshes;
  99128. /**
  99129. * Forces the meshes to update their light related information in their rendering used effects
  99130. * @hidden Internal Use Only
  99131. */
  99132. _markMeshesAsLightDirty(): void;
  99133. /**
  99134. * Recomputes the cached photometric scale if needed.
  99135. */
  99136. private _computePhotometricScale;
  99137. /**
  99138. * Returns the Photometric Scale according to the light type and intensity mode.
  99139. */
  99140. private _getPhotometricScale;
  99141. /**
  99142. * Reorder the light in the scene according to their defined priority.
  99143. * @hidden Internal Use Only
  99144. */
  99145. _reorderLightsInScene(): void;
  99146. /**
  99147. * Prepares the list of defines specific to the light type.
  99148. * @param defines the list of defines
  99149. * @param lightIndex defines the index of the light for the effect
  99150. */
  99151. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99152. }
  99153. }
  99154. declare module BABYLON {
  99155. /**
  99156. * Configuration needed for prepass-capable materials
  99157. */
  99158. export class PrePassConfiguration {
  99159. /**
  99160. * Previous world matrices of meshes carrying this material
  99161. * Used for computing velocity
  99162. */
  99163. previousWorldMatrices: {
  99164. [index: number]: Matrix;
  99165. };
  99166. /**
  99167. * Previous view project matrix
  99168. * Used for computing velocity
  99169. */
  99170. previousViewProjection: Matrix;
  99171. /**
  99172. * Previous bones of meshes carrying this material
  99173. * Used for computing velocity
  99174. */
  99175. previousBones: {
  99176. [index: number]: Float32Array;
  99177. };
  99178. /**
  99179. * Add the required uniforms to the current list.
  99180. * @param uniforms defines the current uniform list.
  99181. */
  99182. static AddUniforms(uniforms: string[]): void;
  99183. /**
  99184. * Add the required samplers to the current list.
  99185. * @param samplers defines the current sampler list.
  99186. */
  99187. static AddSamplers(samplers: string[]): void;
  99188. /**
  99189. * Binds the material data.
  99190. * @param effect defines the effect to update
  99191. * @param scene defines the scene the material belongs to.
  99192. * @param mesh The mesh
  99193. * @param world World matrix of this mesh
  99194. * @param isFrozen Is the material frozen
  99195. */
  99196. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99197. }
  99198. }
  99199. declare module BABYLON {
  99200. /**
  99201. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99202. * This is the base of the follow, arc rotate cameras and Free camera
  99203. * @see https://doc.babylonjs.com/features/cameras
  99204. */
  99205. export class TargetCamera extends Camera {
  99206. private static _RigCamTransformMatrix;
  99207. private static _TargetTransformMatrix;
  99208. private static _TargetFocalPoint;
  99209. private _tmpUpVector;
  99210. private _tmpTargetVector;
  99211. /**
  99212. * Define the current direction the camera is moving to
  99213. */
  99214. cameraDirection: Vector3;
  99215. /**
  99216. * Define the current rotation the camera is rotating to
  99217. */
  99218. cameraRotation: Vector2;
  99219. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99220. ignoreParentScaling: boolean;
  99221. /**
  99222. * When set, the up vector of the camera will be updated by the rotation of the camera
  99223. */
  99224. updateUpVectorFromRotation: boolean;
  99225. private _tmpQuaternion;
  99226. /**
  99227. * Define the current rotation of the camera
  99228. */
  99229. rotation: Vector3;
  99230. /**
  99231. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99232. */
  99233. rotationQuaternion: Quaternion;
  99234. /**
  99235. * Define the current speed of the camera
  99236. */
  99237. speed: number;
  99238. /**
  99239. * Add constraint to the camera to prevent it to move freely in all directions and
  99240. * around all axis.
  99241. */
  99242. noRotationConstraint: boolean;
  99243. /**
  99244. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99245. * panning
  99246. */
  99247. invertRotation: boolean;
  99248. /**
  99249. * Speed multiplier for inverse camera panning
  99250. */
  99251. inverseRotationSpeed: number;
  99252. /**
  99253. * Define the current target of the camera as an object or a position.
  99254. */
  99255. lockedTarget: any;
  99256. /** @hidden */
  99257. _currentTarget: Vector3;
  99258. /** @hidden */
  99259. _initialFocalDistance: number;
  99260. /** @hidden */
  99261. _viewMatrix: Matrix;
  99262. /** @hidden */
  99263. _camMatrix: Matrix;
  99264. /** @hidden */
  99265. _cameraTransformMatrix: Matrix;
  99266. /** @hidden */
  99267. _cameraRotationMatrix: Matrix;
  99268. /** @hidden */
  99269. _referencePoint: Vector3;
  99270. /** @hidden */
  99271. _transformedReferencePoint: Vector3;
  99272. /** @hidden */
  99273. _reset: () => void;
  99274. private _defaultUp;
  99275. /**
  99276. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99277. * This is the base of the follow, arc rotate cameras and Free camera
  99278. * @see https://doc.babylonjs.com/features/cameras
  99279. * @param name Defines the name of the camera in the scene
  99280. * @param position Defines the start position of the camera in the scene
  99281. * @param scene Defines the scene the camera belongs to
  99282. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99283. */
  99284. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99285. /**
  99286. * Gets the position in front of the camera at a given distance.
  99287. * @param distance The distance from the camera we want the position to be
  99288. * @returns the position
  99289. */
  99290. getFrontPosition(distance: number): Vector3;
  99291. /** @hidden */
  99292. _getLockedTargetPosition(): Nullable<Vector3>;
  99293. private _storedPosition;
  99294. private _storedRotation;
  99295. private _storedRotationQuaternion;
  99296. /**
  99297. * Store current camera state of the camera (fov, position, rotation, etc..)
  99298. * @returns the camera
  99299. */
  99300. storeState(): Camera;
  99301. /**
  99302. * Restored camera state. You must call storeState() first
  99303. * @returns whether it was successful or not
  99304. * @hidden
  99305. */
  99306. _restoreStateValues(): boolean;
  99307. /** @hidden */
  99308. _initCache(): void;
  99309. /** @hidden */
  99310. _updateCache(ignoreParentClass?: boolean): void;
  99311. /** @hidden */
  99312. _isSynchronizedViewMatrix(): boolean;
  99313. /** @hidden */
  99314. _computeLocalCameraSpeed(): number;
  99315. /**
  99316. * Defines the target the camera should look at.
  99317. * @param target Defines the new target as a Vector or a mesh
  99318. */
  99319. setTarget(target: Vector3): void;
  99320. /**
  99321. * Defines the target point of the camera.
  99322. * The camera looks towards it form the radius distance.
  99323. */
  99324. get target(): Vector3;
  99325. set target(value: Vector3);
  99326. /**
  99327. * Return the current target position of the camera. This value is expressed in local space.
  99328. * @returns the target position
  99329. */
  99330. getTarget(): Vector3;
  99331. /** @hidden */
  99332. _decideIfNeedsToMove(): boolean;
  99333. /** @hidden */
  99334. _updatePosition(): void;
  99335. /** @hidden */
  99336. _checkInputs(): void;
  99337. protected _updateCameraRotationMatrix(): void;
  99338. /**
  99339. * 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)
  99340. * @returns the current camera
  99341. */
  99342. private _rotateUpVectorWithCameraRotationMatrix;
  99343. private _cachedRotationZ;
  99344. private _cachedQuaternionRotationZ;
  99345. /** @hidden */
  99346. _getViewMatrix(): Matrix;
  99347. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99348. /**
  99349. * @hidden
  99350. */
  99351. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99352. /**
  99353. * @hidden
  99354. */
  99355. _updateRigCameras(): void;
  99356. private _getRigCamPositionAndTarget;
  99357. /**
  99358. * Gets the current object class name.
  99359. * @return the class name
  99360. */
  99361. getClassName(): string;
  99362. }
  99363. }
  99364. declare module BABYLON {
  99365. /**
  99366. * Gather the list of keyboard event types as constants.
  99367. */
  99368. export class KeyboardEventTypes {
  99369. /**
  99370. * The keydown event is fired when a key becomes active (pressed).
  99371. */
  99372. static readonly KEYDOWN: number;
  99373. /**
  99374. * The keyup event is fired when a key has been released.
  99375. */
  99376. static readonly KEYUP: number;
  99377. }
  99378. /**
  99379. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99380. */
  99381. export class KeyboardInfo {
  99382. /**
  99383. * Defines the type of event (KeyboardEventTypes)
  99384. */
  99385. type: number;
  99386. /**
  99387. * Defines the related dom event
  99388. */
  99389. event: KeyboardEvent;
  99390. /**
  99391. * Instantiates a new keyboard info.
  99392. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99393. * @param type Defines the type of event (KeyboardEventTypes)
  99394. * @param event Defines the related dom event
  99395. */
  99396. constructor(
  99397. /**
  99398. * Defines the type of event (KeyboardEventTypes)
  99399. */
  99400. type: number,
  99401. /**
  99402. * Defines the related dom event
  99403. */
  99404. event: KeyboardEvent);
  99405. }
  99406. /**
  99407. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99408. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99409. */
  99410. export class KeyboardInfoPre extends KeyboardInfo {
  99411. /**
  99412. * Defines the type of event (KeyboardEventTypes)
  99413. */
  99414. type: number;
  99415. /**
  99416. * Defines the related dom event
  99417. */
  99418. event: KeyboardEvent;
  99419. /**
  99420. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99421. */
  99422. skipOnPointerObservable: boolean;
  99423. /**
  99424. * Instantiates a new keyboard pre info.
  99425. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99426. * @param type Defines the type of event (KeyboardEventTypes)
  99427. * @param event Defines the related dom event
  99428. */
  99429. constructor(
  99430. /**
  99431. * Defines the type of event (KeyboardEventTypes)
  99432. */
  99433. type: number,
  99434. /**
  99435. * Defines the related dom event
  99436. */
  99437. event: KeyboardEvent);
  99438. }
  99439. }
  99440. declare module BABYLON {
  99441. /**
  99442. * Manage the keyboard inputs to control the movement of a free camera.
  99443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99444. */
  99445. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99446. /**
  99447. * Defines the camera the input is attached to.
  99448. */
  99449. camera: FreeCamera;
  99450. /**
  99451. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99452. */
  99453. keysUp: number[];
  99454. /**
  99455. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99456. */
  99457. keysUpward: number[];
  99458. /**
  99459. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99460. */
  99461. keysDown: number[];
  99462. /**
  99463. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99464. */
  99465. keysDownward: number[];
  99466. /**
  99467. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99468. */
  99469. keysLeft: number[];
  99470. /**
  99471. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99472. */
  99473. keysRight: number[];
  99474. private _keys;
  99475. private _onCanvasBlurObserver;
  99476. private _onKeyboardObserver;
  99477. private _engine;
  99478. private _scene;
  99479. /**
  99480. * Attach the input controls to a specific dom element to get the input from.
  99481. * @param element Defines the element the controls should be listened from
  99482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99483. */
  99484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99485. /**
  99486. * Detach the current controls from the specified dom element.
  99487. * @param element Defines the element to stop listening the inputs from
  99488. */
  99489. detachControl(element: Nullable<HTMLElement>): void;
  99490. /**
  99491. * Update the current camera state depending on the inputs that have been used this frame.
  99492. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99493. */
  99494. checkInputs(): void;
  99495. /**
  99496. * Gets the class name of the current intput.
  99497. * @returns the class name
  99498. */
  99499. getClassName(): string;
  99500. /** @hidden */
  99501. _onLostFocus(): void;
  99502. /**
  99503. * Get the friendly name associated with the input class.
  99504. * @returns the input friendly name
  99505. */
  99506. getSimpleName(): string;
  99507. }
  99508. }
  99509. declare module BABYLON {
  99510. /**
  99511. * Gather the list of pointer event types as constants.
  99512. */
  99513. export class PointerEventTypes {
  99514. /**
  99515. * 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.
  99516. */
  99517. static readonly POINTERDOWN: number;
  99518. /**
  99519. * The pointerup event is fired when a pointer is no longer active.
  99520. */
  99521. static readonly POINTERUP: number;
  99522. /**
  99523. * The pointermove event is fired when a pointer changes coordinates.
  99524. */
  99525. static readonly POINTERMOVE: number;
  99526. /**
  99527. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99528. */
  99529. static readonly POINTERWHEEL: number;
  99530. /**
  99531. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99532. */
  99533. static readonly POINTERPICK: number;
  99534. /**
  99535. * The pointertap event is fired when a the object has been touched and released without drag.
  99536. */
  99537. static readonly POINTERTAP: number;
  99538. /**
  99539. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99540. */
  99541. static readonly POINTERDOUBLETAP: number;
  99542. }
  99543. /**
  99544. * Base class of pointer info types.
  99545. */
  99546. export class PointerInfoBase {
  99547. /**
  99548. * Defines the type of event (PointerEventTypes)
  99549. */
  99550. type: number;
  99551. /**
  99552. * Defines the related dom event
  99553. */
  99554. event: PointerEvent | MouseWheelEvent;
  99555. /**
  99556. * Instantiates the base class of pointers info.
  99557. * @param type Defines the type of event (PointerEventTypes)
  99558. * @param event Defines the related dom event
  99559. */
  99560. constructor(
  99561. /**
  99562. * Defines the type of event (PointerEventTypes)
  99563. */
  99564. type: number,
  99565. /**
  99566. * Defines the related dom event
  99567. */
  99568. event: PointerEvent | MouseWheelEvent);
  99569. }
  99570. /**
  99571. * This class is used to store pointer related info for the onPrePointerObservable event.
  99572. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99573. */
  99574. export class PointerInfoPre extends PointerInfoBase {
  99575. /**
  99576. * Ray from a pointer if availible (eg. 6dof controller)
  99577. */
  99578. ray: Nullable<Ray>;
  99579. /**
  99580. * Defines the local position of the pointer on the canvas.
  99581. */
  99582. localPosition: Vector2;
  99583. /**
  99584. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99585. */
  99586. skipOnPointerObservable: boolean;
  99587. /**
  99588. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99589. * @param type Defines the type of event (PointerEventTypes)
  99590. * @param event Defines the related dom event
  99591. * @param localX Defines the local x coordinates of the pointer when the event occured
  99592. * @param localY Defines the local y coordinates of the pointer when the event occured
  99593. */
  99594. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99595. }
  99596. /**
  99597. * This type contains all the data related to a pointer event in Babylon.js.
  99598. * 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.
  99599. */
  99600. export class PointerInfo extends PointerInfoBase {
  99601. /**
  99602. * Defines the picking info associated to the info (if any)\
  99603. */
  99604. pickInfo: Nullable<PickingInfo>;
  99605. /**
  99606. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99607. * @param type Defines the type of event (PointerEventTypes)
  99608. * @param event Defines the related dom event
  99609. * @param pickInfo Defines the picking info associated to the info (if any)\
  99610. */
  99611. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99612. /**
  99613. * Defines the picking info associated to the info (if any)\
  99614. */
  99615. pickInfo: Nullable<PickingInfo>);
  99616. }
  99617. /**
  99618. * Data relating to a touch event on the screen.
  99619. */
  99620. export interface PointerTouch {
  99621. /**
  99622. * X coordinate of touch.
  99623. */
  99624. x: number;
  99625. /**
  99626. * Y coordinate of touch.
  99627. */
  99628. y: number;
  99629. /**
  99630. * Id of touch. Unique for each finger.
  99631. */
  99632. pointerId: number;
  99633. /**
  99634. * Event type passed from DOM.
  99635. */
  99636. type: any;
  99637. }
  99638. }
  99639. declare module BABYLON {
  99640. /**
  99641. * Manage the mouse inputs to control the movement of a free camera.
  99642. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99643. */
  99644. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99645. /**
  99646. * Define if touch is enabled in the mouse input
  99647. */
  99648. touchEnabled: boolean;
  99649. /**
  99650. * Defines the camera the input is attached to.
  99651. */
  99652. camera: FreeCamera;
  99653. /**
  99654. * Defines the buttons associated with the input to handle camera move.
  99655. */
  99656. buttons: number[];
  99657. /**
  99658. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99659. */
  99660. angularSensibility: number;
  99661. private _pointerInput;
  99662. private _onMouseMove;
  99663. private _observer;
  99664. private previousPosition;
  99665. /**
  99666. * Observable for when a pointer move event occurs containing the move offset
  99667. */
  99668. onPointerMovedObservable: Observable<{
  99669. offsetX: number;
  99670. offsetY: number;
  99671. }>;
  99672. /**
  99673. * @hidden
  99674. * If the camera should be rotated automatically based on pointer movement
  99675. */
  99676. _allowCameraRotation: boolean;
  99677. /**
  99678. * Manage the mouse inputs to control the movement of a free camera.
  99679. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99680. * @param touchEnabled Defines if touch is enabled or not
  99681. */
  99682. constructor(
  99683. /**
  99684. * Define if touch is enabled in the mouse input
  99685. */
  99686. touchEnabled?: boolean);
  99687. /**
  99688. * Attach the input controls to a specific dom element to get the input from.
  99689. * @param element Defines the element the controls should be listened from
  99690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99691. */
  99692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99693. /**
  99694. * Called on JS contextmenu event.
  99695. * Override this method to provide functionality.
  99696. */
  99697. protected onContextMenu(evt: PointerEvent): void;
  99698. /**
  99699. * Detach the current controls from the specified dom element.
  99700. * @param element Defines the element to stop listening the inputs from
  99701. */
  99702. detachControl(element: Nullable<HTMLElement>): void;
  99703. /**
  99704. * Gets the class name of the current intput.
  99705. * @returns the class name
  99706. */
  99707. getClassName(): string;
  99708. /**
  99709. * Get the friendly name associated with the input class.
  99710. * @returns the input friendly name
  99711. */
  99712. getSimpleName(): string;
  99713. }
  99714. }
  99715. declare module BABYLON {
  99716. /**
  99717. * Manage the touch inputs to control the movement of a free camera.
  99718. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99719. */
  99720. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99721. /**
  99722. * Define if mouse events can be treated as touch events
  99723. */
  99724. allowMouse: boolean;
  99725. /**
  99726. * Defines the camera the input is attached to.
  99727. */
  99728. camera: FreeCamera;
  99729. /**
  99730. * Defines the touch sensibility for rotation.
  99731. * The higher the faster.
  99732. */
  99733. touchAngularSensibility: number;
  99734. /**
  99735. * Defines the touch sensibility for move.
  99736. * The higher the faster.
  99737. */
  99738. touchMoveSensibility: number;
  99739. private _offsetX;
  99740. private _offsetY;
  99741. private _pointerPressed;
  99742. private _pointerInput;
  99743. private _observer;
  99744. private _onLostFocus;
  99745. /**
  99746. * Manage the touch inputs to control the movement of a free camera.
  99747. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99748. * @param allowMouse Defines if mouse events can be treated as touch events
  99749. */
  99750. constructor(
  99751. /**
  99752. * Define if mouse events can be treated as touch events
  99753. */
  99754. allowMouse?: boolean);
  99755. /**
  99756. * Attach the input controls to a specific dom element to get the input from.
  99757. * @param element Defines the element the controls should be listened from
  99758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99759. */
  99760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99761. /**
  99762. * Detach the current controls from the specified dom element.
  99763. * @param element Defines the element to stop listening the inputs from
  99764. */
  99765. detachControl(element: Nullable<HTMLElement>): void;
  99766. /**
  99767. * Update the current camera state depending on the inputs that have been used this frame.
  99768. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99769. */
  99770. checkInputs(): void;
  99771. /**
  99772. * Gets the class name of the current intput.
  99773. * @returns the class name
  99774. */
  99775. getClassName(): string;
  99776. /**
  99777. * Get the friendly name associated with the input class.
  99778. * @returns the input friendly name
  99779. */
  99780. getSimpleName(): string;
  99781. }
  99782. }
  99783. declare module BABYLON {
  99784. /**
  99785. * Default Inputs manager for the FreeCamera.
  99786. * It groups all the default supported inputs for ease of use.
  99787. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99788. */
  99789. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99790. /**
  99791. * @hidden
  99792. */
  99793. _mouseInput: Nullable<FreeCameraMouseInput>;
  99794. /**
  99795. * Instantiates a new FreeCameraInputsManager.
  99796. * @param camera Defines the camera the inputs belong to
  99797. */
  99798. constructor(camera: FreeCamera);
  99799. /**
  99800. * Add keyboard input support to the input manager.
  99801. * @returns the current input manager
  99802. */
  99803. addKeyboard(): FreeCameraInputsManager;
  99804. /**
  99805. * Add mouse input support to the input manager.
  99806. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99807. * @returns the current input manager
  99808. */
  99809. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99810. /**
  99811. * Removes the mouse input support from the manager
  99812. * @returns the current input manager
  99813. */
  99814. removeMouse(): FreeCameraInputsManager;
  99815. /**
  99816. * Add touch input support to the input manager.
  99817. * @returns the current input manager
  99818. */
  99819. addTouch(): FreeCameraInputsManager;
  99820. /**
  99821. * Remove all attached input methods from a camera
  99822. */
  99823. clear(): void;
  99824. }
  99825. }
  99826. declare module BABYLON {
  99827. /**
  99828. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99829. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99830. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99831. */
  99832. export class FreeCamera extends TargetCamera {
  99833. /**
  99834. * Define the collision ellipsoid of the camera.
  99835. * This is helpful to simulate a camera body like the player body around the camera
  99836. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99837. */
  99838. ellipsoid: Vector3;
  99839. /**
  99840. * Define an offset for the position of the ellipsoid around the camera.
  99841. * This can be helpful to determine the center of the body near the gravity center of the body
  99842. * instead of its head.
  99843. */
  99844. ellipsoidOffset: Vector3;
  99845. /**
  99846. * Enable or disable collisions of the camera with the rest of the scene objects.
  99847. */
  99848. checkCollisions: boolean;
  99849. /**
  99850. * Enable or disable gravity on the camera.
  99851. */
  99852. applyGravity: boolean;
  99853. /**
  99854. * Define the input manager associated to the camera.
  99855. */
  99856. inputs: FreeCameraInputsManager;
  99857. /**
  99858. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99859. * Higher values reduce sensitivity.
  99860. */
  99861. get angularSensibility(): number;
  99862. /**
  99863. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99864. * Higher values reduce sensitivity.
  99865. */
  99866. set angularSensibility(value: number);
  99867. /**
  99868. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99869. */
  99870. get keysUp(): number[];
  99871. set keysUp(value: number[]);
  99872. /**
  99873. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99874. */
  99875. get keysUpward(): number[];
  99876. set keysUpward(value: number[]);
  99877. /**
  99878. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99879. */
  99880. get keysDown(): number[];
  99881. set keysDown(value: number[]);
  99882. /**
  99883. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99884. */
  99885. get keysDownward(): number[];
  99886. set keysDownward(value: number[]);
  99887. /**
  99888. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99889. */
  99890. get keysLeft(): number[];
  99891. set keysLeft(value: number[]);
  99892. /**
  99893. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99894. */
  99895. get keysRight(): number[];
  99896. set keysRight(value: number[]);
  99897. /**
  99898. * Event raised when the camera collide with a mesh in the scene.
  99899. */
  99900. onCollide: (collidedMesh: AbstractMesh) => void;
  99901. private _collider;
  99902. private _needMoveForGravity;
  99903. private _oldPosition;
  99904. private _diffPosition;
  99905. private _newPosition;
  99906. /** @hidden */
  99907. _localDirection: Vector3;
  99908. /** @hidden */
  99909. _transformedDirection: Vector3;
  99910. /**
  99911. * Instantiates a Free Camera.
  99912. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99913. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99914. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99915. * @param name Define the name of the camera in the scene
  99916. * @param position Define the start position of the camera in the scene
  99917. * @param scene Define the scene the camera belongs to
  99918. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99919. */
  99920. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99921. /**
  99922. * Attached controls to the current camera.
  99923. * @param element Defines the element the controls should be listened from
  99924. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99925. */
  99926. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99927. /**
  99928. * Detach the current controls from the camera.
  99929. * The camera will stop reacting to inputs.
  99930. * @param element Defines the element to stop listening the inputs from
  99931. */
  99932. detachControl(element: HTMLElement): void;
  99933. private _collisionMask;
  99934. /**
  99935. * Define a collision mask to limit the list of object the camera can collide with
  99936. */
  99937. get collisionMask(): number;
  99938. set collisionMask(mask: number);
  99939. /** @hidden */
  99940. _collideWithWorld(displacement: Vector3): void;
  99941. private _onCollisionPositionChange;
  99942. /** @hidden */
  99943. _checkInputs(): void;
  99944. /** @hidden */
  99945. _decideIfNeedsToMove(): boolean;
  99946. /** @hidden */
  99947. _updatePosition(): void;
  99948. /**
  99949. * Destroy the camera and release the current resources hold by it.
  99950. */
  99951. dispose(): void;
  99952. /**
  99953. * Gets the current object class name.
  99954. * @return the class name
  99955. */
  99956. getClassName(): string;
  99957. }
  99958. }
  99959. declare module BABYLON {
  99960. /**
  99961. * Represents a gamepad control stick position
  99962. */
  99963. export class StickValues {
  99964. /**
  99965. * The x component of the control stick
  99966. */
  99967. x: number;
  99968. /**
  99969. * The y component of the control stick
  99970. */
  99971. y: number;
  99972. /**
  99973. * Initializes the gamepad x and y control stick values
  99974. * @param x The x component of the gamepad control stick value
  99975. * @param y The y component of the gamepad control stick value
  99976. */
  99977. constructor(
  99978. /**
  99979. * The x component of the control stick
  99980. */
  99981. x: number,
  99982. /**
  99983. * The y component of the control stick
  99984. */
  99985. y: number);
  99986. }
  99987. /**
  99988. * An interface which manages callbacks for gamepad button changes
  99989. */
  99990. export interface GamepadButtonChanges {
  99991. /**
  99992. * Called when a gamepad has been changed
  99993. */
  99994. changed: boolean;
  99995. /**
  99996. * Called when a gamepad press event has been triggered
  99997. */
  99998. pressChanged: boolean;
  99999. /**
  100000. * Called when a touch event has been triggered
  100001. */
  100002. touchChanged: boolean;
  100003. /**
  100004. * Called when a value has changed
  100005. */
  100006. valueChanged: boolean;
  100007. }
  100008. /**
  100009. * Represents a gamepad
  100010. */
  100011. export class Gamepad {
  100012. /**
  100013. * The id of the gamepad
  100014. */
  100015. id: string;
  100016. /**
  100017. * The index of the gamepad
  100018. */
  100019. index: number;
  100020. /**
  100021. * The browser gamepad
  100022. */
  100023. browserGamepad: any;
  100024. /**
  100025. * Specifies what type of gamepad this represents
  100026. */
  100027. type: number;
  100028. private _leftStick;
  100029. private _rightStick;
  100030. /** @hidden */
  100031. _isConnected: boolean;
  100032. private _leftStickAxisX;
  100033. private _leftStickAxisY;
  100034. private _rightStickAxisX;
  100035. private _rightStickAxisY;
  100036. /**
  100037. * Triggered when the left control stick has been changed
  100038. */
  100039. private _onleftstickchanged;
  100040. /**
  100041. * Triggered when the right control stick has been changed
  100042. */
  100043. private _onrightstickchanged;
  100044. /**
  100045. * Represents a gamepad controller
  100046. */
  100047. static GAMEPAD: number;
  100048. /**
  100049. * Represents a generic controller
  100050. */
  100051. static GENERIC: number;
  100052. /**
  100053. * Represents an XBox controller
  100054. */
  100055. static XBOX: number;
  100056. /**
  100057. * Represents a pose-enabled controller
  100058. */
  100059. static POSE_ENABLED: number;
  100060. /**
  100061. * Represents an Dual Shock controller
  100062. */
  100063. static DUALSHOCK: number;
  100064. /**
  100065. * Specifies whether the left control stick should be Y-inverted
  100066. */
  100067. protected _invertLeftStickY: boolean;
  100068. /**
  100069. * Specifies if the gamepad has been connected
  100070. */
  100071. get isConnected(): boolean;
  100072. /**
  100073. * Initializes the gamepad
  100074. * @param id The id of the gamepad
  100075. * @param index The index of the gamepad
  100076. * @param browserGamepad The browser gamepad
  100077. * @param leftStickX The x component of the left joystick
  100078. * @param leftStickY The y component of the left joystick
  100079. * @param rightStickX The x component of the right joystick
  100080. * @param rightStickY The y component of the right joystick
  100081. */
  100082. constructor(
  100083. /**
  100084. * The id of the gamepad
  100085. */
  100086. id: string,
  100087. /**
  100088. * The index of the gamepad
  100089. */
  100090. index: number,
  100091. /**
  100092. * The browser gamepad
  100093. */
  100094. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100095. /**
  100096. * Callback triggered when the left joystick has changed
  100097. * @param callback
  100098. */
  100099. onleftstickchanged(callback: (values: StickValues) => void): void;
  100100. /**
  100101. * Callback triggered when the right joystick has changed
  100102. * @param callback
  100103. */
  100104. onrightstickchanged(callback: (values: StickValues) => void): void;
  100105. /**
  100106. * Gets the left joystick
  100107. */
  100108. get leftStick(): StickValues;
  100109. /**
  100110. * Sets the left joystick values
  100111. */
  100112. set leftStick(newValues: StickValues);
  100113. /**
  100114. * Gets the right joystick
  100115. */
  100116. get rightStick(): StickValues;
  100117. /**
  100118. * Sets the right joystick value
  100119. */
  100120. set rightStick(newValues: StickValues);
  100121. /**
  100122. * Updates the gamepad joystick positions
  100123. */
  100124. update(): void;
  100125. /**
  100126. * Disposes the gamepad
  100127. */
  100128. dispose(): void;
  100129. }
  100130. /**
  100131. * Represents a generic gamepad
  100132. */
  100133. export class GenericPad extends Gamepad {
  100134. private _buttons;
  100135. private _onbuttondown;
  100136. private _onbuttonup;
  100137. /**
  100138. * Observable triggered when a button has been pressed
  100139. */
  100140. onButtonDownObservable: Observable<number>;
  100141. /**
  100142. * Observable triggered when a button has been released
  100143. */
  100144. onButtonUpObservable: Observable<number>;
  100145. /**
  100146. * Callback triggered when a button has been pressed
  100147. * @param callback Called when a button has been pressed
  100148. */
  100149. onbuttondown(callback: (buttonPressed: number) => void): void;
  100150. /**
  100151. * Callback triggered when a button has been released
  100152. * @param callback Called when a button has been released
  100153. */
  100154. onbuttonup(callback: (buttonReleased: number) => void): void;
  100155. /**
  100156. * Initializes the generic gamepad
  100157. * @param id The id of the generic gamepad
  100158. * @param index The index of the generic gamepad
  100159. * @param browserGamepad The browser gamepad
  100160. */
  100161. constructor(id: string, index: number, browserGamepad: any);
  100162. private _setButtonValue;
  100163. /**
  100164. * Updates the generic gamepad
  100165. */
  100166. update(): void;
  100167. /**
  100168. * Disposes the generic gamepad
  100169. */
  100170. dispose(): void;
  100171. }
  100172. }
  100173. declare module BABYLON {
  100174. /**
  100175. * Defines the types of pose enabled controllers that are supported
  100176. */
  100177. export enum PoseEnabledControllerType {
  100178. /**
  100179. * HTC Vive
  100180. */
  100181. VIVE = 0,
  100182. /**
  100183. * Oculus Rift
  100184. */
  100185. OCULUS = 1,
  100186. /**
  100187. * Windows mixed reality
  100188. */
  100189. WINDOWS = 2,
  100190. /**
  100191. * Samsung gear VR
  100192. */
  100193. GEAR_VR = 3,
  100194. /**
  100195. * Google Daydream
  100196. */
  100197. DAYDREAM = 4,
  100198. /**
  100199. * Generic
  100200. */
  100201. GENERIC = 5
  100202. }
  100203. /**
  100204. * Defines the MutableGamepadButton interface for the state of a gamepad button
  100205. */
  100206. export interface MutableGamepadButton {
  100207. /**
  100208. * Value of the button/trigger
  100209. */
  100210. value: number;
  100211. /**
  100212. * If the button/trigger is currently touched
  100213. */
  100214. touched: boolean;
  100215. /**
  100216. * If the button/trigger is currently pressed
  100217. */
  100218. pressed: boolean;
  100219. }
  100220. /**
  100221. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  100222. * @hidden
  100223. */
  100224. export interface ExtendedGamepadButton extends GamepadButton {
  100225. /**
  100226. * If the button/trigger is currently pressed
  100227. */
  100228. readonly pressed: boolean;
  100229. /**
  100230. * If the button/trigger is currently touched
  100231. */
  100232. readonly touched: boolean;
  100233. /**
  100234. * Value of the button/trigger
  100235. */
  100236. readonly value: number;
  100237. }
  100238. /** @hidden */
  100239. export interface _GamePadFactory {
  100240. /**
  100241. * Returns whether or not the current gamepad can be created for this type of controller.
  100242. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100243. * @returns true if it can be created, otherwise false
  100244. */
  100245. canCreate(gamepadInfo: any): boolean;
  100246. /**
  100247. * Creates a new instance of the Gamepad.
  100248. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100249. * @returns the new gamepad instance
  100250. */
  100251. create(gamepadInfo: any): Gamepad;
  100252. }
  100253. /**
  100254. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100255. */
  100256. export class PoseEnabledControllerHelper {
  100257. /** @hidden */
  100258. static _ControllerFactories: _GamePadFactory[];
  100259. /** @hidden */
  100260. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100261. /**
  100262. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100263. * @param vrGamepad the gamepad to initialized
  100264. * @returns a vr controller of the type the gamepad identified as
  100265. */
  100266. static InitiateController(vrGamepad: any): Gamepad;
  100267. }
  100268. /**
  100269. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100270. */
  100271. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100272. /**
  100273. * If the controller is used in a webXR session
  100274. */
  100275. isXR: boolean;
  100276. private _deviceRoomPosition;
  100277. private _deviceRoomRotationQuaternion;
  100278. /**
  100279. * The device position in babylon space
  100280. */
  100281. devicePosition: Vector3;
  100282. /**
  100283. * The device rotation in babylon space
  100284. */
  100285. deviceRotationQuaternion: Quaternion;
  100286. /**
  100287. * The scale factor of the device in babylon space
  100288. */
  100289. deviceScaleFactor: number;
  100290. /**
  100291. * (Likely devicePosition should be used instead) The device position in its room space
  100292. */
  100293. position: Vector3;
  100294. /**
  100295. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  100296. */
  100297. rotationQuaternion: Quaternion;
  100298. /**
  100299. * The type of controller (Eg. Windows mixed reality)
  100300. */
  100301. controllerType: PoseEnabledControllerType;
  100302. protected _calculatedPosition: Vector3;
  100303. private _calculatedRotation;
  100304. /**
  100305. * The raw pose from the device
  100306. */
  100307. rawPose: DevicePose;
  100308. private _trackPosition;
  100309. private _maxRotationDistFromHeadset;
  100310. private _draggedRoomRotation;
  100311. /**
  100312. * @hidden
  100313. */
  100314. _disableTrackPosition(fixedPosition: Vector3): void;
  100315. /**
  100316. * Internal, the mesh attached to the controller
  100317. * @hidden
  100318. */
  100319. _mesh: Nullable<AbstractMesh>;
  100320. private _poseControlledCamera;
  100321. private _leftHandSystemQuaternion;
  100322. /**
  100323. * Internal, matrix used to convert room space to babylon space
  100324. * @hidden
  100325. */
  100326. _deviceToWorld: Matrix;
  100327. /**
  100328. * Node to be used when casting a ray from the controller
  100329. * @hidden
  100330. */
  100331. _pointingPoseNode: Nullable<TransformNode>;
  100332. /**
  100333. * Name of the child mesh that can be used to cast a ray from the controller
  100334. */
  100335. static readonly POINTING_POSE: string;
  100336. /**
  100337. * Creates a new PoseEnabledController from a gamepad
  100338. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  100339. */
  100340. constructor(browserGamepad: any);
  100341. private _workingMatrix;
  100342. /**
  100343. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  100344. */
  100345. update(): void;
  100346. /**
  100347. * Updates only the pose device and mesh without doing any button event checking
  100348. */
  100349. protected _updatePoseAndMesh(): void;
  100350. /**
  100351. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  100352. * @param poseData raw pose fromthe device
  100353. */
  100354. updateFromDevice(poseData: DevicePose): void;
  100355. /**
  100356. * @hidden
  100357. */
  100358. _meshAttachedObservable: Observable<AbstractMesh>;
  100359. /**
  100360. * Attaches a mesh to the controller
  100361. * @param mesh the mesh to be attached
  100362. */
  100363. attachToMesh(mesh: AbstractMesh): void;
  100364. /**
  100365. * Attaches the controllers mesh to a camera
  100366. * @param camera the camera the mesh should be attached to
  100367. */
  100368. attachToPoseControlledCamera(camera: TargetCamera): void;
  100369. /**
  100370. * Disposes of the controller
  100371. */
  100372. dispose(): void;
  100373. /**
  100374. * The mesh that is attached to the controller
  100375. */
  100376. get mesh(): Nullable<AbstractMesh>;
  100377. /**
  100378. * Gets the ray of the controller in the direction the controller is pointing
  100379. * @param length the length the resulting ray should be
  100380. * @returns a ray in the direction the controller is pointing
  100381. */
  100382. getForwardRay(length?: number): Ray;
  100383. }
  100384. }
  100385. declare module BABYLON {
  100386. /**
  100387. * Defines the WebVRController object that represents controllers tracked in 3D space
  100388. */
  100389. export abstract class WebVRController extends PoseEnabledController {
  100390. /**
  100391. * Internal, the default controller model for the controller
  100392. */
  100393. protected _defaultModel: Nullable<AbstractMesh>;
  100394. /**
  100395. * Fired when the trigger state has changed
  100396. */
  100397. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100398. /**
  100399. * Fired when the main button state has changed
  100400. */
  100401. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100402. /**
  100403. * Fired when the secondary button state has changed
  100404. */
  100405. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100406. /**
  100407. * Fired when the pad state has changed
  100408. */
  100409. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  100410. /**
  100411. * Fired when controllers stick values have changed
  100412. */
  100413. onPadValuesChangedObservable: Observable<StickValues>;
  100414. /**
  100415. * Array of button availible on the controller
  100416. */
  100417. protected _buttons: Array<MutableGamepadButton>;
  100418. private _onButtonStateChange;
  100419. /**
  100420. * Fired when a controller button's state has changed
  100421. * @param callback the callback containing the button that was modified
  100422. */
  100423. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  100424. /**
  100425. * X and Y axis corresponding to the controllers joystick
  100426. */
  100427. pad: StickValues;
  100428. /**
  100429. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  100430. */
  100431. hand: string;
  100432. /**
  100433. * The default controller model for the controller
  100434. */
  100435. get defaultModel(): Nullable<AbstractMesh>;
  100436. /**
  100437. * Creates a new WebVRController from a gamepad
  100438. * @param vrGamepad the gamepad that the WebVRController should be created from
  100439. */
  100440. constructor(vrGamepad: any);
  100441. /**
  100442. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  100443. */
  100444. update(): void;
  100445. /**
  100446. * Function to be called when a button is modified
  100447. */
  100448. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100449. /**
  100450. * Loads a mesh and attaches it to the controller
  100451. * @param scene the scene the mesh should be added to
  100452. * @param meshLoaded callback for when the mesh has been loaded
  100453. */
  100454. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100455. private _setButtonValue;
  100456. private _changes;
  100457. private _checkChanges;
  100458. /**
  100459. * Disposes of th webVRCOntroller
  100460. */
  100461. dispose(): void;
  100462. }
  100463. }
  100464. declare module BABYLON {
  100465. /**
  100466. * The HemisphericLight simulates the ambient environment light,
  100467. * so the passed direction is the light reflection direction, not the incoming direction.
  100468. */
  100469. export class HemisphericLight extends Light {
  100470. /**
  100471. * The groundColor is the light in the opposite direction to the one specified during creation.
  100472. * 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.
  100473. */
  100474. groundColor: Color3;
  100475. /**
  100476. * The light reflection direction, not the incoming direction.
  100477. */
  100478. direction: Vector3;
  100479. /**
  100480. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100481. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100482. * The HemisphericLight can't cast shadows.
  100483. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100484. * @param name The friendly name of the light
  100485. * @param direction The direction of the light reflection
  100486. * @param scene The scene the light belongs to
  100487. */
  100488. constructor(name: string, direction: Vector3, scene: Scene);
  100489. protected _buildUniformLayout(): void;
  100490. /**
  100491. * Returns the string "HemisphericLight".
  100492. * @return The class name
  100493. */
  100494. getClassName(): string;
  100495. /**
  100496. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100497. * Returns the updated direction.
  100498. * @param target The target the direction should point to
  100499. * @return The computed direction
  100500. */
  100501. setDirectionToTarget(target: Vector3): Vector3;
  100502. /**
  100503. * Returns the shadow generator associated to the light.
  100504. * @returns Always null for hemispheric lights because it does not support shadows.
  100505. */
  100506. getShadowGenerator(): Nullable<IShadowGenerator>;
  100507. /**
  100508. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100509. * @param effect The effect to update
  100510. * @param lightIndex The index of the light in the effect to update
  100511. * @returns The hemispheric light
  100512. */
  100513. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100514. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100515. /**
  100516. * Computes the world matrix of the node
  100517. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100518. * @param useWasUpdatedFlag defines a reserved property
  100519. * @returns the world matrix
  100520. */
  100521. computeWorldMatrix(): Matrix;
  100522. /**
  100523. * Returns the integer 3.
  100524. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100525. */
  100526. getTypeID(): number;
  100527. /**
  100528. * Prepares the list of defines specific to the light type.
  100529. * @param defines the list of defines
  100530. * @param lightIndex defines the index of the light for the effect
  100531. */
  100532. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100533. }
  100534. }
  100535. declare module BABYLON {
  100536. /** @hidden */
  100537. export var vrMultiviewToSingleviewPixelShader: {
  100538. name: string;
  100539. shader: string;
  100540. };
  100541. }
  100542. declare module BABYLON {
  100543. /**
  100544. * Renders to multiple views with a single draw call
  100545. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100546. */
  100547. export class MultiviewRenderTarget extends RenderTargetTexture {
  100548. /**
  100549. * Creates a multiview render target
  100550. * @param scene scene used with the render target
  100551. * @param size the size of the render target (used for each view)
  100552. */
  100553. constructor(scene: Scene, size?: number | {
  100554. width: number;
  100555. height: number;
  100556. } | {
  100557. ratio: number;
  100558. });
  100559. /**
  100560. * @hidden
  100561. * @param faceIndex the face index, if its a cube texture
  100562. */
  100563. _bindFrameBuffer(faceIndex?: number): void;
  100564. /**
  100565. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100566. * @returns the view count
  100567. */
  100568. getViewCount(): number;
  100569. }
  100570. }
  100571. declare module BABYLON {
  100572. interface Engine {
  100573. /**
  100574. * Creates a new multiview render target
  100575. * @param width defines the width of the texture
  100576. * @param height defines the height of the texture
  100577. * @returns the created multiview texture
  100578. */
  100579. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100580. /**
  100581. * Binds a multiview framebuffer to be drawn to
  100582. * @param multiviewTexture texture to bind
  100583. */
  100584. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100585. }
  100586. interface Camera {
  100587. /**
  100588. * @hidden
  100589. * 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)
  100590. */
  100591. _useMultiviewToSingleView: boolean;
  100592. /**
  100593. * @hidden
  100594. * 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)
  100595. */
  100596. _multiviewTexture: Nullable<RenderTargetTexture>;
  100597. /**
  100598. * @hidden
  100599. * ensures the multiview texture of the camera exists and has the specified width/height
  100600. * @param width height to set on the multiview texture
  100601. * @param height width to set on the multiview texture
  100602. */
  100603. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100604. }
  100605. interface Scene {
  100606. /** @hidden */
  100607. _transformMatrixR: Matrix;
  100608. /** @hidden */
  100609. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100610. /** @hidden */
  100611. _createMultiviewUbo(): void;
  100612. /** @hidden */
  100613. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100614. /** @hidden */
  100615. _renderMultiviewToSingleView(camera: Camera): void;
  100616. }
  100617. }
  100618. declare module BABYLON {
  100619. /**
  100620. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100621. * This will not be used for webXR as it supports displaying texture arrays directly
  100622. */
  100623. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100624. /**
  100625. * Gets a string identifying the name of the class
  100626. * @returns "VRMultiviewToSingleviewPostProcess" string
  100627. */
  100628. getClassName(): string;
  100629. /**
  100630. * Initializes a VRMultiviewToSingleview
  100631. * @param name name of the post process
  100632. * @param camera camera to be applied to
  100633. * @param scaleFactor scaling factor to the size of the output texture
  100634. */
  100635. constructor(name: string, camera: Camera, scaleFactor: number);
  100636. }
  100637. }
  100638. declare module BABYLON {
  100639. /**
  100640. * Interface used to define additional presentation attributes
  100641. */
  100642. export interface IVRPresentationAttributes {
  100643. /**
  100644. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100645. */
  100646. highRefreshRate: boolean;
  100647. /**
  100648. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100649. */
  100650. foveationLevel: number;
  100651. }
  100652. interface Engine {
  100653. /** @hidden */
  100654. _vrDisplay: any;
  100655. /** @hidden */
  100656. _vrSupported: boolean;
  100657. /** @hidden */
  100658. _oldSize: Size;
  100659. /** @hidden */
  100660. _oldHardwareScaleFactor: number;
  100661. /** @hidden */
  100662. _vrExclusivePointerMode: boolean;
  100663. /** @hidden */
  100664. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100665. /** @hidden */
  100666. _onVRDisplayPointerRestricted: () => void;
  100667. /** @hidden */
  100668. _onVRDisplayPointerUnrestricted: () => void;
  100669. /** @hidden */
  100670. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100671. /** @hidden */
  100672. _onVrDisplayDisconnect: Nullable<() => void>;
  100673. /** @hidden */
  100674. _onVrDisplayPresentChange: Nullable<() => void>;
  100675. /**
  100676. * Observable signaled when VR display mode changes
  100677. */
  100678. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100679. /**
  100680. * Observable signaled when VR request present is complete
  100681. */
  100682. onVRRequestPresentComplete: Observable<boolean>;
  100683. /**
  100684. * Observable signaled when VR request present starts
  100685. */
  100686. onVRRequestPresentStart: Observable<Engine>;
  100687. /**
  100688. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100689. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100690. */
  100691. isInVRExclusivePointerMode: boolean;
  100692. /**
  100693. * Gets a boolean indicating if a webVR device was detected
  100694. * @returns true if a webVR device was detected
  100695. */
  100696. isVRDevicePresent(): boolean;
  100697. /**
  100698. * Gets the current webVR device
  100699. * @returns the current webVR device (or null)
  100700. */
  100701. getVRDevice(): any;
  100702. /**
  100703. * Initializes a webVR display and starts listening to display change events
  100704. * The onVRDisplayChangedObservable will be notified upon these changes
  100705. * @returns A promise containing a VRDisplay and if vr is supported
  100706. */
  100707. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100708. /** @hidden */
  100709. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100710. /**
  100711. * Gets or sets the presentation attributes used to configure VR rendering
  100712. */
  100713. vrPresentationAttributes?: IVRPresentationAttributes;
  100714. /**
  100715. * Call this function to switch to webVR mode
  100716. * Will do nothing if webVR is not supported or if there is no webVR device
  100717. * @param options the webvr options provided to the camera. mainly used for multiview
  100718. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100719. */
  100720. enableVR(options: WebVROptions): void;
  100721. /** @hidden */
  100722. _onVRFullScreenTriggered(): void;
  100723. }
  100724. }
  100725. declare module BABYLON {
  100726. /**
  100727. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100728. * IMPORTANT!! The data is right-hand data.
  100729. * @export
  100730. * @interface DevicePose
  100731. */
  100732. export interface DevicePose {
  100733. /**
  100734. * The position of the device, values in array are [x,y,z].
  100735. */
  100736. readonly position: Nullable<Float32Array>;
  100737. /**
  100738. * The linearVelocity of the device, values in array are [x,y,z].
  100739. */
  100740. readonly linearVelocity: Nullable<Float32Array>;
  100741. /**
  100742. * The linearAcceleration of the device, values in array are [x,y,z].
  100743. */
  100744. readonly linearAcceleration: Nullable<Float32Array>;
  100745. /**
  100746. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100747. */
  100748. readonly orientation: Nullable<Float32Array>;
  100749. /**
  100750. * The angularVelocity of the device, values in array are [x,y,z].
  100751. */
  100752. readonly angularVelocity: Nullable<Float32Array>;
  100753. /**
  100754. * The angularAcceleration of the device, values in array are [x,y,z].
  100755. */
  100756. readonly angularAcceleration: Nullable<Float32Array>;
  100757. }
  100758. /**
  100759. * Interface representing a pose controlled object in Babylon.
  100760. * A pose controlled object has both regular pose values as well as pose values
  100761. * from an external device such as a VR head mounted display
  100762. */
  100763. export interface PoseControlled {
  100764. /**
  100765. * The position of the object in babylon space.
  100766. */
  100767. position: Vector3;
  100768. /**
  100769. * The rotation quaternion of the object in babylon space.
  100770. */
  100771. rotationQuaternion: Quaternion;
  100772. /**
  100773. * The position of the device in babylon space.
  100774. */
  100775. devicePosition?: Vector3;
  100776. /**
  100777. * The rotation quaternion of the device in babylon space.
  100778. */
  100779. deviceRotationQuaternion: Quaternion;
  100780. /**
  100781. * The raw pose coming from the device.
  100782. */
  100783. rawPose: Nullable<DevicePose>;
  100784. /**
  100785. * The scale of the device to be used when translating from device space to babylon space.
  100786. */
  100787. deviceScaleFactor: number;
  100788. /**
  100789. * Updates the poseControlled values based on the input device pose.
  100790. * @param poseData the pose data to update the object with
  100791. */
  100792. updateFromDevice(poseData: DevicePose): void;
  100793. }
  100794. /**
  100795. * Set of options to customize the webVRCamera
  100796. */
  100797. export interface WebVROptions {
  100798. /**
  100799. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100800. */
  100801. trackPosition?: boolean;
  100802. /**
  100803. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100804. */
  100805. positionScale?: number;
  100806. /**
  100807. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100808. */
  100809. displayName?: string;
  100810. /**
  100811. * Should the native controller meshes be initialized. (default: true)
  100812. */
  100813. controllerMeshes?: boolean;
  100814. /**
  100815. * Creating a default HemiLight only on controllers. (default: true)
  100816. */
  100817. defaultLightingOnControllers?: boolean;
  100818. /**
  100819. * If you don't want to use the default VR button of the helper. (default: false)
  100820. */
  100821. useCustomVRButton?: boolean;
  100822. /**
  100823. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100824. */
  100825. customVRButton?: HTMLButtonElement;
  100826. /**
  100827. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100828. */
  100829. rayLength?: number;
  100830. /**
  100831. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100832. */
  100833. defaultHeight?: number;
  100834. /**
  100835. * If multiview should be used if availible (default: false)
  100836. */
  100837. useMultiview?: boolean;
  100838. }
  100839. /**
  100840. * This represents a WebVR camera.
  100841. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100842. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100843. */
  100844. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100845. private webVROptions;
  100846. /**
  100847. * @hidden
  100848. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100849. */
  100850. _vrDevice: any;
  100851. /**
  100852. * The rawPose of the vrDevice.
  100853. */
  100854. rawPose: Nullable<DevicePose>;
  100855. private _onVREnabled;
  100856. private _specsVersion;
  100857. private _attached;
  100858. private _frameData;
  100859. protected _descendants: Array<Node>;
  100860. private _deviceRoomPosition;
  100861. /** @hidden */
  100862. _deviceRoomRotationQuaternion: Quaternion;
  100863. private _standingMatrix;
  100864. /**
  100865. * Represents device position in babylon space.
  100866. */
  100867. devicePosition: Vector3;
  100868. /**
  100869. * Represents device rotation in babylon space.
  100870. */
  100871. deviceRotationQuaternion: Quaternion;
  100872. /**
  100873. * The scale of the device to be used when translating from device space to babylon space.
  100874. */
  100875. deviceScaleFactor: number;
  100876. private _deviceToWorld;
  100877. private _worldToDevice;
  100878. /**
  100879. * References to the webVR controllers for the vrDevice.
  100880. */
  100881. controllers: Array<WebVRController>;
  100882. /**
  100883. * Emits an event when a controller is attached.
  100884. */
  100885. onControllersAttachedObservable: Observable<WebVRController[]>;
  100886. /**
  100887. * Emits an event when a controller's mesh has been loaded;
  100888. */
  100889. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100890. /**
  100891. * Emits an event when the HMD's pose has been updated.
  100892. */
  100893. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100894. private _poseSet;
  100895. /**
  100896. * If the rig cameras be used as parent instead of this camera.
  100897. */
  100898. rigParenting: boolean;
  100899. private _lightOnControllers;
  100900. private _defaultHeight?;
  100901. /**
  100902. * Instantiates a WebVRFreeCamera.
  100903. * @param name The name of the WebVRFreeCamera
  100904. * @param position The starting anchor position for the camera
  100905. * @param scene The scene the camera belongs to
  100906. * @param webVROptions a set of customizable options for the webVRCamera
  100907. */
  100908. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100909. /**
  100910. * Gets the device distance from the ground in meters.
  100911. * @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.
  100912. */
  100913. deviceDistanceToRoomGround(): number;
  100914. /**
  100915. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100916. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100917. */
  100918. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100919. /**
  100920. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100921. * @returns A promise with a boolean set to if the standing matrix is supported.
  100922. */
  100923. useStandingMatrixAsync(): Promise<boolean>;
  100924. /**
  100925. * Disposes the camera
  100926. */
  100927. dispose(): void;
  100928. /**
  100929. * Gets a vrController by name.
  100930. * @param name The name of the controller to retreive
  100931. * @returns the controller matching the name specified or null if not found
  100932. */
  100933. getControllerByName(name: string): Nullable<WebVRController>;
  100934. private _leftController;
  100935. /**
  100936. * The controller corresponding to the users left hand.
  100937. */
  100938. get leftController(): Nullable<WebVRController>;
  100939. private _rightController;
  100940. /**
  100941. * The controller corresponding to the users right hand.
  100942. */
  100943. get rightController(): Nullable<WebVRController>;
  100944. /**
  100945. * Casts a ray forward from the vrCamera's gaze.
  100946. * @param length Length of the ray (default: 100)
  100947. * @returns the ray corresponding to the gaze
  100948. */
  100949. getForwardRay(length?: number): Ray;
  100950. /**
  100951. * @hidden
  100952. * Updates the camera based on device's frame data
  100953. */
  100954. _checkInputs(): void;
  100955. /**
  100956. * Updates the poseControlled values based on the input device pose.
  100957. * @param poseData Pose coming from the device
  100958. */
  100959. updateFromDevice(poseData: DevicePose): void;
  100960. private _htmlElementAttached;
  100961. private _detachIfAttached;
  100962. /**
  100963. * WebVR's attach control will start broadcasting frames to the device.
  100964. * Note that in certain browsers (chrome for example) this function must be called
  100965. * within a user-interaction callback. Example:
  100966. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100967. *
  100968. * @param element html element to attach the vrDevice to
  100969. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100970. */
  100971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100972. /**
  100973. * Detaches the camera from the html element and disables VR
  100974. *
  100975. * @param element html element to detach from
  100976. */
  100977. detachControl(element: HTMLElement): void;
  100978. /**
  100979. * @returns the name of this class
  100980. */
  100981. getClassName(): string;
  100982. /**
  100983. * Calls resetPose on the vrDisplay
  100984. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100985. */
  100986. resetToCurrentRotation(): void;
  100987. /**
  100988. * @hidden
  100989. * Updates the rig cameras (left and right eye)
  100990. */
  100991. _updateRigCameras(): void;
  100992. private _workingVector;
  100993. private _oneVector;
  100994. private _workingMatrix;
  100995. private updateCacheCalled;
  100996. private _correctPositionIfNotTrackPosition;
  100997. /**
  100998. * @hidden
  100999. * Updates the cached values of the camera
  101000. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  101001. */
  101002. _updateCache(ignoreParentClass?: boolean): void;
  101003. /**
  101004. * @hidden
  101005. * Get current device position in babylon world
  101006. */
  101007. _computeDevicePosition(): void;
  101008. /**
  101009. * Updates the current device position and rotation in the babylon world
  101010. */
  101011. update(): void;
  101012. /**
  101013. * @hidden
  101014. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  101015. * @returns an identity matrix
  101016. */
  101017. _getViewMatrix(): Matrix;
  101018. private _tmpMatrix;
  101019. /**
  101020. * This function is called by the two RIG cameras.
  101021. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  101022. * @hidden
  101023. */
  101024. _getWebVRViewMatrix(): Matrix;
  101025. /** @hidden */
  101026. _getWebVRProjectionMatrix(): Matrix;
  101027. private _onGamepadConnectedObserver;
  101028. private _onGamepadDisconnectedObserver;
  101029. private _updateCacheWhenTrackingDisabledObserver;
  101030. /**
  101031. * Initializes the controllers and their meshes
  101032. */
  101033. initControllers(): void;
  101034. }
  101035. }
  101036. declare module BABYLON {
  101037. /**
  101038. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  101039. *
  101040. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  101041. *
  101042. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  101043. */
  101044. export class MaterialHelper {
  101045. /**
  101046. * Bind the current view position to an effect.
  101047. * @param effect The effect to be bound
  101048. * @param scene The scene the eyes position is used from
  101049. * @param variableName name of the shader variable that will hold the eye position
  101050. */
  101051. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  101052. /**
  101053. * Helps preparing the defines values about the UVs in used in the effect.
  101054. * UVs are shared as much as we can accross channels in the shaders.
  101055. * @param texture The texture we are preparing the UVs for
  101056. * @param defines The defines to update
  101057. * @param key The channel key "diffuse", "specular"... used in the shader
  101058. */
  101059. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  101060. /**
  101061. * Binds a texture matrix value to its corrsponding uniform
  101062. * @param texture The texture to bind the matrix for
  101063. * @param uniformBuffer The uniform buffer receivin the data
  101064. * @param key The channel key "diffuse", "specular"... used in the shader
  101065. */
  101066. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  101067. /**
  101068. * Gets the current status of the fog (should it be enabled?)
  101069. * @param mesh defines the mesh to evaluate for fog support
  101070. * @param scene defines the hosting scene
  101071. * @returns true if fog must be enabled
  101072. */
  101073. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  101074. /**
  101075. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  101076. * @param mesh defines the current mesh
  101077. * @param scene defines the current scene
  101078. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  101079. * @param pointsCloud defines if point cloud rendering has to be turned on
  101080. * @param fogEnabled defines if fog has to be turned on
  101081. * @param alphaTest defines if alpha testing has to be turned on
  101082. * @param defines defines the current list of defines
  101083. */
  101084. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  101085. /**
  101086. * Helper used to prepare the list of defines associated with frame values for shader compilation
  101087. * @param scene defines the current scene
  101088. * @param engine defines the current engine
  101089. * @param defines specifies the list of active defines
  101090. * @param useInstances defines if instances have to be turned on
  101091. * @param useClipPlane defines if clip plane have to be turned on
  101092. * @param useInstances defines if instances have to be turned on
  101093. * @param useThinInstances defines if thin instances have to be turned on
  101094. */
  101095. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101096. /**
  101097. * Prepares the defines for bones
  101098. * @param mesh The mesh containing the geometry data we will draw
  101099. * @param defines The defines to update
  101100. */
  101101. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101102. /**
  101103. * Prepares the defines for morph targets
  101104. * @param mesh The mesh containing the geometry data we will draw
  101105. * @param defines The defines to update
  101106. */
  101107. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101108. /**
  101109. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101110. * @param mesh The mesh containing the geometry data we will draw
  101111. * @param defines The defines to update
  101112. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101113. * @param useBones Precise whether bones should be used or not (override mesh info)
  101114. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101115. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101116. * @returns false if defines are considered not dirty and have not been checked
  101117. */
  101118. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101119. /**
  101120. * Prepares the defines related to multiview
  101121. * @param scene The scene we are intending to draw
  101122. * @param defines The defines to update
  101123. */
  101124. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101125. /**
  101126. * Prepares the defines related to the prepass
  101127. * @param scene The scene we are intending to draw
  101128. * @param defines The defines to update
  101129. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101130. */
  101131. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101132. /**
  101133. * Prepares the defines related to the light information passed in parameter
  101134. * @param scene The scene we are intending to draw
  101135. * @param mesh The mesh the effect is compiling for
  101136. * @param light The light the effect is compiling for
  101137. * @param lightIndex The index of the light
  101138. * @param defines The defines to update
  101139. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101140. * @param state Defines the current state regarding what is needed (normals, etc...)
  101141. */
  101142. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101143. needNormals: boolean;
  101144. needRebuild: boolean;
  101145. shadowEnabled: boolean;
  101146. specularEnabled: boolean;
  101147. lightmapMode: boolean;
  101148. }): void;
  101149. /**
  101150. * Prepares the defines related to the light information passed in parameter
  101151. * @param scene The scene we are intending to draw
  101152. * @param mesh The mesh the effect is compiling for
  101153. * @param defines The defines to update
  101154. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101155. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101156. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101157. * @returns true if normals will be required for the rest of the effect
  101158. */
  101159. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101160. /**
  101161. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101162. * @param lightIndex defines the light index
  101163. * @param uniformsList The uniform list
  101164. * @param samplersList The sampler list
  101165. * @param projectedLightTexture defines if projected texture must be used
  101166. * @param uniformBuffersList defines an optional list of uniform buffers
  101167. */
  101168. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101169. /**
  101170. * Prepares the uniforms and samplers list to be used in the effect
  101171. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101172. * @param samplersList The sampler list
  101173. * @param defines The defines helping in the list generation
  101174. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101175. */
  101176. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101177. /**
  101178. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101179. * @param defines The defines to update while falling back
  101180. * @param fallbacks The authorized effect fallbacks
  101181. * @param maxSimultaneousLights The maximum number of lights allowed
  101182. * @param rank the current rank of the Effect
  101183. * @returns The newly affected rank
  101184. */
  101185. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101186. private static _TmpMorphInfluencers;
  101187. /**
  101188. * Prepares the list of attributes required for morph targets according to the effect defines.
  101189. * @param attribs The current list of supported attribs
  101190. * @param mesh The mesh to prepare the morph targets attributes for
  101191. * @param influencers The number of influencers
  101192. */
  101193. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101194. /**
  101195. * Prepares the list of attributes required for morph targets according to the effect defines.
  101196. * @param attribs The current list of supported attribs
  101197. * @param mesh The mesh to prepare the morph targets attributes for
  101198. * @param defines The current Defines of the effect
  101199. */
  101200. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  101201. /**
  101202. * Prepares the list of attributes required for bones according to the effect defines.
  101203. * @param attribs The current list of supported attribs
  101204. * @param mesh The mesh to prepare the bones attributes for
  101205. * @param defines The current Defines of the effect
  101206. * @param fallbacks The current efffect fallback strategy
  101207. */
  101208. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  101209. /**
  101210. * Check and prepare the list of attributes required for instances according to the effect defines.
  101211. * @param attribs The current list of supported attribs
  101212. * @param defines The current MaterialDefines of the effect
  101213. */
  101214. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  101215. /**
  101216. * Add the list of attributes required for instances to the attribs array.
  101217. * @param attribs The current list of supported attribs
  101218. */
  101219. static PushAttributesForInstances(attribs: string[]): void;
  101220. /**
  101221. * Binds the light information to the effect.
  101222. * @param light The light containing the generator
  101223. * @param effect The effect we are binding the data to
  101224. * @param lightIndex The light index in the effect used to render
  101225. */
  101226. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  101227. /**
  101228. * Binds the lights information from the scene to the effect for the given mesh.
  101229. * @param light Light to bind
  101230. * @param lightIndex Light index
  101231. * @param scene The scene where the light belongs to
  101232. * @param effect The effect we are binding the data to
  101233. * @param useSpecular Defines if specular is supported
  101234. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101235. */
  101236. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  101237. /**
  101238. * Binds the lights information from the scene to the effect for the given mesh.
  101239. * @param scene The scene the lights belongs to
  101240. * @param mesh The mesh we are binding the information to render
  101241. * @param effect The effect we are binding the data to
  101242. * @param defines The generated defines for the effect
  101243. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  101244. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101245. */
  101246. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101247. private static _tempFogColor;
  101248. /**
  101249. * Binds the fog information from the scene to the effect for the given mesh.
  101250. * @param scene The scene the lights belongs to
  101251. * @param mesh The mesh we are binding the information to render
  101252. * @param effect The effect we are binding the data to
  101253. * @param linearSpace Defines if the fog effect is applied in linear space
  101254. */
  101255. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101256. /**
  101257. * Binds the bones information from the mesh to the effect.
  101258. * @param mesh The mesh we are binding the information to render
  101259. * @param effect The effect we are binding the data to
  101260. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101261. */
  101262. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101263. private static _CopyBonesTransformationMatrices;
  101264. /**
  101265. * Binds the morph targets information from the mesh to the effect.
  101266. * @param abstractMesh The mesh we are binding the information to render
  101267. * @param effect The effect we are binding the data to
  101268. */
  101269. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101270. /**
  101271. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101272. * @param defines The generated defines used in the effect
  101273. * @param effect The effect we are binding the data to
  101274. * @param scene The scene we are willing to render with logarithmic scale for
  101275. */
  101276. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101277. /**
  101278. * Binds the clip plane information from the scene to the effect.
  101279. * @param scene The scene the clip plane information are extracted from
  101280. * @param effect The effect we are binding the data to
  101281. */
  101282. static BindClipPlane(effect: Effect, scene: Scene): void;
  101283. }
  101284. }
  101285. declare module BABYLON {
  101286. /**
  101287. * Block used to expose an input value
  101288. */
  101289. export class InputBlock extends NodeMaterialBlock {
  101290. private _mode;
  101291. private _associatedVariableName;
  101292. private _storedValue;
  101293. private _valueCallback;
  101294. private _type;
  101295. private _animationType;
  101296. /** Gets or set a value used to limit the range of float values */
  101297. min: number;
  101298. /** Gets or set a value used to limit the range of float values */
  101299. max: number;
  101300. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  101301. isBoolean: boolean;
  101302. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  101303. matrixMode: number;
  101304. /** @hidden */
  101305. _systemValue: Nullable<NodeMaterialSystemValues>;
  101306. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  101307. isConstant: boolean;
  101308. /** Gets or sets the group to use to display this block in the Inspector */
  101309. groupInInspector: string;
  101310. /** Gets an observable raised when the value is changed */
  101311. onValueChangedObservable: Observable<InputBlock>;
  101312. /**
  101313. * Gets or sets the connection point type (default is float)
  101314. */
  101315. get type(): NodeMaterialBlockConnectionPointTypes;
  101316. /**
  101317. * Creates a new InputBlock
  101318. * @param name defines the block name
  101319. * @param target defines the target of that block (Vertex by default)
  101320. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  101321. */
  101322. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  101323. /**
  101324. * Validates if a name is a reserve word.
  101325. * @param newName the new name to be given to the node.
  101326. * @returns false if the name is a reserve word, else true.
  101327. */
  101328. validateBlockName(newName: string): boolean;
  101329. /**
  101330. * Gets the output component
  101331. */
  101332. get output(): NodeMaterialConnectionPoint;
  101333. /**
  101334. * Set the source of this connection point to a vertex attribute
  101335. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  101336. * @returns the current connection point
  101337. */
  101338. setAsAttribute(attributeName?: string): InputBlock;
  101339. /**
  101340. * Set the source of this connection point to a system value
  101341. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  101342. * @returns the current connection point
  101343. */
  101344. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  101345. /**
  101346. * Gets or sets the value of that point.
  101347. * Please note that this value will be ignored if valueCallback is defined
  101348. */
  101349. get value(): any;
  101350. set value(value: any);
  101351. /**
  101352. * Gets or sets a callback used to get the value of that point.
  101353. * Please note that setting this value will force the connection point to ignore the value property
  101354. */
  101355. get valueCallback(): () => any;
  101356. set valueCallback(value: () => any);
  101357. /**
  101358. * Gets or sets the associated variable name in the shader
  101359. */
  101360. get associatedVariableName(): string;
  101361. set associatedVariableName(value: string);
  101362. /** Gets or sets the type of animation applied to the input */
  101363. get animationType(): AnimatedInputBlockTypes;
  101364. set animationType(value: AnimatedInputBlockTypes);
  101365. /**
  101366. * Gets a boolean indicating that this connection point not defined yet
  101367. */
  101368. get isUndefined(): boolean;
  101369. /**
  101370. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  101371. * In this case the connection point name must be the name of the uniform to use.
  101372. * Can only be set on inputs
  101373. */
  101374. get isUniform(): boolean;
  101375. set isUniform(value: boolean);
  101376. /**
  101377. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  101378. * In this case the connection point name must be the name of the attribute to use
  101379. * Can only be set on inputs
  101380. */
  101381. get isAttribute(): boolean;
  101382. set isAttribute(value: boolean);
  101383. /**
  101384. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  101385. * Can only be set on exit points
  101386. */
  101387. get isVarying(): boolean;
  101388. set isVarying(value: boolean);
  101389. /**
  101390. * Gets a boolean indicating that the current connection point is a system value
  101391. */
  101392. get isSystemValue(): boolean;
  101393. /**
  101394. * Gets or sets the current well known value or null if not defined as a system value
  101395. */
  101396. get systemValue(): Nullable<NodeMaterialSystemValues>;
  101397. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  101398. /**
  101399. * Gets the current class name
  101400. * @returns the class name
  101401. */
  101402. getClassName(): string;
  101403. /**
  101404. * Animate the input if animationType !== None
  101405. * @param scene defines the rendering scene
  101406. */
  101407. animate(scene: Scene): void;
  101408. private _emitDefine;
  101409. initialize(state: NodeMaterialBuildState): void;
  101410. /**
  101411. * Set the input block to its default value (based on its type)
  101412. */
  101413. setDefaultValue(): void;
  101414. private _emitConstant;
  101415. /** @hidden */
  101416. get _noContextSwitch(): boolean;
  101417. private _emit;
  101418. /** @hidden */
  101419. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  101420. /** @hidden */
  101421. _transmit(effect: Effect, scene: Scene): void;
  101422. protected _buildBlock(state: NodeMaterialBuildState): void;
  101423. protected _dumpPropertiesCode(): string;
  101424. dispose(): void;
  101425. serialize(): any;
  101426. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101427. }
  101428. }
  101429. declare module BABYLON {
  101430. /**
  101431. * Enum used to define the compatibility state between two connection points
  101432. */
  101433. export enum NodeMaterialConnectionPointCompatibilityStates {
  101434. /** Points are compatibles */
  101435. Compatible = 0,
  101436. /** Points are incompatible because of their types */
  101437. TypeIncompatible = 1,
  101438. /** Points are incompatible because of their targets (vertex vs fragment) */
  101439. TargetIncompatible = 2
  101440. }
  101441. /**
  101442. * Defines the direction of a connection point
  101443. */
  101444. export enum NodeMaterialConnectionPointDirection {
  101445. /** Input */
  101446. Input = 0,
  101447. /** Output */
  101448. Output = 1
  101449. }
  101450. /**
  101451. * Defines a connection point for a block
  101452. */
  101453. export class NodeMaterialConnectionPoint {
  101454. /** @hidden */
  101455. _ownerBlock: NodeMaterialBlock;
  101456. /** @hidden */
  101457. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  101458. private _endpoints;
  101459. private _associatedVariableName;
  101460. private _direction;
  101461. /** @hidden */
  101462. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101463. /** @hidden */
  101464. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101465. private _type;
  101466. /** @hidden */
  101467. _enforceAssociatedVariableName: boolean;
  101468. /** Gets the direction of the point */
  101469. get direction(): NodeMaterialConnectionPointDirection;
  101470. /** Indicates that this connection point needs dual validation before being connected to another point */
  101471. needDualDirectionValidation: boolean;
  101472. /**
  101473. * Gets or sets the additional types supported by this connection point
  101474. */
  101475. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101476. /**
  101477. * Gets or sets the additional types excluded by this connection point
  101478. */
  101479. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101480. /**
  101481. * Observable triggered when this point is connected
  101482. */
  101483. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101484. /**
  101485. * Gets or sets the associated variable name in the shader
  101486. */
  101487. get associatedVariableName(): string;
  101488. set associatedVariableName(value: string);
  101489. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101490. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101491. /**
  101492. * Gets or sets the connection point type (default is float)
  101493. */
  101494. get type(): NodeMaterialBlockConnectionPointTypes;
  101495. set type(value: NodeMaterialBlockConnectionPointTypes);
  101496. /**
  101497. * Gets or sets the connection point name
  101498. */
  101499. name: string;
  101500. /**
  101501. * Gets or sets the connection point name
  101502. */
  101503. displayName: string;
  101504. /**
  101505. * Gets or sets a boolean indicating that this connection point can be omitted
  101506. */
  101507. isOptional: boolean;
  101508. /**
  101509. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101510. */
  101511. isExposedOnFrame: boolean;
  101512. /**
  101513. * Gets or sets number indicating the position that the port is exposed to on a frame
  101514. */
  101515. exposedPortPosition: number;
  101516. /**
  101517. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101518. */
  101519. define: string;
  101520. /** @hidden */
  101521. _prioritizeVertex: boolean;
  101522. private _target;
  101523. /** Gets or sets the target of that connection point */
  101524. get target(): NodeMaterialBlockTargets;
  101525. set target(value: NodeMaterialBlockTargets);
  101526. /**
  101527. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101528. */
  101529. get isConnected(): boolean;
  101530. /**
  101531. * Gets a boolean indicating that the current point is connected to an input block
  101532. */
  101533. get isConnectedToInputBlock(): boolean;
  101534. /**
  101535. * Gets a the connected input block (if any)
  101536. */
  101537. get connectInputBlock(): Nullable<InputBlock>;
  101538. /** Get the other side of the connection (if any) */
  101539. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101540. /** Get the block that owns this connection point */
  101541. get ownerBlock(): NodeMaterialBlock;
  101542. /** Get the block connected on the other side of this connection (if any) */
  101543. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101544. /** Get the block connected on the endpoints of this connection (if any) */
  101545. get connectedBlocks(): Array<NodeMaterialBlock>;
  101546. /** Gets the list of connected endpoints */
  101547. get endpoints(): NodeMaterialConnectionPoint[];
  101548. /** Gets a boolean indicating if that output point is connected to at least one input */
  101549. get hasEndpoints(): boolean;
  101550. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101551. get isConnectedInVertexShader(): boolean;
  101552. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101553. get isConnectedInFragmentShader(): boolean;
  101554. /**
  101555. * Creates a block suitable to be used as an input for this input point.
  101556. * If null is returned, a block based on the point type will be created.
  101557. * @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
  101558. */
  101559. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101560. /**
  101561. * Creates a new connection point
  101562. * @param name defines the connection point name
  101563. * @param ownerBlock defines the block hosting this connection point
  101564. * @param direction defines the direction of the connection point
  101565. */
  101566. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101567. /**
  101568. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101569. * @returns the class name
  101570. */
  101571. getClassName(): string;
  101572. /**
  101573. * Gets a boolean indicating if the current point can be connected to another point
  101574. * @param connectionPoint defines the other connection point
  101575. * @returns a boolean
  101576. */
  101577. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101578. /**
  101579. * Gets a number indicating if the current point can be connected to another point
  101580. * @param connectionPoint defines the other connection point
  101581. * @returns a number defining the compatibility state
  101582. */
  101583. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101584. /**
  101585. * Connect this point to another connection point
  101586. * @param connectionPoint defines the other connection point
  101587. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101588. * @returns the current connection point
  101589. */
  101590. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101591. /**
  101592. * Disconnect this point from one of his endpoint
  101593. * @param endpoint defines the other connection point
  101594. * @returns the current connection point
  101595. */
  101596. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101597. /**
  101598. * Serializes this point in a JSON representation
  101599. * @param isInput defines if the connection point is an input (default is true)
  101600. * @returns the serialized point object
  101601. */
  101602. serialize(isInput?: boolean): any;
  101603. /**
  101604. * Release resources
  101605. */
  101606. dispose(): void;
  101607. }
  101608. }
  101609. declare module BABYLON {
  101610. /**
  101611. * Enum used to define the material modes
  101612. */
  101613. export enum NodeMaterialModes {
  101614. /** Regular material */
  101615. Material = 0,
  101616. /** For post process */
  101617. PostProcess = 1,
  101618. /** For particle system */
  101619. Particle = 2,
  101620. /** For procedural texture */
  101621. ProceduralTexture = 3
  101622. }
  101623. }
  101624. declare module BABYLON {
  101625. /**
  101626. * Block used to read a texture from a sampler
  101627. */
  101628. export class TextureBlock extends NodeMaterialBlock {
  101629. private _defineName;
  101630. private _linearDefineName;
  101631. private _gammaDefineName;
  101632. private _tempTextureRead;
  101633. private _samplerName;
  101634. private _transformedUVName;
  101635. private _textureTransformName;
  101636. private _textureInfoName;
  101637. private _mainUVName;
  101638. private _mainUVDefineName;
  101639. private _fragmentOnly;
  101640. /**
  101641. * Gets or sets the texture associated with the node
  101642. */
  101643. texture: Nullable<Texture>;
  101644. /**
  101645. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101646. */
  101647. convertToGammaSpace: boolean;
  101648. /**
  101649. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101650. */
  101651. convertToLinearSpace: boolean;
  101652. /**
  101653. * Create a new TextureBlock
  101654. * @param name defines the block name
  101655. */
  101656. constructor(name: string, fragmentOnly?: boolean);
  101657. /**
  101658. * Gets the current class name
  101659. * @returns the class name
  101660. */
  101661. getClassName(): string;
  101662. /**
  101663. * Gets the uv input component
  101664. */
  101665. get uv(): NodeMaterialConnectionPoint;
  101666. /**
  101667. * Gets the rgba output component
  101668. */
  101669. get rgba(): NodeMaterialConnectionPoint;
  101670. /**
  101671. * Gets the rgb output component
  101672. */
  101673. get rgb(): NodeMaterialConnectionPoint;
  101674. /**
  101675. * Gets the r output component
  101676. */
  101677. get r(): NodeMaterialConnectionPoint;
  101678. /**
  101679. * Gets the g output component
  101680. */
  101681. get g(): NodeMaterialConnectionPoint;
  101682. /**
  101683. * Gets the b output component
  101684. */
  101685. get b(): NodeMaterialConnectionPoint;
  101686. /**
  101687. * Gets the a output component
  101688. */
  101689. get a(): NodeMaterialConnectionPoint;
  101690. get target(): NodeMaterialBlockTargets;
  101691. autoConfigure(material: NodeMaterial): void;
  101692. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101693. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101694. isReady(): boolean;
  101695. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101696. private get _isMixed();
  101697. private _injectVertexCode;
  101698. private _writeTextureRead;
  101699. private _writeOutput;
  101700. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101701. protected _dumpPropertiesCode(): string;
  101702. serialize(): any;
  101703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101704. }
  101705. }
  101706. declare module BABYLON {
  101707. /** @hidden */
  101708. export var reflectionFunction: {
  101709. name: string;
  101710. shader: string;
  101711. };
  101712. }
  101713. declare module BABYLON {
  101714. /**
  101715. * Base block used to read a reflection texture from a sampler
  101716. */
  101717. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101718. /** @hidden */
  101719. _define3DName: string;
  101720. /** @hidden */
  101721. _defineCubicName: string;
  101722. /** @hidden */
  101723. _defineExplicitName: string;
  101724. /** @hidden */
  101725. _defineProjectionName: string;
  101726. /** @hidden */
  101727. _defineLocalCubicName: string;
  101728. /** @hidden */
  101729. _defineSphericalName: string;
  101730. /** @hidden */
  101731. _definePlanarName: string;
  101732. /** @hidden */
  101733. _defineEquirectangularName: string;
  101734. /** @hidden */
  101735. _defineMirroredEquirectangularFixedName: string;
  101736. /** @hidden */
  101737. _defineEquirectangularFixedName: string;
  101738. /** @hidden */
  101739. _defineSkyboxName: string;
  101740. /** @hidden */
  101741. _defineOppositeZ: string;
  101742. /** @hidden */
  101743. _cubeSamplerName: string;
  101744. /** @hidden */
  101745. _2DSamplerName: string;
  101746. protected _positionUVWName: string;
  101747. protected _directionWName: string;
  101748. protected _reflectionVectorName: string;
  101749. /** @hidden */
  101750. _reflectionCoordsName: string;
  101751. /** @hidden */
  101752. _reflectionMatrixName: string;
  101753. protected _reflectionColorName: string;
  101754. /**
  101755. * Gets or sets the texture associated with the node
  101756. */
  101757. texture: Nullable<BaseTexture>;
  101758. /**
  101759. * Create a new ReflectionTextureBaseBlock
  101760. * @param name defines the block name
  101761. */
  101762. constructor(name: string);
  101763. /**
  101764. * Gets the current class name
  101765. * @returns the class name
  101766. */
  101767. getClassName(): string;
  101768. /**
  101769. * Gets the world position input component
  101770. */
  101771. abstract get position(): NodeMaterialConnectionPoint;
  101772. /**
  101773. * Gets the world position input component
  101774. */
  101775. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101776. /**
  101777. * Gets the world normal input component
  101778. */
  101779. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101780. /**
  101781. * Gets the world input component
  101782. */
  101783. abstract get world(): NodeMaterialConnectionPoint;
  101784. /**
  101785. * Gets the camera (or eye) position component
  101786. */
  101787. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101788. /**
  101789. * Gets the view input component
  101790. */
  101791. abstract get view(): NodeMaterialConnectionPoint;
  101792. protected _getTexture(): Nullable<BaseTexture>;
  101793. autoConfigure(material: NodeMaterial): void;
  101794. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101795. isReady(): boolean;
  101796. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101797. /**
  101798. * Gets the code to inject in the vertex shader
  101799. * @param state current state of the node material building
  101800. * @returns the shader code
  101801. */
  101802. handleVertexSide(state: NodeMaterialBuildState): string;
  101803. /**
  101804. * Handles the inits for the fragment code path
  101805. * @param state node material build state
  101806. */
  101807. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101808. /**
  101809. * Generates the reflection coords code for the fragment code path
  101810. * @param worldNormalVarName name of the world normal variable
  101811. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101812. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101813. * @returns the shader code
  101814. */
  101815. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101816. /**
  101817. * Generates the reflection color code for the fragment code path
  101818. * @param lodVarName name of the lod variable
  101819. * @param swizzleLookupTexture swizzle to use for the final color variable
  101820. * @returns the shader code
  101821. */
  101822. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101823. /**
  101824. * Generates the code corresponding to the connected output points
  101825. * @param state node material build state
  101826. * @param varName name of the variable to output
  101827. * @returns the shader code
  101828. */
  101829. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101830. protected _buildBlock(state: NodeMaterialBuildState): this;
  101831. protected _dumpPropertiesCode(): string;
  101832. serialize(): any;
  101833. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101834. }
  101835. }
  101836. declare module BABYLON {
  101837. /**
  101838. * Defines a connection point to be used for points with a custom object type
  101839. */
  101840. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101841. private _blockType;
  101842. private _blockName;
  101843. private _nameForCheking?;
  101844. /**
  101845. * Creates a new connection point
  101846. * @param name defines the connection point name
  101847. * @param ownerBlock defines the block hosting this connection point
  101848. * @param direction defines the direction of the connection point
  101849. */
  101850. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101851. /**
  101852. * Gets a number indicating if the current point can be connected to another point
  101853. * @param connectionPoint defines the other connection point
  101854. * @returns a number defining the compatibility state
  101855. */
  101856. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101857. /**
  101858. * Creates a block suitable to be used as an input for this input point.
  101859. * If null is returned, a block based on the point type will be created.
  101860. * @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
  101861. */
  101862. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101863. }
  101864. }
  101865. declare module BABYLON {
  101866. /**
  101867. * Enum defining the type of properties that can be edited in the property pages in the NME
  101868. */
  101869. export enum PropertyTypeForEdition {
  101870. /** property is a boolean */
  101871. Boolean = 0,
  101872. /** property is a float */
  101873. Float = 1,
  101874. /** property is a Vector2 */
  101875. Vector2 = 2,
  101876. /** property is a list of values */
  101877. List = 3
  101878. }
  101879. /**
  101880. * Interface that defines an option in a variable of type list
  101881. */
  101882. export interface IEditablePropertyListOption {
  101883. /** label of the option */
  101884. "label": string;
  101885. /** value of the option */
  101886. "value": number;
  101887. }
  101888. /**
  101889. * Interface that defines the options available for an editable property
  101890. */
  101891. export interface IEditablePropertyOption {
  101892. /** min value */
  101893. "min"?: number;
  101894. /** max value */
  101895. "max"?: number;
  101896. /** notifiers: indicates which actions to take when the property is changed */
  101897. "notifiers"?: {
  101898. /** the material should be rebuilt */
  101899. "rebuild"?: boolean;
  101900. /** the preview should be updated */
  101901. "update"?: boolean;
  101902. };
  101903. /** list of the options for a variable of type list */
  101904. "options"?: IEditablePropertyListOption[];
  101905. }
  101906. /**
  101907. * Interface that describes an editable property
  101908. */
  101909. export interface IPropertyDescriptionForEdition {
  101910. /** name of the property */
  101911. "propertyName": string;
  101912. /** display name of the property */
  101913. "displayName": string;
  101914. /** type of the property */
  101915. "type": PropertyTypeForEdition;
  101916. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101917. "groupName": string;
  101918. /** options for the property */
  101919. "options": IEditablePropertyOption;
  101920. }
  101921. /**
  101922. * Decorator that flags a property in a node material block as being editable
  101923. */
  101924. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101925. }
  101926. declare module BABYLON {
  101927. /**
  101928. * Block used to implement the refraction part of the sub surface module of the PBR material
  101929. */
  101930. export class RefractionBlock extends NodeMaterialBlock {
  101931. /** @hidden */
  101932. _define3DName: string;
  101933. /** @hidden */
  101934. _refractionMatrixName: string;
  101935. /** @hidden */
  101936. _defineLODRefractionAlpha: string;
  101937. /** @hidden */
  101938. _defineLinearSpecularRefraction: string;
  101939. /** @hidden */
  101940. _defineOppositeZ: string;
  101941. /** @hidden */
  101942. _cubeSamplerName: string;
  101943. /** @hidden */
  101944. _2DSamplerName: string;
  101945. /** @hidden */
  101946. _vRefractionMicrosurfaceInfosName: string;
  101947. /** @hidden */
  101948. _vRefractionInfosName: string;
  101949. private _scene;
  101950. /**
  101951. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101952. * Materials half opaque for instance using refraction could benefit from this control.
  101953. */
  101954. linkRefractionWithTransparency: boolean;
  101955. /**
  101956. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101957. */
  101958. invertRefractionY: boolean;
  101959. /**
  101960. * Gets or sets the texture associated with the node
  101961. */
  101962. texture: Nullable<BaseTexture>;
  101963. /**
  101964. * Create a new RefractionBlock
  101965. * @param name defines the block name
  101966. */
  101967. constructor(name: string);
  101968. /**
  101969. * Gets the current class name
  101970. * @returns the class name
  101971. */
  101972. getClassName(): string;
  101973. /**
  101974. * Gets the intensity input component
  101975. */
  101976. get intensity(): NodeMaterialConnectionPoint;
  101977. /**
  101978. * Gets the index of refraction input component
  101979. */
  101980. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101981. /**
  101982. * Gets the tint at distance input component
  101983. */
  101984. get tintAtDistance(): NodeMaterialConnectionPoint;
  101985. /**
  101986. * Gets the view input component
  101987. */
  101988. get view(): NodeMaterialConnectionPoint;
  101989. /**
  101990. * Gets the refraction object output component
  101991. */
  101992. get refraction(): NodeMaterialConnectionPoint;
  101993. /**
  101994. * Returns true if the block has a texture
  101995. */
  101996. get hasTexture(): boolean;
  101997. protected _getTexture(): Nullable<BaseTexture>;
  101998. autoConfigure(material: NodeMaterial): void;
  101999. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102000. isReady(): boolean;
  102001. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102002. /**
  102003. * Gets the main code of the block (fragment side)
  102004. * @param state current state of the node material building
  102005. * @returns the shader code
  102006. */
  102007. getCode(state: NodeMaterialBuildState): string;
  102008. protected _buildBlock(state: NodeMaterialBuildState): this;
  102009. protected _dumpPropertiesCode(): string;
  102010. serialize(): any;
  102011. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102012. }
  102013. }
  102014. declare module BABYLON {
  102015. /**
  102016. * Base block used as input for post process
  102017. */
  102018. export class CurrentScreenBlock extends NodeMaterialBlock {
  102019. private _samplerName;
  102020. private _linearDefineName;
  102021. private _gammaDefineName;
  102022. private _mainUVName;
  102023. private _tempTextureRead;
  102024. /**
  102025. * Gets or sets the texture associated with the node
  102026. */
  102027. texture: Nullable<BaseTexture>;
  102028. /**
  102029. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102030. */
  102031. convertToGammaSpace: boolean;
  102032. /**
  102033. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102034. */
  102035. convertToLinearSpace: boolean;
  102036. /**
  102037. * Create a new CurrentScreenBlock
  102038. * @param name defines the block name
  102039. */
  102040. constructor(name: string);
  102041. /**
  102042. * Gets the current class name
  102043. * @returns the class name
  102044. */
  102045. getClassName(): string;
  102046. /**
  102047. * Gets the uv input component
  102048. */
  102049. get uv(): NodeMaterialConnectionPoint;
  102050. /**
  102051. * Gets the rgba output component
  102052. */
  102053. get rgba(): NodeMaterialConnectionPoint;
  102054. /**
  102055. * Gets the rgb output component
  102056. */
  102057. get rgb(): NodeMaterialConnectionPoint;
  102058. /**
  102059. * Gets the r output component
  102060. */
  102061. get r(): NodeMaterialConnectionPoint;
  102062. /**
  102063. * Gets the g output component
  102064. */
  102065. get g(): NodeMaterialConnectionPoint;
  102066. /**
  102067. * Gets the b output component
  102068. */
  102069. get b(): NodeMaterialConnectionPoint;
  102070. /**
  102071. * Gets the a output component
  102072. */
  102073. get a(): NodeMaterialConnectionPoint;
  102074. /**
  102075. * Initialize the block and prepare the context for build
  102076. * @param state defines the state that will be used for the build
  102077. */
  102078. initialize(state: NodeMaterialBuildState): void;
  102079. get target(): NodeMaterialBlockTargets;
  102080. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102081. isReady(): boolean;
  102082. private _injectVertexCode;
  102083. private _writeTextureRead;
  102084. private _writeOutput;
  102085. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102086. serialize(): any;
  102087. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102088. }
  102089. }
  102090. declare module BABYLON {
  102091. /**
  102092. * Base block used for the particle texture
  102093. */
  102094. export class ParticleTextureBlock extends NodeMaterialBlock {
  102095. private _samplerName;
  102096. private _linearDefineName;
  102097. private _gammaDefineName;
  102098. private _tempTextureRead;
  102099. /**
  102100. * Gets or sets the texture associated with the node
  102101. */
  102102. texture: Nullable<BaseTexture>;
  102103. /**
  102104. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102105. */
  102106. convertToGammaSpace: boolean;
  102107. /**
  102108. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102109. */
  102110. convertToLinearSpace: boolean;
  102111. /**
  102112. * Create a new ParticleTextureBlock
  102113. * @param name defines the block name
  102114. */
  102115. constructor(name: string);
  102116. /**
  102117. * Gets the current class name
  102118. * @returns the class name
  102119. */
  102120. getClassName(): string;
  102121. /**
  102122. * Gets the uv input component
  102123. */
  102124. get uv(): NodeMaterialConnectionPoint;
  102125. /**
  102126. * Gets the rgba output component
  102127. */
  102128. get rgba(): NodeMaterialConnectionPoint;
  102129. /**
  102130. * Gets the rgb output component
  102131. */
  102132. get rgb(): NodeMaterialConnectionPoint;
  102133. /**
  102134. * Gets the r output component
  102135. */
  102136. get r(): NodeMaterialConnectionPoint;
  102137. /**
  102138. * Gets the g output component
  102139. */
  102140. get g(): NodeMaterialConnectionPoint;
  102141. /**
  102142. * Gets the b output component
  102143. */
  102144. get b(): NodeMaterialConnectionPoint;
  102145. /**
  102146. * Gets the a output component
  102147. */
  102148. get a(): NodeMaterialConnectionPoint;
  102149. /**
  102150. * Initialize the block and prepare the context for build
  102151. * @param state defines the state that will be used for the build
  102152. */
  102153. initialize(state: NodeMaterialBuildState): void;
  102154. autoConfigure(material: NodeMaterial): void;
  102155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102156. isReady(): boolean;
  102157. private _writeOutput;
  102158. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102159. serialize(): any;
  102160. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102161. }
  102162. }
  102163. declare module BABYLON {
  102164. /**
  102165. * Class used to store shared data between 2 NodeMaterialBuildState
  102166. */
  102167. export class NodeMaterialBuildStateSharedData {
  102168. /**
  102169. * Gets the list of emitted varyings
  102170. */
  102171. temps: string[];
  102172. /**
  102173. * Gets the list of emitted varyings
  102174. */
  102175. varyings: string[];
  102176. /**
  102177. * Gets the varying declaration string
  102178. */
  102179. varyingDeclaration: string;
  102180. /**
  102181. * Input blocks
  102182. */
  102183. inputBlocks: InputBlock[];
  102184. /**
  102185. * Input blocks
  102186. */
  102187. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102188. /**
  102189. * Bindable blocks (Blocks that need to set data to the effect)
  102190. */
  102191. bindableBlocks: NodeMaterialBlock[];
  102192. /**
  102193. * List of blocks that can provide a compilation fallback
  102194. */
  102195. blocksWithFallbacks: NodeMaterialBlock[];
  102196. /**
  102197. * List of blocks that can provide a define update
  102198. */
  102199. blocksWithDefines: NodeMaterialBlock[];
  102200. /**
  102201. * List of blocks that can provide a repeatable content
  102202. */
  102203. repeatableContentBlocks: NodeMaterialBlock[];
  102204. /**
  102205. * List of blocks that can provide a dynamic list of uniforms
  102206. */
  102207. dynamicUniformBlocks: NodeMaterialBlock[];
  102208. /**
  102209. * List of blocks that can block the isReady function for the material
  102210. */
  102211. blockingBlocks: NodeMaterialBlock[];
  102212. /**
  102213. * Gets the list of animated inputs
  102214. */
  102215. animatedInputs: InputBlock[];
  102216. /**
  102217. * Build Id used to avoid multiple recompilations
  102218. */
  102219. buildId: number;
  102220. /** List of emitted variables */
  102221. variableNames: {
  102222. [key: string]: number;
  102223. };
  102224. /** List of emitted defines */
  102225. defineNames: {
  102226. [key: string]: number;
  102227. };
  102228. /** Should emit comments? */
  102229. emitComments: boolean;
  102230. /** Emit build activity */
  102231. verbose: boolean;
  102232. /** Gets or sets the hosting scene */
  102233. scene: Scene;
  102234. /**
  102235. * Gets the compilation hints emitted at compilation time
  102236. */
  102237. hints: {
  102238. needWorldViewMatrix: boolean;
  102239. needWorldViewProjectionMatrix: boolean;
  102240. needAlphaBlending: boolean;
  102241. needAlphaTesting: boolean;
  102242. };
  102243. /**
  102244. * List of compilation checks
  102245. */
  102246. checks: {
  102247. emitVertex: boolean;
  102248. emitFragment: boolean;
  102249. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102250. };
  102251. /**
  102252. * Is vertex program allowed to be empty?
  102253. */
  102254. allowEmptyVertexProgram: boolean;
  102255. /** Creates a new shared data */
  102256. constructor();
  102257. /**
  102258. * Emits console errors and exceptions if there is a failing check
  102259. */
  102260. emitErrors(): void;
  102261. }
  102262. }
  102263. declare module BABYLON {
  102264. /**
  102265. * Class used to store node based material build state
  102266. */
  102267. export class NodeMaterialBuildState {
  102268. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102269. supportUniformBuffers: boolean;
  102270. /**
  102271. * Gets the list of emitted attributes
  102272. */
  102273. attributes: string[];
  102274. /**
  102275. * Gets the list of emitted uniforms
  102276. */
  102277. uniforms: string[];
  102278. /**
  102279. * Gets the list of emitted constants
  102280. */
  102281. constants: string[];
  102282. /**
  102283. * Gets the list of emitted samplers
  102284. */
  102285. samplers: string[];
  102286. /**
  102287. * Gets the list of emitted functions
  102288. */
  102289. functions: {
  102290. [key: string]: string;
  102291. };
  102292. /**
  102293. * Gets the list of emitted extensions
  102294. */
  102295. extensions: {
  102296. [key: string]: string;
  102297. };
  102298. /**
  102299. * Gets the target of the compilation state
  102300. */
  102301. target: NodeMaterialBlockTargets;
  102302. /**
  102303. * Gets the list of emitted counters
  102304. */
  102305. counters: {
  102306. [key: string]: number;
  102307. };
  102308. /**
  102309. * Shared data between multiple NodeMaterialBuildState instances
  102310. */
  102311. sharedData: NodeMaterialBuildStateSharedData;
  102312. /** @hidden */
  102313. _vertexState: NodeMaterialBuildState;
  102314. /** @hidden */
  102315. _attributeDeclaration: string;
  102316. /** @hidden */
  102317. _uniformDeclaration: string;
  102318. /** @hidden */
  102319. _constantDeclaration: string;
  102320. /** @hidden */
  102321. _samplerDeclaration: string;
  102322. /** @hidden */
  102323. _varyingTransfer: string;
  102324. /** @hidden */
  102325. _injectAtEnd: string;
  102326. private _repeatableContentAnchorIndex;
  102327. /** @hidden */
  102328. _builtCompilationString: string;
  102329. /**
  102330. * Gets the emitted compilation strings
  102331. */
  102332. compilationString: string;
  102333. /**
  102334. * Finalize the compilation strings
  102335. * @param state defines the current compilation state
  102336. */
  102337. finalize(state: NodeMaterialBuildState): void;
  102338. /** @hidden */
  102339. get _repeatableContentAnchor(): string;
  102340. /** @hidden */
  102341. _getFreeVariableName(prefix: string): string;
  102342. /** @hidden */
  102343. _getFreeDefineName(prefix: string): string;
  102344. /** @hidden */
  102345. _excludeVariableName(name: string): void;
  102346. /** @hidden */
  102347. _emit2DSampler(name: string): void;
  102348. /** @hidden */
  102349. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  102350. /** @hidden */
  102351. _emitExtension(name: string, extension: string, define?: string): void;
  102352. /** @hidden */
  102353. _emitFunction(name: string, code: string, comments: string): void;
  102354. /** @hidden */
  102355. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  102356. replaceStrings?: {
  102357. search: RegExp;
  102358. replace: string;
  102359. }[];
  102360. repeatKey?: string;
  102361. }): string;
  102362. /** @hidden */
  102363. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  102364. repeatKey?: string;
  102365. removeAttributes?: boolean;
  102366. removeUniforms?: boolean;
  102367. removeVaryings?: boolean;
  102368. removeIfDef?: boolean;
  102369. replaceStrings?: {
  102370. search: RegExp;
  102371. replace: string;
  102372. }[];
  102373. }, storeKey?: string): void;
  102374. /** @hidden */
  102375. _registerTempVariable(name: string): boolean;
  102376. /** @hidden */
  102377. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  102378. /** @hidden */
  102379. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  102380. /** @hidden */
  102381. _emitFloat(value: number): string;
  102382. }
  102383. }
  102384. declare module BABYLON {
  102385. /**
  102386. * Helper class used to generate session unique ID
  102387. */
  102388. export class UniqueIdGenerator {
  102389. private static _UniqueIdCounter;
  102390. /**
  102391. * Gets an unique (relatively to the current scene) Id
  102392. */
  102393. static get UniqueId(): number;
  102394. }
  102395. }
  102396. declare module BABYLON {
  102397. /**
  102398. * Defines a block that can be used inside a node based material
  102399. */
  102400. export class NodeMaterialBlock {
  102401. private _buildId;
  102402. private _buildTarget;
  102403. private _target;
  102404. private _isFinalMerger;
  102405. private _isInput;
  102406. private _name;
  102407. protected _isUnique: boolean;
  102408. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  102409. inputsAreExclusive: boolean;
  102410. /** @hidden */
  102411. _codeVariableName: string;
  102412. /** @hidden */
  102413. _inputs: NodeMaterialConnectionPoint[];
  102414. /** @hidden */
  102415. _outputs: NodeMaterialConnectionPoint[];
  102416. /** @hidden */
  102417. _preparationId: number;
  102418. /**
  102419. * Gets the name of the block
  102420. */
  102421. get name(): string;
  102422. /**
  102423. * Sets the name of the block. Will check if the name is valid.
  102424. */
  102425. set name(newName: string);
  102426. /**
  102427. * Gets or sets the unique id of the node
  102428. */
  102429. uniqueId: number;
  102430. /**
  102431. * Gets or sets the comments associated with this block
  102432. */
  102433. comments: string;
  102434. /**
  102435. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  102436. */
  102437. get isUnique(): boolean;
  102438. /**
  102439. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  102440. */
  102441. get isFinalMerger(): boolean;
  102442. /**
  102443. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  102444. */
  102445. get isInput(): boolean;
  102446. /**
  102447. * Gets or sets the build Id
  102448. */
  102449. get buildId(): number;
  102450. set buildId(value: number);
  102451. /**
  102452. * Gets or sets the target of the block
  102453. */
  102454. get target(): NodeMaterialBlockTargets;
  102455. set target(value: NodeMaterialBlockTargets);
  102456. /**
  102457. * Gets the list of input points
  102458. */
  102459. get inputs(): NodeMaterialConnectionPoint[];
  102460. /** Gets the list of output points */
  102461. get outputs(): NodeMaterialConnectionPoint[];
  102462. /**
  102463. * Find an input by its name
  102464. * @param name defines the name of the input to look for
  102465. * @returns the input or null if not found
  102466. */
  102467. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102468. /**
  102469. * Find an output by its name
  102470. * @param name defines the name of the outputto look for
  102471. * @returns the output or null if not found
  102472. */
  102473. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102474. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102475. visibleInInspector: boolean;
  102476. /**
  102477. * Creates a new NodeMaterialBlock
  102478. * @param name defines the block name
  102479. * @param target defines the target of that block (Vertex by default)
  102480. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102481. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102482. */
  102483. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102484. /**
  102485. * Initialize the block and prepare the context for build
  102486. * @param state defines the state that will be used for the build
  102487. */
  102488. initialize(state: NodeMaterialBuildState): void;
  102489. /**
  102490. * Bind data to effect. Will only be called for blocks with isBindable === true
  102491. * @param effect defines the effect to bind data to
  102492. * @param nodeMaterial defines the hosting NodeMaterial
  102493. * @param mesh defines the mesh that will be rendered
  102494. * @param subMesh defines the submesh that will be rendered
  102495. */
  102496. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102497. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102498. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102499. protected _writeFloat(value: number): string;
  102500. /**
  102501. * Gets the current class name e.g. "NodeMaterialBlock"
  102502. * @returns the class name
  102503. */
  102504. getClassName(): string;
  102505. /**
  102506. * Register a new input. Must be called inside a block constructor
  102507. * @param name defines the connection point name
  102508. * @param type defines the connection point type
  102509. * @param isOptional defines a boolean indicating that this input can be omitted
  102510. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102511. * @param point an already created connection point. If not provided, create a new one
  102512. * @returns the current block
  102513. */
  102514. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102515. /**
  102516. * Register a new output. Must be called inside a block constructor
  102517. * @param name defines the connection point name
  102518. * @param type defines the connection point type
  102519. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102520. * @param point an already created connection point. If not provided, create a new one
  102521. * @returns the current block
  102522. */
  102523. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102524. /**
  102525. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102526. * @param forOutput defines an optional connection point to check compatibility with
  102527. * @returns the first available input or null
  102528. */
  102529. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102530. /**
  102531. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102532. * @param forBlock defines an optional block to check compatibility with
  102533. * @returns the first available input or null
  102534. */
  102535. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102536. /**
  102537. * Gets the sibling of the given output
  102538. * @param current defines the current output
  102539. * @returns the next output in the list or null
  102540. */
  102541. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102542. /**
  102543. * Connect current block with another block
  102544. * @param other defines the block to connect with
  102545. * @param options define the various options to help pick the right connections
  102546. * @returns the current block
  102547. */
  102548. connectTo(other: NodeMaterialBlock, options?: {
  102549. input?: string;
  102550. output?: string;
  102551. outputSwizzle?: string;
  102552. }): this | undefined;
  102553. protected _buildBlock(state: NodeMaterialBuildState): void;
  102554. /**
  102555. * Add uniforms, samplers and uniform buffers at compilation time
  102556. * @param state defines the state to update
  102557. * @param nodeMaterial defines the node material requesting the update
  102558. * @param defines defines the material defines to update
  102559. * @param uniformBuffers defines the list of uniform buffer names
  102560. */
  102561. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102562. /**
  102563. * Add potential fallbacks if shader compilation fails
  102564. * @param mesh defines the mesh to be rendered
  102565. * @param fallbacks defines the current prioritized list of fallbacks
  102566. */
  102567. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102568. /**
  102569. * Initialize defines for shader compilation
  102570. * @param mesh defines the mesh to be rendered
  102571. * @param nodeMaterial defines the node material requesting the update
  102572. * @param defines defines the material defines to update
  102573. * @param useInstances specifies that instances should be used
  102574. */
  102575. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102576. /**
  102577. * Update defines for shader compilation
  102578. * @param mesh defines the mesh to be rendered
  102579. * @param nodeMaterial defines the node material requesting the update
  102580. * @param defines defines the material defines to update
  102581. * @param useInstances specifies that instances should be used
  102582. * @param subMesh defines which submesh to render
  102583. */
  102584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102585. /**
  102586. * Lets the block try to connect some inputs automatically
  102587. * @param material defines the hosting NodeMaterial
  102588. */
  102589. autoConfigure(material: NodeMaterial): void;
  102590. /**
  102591. * Function called when a block is declared as repeatable content generator
  102592. * @param vertexShaderState defines the current compilation state for the vertex shader
  102593. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102594. * @param mesh defines the mesh to be rendered
  102595. * @param defines defines the material defines to update
  102596. */
  102597. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102598. /**
  102599. * Checks if the block is ready
  102600. * @param mesh defines the mesh to be rendered
  102601. * @param nodeMaterial defines the node material requesting the update
  102602. * @param defines defines the material defines to update
  102603. * @param useInstances specifies that instances should be used
  102604. * @returns true if the block is ready
  102605. */
  102606. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102607. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102608. private _processBuild;
  102609. /**
  102610. * Validates the new name for the block node.
  102611. * @param newName the new name to be given to the node.
  102612. * @returns false if the name is a reserve word, else true.
  102613. */
  102614. validateBlockName(newName: string): boolean;
  102615. /**
  102616. * Compile the current node and generate the shader code
  102617. * @param state defines the current compilation state (uniforms, samplers, current string)
  102618. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102619. * @returns true if already built
  102620. */
  102621. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102622. protected _inputRename(name: string): string;
  102623. protected _outputRename(name: string): string;
  102624. protected _dumpPropertiesCode(): string;
  102625. /** @hidden */
  102626. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102627. /** @hidden */
  102628. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102629. /**
  102630. * Clone the current block to a new identical block
  102631. * @param scene defines the hosting scene
  102632. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102633. * @returns a copy of the current block
  102634. */
  102635. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102636. /**
  102637. * Serializes this block in a JSON representation
  102638. * @returns the serialized block object
  102639. */
  102640. serialize(): any;
  102641. /** @hidden */
  102642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102643. private _deserializePortDisplayNamesAndExposedOnFrame;
  102644. /**
  102645. * Release resources
  102646. */
  102647. dispose(): void;
  102648. }
  102649. }
  102650. declare module BABYLON {
  102651. /**
  102652. * Base class of materials working in push mode in babylon JS
  102653. * @hidden
  102654. */
  102655. export class PushMaterial extends Material {
  102656. protected _activeEffect: Effect;
  102657. protected _normalMatrix: Matrix;
  102658. constructor(name: string, scene: Scene);
  102659. getEffect(): Effect;
  102660. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102661. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102662. /**
  102663. * Binds the given world matrix to the active effect
  102664. *
  102665. * @param world the matrix to bind
  102666. */
  102667. bindOnlyWorldMatrix(world: Matrix): void;
  102668. /**
  102669. * Binds the given normal matrix to the active effect
  102670. *
  102671. * @param normalMatrix the matrix to bind
  102672. */
  102673. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102674. bind(world: Matrix, mesh?: Mesh): void;
  102675. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102676. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102677. }
  102678. }
  102679. declare module BABYLON {
  102680. /**
  102681. * Root class for all node material optimizers
  102682. */
  102683. export class NodeMaterialOptimizer {
  102684. /**
  102685. * Function used to optimize a NodeMaterial graph
  102686. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102687. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102688. */
  102689. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102690. }
  102691. }
  102692. declare module BABYLON {
  102693. /**
  102694. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102695. */
  102696. export class TransformBlock extends NodeMaterialBlock {
  102697. /**
  102698. * Defines the value to use to complement W value to transform it to a Vector4
  102699. */
  102700. complementW: number;
  102701. /**
  102702. * Defines the value to use to complement z value to transform it to a Vector4
  102703. */
  102704. complementZ: number;
  102705. /**
  102706. * Creates a new TransformBlock
  102707. * @param name defines the block name
  102708. */
  102709. constructor(name: string);
  102710. /**
  102711. * Gets the current class name
  102712. * @returns the class name
  102713. */
  102714. getClassName(): string;
  102715. /**
  102716. * Gets the vector input
  102717. */
  102718. get vector(): NodeMaterialConnectionPoint;
  102719. /**
  102720. * Gets the output component
  102721. */
  102722. get output(): NodeMaterialConnectionPoint;
  102723. /**
  102724. * Gets the xyz output component
  102725. */
  102726. get xyz(): NodeMaterialConnectionPoint;
  102727. /**
  102728. * Gets the matrix transform input
  102729. */
  102730. get transform(): NodeMaterialConnectionPoint;
  102731. protected _buildBlock(state: NodeMaterialBuildState): this;
  102732. /**
  102733. * Update defines for shader compilation
  102734. * @param mesh defines the mesh to be rendered
  102735. * @param nodeMaterial defines the node material requesting the update
  102736. * @param defines defines the material defines to update
  102737. * @param useInstances specifies that instances should be used
  102738. * @param subMesh defines which submesh to render
  102739. */
  102740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102741. serialize(): any;
  102742. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102743. protected _dumpPropertiesCode(): string;
  102744. }
  102745. }
  102746. declare module BABYLON {
  102747. /**
  102748. * Block used to output the vertex position
  102749. */
  102750. export class VertexOutputBlock extends NodeMaterialBlock {
  102751. /**
  102752. * Creates a new VertexOutputBlock
  102753. * @param name defines the block name
  102754. */
  102755. constructor(name: string);
  102756. /**
  102757. * Gets the current class name
  102758. * @returns the class name
  102759. */
  102760. getClassName(): string;
  102761. /**
  102762. * Gets the vector input component
  102763. */
  102764. get vector(): NodeMaterialConnectionPoint;
  102765. protected _buildBlock(state: NodeMaterialBuildState): this;
  102766. }
  102767. }
  102768. declare module BABYLON {
  102769. /**
  102770. * Block used to output the final color
  102771. */
  102772. export class FragmentOutputBlock extends NodeMaterialBlock {
  102773. /**
  102774. * Create a new FragmentOutputBlock
  102775. * @param name defines the block name
  102776. */
  102777. constructor(name: string);
  102778. /**
  102779. * Gets the current class name
  102780. * @returns the class name
  102781. */
  102782. getClassName(): string;
  102783. /**
  102784. * Gets the rgba input component
  102785. */
  102786. get rgba(): NodeMaterialConnectionPoint;
  102787. /**
  102788. * Gets the rgb input component
  102789. */
  102790. get rgb(): NodeMaterialConnectionPoint;
  102791. /**
  102792. * Gets the a input component
  102793. */
  102794. get a(): NodeMaterialConnectionPoint;
  102795. protected _buildBlock(state: NodeMaterialBuildState): this;
  102796. }
  102797. }
  102798. declare module BABYLON {
  102799. /**
  102800. * Block used for the particle ramp gradient section
  102801. */
  102802. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102803. /**
  102804. * Create a new ParticleRampGradientBlock
  102805. * @param name defines the block name
  102806. */
  102807. constructor(name: string);
  102808. /**
  102809. * Gets the current class name
  102810. * @returns the class name
  102811. */
  102812. getClassName(): string;
  102813. /**
  102814. * Gets the color input component
  102815. */
  102816. get color(): NodeMaterialConnectionPoint;
  102817. /**
  102818. * Gets the rampColor output component
  102819. */
  102820. get rampColor(): NodeMaterialConnectionPoint;
  102821. /**
  102822. * Initialize the block and prepare the context for build
  102823. * @param state defines the state that will be used for the build
  102824. */
  102825. initialize(state: NodeMaterialBuildState): void;
  102826. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102827. }
  102828. }
  102829. declare module BABYLON {
  102830. /**
  102831. * Block used for the particle blend multiply section
  102832. */
  102833. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102834. /**
  102835. * Create a new ParticleBlendMultiplyBlock
  102836. * @param name defines the block name
  102837. */
  102838. constructor(name: string);
  102839. /**
  102840. * Gets the current class name
  102841. * @returns the class name
  102842. */
  102843. getClassName(): string;
  102844. /**
  102845. * Gets the color input component
  102846. */
  102847. get color(): NodeMaterialConnectionPoint;
  102848. /**
  102849. * Gets the alphaTexture input component
  102850. */
  102851. get alphaTexture(): NodeMaterialConnectionPoint;
  102852. /**
  102853. * Gets the alphaColor input component
  102854. */
  102855. get alphaColor(): NodeMaterialConnectionPoint;
  102856. /**
  102857. * Gets the blendColor output component
  102858. */
  102859. get blendColor(): NodeMaterialConnectionPoint;
  102860. /**
  102861. * Initialize the block and prepare the context for build
  102862. * @param state defines the state that will be used for the build
  102863. */
  102864. initialize(state: NodeMaterialBuildState): void;
  102865. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102866. }
  102867. }
  102868. declare module BABYLON {
  102869. /**
  102870. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102871. */
  102872. export class VectorMergerBlock extends NodeMaterialBlock {
  102873. /**
  102874. * Create a new VectorMergerBlock
  102875. * @param name defines the block name
  102876. */
  102877. constructor(name: string);
  102878. /**
  102879. * Gets the current class name
  102880. * @returns the class name
  102881. */
  102882. getClassName(): string;
  102883. /**
  102884. * Gets the xyz component (input)
  102885. */
  102886. get xyzIn(): NodeMaterialConnectionPoint;
  102887. /**
  102888. * Gets the xy component (input)
  102889. */
  102890. get xyIn(): NodeMaterialConnectionPoint;
  102891. /**
  102892. * Gets the x component (input)
  102893. */
  102894. get x(): NodeMaterialConnectionPoint;
  102895. /**
  102896. * Gets the y component (input)
  102897. */
  102898. get y(): NodeMaterialConnectionPoint;
  102899. /**
  102900. * Gets the z component (input)
  102901. */
  102902. get z(): NodeMaterialConnectionPoint;
  102903. /**
  102904. * Gets the w component (input)
  102905. */
  102906. get w(): NodeMaterialConnectionPoint;
  102907. /**
  102908. * Gets the xyzw component (output)
  102909. */
  102910. get xyzw(): NodeMaterialConnectionPoint;
  102911. /**
  102912. * Gets the xyz component (output)
  102913. */
  102914. get xyzOut(): NodeMaterialConnectionPoint;
  102915. /**
  102916. * Gets the xy component (output)
  102917. */
  102918. get xyOut(): NodeMaterialConnectionPoint;
  102919. /**
  102920. * Gets the xy component (output)
  102921. * @deprecated Please use xyOut instead.
  102922. */
  102923. get xy(): NodeMaterialConnectionPoint;
  102924. /**
  102925. * Gets the xyz component (output)
  102926. * @deprecated Please use xyzOut instead.
  102927. */
  102928. get xyz(): NodeMaterialConnectionPoint;
  102929. protected _buildBlock(state: NodeMaterialBuildState): this;
  102930. }
  102931. }
  102932. declare module BABYLON {
  102933. /**
  102934. * Block used to remap a float from a range to a new one
  102935. */
  102936. export class RemapBlock extends NodeMaterialBlock {
  102937. /**
  102938. * Gets or sets the source range
  102939. */
  102940. sourceRange: Vector2;
  102941. /**
  102942. * Gets or sets the target range
  102943. */
  102944. targetRange: Vector2;
  102945. /**
  102946. * Creates a new RemapBlock
  102947. * @param name defines the block name
  102948. */
  102949. constructor(name: string);
  102950. /**
  102951. * Gets the current class name
  102952. * @returns the class name
  102953. */
  102954. getClassName(): string;
  102955. /**
  102956. * Gets the input component
  102957. */
  102958. get input(): NodeMaterialConnectionPoint;
  102959. /**
  102960. * Gets the source min input component
  102961. */
  102962. get sourceMin(): NodeMaterialConnectionPoint;
  102963. /**
  102964. * Gets the source max input component
  102965. */
  102966. get sourceMax(): NodeMaterialConnectionPoint;
  102967. /**
  102968. * Gets the target min input component
  102969. */
  102970. get targetMin(): NodeMaterialConnectionPoint;
  102971. /**
  102972. * Gets the target max input component
  102973. */
  102974. get targetMax(): NodeMaterialConnectionPoint;
  102975. /**
  102976. * Gets the output component
  102977. */
  102978. get output(): NodeMaterialConnectionPoint;
  102979. protected _buildBlock(state: NodeMaterialBuildState): this;
  102980. protected _dumpPropertiesCode(): string;
  102981. serialize(): any;
  102982. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102983. }
  102984. }
  102985. declare module BABYLON {
  102986. /**
  102987. * Block used to multiply 2 values
  102988. */
  102989. export class MultiplyBlock extends NodeMaterialBlock {
  102990. /**
  102991. * Creates a new MultiplyBlock
  102992. * @param name defines the block name
  102993. */
  102994. constructor(name: string);
  102995. /**
  102996. * Gets the current class name
  102997. * @returns the class name
  102998. */
  102999. getClassName(): string;
  103000. /**
  103001. * Gets the left operand input component
  103002. */
  103003. get left(): NodeMaterialConnectionPoint;
  103004. /**
  103005. * Gets the right operand input component
  103006. */
  103007. get right(): NodeMaterialConnectionPoint;
  103008. /**
  103009. * Gets the output component
  103010. */
  103011. get output(): NodeMaterialConnectionPoint;
  103012. protected _buildBlock(state: NodeMaterialBuildState): this;
  103013. }
  103014. }
  103015. declare module BABYLON {
  103016. /**
  103017. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  103018. */
  103019. export class ColorSplitterBlock extends NodeMaterialBlock {
  103020. /**
  103021. * Create a new ColorSplitterBlock
  103022. * @param name defines the block name
  103023. */
  103024. constructor(name: string);
  103025. /**
  103026. * Gets the current class name
  103027. * @returns the class name
  103028. */
  103029. getClassName(): string;
  103030. /**
  103031. * Gets the rgba component (input)
  103032. */
  103033. get rgba(): NodeMaterialConnectionPoint;
  103034. /**
  103035. * Gets the rgb component (input)
  103036. */
  103037. get rgbIn(): NodeMaterialConnectionPoint;
  103038. /**
  103039. * Gets the rgb component (output)
  103040. */
  103041. get rgbOut(): NodeMaterialConnectionPoint;
  103042. /**
  103043. * Gets the r component (output)
  103044. */
  103045. get r(): NodeMaterialConnectionPoint;
  103046. /**
  103047. * Gets the g component (output)
  103048. */
  103049. get g(): NodeMaterialConnectionPoint;
  103050. /**
  103051. * Gets the b component (output)
  103052. */
  103053. get b(): NodeMaterialConnectionPoint;
  103054. /**
  103055. * Gets the a component (output)
  103056. */
  103057. get a(): NodeMaterialConnectionPoint;
  103058. protected _inputRename(name: string): string;
  103059. protected _outputRename(name: string): string;
  103060. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103061. }
  103062. }
  103063. declare module BABYLON {
  103064. /**
  103065. * Operations supported by the Trigonometry block
  103066. */
  103067. export enum TrigonometryBlockOperations {
  103068. /** Cos */
  103069. Cos = 0,
  103070. /** Sin */
  103071. Sin = 1,
  103072. /** Abs */
  103073. Abs = 2,
  103074. /** Exp */
  103075. Exp = 3,
  103076. /** Exp2 */
  103077. Exp2 = 4,
  103078. /** Round */
  103079. Round = 5,
  103080. /** Floor */
  103081. Floor = 6,
  103082. /** Ceiling */
  103083. Ceiling = 7,
  103084. /** Square root */
  103085. Sqrt = 8,
  103086. /** Log */
  103087. Log = 9,
  103088. /** Tangent */
  103089. Tan = 10,
  103090. /** Arc tangent */
  103091. ArcTan = 11,
  103092. /** Arc cosinus */
  103093. ArcCos = 12,
  103094. /** Arc sinus */
  103095. ArcSin = 13,
  103096. /** Fraction */
  103097. Fract = 14,
  103098. /** Sign */
  103099. Sign = 15,
  103100. /** To radians (from degrees) */
  103101. Radians = 16,
  103102. /** To degrees (from radians) */
  103103. Degrees = 17
  103104. }
  103105. /**
  103106. * Block used to apply trigonometry operation to floats
  103107. */
  103108. export class TrigonometryBlock extends NodeMaterialBlock {
  103109. /**
  103110. * Gets or sets the operation applied by the block
  103111. */
  103112. operation: TrigonometryBlockOperations;
  103113. /**
  103114. * Creates a new TrigonometryBlock
  103115. * @param name defines the block name
  103116. */
  103117. constructor(name: string);
  103118. /**
  103119. * Gets the current class name
  103120. * @returns the class name
  103121. */
  103122. getClassName(): string;
  103123. /**
  103124. * Gets the input component
  103125. */
  103126. get input(): NodeMaterialConnectionPoint;
  103127. /**
  103128. * Gets the output component
  103129. */
  103130. get output(): NodeMaterialConnectionPoint;
  103131. protected _buildBlock(state: NodeMaterialBuildState): this;
  103132. serialize(): any;
  103133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103134. protected _dumpPropertiesCode(): string;
  103135. }
  103136. }
  103137. declare module BABYLON {
  103138. /**
  103139. * Interface used to configure the node material editor
  103140. */
  103141. export interface INodeMaterialEditorOptions {
  103142. /** Define the URl to load node editor script */
  103143. editorURL?: string;
  103144. }
  103145. /** @hidden */
  103146. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103147. NORMAL: boolean;
  103148. TANGENT: boolean;
  103149. UV1: boolean;
  103150. /** BONES */
  103151. NUM_BONE_INFLUENCERS: number;
  103152. BonesPerMesh: number;
  103153. BONETEXTURE: boolean;
  103154. /** MORPH TARGETS */
  103155. MORPHTARGETS: boolean;
  103156. MORPHTARGETS_NORMAL: boolean;
  103157. MORPHTARGETS_TANGENT: boolean;
  103158. MORPHTARGETS_UV: boolean;
  103159. NUM_MORPH_INFLUENCERS: number;
  103160. /** IMAGE PROCESSING */
  103161. IMAGEPROCESSING: boolean;
  103162. VIGNETTE: boolean;
  103163. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103164. VIGNETTEBLENDMODEOPAQUE: boolean;
  103165. TONEMAPPING: boolean;
  103166. TONEMAPPING_ACES: boolean;
  103167. CONTRAST: boolean;
  103168. EXPOSURE: boolean;
  103169. COLORCURVES: boolean;
  103170. COLORGRADING: boolean;
  103171. COLORGRADING3D: boolean;
  103172. SAMPLER3DGREENDEPTH: boolean;
  103173. SAMPLER3DBGRMAP: boolean;
  103174. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103175. /** MISC. */
  103176. BUMPDIRECTUV: number;
  103177. constructor();
  103178. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103179. }
  103180. /**
  103181. * Class used to configure NodeMaterial
  103182. */
  103183. export interface INodeMaterialOptions {
  103184. /**
  103185. * Defines if blocks should emit comments
  103186. */
  103187. emitComments: boolean;
  103188. }
  103189. /**
  103190. * Class used to create a node based material built by assembling shader blocks
  103191. */
  103192. export class NodeMaterial extends PushMaterial {
  103193. private static _BuildIdGenerator;
  103194. private _options;
  103195. private _vertexCompilationState;
  103196. private _fragmentCompilationState;
  103197. private _sharedData;
  103198. private _buildId;
  103199. private _buildWasSuccessful;
  103200. private _cachedWorldViewMatrix;
  103201. private _cachedWorldViewProjectionMatrix;
  103202. private _optimizers;
  103203. private _animationFrame;
  103204. /** Define the Url to load node editor script */
  103205. static EditorURL: string;
  103206. /** Define the Url to load snippets */
  103207. static SnippetUrl: string;
  103208. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  103209. static IgnoreTexturesAtLoadTime: boolean;
  103210. private BJSNODEMATERIALEDITOR;
  103211. /** Get the inspector from bundle or global */
  103212. private _getGlobalNodeMaterialEditor;
  103213. /**
  103214. * Snippet ID if the material was created from the snippet server
  103215. */
  103216. snippetId: string;
  103217. /**
  103218. * Gets or sets data used by visual editor
  103219. * @see https://nme.babylonjs.com
  103220. */
  103221. editorData: any;
  103222. /**
  103223. * 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)
  103224. */
  103225. ignoreAlpha: boolean;
  103226. /**
  103227. * Defines the maximum number of lights that can be used in the material
  103228. */
  103229. maxSimultaneousLights: number;
  103230. /**
  103231. * Observable raised when the material is built
  103232. */
  103233. onBuildObservable: Observable<NodeMaterial>;
  103234. /**
  103235. * Gets or sets the root nodes of the material vertex shader
  103236. */
  103237. _vertexOutputNodes: NodeMaterialBlock[];
  103238. /**
  103239. * Gets or sets the root nodes of the material fragment (pixel) shader
  103240. */
  103241. _fragmentOutputNodes: NodeMaterialBlock[];
  103242. /** Gets or sets options to control the node material overall behavior */
  103243. get options(): INodeMaterialOptions;
  103244. set options(options: INodeMaterialOptions);
  103245. /**
  103246. * Default configuration related to image processing available in the standard Material.
  103247. */
  103248. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103249. /**
  103250. * Gets the image processing configuration used either in this material.
  103251. */
  103252. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103253. /**
  103254. * Sets the Default image processing configuration used either in the this material.
  103255. *
  103256. * If sets to null, the scene one is in use.
  103257. */
  103258. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103259. /**
  103260. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103261. */
  103262. attachedBlocks: NodeMaterialBlock[];
  103263. /**
  103264. * Specifies the mode of the node material
  103265. * @hidden
  103266. */
  103267. _mode: NodeMaterialModes;
  103268. /**
  103269. * Gets the mode property
  103270. */
  103271. get mode(): NodeMaterialModes;
  103272. /**
  103273. * Create a new node based material
  103274. * @param name defines the material name
  103275. * @param scene defines the hosting scene
  103276. * @param options defines creation option
  103277. */
  103278. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103279. /**
  103280. * Gets the current class name of the material e.g. "NodeMaterial"
  103281. * @returns the class name
  103282. */
  103283. getClassName(): string;
  103284. /**
  103285. * Keep track of the image processing observer to allow dispose and replace.
  103286. */
  103287. private _imageProcessingObserver;
  103288. /**
  103289. * Attaches a new image processing configuration to the Standard Material.
  103290. * @param configuration
  103291. */
  103292. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103293. /**
  103294. * Get a block by its name
  103295. * @param name defines the name of the block to retrieve
  103296. * @returns the required block or null if not found
  103297. */
  103298. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103299. /**
  103300. * Get a block by its name
  103301. * @param predicate defines the predicate used to find the good candidate
  103302. * @returns the required block or null if not found
  103303. */
  103304. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103305. /**
  103306. * Get an input block by its name
  103307. * @param predicate defines the predicate used to find the good candidate
  103308. * @returns the required input block or null if not found
  103309. */
  103310. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103311. /**
  103312. * Gets the list of input blocks attached to this material
  103313. * @returns an array of InputBlocks
  103314. */
  103315. getInputBlocks(): InputBlock[];
  103316. /**
  103317. * Adds a new optimizer to the list of optimizers
  103318. * @param optimizer defines the optimizers to add
  103319. * @returns the current material
  103320. */
  103321. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103322. /**
  103323. * Remove an optimizer from the list of optimizers
  103324. * @param optimizer defines the optimizers to remove
  103325. * @returns the current material
  103326. */
  103327. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103328. /**
  103329. * Add a new block to the list of output nodes
  103330. * @param node defines the node to add
  103331. * @returns the current material
  103332. */
  103333. addOutputNode(node: NodeMaterialBlock): this;
  103334. /**
  103335. * Remove a block from the list of root nodes
  103336. * @param node defines the node to remove
  103337. * @returns the current material
  103338. */
  103339. removeOutputNode(node: NodeMaterialBlock): this;
  103340. private _addVertexOutputNode;
  103341. private _removeVertexOutputNode;
  103342. private _addFragmentOutputNode;
  103343. private _removeFragmentOutputNode;
  103344. /**
  103345. * Specifies if the material will require alpha blending
  103346. * @returns a boolean specifying if alpha blending is needed
  103347. */
  103348. needAlphaBlending(): boolean;
  103349. /**
  103350. * Specifies if this material should be rendered in alpha test mode
  103351. * @returns a boolean specifying if an alpha test is needed.
  103352. */
  103353. needAlphaTesting(): boolean;
  103354. private _initializeBlock;
  103355. private _resetDualBlocks;
  103356. /**
  103357. * Remove a block from the current node material
  103358. * @param block defines the block to remove
  103359. */
  103360. removeBlock(block: NodeMaterialBlock): void;
  103361. /**
  103362. * Build the material and generates the inner effect
  103363. * @param verbose defines if the build should log activity
  103364. */
  103365. build(verbose?: boolean): void;
  103366. /**
  103367. * Runs an otpimization phase to try to improve the shader code
  103368. */
  103369. optimize(): void;
  103370. private _prepareDefinesForAttributes;
  103371. /**
  103372. * Create a post process from the material
  103373. * @param camera The camera to apply the render pass to.
  103374. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103376. * @param engine The engine which the post process will be applied. (default: current engine)
  103377. * @param reusable If the post process can be reused on the same frame. (default: false)
  103378. * @param textureType Type of textures used when performing the post process. (default: 0)
  103379. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103380. * @returns the post process created
  103381. */
  103382. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103383. /**
  103384. * Create the post process effect from the material
  103385. * @param postProcess The post process to create the effect for
  103386. */
  103387. createEffectForPostProcess(postProcess: PostProcess): void;
  103388. private _createEffectForPostProcess;
  103389. /**
  103390. * Create a new procedural texture based on this node material
  103391. * @param size defines the size of the texture
  103392. * @param scene defines the hosting scene
  103393. * @returns the new procedural texture attached to this node material
  103394. */
  103395. createProceduralTexture(size: number | {
  103396. width: number;
  103397. height: number;
  103398. layers?: number;
  103399. }, scene: Scene): Nullable<ProceduralTexture>;
  103400. private _createEffectForParticles;
  103401. private _checkInternals;
  103402. /**
  103403. * Create the effect to be used as the custom effect for a particle system
  103404. * @param particleSystem Particle system to create the effect for
  103405. * @param onCompiled defines a function to call when the effect creation is successful
  103406. * @param onError defines a function to call when the effect creation has failed
  103407. */
  103408. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103409. private _processDefines;
  103410. /**
  103411. * Get if the submesh is ready to be used and all its information available.
  103412. * Child classes can use it to update shaders
  103413. * @param mesh defines the mesh to check
  103414. * @param subMesh defines which submesh to check
  103415. * @param useInstances specifies that instances should be used
  103416. * @returns a boolean indicating that the submesh is ready or not
  103417. */
  103418. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103419. /**
  103420. * Get a string representing the shaders built by the current node graph
  103421. */
  103422. get compiledShaders(): string;
  103423. /**
  103424. * Binds the world matrix to the material
  103425. * @param world defines the world transformation matrix
  103426. */
  103427. bindOnlyWorldMatrix(world: Matrix): void;
  103428. /**
  103429. * Binds the submesh to this material by preparing the effect and shader to draw
  103430. * @param world defines the world transformation matrix
  103431. * @param mesh defines the mesh containing the submesh
  103432. * @param subMesh defines the submesh to bind the material to
  103433. */
  103434. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103435. /**
  103436. * Gets the active textures from the material
  103437. * @returns an array of textures
  103438. */
  103439. getActiveTextures(): BaseTexture[];
  103440. /**
  103441. * Gets the list of texture blocks
  103442. * @returns an array of texture blocks
  103443. */
  103444. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103445. /**
  103446. * Specifies if the material uses a texture
  103447. * @param texture defines the texture to check against the material
  103448. * @returns a boolean specifying if the material uses the texture
  103449. */
  103450. hasTexture(texture: BaseTexture): boolean;
  103451. /**
  103452. * Disposes the material
  103453. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103454. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103455. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103456. */
  103457. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103458. /** Creates the node editor window. */
  103459. private _createNodeEditor;
  103460. /**
  103461. * Launch the node material editor
  103462. * @param config Define the configuration of the editor
  103463. * @return a promise fulfilled when the node editor is visible
  103464. */
  103465. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103466. /**
  103467. * Clear the current material
  103468. */
  103469. clear(): void;
  103470. /**
  103471. * Clear the current material and set it to a default state
  103472. */
  103473. setToDefault(): void;
  103474. /**
  103475. * Clear the current material and set it to a default state for post process
  103476. */
  103477. setToDefaultPostProcess(): void;
  103478. /**
  103479. * Clear the current material and set it to a default state for procedural texture
  103480. */
  103481. setToDefaultProceduralTexture(): void;
  103482. /**
  103483. * Clear the current material and set it to a default state for particle
  103484. */
  103485. setToDefaultParticle(): void;
  103486. /**
  103487. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103488. * @param url defines the url to load from
  103489. * @returns a promise that will fullfil when the material is fully loaded
  103490. */
  103491. loadAsync(url: string): Promise<void>;
  103492. private _gatherBlocks;
  103493. /**
  103494. * Generate a string containing the code declaration required to create an equivalent of this material
  103495. * @returns a string
  103496. */
  103497. generateCode(): string;
  103498. /**
  103499. * Serializes this material in a JSON representation
  103500. * @returns the serialized material object
  103501. */
  103502. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103503. private _restoreConnections;
  103504. /**
  103505. * Clear the current graph and load a new one from a serialization object
  103506. * @param source defines the JSON representation of the material
  103507. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103508. * @param merge defines whether or not the source must be merged or replace the current content
  103509. */
  103510. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103511. /**
  103512. * Makes a duplicate of the current material.
  103513. * @param name - name to use for the new material.
  103514. */
  103515. clone(name: string): NodeMaterial;
  103516. /**
  103517. * Creates a node material from parsed material data
  103518. * @param source defines the JSON representation of the material
  103519. * @param scene defines the hosting scene
  103520. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103521. * @returns a new node material
  103522. */
  103523. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103524. /**
  103525. * Creates a node material from a snippet saved in a remote file
  103526. * @param name defines the name of the material to create
  103527. * @param url defines the url to load from
  103528. * @param scene defines the hosting scene
  103529. * @returns a promise that will resolve to the new node material
  103530. */
  103531. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103532. /**
  103533. * Creates a node material from a snippet saved by the node material editor
  103534. * @param snippetId defines the snippet to load
  103535. * @param scene defines the hosting scene
  103536. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103537. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103538. * @returns a promise that will resolve to the new node material
  103539. */
  103540. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103541. /**
  103542. * Creates a new node material set to default basic configuration
  103543. * @param name defines the name of the material
  103544. * @param scene defines the hosting scene
  103545. * @returns a new NodeMaterial
  103546. */
  103547. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103548. }
  103549. }
  103550. declare module BABYLON {
  103551. interface ThinEngine {
  103552. /**
  103553. * Unbind a list of render target textures from the webGL context
  103554. * This is used only when drawBuffer extension or webGL2 are active
  103555. * @param textures defines the render target textures to unbind
  103556. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103557. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103558. */
  103559. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103560. /**
  103561. * Create a multi render target texture
  103562. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103563. * @param size defines the size of the texture
  103564. * @param options defines the creation options
  103565. * @returns the cube texture as an InternalTexture
  103566. */
  103567. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103568. /**
  103569. * Update the sample count for a given multiple render target texture
  103570. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103571. * @param textures defines the textures to update
  103572. * @param samples defines the sample count to set
  103573. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103574. */
  103575. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103576. /**
  103577. * Select a subsets of attachments to draw to.
  103578. * @param attachments gl attachments
  103579. */
  103580. bindAttachments(attachments: number[]): void;
  103581. /**
  103582. * Creates a layout object to draw/clear on specific textures in a MRT
  103583. * @param textureStatus textureStatus[i] indicates if the i-th is active
  103584. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  103585. */
  103586. buildTextureLayout(textureStatus: boolean[]): number[];
  103587. /**
  103588. * Restores the webgl state to only draw on the main color attachment
  103589. */
  103590. restoreSingleAttachment(): void;
  103591. }
  103592. }
  103593. declare module BABYLON {
  103594. /**
  103595. * Creation options of the multi render target texture.
  103596. */
  103597. export interface IMultiRenderTargetOptions {
  103598. /**
  103599. * Define if the texture needs to create mip maps after render.
  103600. */
  103601. generateMipMaps?: boolean;
  103602. /**
  103603. * Define the types of all the draw buffers we want to create
  103604. */
  103605. types?: number[];
  103606. /**
  103607. * Define the sampling modes of all the draw buffers we want to create
  103608. */
  103609. samplingModes?: number[];
  103610. /**
  103611. * Define if a depth buffer is required
  103612. */
  103613. generateDepthBuffer?: boolean;
  103614. /**
  103615. * Define if a stencil buffer is required
  103616. */
  103617. generateStencilBuffer?: boolean;
  103618. /**
  103619. * Define if a depth texture is required instead of a depth buffer
  103620. */
  103621. generateDepthTexture?: boolean;
  103622. /**
  103623. * Define the number of desired draw buffers
  103624. */
  103625. textureCount?: number;
  103626. /**
  103627. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103628. */
  103629. doNotChangeAspectRatio?: boolean;
  103630. /**
  103631. * Define the default type of the buffers we are creating
  103632. */
  103633. defaultType?: number;
  103634. }
  103635. /**
  103636. * A multi render target, like a render target provides the ability to render to a texture.
  103637. * Unlike the render target, it can render to several draw buffers in one draw.
  103638. * This is specially interesting in deferred rendering or for any effects requiring more than
  103639. * just one color from a single pass.
  103640. */
  103641. export class MultiRenderTarget extends RenderTargetTexture {
  103642. private _internalTextures;
  103643. private _textures;
  103644. private _multiRenderTargetOptions;
  103645. private _count;
  103646. /**
  103647. * Get if draw buffers are currently supported by the used hardware and browser.
  103648. */
  103649. get isSupported(): boolean;
  103650. /**
  103651. * Get the list of textures generated by the multi render target.
  103652. */
  103653. get textures(): Texture[];
  103654. /**
  103655. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103656. */
  103657. get count(): number;
  103658. /**
  103659. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103660. */
  103661. get depthTexture(): Texture;
  103662. /**
  103663. * Set the wrapping mode on U of all the textures we are rendering to.
  103664. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103665. */
  103666. set wrapU(wrap: number);
  103667. /**
  103668. * Set the wrapping mode on V of all the textures we are rendering to.
  103669. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103670. */
  103671. set wrapV(wrap: number);
  103672. /**
  103673. * Instantiate a new multi render target texture.
  103674. * A multi render target, like a render target provides the ability to render to a texture.
  103675. * Unlike the render target, it can render to several draw buffers in one draw.
  103676. * This is specially interesting in deferred rendering or for any effects requiring more than
  103677. * just one color from a single pass.
  103678. * @param name Define the name of the texture
  103679. * @param size Define the size of the buffers to render to
  103680. * @param count Define the number of target we are rendering into
  103681. * @param scene Define the scene the texture belongs to
  103682. * @param options Define the options used to create the multi render target
  103683. */
  103684. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103685. private _initTypes;
  103686. /** @hidden */
  103687. _rebuild(forceFullRebuild?: boolean): void;
  103688. private _createInternalTextures;
  103689. private _createTextures;
  103690. /**
  103691. * Replaces a texture within the MRT.
  103692. * @param texture The new texture to insert in the MRT
  103693. * @param index The index of the texture to replace
  103694. */
  103695. replaceTexture(texture: Texture, index: number): void;
  103696. /**
  103697. * Define the number of samples used if MSAA is enabled.
  103698. */
  103699. get samples(): number;
  103700. set samples(value: number);
  103701. /**
  103702. * Resize all the textures in the multi render target.
  103703. * Be careful as it will recreate all the data in the new texture.
  103704. * @param size Define the new size
  103705. */
  103706. resize(size: any): void;
  103707. /**
  103708. * Changes the number of render targets in this MRT
  103709. * Be careful as it will recreate all the data in the new texture.
  103710. * @param count new texture count
  103711. * @param options Specifies texture types and sampling modes for new textures
  103712. */
  103713. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103714. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103715. /**
  103716. * Dispose the render targets and their associated resources
  103717. */
  103718. dispose(): void;
  103719. /**
  103720. * Release all the underlying texture used as draw buffers.
  103721. */
  103722. releaseInternalTextures(): void;
  103723. }
  103724. }
  103725. declare module BABYLON {
  103726. /** @hidden */
  103727. export var imageProcessingPixelShader: {
  103728. name: string;
  103729. shader: string;
  103730. };
  103731. }
  103732. declare module BABYLON {
  103733. /**
  103734. * ImageProcessingPostProcess
  103735. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103736. */
  103737. export class ImageProcessingPostProcess extends PostProcess {
  103738. /**
  103739. * Default configuration related to image processing available in the PBR Material.
  103740. */
  103741. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103742. /**
  103743. * Gets the image processing configuration used either in this material.
  103744. */
  103745. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103746. /**
  103747. * Sets the Default image processing configuration used either in the this material.
  103748. *
  103749. * If sets to null, the scene one is in use.
  103750. */
  103751. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103752. /**
  103753. * Keep track of the image processing observer to allow dispose and replace.
  103754. */
  103755. private _imageProcessingObserver;
  103756. /**
  103757. * Attaches a new image processing configuration to the PBR Material.
  103758. * @param configuration
  103759. */
  103760. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103761. /**
  103762. * If the post process is supported.
  103763. */
  103764. get isSupported(): boolean;
  103765. /**
  103766. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103767. */
  103768. get colorCurves(): Nullable<ColorCurves>;
  103769. /**
  103770. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103771. */
  103772. set colorCurves(value: Nullable<ColorCurves>);
  103773. /**
  103774. * Gets wether the color curves effect is enabled.
  103775. */
  103776. get colorCurvesEnabled(): boolean;
  103777. /**
  103778. * Sets wether the color curves effect is enabled.
  103779. */
  103780. set colorCurvesEnabled(value: boolean);
  103781. /**
  103782. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103783. */
  103784. get colorGradingTexture(): Nullable<BaseTexture>;
  103785. /**
  103786. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103787. */
  103788. set colorGradingTexture(value: Nullable<BaseTexture>);
  103789. /**
  103790. * Gets wether the color grading effect is enabled.
  103791. */
  103792. get colorGradingEnabled(): boolean;
  103793. /**
  103794. * Gets wether the color grading effect is enabled.
  103795. */
  103796. set colorGradingEnabled(value: boolean);
  103797. /**
  103798. * Gets exposure used in the effect.
  103799. */
  103800. get exposure(): number;
  103801. /**
  103802. * Sets exposure used in the effect.
  103803. */
  103804. set exposure(value: number);
  103805. /**
  103806. * Gets wether tonemapping is enabled or not.
  103807. */
  103808. get toneMappingEnabled(): boolean;
  103809. /**
  103810. * Sets wether tonemapping is enabled or not
  103811. */
  103812. set toneMappingEnabled(value: boolean);
  103813. /**
  103814. * Gets the type of tone mapping effect.
  103815. */
  103816. get toneMappingType(): number;
  103817. /**
  103818. * Sets the type of tone mapping effect.
  103819. */
  103820. set toneMappingType(value: number);
  103821. /**
  103822. * Gets contrast used in the effect.
  103823. */
  103824. get contrast(): number;
  103825. /**
  103826. * Sets contrast used in the effect.
  103827. */
  103828. set contrast(value: number);
  103829. /**
  103830. * Gets Vignette stretch size.
  103831. */
  103832. get vignetteStretch(): number;
  103833. /**
  103834. * Sets Vignette stretch size.
  103835. */
  103836. set vignetteStretch(value: number);
  103837. /**
  103838. * Gets Vignette centre X Offset.
  103839. */
  103840. get vignetteCentreX(): number;
  103841. /**
  103842. * Sets Vignette centre X Offset.
  103843. */
  103844. set vignetteCentreX(value: number);
  103845. /**
  103846. * Gets Vignette centre Y Offset.
  103847. */
  103848. get vignetteCentreY(): number;
  103849. /**
  103850. * Sets Vignette centre Y Offset.
  103851. */
  103852. set vignetteCentreY(value: number);
  103853. /**
  103854. * Gets Vignette weight or intensity of the vignette effect.
  103855. */
  103856. get vignetteWeight(): number;
  103857. /**
  103858. * Sets Vignette weight or intensity of the vignette effect.
  103859. */
  103860. set vignetteWeight(value: number);
  103861. /**
  103862. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103863. * if vignetteEnabled is set to true.
  103864. */
  103865. get vignetteColor(): Color4;
  103866. /**
  103867. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103868. * if vignetteEnabled is set to true.
  103869. */
  103870. set vignetteColor(value: Color4);
  103871. /**
  103872. * Gets Camera field of view used by the Vignette effect.
  103873. */
  103874. get vignetteCameraFov(): number;
  103875. /**
  103876. * Sets Camera field of view used by the Vignette effect.
  103877. */
  103878. set vignetteCameraFov(value: number);
  103879. /**
  103880. * Gets the vignette blend mode allowing different kind of effect.
  103881. */
  103882. get vignetteBlendMode(): number;
  103883. /**
  103884. * Sets the vignette blend mode allowing different kind of effect.
  103885. */
  103886. set vignetteBlendMode(value: number);
  103887. /**
  103888. * Gets wether the vignette effect is enabled.
  103889. */
  103890. get vignetteEnabled(): boolean;
  103891. /**
  103892. * Sets wether the vignette effect is enabled.
  103893. */
  103894. set vignetteEnabled(value: boolean);
  103895. private _fromLinearSpace;
  103896. /**
  103897. * Gets wether the input of the processing is in Gamma or Linear Space.
  103898. */
  103899. get fromLinearSpace(): boolean;
  103900. /**
  103901. * Sets wether the input of the processing is in Gamma or Linear Space.
  103902. */
  103903. set fromLinearSpace(value: boolean);
  103904. /**
  103905. * Defines cache preventing GC.
  103906. */
  103907. private _defines;
  103908. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103909. /**
  103910. * "ImageProcessingPostProcess"
  103911. * @returns "ImageProcessingPostProcess"
  103912. */
  103913. getClassName(): string;
  103914. /**
  103915. * @hidden
  103916. */
  103917. _updateParameters(): void;
  103918. dispose(camera?: Camera): void;
  103919. }
  103920. }
  103921. declare module BABYLON {
  103922. /**
  103923. * Interface for defining prepass effects in the prepass post-process pipeline
  103924. */
  103925. export interface PrePassEffectConfiguration {
  103926. /**
  103927. * Name of the effect
  103928. */
  103929. name: string;
  103930. /**
  103931. * Post process to attach for this effect
  103932. */
  103933. postProcess?: PostProcess;
  103934. /**
  103935. * Textures required in the MRT
  103936. */
  103937. texturesRequired: number[];
  103938. /**
  103939. * Is the effect enabled
  103940. */
  103941. enabled: boolean;
  103942. /**
  103943. * Disposes the effect configuration
  103944. */
  103945. dispose?: () => void;
  103946. /**
  103947. * Creates the associated post process
  103948. */
  103949. createPostProcess?: () => PostProcess;
  103950. }
  103951. }
  103952. declare module BABYLON {
  103953. /**
  103954. * Options to be used when creating a FresnelParameters.
  103955. */
  103956. export type IFresnelParametersCreationOptions = {
  103957. /**
  103958. * Define the color used on edges (grazing angle)
  103959. */
  103960. leftColor?: Color3;
  103961. /**
  103962. * Define the color used on center
  103963. */
  103964. rightColor?: Color3;
  103965. /**
  103966. * Define bias applied to computed fresnel term
  103967. */
  103968. bias?: number;
  103969. /**
  103970. * Defined the power exponent applied to fresnel term
  103971. */
  103972. power?: number;
  103973. /**
  103974. * Define if the fresnel effect is enable or not.
  103975. */
  103976. isEnabled?: boolean;
  103977. };
  103978. /**
  103979. * Serialized format for FresnelParameters.
  103980. */
  103981. export type IFresnelParametersSerialized = {
  103982. /**
  103983. * Define the color used on edges (grazing angle) [as an array]
  103984. */
  103985. leftColor: number[];
  103986. /**
  103987. * Define the color used on center [as an array]
  103988. */
  103989. rightColor: number[];
  103990. /**
  103991. * Define bias applied to computed fresnel term
  103992. */
  103993. bias: number;
  103994. /**
  103995. * Defined the power exponent applied to fresnel term
  103996. */
  103997. power?: number;
  103998. /**
  103999. * Define if the fresnel effect is enable or not.
  104000. */
  104001. isEnabled: boolean;
  104002. };
  104003. /**
  104004. * This represents all the required information to add a fresnel effect on a material:
  104005. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104006. */
  104007. export class FresnelParameters {
  104008. private _isEnabled;
  104009. /**
  104010. * Define if the fresnel effect is enable or not.
  104011. */
  104012. get isEnabled(): boolean;
  104013. set isEnabled(value: boolean);
  104014. /**
  104015. * Define the color used on edges (grazing angle)
  104016. */
  104017. leftColor: Color3;
  104018. /**
  104019. * Define the color used on center
  104020. */
  104021. rightColor: Color3;
  104022. /**
  104023. * Define bias applied to computed fresnel term
  104024. */
  104025. bias: number;
  104026. /**
  104027. * Defined the power exponent applied to fresnel term
  104028. */
  104029. power: number;
  104030. /**
  104031. * Creates a new FresnelParameters object.
  104032. *
  104033. * @param options provide your own settings to optionally to override defaults
  104034. */
  104035. constructor(options?: IFresnelParametersCreationOptions);
  104036. /**
  104037. * Clones the current fresnel and its valuues
  104038. * @returns a clone fresnel configuration
  104039. */
  104040. clone(): FresnelParameters;
  104041. /**
  104042. * Determines equality between FresnelParameters objects
  104043. * @param otherFresnelParameters defines the second operand
  104044. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  104045. */
  104046. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  104047. /**
  104048. * Serializes the current fresnel parameters to a JSON representation.
  104049. * @return the JSON serialization
  104050. */
  104051. serialize(): IFresnelParametersSerialized;
  104052. /**
  104053. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  104054. * @param parsedFresnelParameters Define the JSON representation
  104055. * @returns the parsed parameters
  104056. */
  104057. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  104058. }
  104059. }
  104060. declare module BABYLON {
  104061. /**
  104062. * This groups all the flags used to control the materials channel.
  104063. */
  104064. export class MaterialFlags {
  104065. private static _DiffuseTextureEnabled;
  104066. /**
  104067. * Are diffuse textures enabled in the application.
  104068. */
  104069. static get DiffuseTextureEnabled(): boolean;
  104070. static set DiffuseTextureEnabled(value: boolean);
  104071. private static _DetailTextureEnabled;
  104072. /**
  104073. * Are detail textures enabled in the application.
  104074. */
  104075. static get DetailTextureEnabled(): boolean;
  104076. static set DetailTextureEnabled(value: boolean);
  104077. private static _AmbientTextureEnabled;
  104078. /**
  104079. * Are ambient textures enabled in the application.
  104080. */
  104081. static get AmbientTextureEnabled(): boolean;
  104082. static set AmbientTextureEnabled(value: boolean);
  104083. private static _OpacityTextureEnabled;
  104084. /**
  104085. * Are opacity textures enabled in the application.
  104086. */
  104087. static get OpacityTextureEnabled(): boolean;
  104088. static set OpacityTextureEnabled(value: boolean);
  104089. private static _ReflectionTextureEnabled;
  104090. /**
  104091. * Are reflection textures enabled in the application.
  104092. */
  104093. static get ReflectionTextureEnabled(): boolean;
  104094. static set ReflectionTextureEnabled(value: boolean);
  104095. private static _EmissiveTextureEnabled;
  104096. /**
  104097. * Are emissive textures enabled in the application.
  104098. */
  104099. static get EmissiveTextureEnabled(): boolean;
  104100. static set EmissiveTextureEnabled(value: boolean);
  104101. private static _SpecularTextureEnabled;
  104102. /**
  104103. * Are specular textures enabled in the application.
  104104. */
  104105. static get SpecularTextureEnabled(): boolean;
  104106. static set SpecularTextureEnabled(value: boolean);
  104107. private static _BumpTextureEnabled;
  104108. /**
  104109. * Are bump textures enabled in the application.
  104110. */
  104111. static get BumpTextureEnabled(): boolean;
  104112. static set BumpTextureEnabled(value: boolean);
  104113. private static _LightmapTextureEnabled;
  104114. /**
  104115. * Are lightmap textures enabled in the application.
  104116. */
  104117. static get LightmapTextureEnabled(): boolean;
  104118. static set LightmapTextureEnabled(value: boolean);
  104119. private static _RefractionTextureEnabled;
  104120. /**
  104121. * Are refraction textures enabled in the application.
  104122. */
  104123. static get RefractionTextureEnabled(): boolean;
  104124. static set RefractionTextureEnabled(value: boolean);
  104125. private static _ColorGradingTextureEnabled;
  104126. /**
  104127. * Are color grading textures enabled in the application.
  104128. */
  104129. static get ColorGradingTextureEnabled(): boolean;
  104130. static set ColorGradingTextureEnabled(value: boolean);
  104131. private static _FresnelEnabled;
  104132. /**
  104133. * Are fresnels enabled in the application.
  104134. */
  104135. static get FresnelEnabled(): boolean;
  104136. static set FresnelEnabled(value: boolean);
  104137. private static _ClearCoatTextureEnabled;
  104138. /**
  104139. * Are clear coat textures enabled in the application.
  104140. */
  104141. static get ClearCoatTextureEnabled(): boolean;
  104142. static set ClearCoatTextureEnabled(value: boolean);
  104143. private static _ClearCoatBumpTextureEnabled;
  104144. /**
  104145. * Are clear coat bump textures enabled in the application.
  104146. */
  104147. static get ClearCoatBumpTextureEnabled(): boolean;
  104148. static set ClearCoatBumpTextureEnabled(value: boolean);
  104149. private static _ClearCoatTintTextureEnabled;
  104150. /**
  104151. * Are clear coat tint textures enabled in the application.
  104152. */
  104153. static get ClearCoatTintTextureEnabled(): boolean;
  104154. static set ClearCoatTintTextureEnabled(value: boolean);
  104155. private static _SheenTextureEnabled;
  104156. /**
  104157. * Are sheen textures enabled in the application.
  104158. */
  104159. static get SheenTextureEnabled(): boolean;
  104160. static set SheenTextureEnabled(value: boolean);
  104161. private static _AnisotropicTextureEnabled;
  104162. /**
  104163. * Are anisotropic textures enabled in the application.
  104164. */
  104165. static get AnisotropicTextureEnabled(): boolean;
  104166. static set AnisotropicTextureEnabled(value: boolean);
  104167. private static _ThicknessTextureEnabled;
  104168. /**
  104169. * Are thickness textures enabled in the application.
  104170. */
  104171. static get ThicknessTextureEnabled(): boolean;
  104172. static set ThicknessTextureEnabled(value: boolean);
  104173. }
  104174. }
  104175. declare module BABYLON {
  104176. /** @hidden */
  104177. export var defaultFragmentDeclaration: {
  104178. name: string;
  104179. shader: string;
  104180. };
  104181. }
  104182. declare module BABYLON {
  104183. /** @hidden */
  104184. export var defaultUboDeclaration: {
  104185. name: string;
  104186. shader: string;
  104187. };
  104188. }
  104189. declare module BABYLON {
  104190. /** @hidden */
  104191. export var prePassDeclaration: {
  104192. name: string;
  104193. shader: string;
  104194. };
  104195. }
  104196. declare module BABYLON {
  104197. /** @hidden */
  104198. export var lightFragmentDeclaration: {
  104199. name: string;
  104200. shader: string;
  104201. };
  104202. }
  104203. declare module BABYLON {
  104204. /** @hidden */
  104205. export var lightUboDeclaration: {
  104206. name: string;
  104207. shader: string;
  104208. };
  104209. }
  104210. declare module BABYLON {
  104211. /** @hidden */
  104212. export var lightsFragmentFunctions: {
  104213. name: string;
  104214. shader: string;
  104215. };
  104216. }
  104217. declare module BABYLON {
  104218. /** @hidden */
  104219. export var shadowsFragmentFunctions: {
  104220. name: string;
  104221. shader: string;
  104222. };
  104223. }
  104224. declare module BABYLON {
  104225. /** @hidden */
  104226. export var fresnelFunction: {
  104227. name: string;
  104228. shader: string;
  104229. };
  104230. }
  104231. declare module BABYLON {
  104232. /** @hidden */
  104233. export var bumpFragmentMainFunctions: {
  104234. name: string;
  104235. shader: string;
  104236. };
  104237. }
  104238. declare module BABYLON {
  104239. /** @hidden */
  104240. export var bumpFragmentFunctions: {
  104241. name: string;
  104242. shader: string;
  104243. };
  104244. }
  104245. declare module BABYLON {
  104246. /** @hidden */
  104247. export var logDepthDeclaration: {
  104248. name: string;
  104249. shader: string;
  104250. };
  104251. }
  104252. declare module BABYLON {
  104253. /** @hidden */
  104254. export var bumpFragment: {
  104255. name: string;
  104256. shader: string;
  104257. };
  104258. }
  104259. declare module BABYLON {
  104260. /** @hidden */
  104261. export var depthPrePass: {
  104262. name: string;
  104263. shader: string;
  104264. };
  104265. }
  104266. declare module BABYLON {
  104267. /** @hidden */
  104268. export var lightFragment: {
  104269. name: string;
  104270. shader: string;
  104271. };
  104272. }
  104273. declare module BABYLON {
  104274. /** @hidden */
  104275. export var logDepthFragment: {
  104276. name: string;
  104277. shader: string;
  104278. };
  104279. }
  104280. declare module BABYLON {
  104281. /** @hidden */
  104282. export var defaultPixelShader: {
  104283. name: string;
  104284. shader: string;
  104285. };
  104286. }
  104287. declare module BABYLON {
  104288. /** @hidden */
  104289. export var defaultVertexDeclaration: {
  104290. name: string;
  104291. shader: string;
  104292. };
  104293. }
  104294. declare module BABYLON {
  104295. /** @hidden */
  104296. export var prePassVertexDeclaration: {
  104297. name: string;
  104298. shader: string;
  104299. };
  104300. }
  104301. declare module BABYLON {
  104302. /** @hidden */
  104303. export var bumpVertexDeclaration: {
  104304. name: string;
  104305. shader: string;
  104306. };
  104307. }
  104308. declare module BABYLON {
  104309. /** @hidden */
  104310. export var prePassVertex: {
  104311. name: string;
  104312. shader: string;
  104313. };
  104314. }
  104315. declare module BABYLON {
  104316. /** @hidden */
  104317. export var bumpVertex: {
  104318. name: string;
  104319. shader: string;
  104320. };
  104321. }
  104322. declare module BABYLON {
  104323. /** @hidden */
  104324. export var fogVertex: {
  104325. name: string;
  104326. shader: string;
  104327. };
  104328. }
  104329. declare module BABYLON {
  104330. /** @hidden */
  104331. export var shadowsVertex: {
  104332. name: string;
  104333. shader: string;
  104334. };
  104335. }
  104336. declare module BABYLON {
  104337. /** @hidden */
  104338. export var pointCloudVertex: {
  104339. name: string;
  104340. shader: string;
  104341. };
  104342. }
  104343. declare module BABYLON {
  104344. /** @hidden */
  104345. export var logDepthVertex: {
  104346. name: string;
  104347. shader: string;
  104348. };
  104349. }
  104350. declare module BABYLON {
  104351. /** @hidden */
  104352. export var defaultVertexShader: {
  104353. name: string;
  104354. shader: string;
  104355. };
  104356. }
  104357. declare module BABYLON {
  104358. /**
  104359. * @hidden
  104360. */
  104361. export interface IMaterialDetailMapDefines {
  104362. DETAIL: boolean;
  104363. DETAILDIRECTUV: number;
  104364. DETAIL_NORMALBLENDMETHOD: number;
  104365. /** @hidden */
  104366. _areTexturesDirty: boolean;
  104367. }
  104368. /**
  104369. * Define the code related to the detail map parameters of a material
  104370. *
  104371. * Inspired from:
  104372. * 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
  104373. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  104374. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  104375. */
  104376. export class DetailMapConfiguration {
  104377. private _texture;
  104378. /**
  104379. * The detail texture of the material.
  104380. */
  104381. texture: Nullable<BaseTexture>;
  104382. /**
  104383. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  104384. * Bigger values mean stronger blending
  104385. */
  104386. diffuseBlendLevel: number;
  104387. /**
  104388. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  104389. * Bigger values mean stronger blending. Only used with PBR materials
  104390. */
  104391. roughnessBlendLevel: number;
  104392. /**
  104393. * Defines how strong the bump effect from the detail map is
  104394. * Bigger values mean stronger effect
  104395. */
  104396. bumpLevel: number;
  104397. private _normalBlendMethod;
  104398. /**
  104399. * The method used to blend the bump and detail normals together
  104400. */
  104401. normalBlendMethod: number;
  104402. private _isEnabled;
  104403. /**
  104404. * Enable or disable the detail map on this material
  104405. */
  104406. isEnabled: boolean;
  104407. /** @hidden */
  104408. private _internalMarkAllSubMeshesAsTexturesDirty;
  104409. /** @hidden */
  104410. _markAllSubMeshesAsTexturesDirty(): void;
  104411. /**
  104412. * Instantiate a new detail map
  104413. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104414. */
  104415. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104416. /**
  104417. * Gets whether the submesh is ready to be used or not.
  104418. * @param defines the list of "defines" to update.
  104419. * @param scene defines the scene the material belongs to.
  104420. * @returns - boolean indicating that the submesh is ready or not.
  104421. */
  104422. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  104423. /**
  104424. * Update the defines for detail map usage
  104425. * @param defines the list of "defines" to update.
  104426. * @param scene defines the scene the material belongs to.
  104427. */
  104428. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  104429. /**
  104430. * Binds the material data.
  104431. * @param uniformBuffer defines the Uniform buffer to fill in.
  104432. * @param scene defines the scene the material belongs to.
  104433. * @param isFrozen defines whether the material is frozen or not.
  104434. */
  104435. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104436. /**
  104437. * Checks to see if a texture is used in the material.
  104438. * @param texture - Base texture to use.
  104439. * @returns - Boolean specifying if a texture is used in the material.
  104440. */
  104441. hasTexture(texture: BaseTexture): boolean;
  104442. /**
  104443. * Returns an array of the actively used textures.
  104444. * @param activeTextures Array of BaseTextures
  104445. */
  104446. getActiveTextures(activeTextures: BaseTexture[]): void;
  104447. /**
  104448. * Returns the animatable textures.
  104449. * @param animatables Array of animatable textures.
  104450. */
  104451. getAnimatables(animatables: IAnimatable[]): void;
  104452. /**
  104453. * Disposes the resources of the material.
  104454. * @param forceDisposeTextures - Forces the disposal of all textures.
  104455. */
  104456. dispose(forceDisposeTextures?: boolean): void;
  104457. /**
  104458. * Get the current class name useful for serialization or dynamic coding.
  104459. * @returns "DetailMap"
  104460. */
  104461. getClassName(): string;
  104462. /**
  104463. * Add the required uniforms to the current list.
  104464. * @param uniforms defines the current uniform list.
  104465. */
  104466. static AddUniforms(uniforms: string[]): void;
  104467. /**
  104468. * Add the required samplers to the current list.
  104469. * @param samplers defines the current sampler list.
  104470. */
  104471. static AddSamplers(samplers: string[]): void;
  104472. /**
  104473. * Add the required uniforms to the current buffer.
  104474. * @param uniformBuffer defines the current uniform buffer.
  104475. */
  104476. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104477. /**
  104478. * Makes a duplicate of the current instance into another one.
  104479. * @param detailMap define the instance where to copy the info
  104480. */
  104481. copyTo(detailMap: DetailMapConfiguration): void;
  104482. /**
  104483. * Serializes this detail map instance
  104484. * @returns - An object with the serialized instance.
  104485. */
  104486. serialize(): any;
  104487. /**
  104488. * Parses a detail map setting from a serialized object.
  104489. * @param source - Serialized object.
  104490. * @param scene Defines the scene we are parsing for
  104491. * @param rootUrl Defines the rootUrl to load from
  104492. */
  104493. parse(source: any, scene: Scene, rootUrl: string): void;
  104494. }
  104495. }
  104496. declare module BABYLON {
  104497. /** @hidden */
  104498. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  104499. MAINUV1: boolean;
  104500. MAINUV2: boolean;
  104501. DIFFUSE: boolean;
  104502. DIFFUSEDIRECTUV: number;
  104503. DETAIL: boolean;
  104504. DETAILDIRECTUV: number;
  104505. DETAIL_NORMALBLENDMETHOD: number;
  104506. AMBIENT: boolean;
  104507. AMBIENTDIRECTUV: number;
  104508. OPACITY: boolean;
  104509. OPACITYDIRECTUV: number;
  104510. OPACITYRGB: boolean;
  104511. REFLECTION: boolean;
  104512. EMISSIVE: boolean;
  104513. EMISSIVEDIRECTUV: number;
  104514. SPECULAR: boolean;
  104515. SPECULARDIRECTUV: number;
  104516. BUMP: boolean;
  104517. BUMPDIRECTUV: number;
  104518. PARALLAX: boolean;
  104519. PARALLAXOCCLUSION: boolean;
  104520. SPECULAROVERALPHA: boolean;
  104521. CLIPPLANE: boolean;
  104522. CLIPPLANE2: boolean;
  104523. CLIPPLANE3: boolean;
  104524. CLIPPLANE4: boolean;
  104525. CLIPPLANE5: boolean;
  104526. CLIPPLANE6: boolean;
  104527. ALPHATEST: boolean;
  104528. DEPTHPREPASS: boolean;
  104529. ALPHAFROMDIFFUSE: boolean;
  104530. POINTSIZE: boolean;
  104531. FOG: boolean;
  104532. SPECULARTERM: boolean;
  104533. DIFFUSEFRESNEL: boolean;
  104534. OPACITYFRESNEL: boolean;
  104535. REFLECTIONFRESNEL: boolean;
  104536. REFRACTIONFRESNEL: boolean;
  104537. EMISSIVEFRESNEL: boolean;
  104538. FRESNEL: boolean;
  104539. NORMAL: boolean;
  104540. UV1: boolean;
  104541. UV2: boolean;
  104542. VERTEXCOLOR: boolean;
  104543. VERTEXALPHA: boolean;
  104544. NUM_BONE_INFLUENCERS: number;
  104545. BonesPerMesh: number;
  104546. BONETEXTURE: boolean;
  104547. BONES_VELOCITY_ENABLED: boolean;
  104548. INSTANCES: boolean;
  104549. THIN_INSTANCES: boolean;
  104550. GLOSSINESS: boolean;
  104551. ROUGHNESS: boolean;
  104552. EMISSIVEASILLUMINATION: boolean;
  104553. LINKEMISSIVEWITHDIFFUSE: boolean;
  104554. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104555. LIGHTMAP: boolean;
  104556. LIGHTMAPDIRECTUV: number;
  104557. OBJECTSPACE_NORMALMAP: boolean;
  104558. USELIGHTMAPASSHADOWMAP: boolean;
  104559. REFLECTIONMAP_3D: boolean;
  104560. REFLECTIONMAP_SPHERICAL: boolean;
  104561. REFLECTIONMAP_PLANAR: boolean;
  104562. REFLECTIONMAP_CUBIC: boolean;
  104563. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104564. REFLECTIONMAP_PROJECTION: boolean;
  104565. REFLECTIONMAP_SKYBOX: boolean;
  104566. REFLECTIONMAP_EXPLICIT: boolean;
  104567. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104568. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104569. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104570. INVERTCUBICMAP: boolean;
  104571. LOGARITHMICDEPTH: boolean;
  104572. REFRACTION: boolean;
  104573. REFRACTIONMAP_3D: boolean;
  104574. REFLECTIONOVERALPHA: boolean;
  104575. TWOSIDEDLIGHTING: boolean;
  104576. SHADOWFLOAT: boolean;
  104577. MORPHTARGETS: boolean;
  104578. MORPHTARGETS_NORMAL: boolean;
  104579. MORPHTARGETS_TANGENT: boolean;
  104580. MORPHTARGETS_UV: boolean;
  104581. NUM_MORPH_INFLUENCERS: number;
  104582. NONUNIFORMSCALING: boolean;
  104583. PREMULTIPLYALPHA: boolean;
  104584. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  104585. ALPHABLEND: boolean;
  104586. PREPASS: boolean;
  104587. PREPASS_IRRADIANCE: boolean;
  104588. PREPASS_IRRADIANCE_INDEX: number;
  104589. PREPASS_ALBEDO: boolean;
  104590. PREPASS_ALBEDO_INDEX: number;
  104591. PREPASS_DEPTHNORMAL: boolean;
  104592. PREPASS_DEPTHNORMAL_INDEX: number;
  104593. PREPASS_POSITION: boolean;
  104594. PREPASS_POSITION_INDEX: number;
  104595. PREPASS_VELOCITY: boolean;
  104596. PREPASS_VELOCITY_INDEX: number;
  104597. PREPASS_REFLECTIVITY: boolean;
  104598. PREPASS_REFLECTIVITY_INDEX: number;
  104599. SCENE_MRT_COUNT: number;
  104600. RGBDLIGHTMAP: boolean;
  104601. RGBDREFLECTION: boolean;
  104602. RGBDREFRACTION: boolean;
  104603. IMAGEPROCESSING: boolean;
  104604. VIGNETTE: boolean;
  104605. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104606. VIGNETTEBLENDMODEOPAQUE: boolean;
  104607. TONEMAPPING: boolean;
  104608. TONEMAPPING_ACES: boolean;
  104609. CONTRAST: boolean;
  104610. COLORCURVES: boolean;
  104611. COLORGRADING: boolean;
  104612. COLORGRADING3D: boolean;
  104613. SAMPLER3DGREENDEPTH: boolean;
  104614. SAMPLER3DBGRMAP: boolean;
  104615. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104616. MULTIVIEW: boolean;
  104617. /**
  104618. * If the reflection texture on this material is in linear color space
  104619. * @hidden
  104620. */
  104621. IS_REFLECTION_LINEAR: boolean;
  104622. /**
  104623. * If the refraction texture on this material is in linear color space
  104624. * @hidden
  104625. */
  104626. IS_REFRACTION_LINEAR: boolean;
  104627. EXPOSURE: boolean;
  104628. constructor();
  104629. setReflectionMode(modeToEnable: string): void;
  104630. }
  104631. /**
  104632. * This is the default material used in Babylon. It is the best trade off between quality
  104633. * and performances.
  104634. * @see https://doc.babylonjs.com/babylon101/materials
  104635. */
  104636. export class StandardMaterial extends PushMaterial {
  104637. private _diffuseTexture;
  104638. /**
  104639. * The basic texture of the material as viewed under a light.
  104640. */
  104641. diffuseTexture: Nullable<BaseTexture>;
  104642. private _ambientTexture;
  104643. /**
  104644. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104645. */
  104646. ambientTexture: Nullable<BaseTexture>;
  104647. private _opacityTexture;
  104648. /**
  104649. * Define the transparency of the material from a texture.
  104650. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104651. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104652. */
  104653. opacityTexture: Nullable<BaseTexture>;
  104654. private _reflectionTexture;
  104655. /**
  104656. * Define the texture used to display the reflection.
  104657. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104658. */
  104659. reflectionTexture: Nullable<BaseTexture>;
  104660. private _emissiveTexture;
  104661. /**
  104662. * Define texture of the material as if self lit.
  104663. * This will be mixed in the final result even in the absence of light.
  104664. */
  104665. emissiveTexture: Nullable<BaseTexture>;
  104666. private _specularTexture;
  104667. /**
  104668. * Define how the color and intensity of the highlight given by the light in the material.
  104669. */
  104670. specularTexture: Nullable<BaseTexture>;
  104671. private _bumpTexture;
  104672. /**
  104673. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104674. * 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.
  104675. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  104676. */
  104677. bumpTexture: Nullable<BaseTexture>;
  104678. private _lightmapTexture;
  104679. /**
  104680. * Complex lighting can be computationally expensive to compute at runtime.
  104681. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104682. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  104683. */
  104684. lightmapTexture: Nullable<BaseTexture>;
  104685. private _refractionTexture;
  104686. /**
  104687. * Define the texture used to display the refraction.
  104688. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104689. */
  104690. refractionTexture: Nullable<BaseTexture>;
  104691. /**
  104692. * The color of the material lit by the environmental background lighting.
  104693. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104694. */
  104695. ambientColor: Color3;
  104696. /**
  104697. * The basic color of the material as viewed under a light.
  104698. */
  104699. diffuseColor: Color3;
  104700. /**
  104701. * Define how the color and intensity of the highlight given by the light in the material.
  104702. */
  104703. specularColor: Color3;
  104704. /**
  104705. * Define the color of the material as if self lit.
  104706. * This will be mixed in the final result even in the absence of light.
  104707. */
  104708. emissiveColor: Color3;
  104709. /**
  104710. * Defines how sharp are the highlights in the material.
  104711. * The bigger the value the sharper giving a more glossy feeling to the result.
  104712. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104713. */
  104714. specularPower: number;
  104715. private _useAlphaFromDiffuseTexture;
  104716. /**
  104717. * Does the transparency come from the diffuse texture alpha channel.
  104718. */
  104719. useAlphaFromDiffuseTexture: boolean;
  104720. private _useEmissiveAsIllumination;
  104721. /**
  104722. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104723. */
  104724. useEmissiveAsIllumination: boolean;
  104725. private _linkEmissiveWithDiffuse;
  104726. /**
  104727. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104728. * the emissive level when the final color is close to one.
  104729. */
  104730. linkEmissiveWithDiffuse: boolean;
  104731. private _useSpecularOverAlpha;
  104732. /**
  104733. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104734. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104735. */
  104736. useSpecularOverAlpha: boolean;
  104737. private _useReflectionOverAlpha;
  104738. /**
  104739. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104740. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104741. */
  104742. useReflectionOverAlpha: boolean;
  104743. private _disableLighting;
  104744. /**
  104745. * Does lights from the scene impacts this material.
  104746. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104747. */
  104748. disableLighting: boolean;
  104749. private _useObjectSpaceNormalMap;
  104750. /**
  104751. * Allows using an object space normal map (instead of tangent space).
  104752. */
  104753. useObjectSpaceNormalMap: boolean;
  104754. private _useParallax;
  104755. /**
  104756. * Is parallax enabled or not.
  104757. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104758. */
  104759. useParallax: boolean;
  104760. private _useParallaxOcclusion;
  104761. /**
  104762. * Is parallax occlusion enabled or not.
  104763. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104764. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  104765. */
  104766. useParallaxOcclusion: boolean;
  104767. /**
  104768. * 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.
  104769. */
  104770. parallaxScaleBias: number;
  104771. private _roughness;
  104772. /**
  104773. * Helps to define how blurry the reflections should appears in the material.
  104774. */
  104775. roughness: number;
  104776. /**
  104777. * In case of refraction, define the value of the index of refraction.
  104778. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104779. */
  104780. indexOfRefraction: number;
  104781. /**
  104782. * Invert the refraction texture alongside the y axis.
  104783. * It can be useful with procedural textures or probe for instance.
  104784. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104785. */
  104786. invertRefractionY: boolean;
  104787. /**
  104788. * Defines the alpha limits in alpha test mode.
  104789. */
  104790. alphaCutOff: number;
  104791. private _useLightmapAsShadowmap;
  104792. /**
  104793. * In case of light mapping, define whether the map contains light or shadow informations.
  104794. */
  104795. useLightmapAsShadowmap: boolean;
  104796. private _diffuseFresnelParameters;
  104797. /**
  104798. * Define the diffuse fresnel parameters of the material.
  104799. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104800. */
  104801. diffuseFresnelParameters: FresnelParameters;
  104802. private _opacityFresnelParameters;
  104803. /**
  104804. * Define the opacity fresnel parameters of the material.
  104805. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104806. */
  104807. opacityFresnelParameters: FresnelParameters;
  104808. private _reflectionFresnelParameters;
  104809. /**
  104810. * Define the reflection fresnel parameters of the material.
  104811. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104812. */
  104813. reflectionFresnelParameters: FresnelParameters;
  104814. private _refractionFresnelParameters;
  104815. /**
  104816. * Define the refraction fresnel parameters of the material.
  104817. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104818. */
  104819. refractionFresnelParameters: FresnelParameters;
  104820. private _emissiveFresnelParameters;
  104821. /**
  104822. * Define the emissive fresnel parameters of the material.
  104823. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104824. */
  104825. emissiveFresnelParameters: FresnelParameters;
  104826. private _useReflectionFresnelFromSpecular;
  104827. /**
  104828. * If true automatically deducts the fresnels values from the material specularity.
  104829. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104830. */
  104831. useReflectionFresnelFromSpecular: boolean;
  104832. private _useGlossinessFromSpecularMapAlpha;
  104833. /**
  104834. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104835. */
  104836. useGlossinessFromSpecularMapAlpha: boolean;
  104837. private _maxSimultaneousLights;
  104838. /**
  104839. * Defines the maximum number of lights that can be used in the material
  104840. */
  104841. maxSimultaneousLights: number;
  104842. private _invertNormalMapX;
  104843. /**
  104844. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104845. */
  104846. invertNormalMapX: boolean;
  104847. private _invertNormalMapY;
  104848. /**
  104849. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104850. */
  104851. invertNormalMapY: boolean;
  104852. private _twoSidedLighting;
  104853. /**
  104854. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104855. */
  104856. twoSidedLighting: boolean;
  104857. /**
  104858. * Default configuration related to image processing available in the standard Material.
  104859. */
  104860. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104861. /**
  104862. * Gets the image processing configuration used either in this material.
  104863. */
  104864. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104865. /**
  104866. * Sets the Default image processing configuration used either in the this material.
  104867. *
  104868. * If sets to null, the scene one is in use.
  104869. */
  104870. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104871. /**
  104872. * Keep track of the image processing observer to allow dispose and replace.
  104873. */
  104874. private _imageProcessingObserver;
  104875. /**
  104876. * Attaches a new image processing configuration to the Standard Material.
  104877. * @param configuration
  104878. */
  104879. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104880. /**
  104881. * Defines additionnal PrePass parameters for the material.
  104882. */
  104883. readonly prePassConfiguration: PrePassConfiguration;
  104884. /**
  104885. * Gets wether the color curves effect is enabled.
  104886. */
  104887. get cameraColorCurvesEnabled(): boolean;
  104888. /**
  104889. * Sets wether the color curves effect is enabled.
  104890. */
  104891. set cameraColorCurvesEnabled(value: boolean);
  104892. /**
  104893. * Gets wether the color grading effect is enabled.
  104894. */
  104895. get cameraColorGradingEnabled(): boolean;
  104896. /**
  104897. * Gets wether the color grading effect is enabled.
  104898. */
  104899. set cameraColorGradingEnabled(value: boolean);
  104900. /**
  104901. * Gets wether tonemapping is enabled or not.
  104902. */
  104903. get cameraToneMappingEnabled(): boolean;
  104904. /**
  104905. * Sets wether tonemapping is enabled or not
  104906. */
  104907. set cameraToneMappingEnabled(value: boolean);
  104908. /**
  104909. * The camera exposure used on this material.
  104910. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104911. * This corresponds to a photographic exposure.
  104912. */
  104913. get cameraExposure(): number;
  104914. /**
  104915. * The camera exposure used on this material.
  104916. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104917. * This corresponds to a photographic exposure.
  104918. */
  104919. set cameraExposure(value: number);
  104920. /**
  104921. * Gets The camera contrast used on this material.
  104922. */
  104923. get cameraContrast(): number;
  104924. /**
  104925. * Sets The camera contrast used on this material.
  104926. */
  104927. set cameraContrast(value: number);
  104928. /**
  104929. * Gets the Color Grading 2D Lookup Texture.
  104930. */
  104931. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  104932. /**
  104933. * Sets the Color Grading 2D Lookup Texture.
  104934. */
  104935. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  104936. /**
  104937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104939. * 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;
  104940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104941. */
  104942. get cameraColorCurves(): Nullable<ColorCurves>;
  104943. /**
  104944. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104945. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104946. * 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;
  104947. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104948. */
  104949. set cameraColorCurves(value: Nullable<ColorCurves>);
  104950. /**
  104951. * Can this material render to several textures at once
  104952. */
  104953. get canRenderToMRT(): boolean;
  104954. /**
  104955. * Defines the detail map parameters for the material.
  104956. */
  104957. readonly detailMap: DetailMapConfiguration;
  104958. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104959. protected _worldViewProjectionMatrix: Matrix;
  104960. protected _globalAmbientColor: Color3;
  104961. protected _useLogarithmicDepth: boolean;
  104962. protected _rebuildInParallel: boolean;
  104963. /**
  104964. * Instantiates a new standard material.
  104965. * This is the default material used in Babylon. It is the best trade off between quality
  104966. * and performances.
  104967. * @see https://doc.babylonjs.com/babylon101/materials
  104968. * @param name Define the name of the material in the scene
  104969. * @param scene Define the scene the material belong to
  104970. */
  104971. constructor(name: string, scene: Scene);
  104972. /**
  104973. * Gets a boolean indicating that current material needs to register RTT
  104974. */
  104975. get hasRenderTargetTextures(): boolean;
  104976. /**
  104977. * Gets the current class name of the material e.g. "StandardMaterial"
  104978. * Mainly use in serialization.
  104979. * @returns the class name
  104980. */
  104981. getClassName(): string;
  104982. /**
  104983. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104984. * You can try switching to logarithmic depth.
  104985. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104986. */
  104987. get useLogarithmicDepth(): boolean;
  104988. set useLogarithmicDepth(value: boolean);
  104989. /**
  104990. * Specifies if the material will require alpha blending
  104991. * @returns a boolean specifying if alpha blending is needed
  104992. */
  104993. needAlphaBlending(): boolean;
  104994. /**
  104995. * Specifies if this material should be rendered in alpha test mode
  104996. * @returns a boolean specifying if an alpha test is needed.
  104997. */
  104998. needAlphaTesting(): boolean;
  104999. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105000. /**
  105001. * Get the texture used for alpha test purpose.
  105002. * @returns the diffuse texture in case of the standard material.
  105003. */
  105004. getAlphaTestTexture(): Nullable<BaseTexture>;
  105005. /**
  105006. * Get if the submesh is ready to be used and all its information available.
  105007. * Child classes can use it to update shaders
  105008. * @param mesh defines the mesh to check
  105009. * @param subMesh defines which submesh to check
  105010. * @param useInstances specifies that instances should be used
  105011. * @returns a boolean indicating that the submesh is ready or not
  105012. */
  105013. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105014. /**
  105015. * Builds the material UBO layouts.
  105016. * Used internally during the effect preparation.
  105017. */
  105018. buildUniformLayout(): void;
  105019. /**
  105020. * Unbinds the material from the mesh
  105021. */
  105022. unbind(): void;
  105023. /**
  105024. * Binds the submesh to this material by preparing the effect and shader to draw
  105025. * @param world defines the world transformation matrix
  105026. * @param mesh defines the mesh containing the submesh
  105027. * @param subMesh defines the submesh to bind the material to
  105028. */
  105029. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105030. /**
  105031. * Get the list of animatables in the material.
  105032. * @returns the list of animatables object used in the material
  105033. */
  105034. getAnimatables(): IAnimatable[];
  105035. /**
  105036. * Gets the active textures from the material
  105037. * @returns an array of textures
  105038. */
  105039. getActiveTextures(): BaseTexture[];
  105040. /**
  105041. * Specifies if the material uses a texture
  105042. * @param texture defines the texture to check against the material
  105043. * @returns a boolean specifying if the material uses the texture
  105044. */
  105045. hasTexture(texture: BaseTexture): boolean;
  105046. /**
  105047. * Disposes the material
  105048. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105049. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105050. */
  105051. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105052. /**
  105053. * Makes a duplicate of the material, and gives it a new name
  105054. * @param name defines the new name for the duplicated material
  105055. * @returns the cloned material
  105056. */
  105057. clone(name: string): StandardMaterial;
  105058. /**
  105059. * Serializes this material in a JSON representation
  105060. * @returns the serialized material object
  105061. */
  105062. serialize(): any;
  105063. /**
  105064. * Creates a standard material from parsed material data
  105065. * @param source defines the JSON representation of the material
  105066. * @param scene defines the hosting scene
  105067. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105068. * @returns a new standard material
  105069. */
  105070. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105071. /**
  105072. * Are diffuse textures enabled in the application.
  105073. */
  105074. static get DiffuseTextureEnabled(): boolean;
  105075. static set DiffuseTextureEnabled(value: boolean);
  105076. /**
  105077. * Are detail textures enabled in the application.
  105078. */
  105079. static get DetailTextureEnabled(): boolean;
  105080. static set DetailTextureEnabled(value: boolean);
  105081. /**
  105082. * Are ambient textures enabled in the application.
  105083. */
  105084. static get AmbientTextureEnabled(): boolean;
  105085. static set AmbientTextureEnabled(value: boolean);
  105086. /**
  105087. * Are opacity textures enabled in the application.
  105088. */
  105089. static get OpacityTextureEnabled(): boolean;
  105090. static set OpacityTextureEnabled(value: boolean);
  105091. /**
  105092. * Are reflection textures enabled in the application.
  105093. */
  105094. static get ReflectionTextureEnabled(): boolean;
  105095. static set ReflectionTextureEnabled(value: boolean);
  105096. /**
  105097. * Are emissive textures enabled in the application.
  105098. */
  105099. static get EmissiveTextureEnabled(): boolean;
  105100. static set EmissiveTextureEnabled(value: boolean);
  105101. /**
  105102. * Are specular textures enabled in the application.
  105103. */
  105104. static get SpecularTextureEnabled(): boolean;
  105105. static set SpecularTextureEnabled(value: boolean);
  105106. /**
  105107. * Are bump textures enabled in the application.
  105108. */
  105109. static get BumpTextureEnabled(): boolean;
  105110. static set BumpTextureEnabled(value: boolean);
  105111. /**
  105112. * Are lightmap textures enabled in the application.
  105113. */
  105114. static get LightmapTextureEnabled(): boolean;
  105115. static set LightmapTextureEnabled(value: boolean);
  105116. /**
  105117. * Are refraction textures enabled in the application.
  105118. */
  105119. static get RefractionTextureEnabled(): boolean;
  105120. static set RefractionTextureEnabled(value: boolean);
  105121. /**
  105122. * Are color grading textures enabled in the application.
  105123. */
  105124. static get ColorGradingTextureEnabled(): boolean;
  105125. static set ColorGradingTextureEnabled(value: boolean);
  105126. /**
  105127. * Are fresnels enabled in the application.
  105128. */
  105129. static get FresnelEnabled(): boolean;
  105130. static set FresnelEnabled(value: boolean);
  105131. }
  105132. }
  105133. declare module BABYLON {
  105134. /** @hidden */
  105135. export var rgbdDecodePixelShader: {
  105136. name: string;
  105137. shader: string;
  105138. };
  105139. }
  105140. declare module BABYLON {
  105141. /**
  105142. * Class used to host RGBD texture specific utilities
  105143. */
  105144. export class RGBDTextureTools {
  105145. /**
  105146. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105147. * @param texture the texture to expand.
  105148. */
  105149. static ExpandRGBDTexture(texture: Texture): void;
  105150. }
  105151. }
  105152. declare module BABYLON {
  105153. /**
  105154. * Class used to host texture specific utilities
  105155. */
  105156. export class BRDFTextureTools {
  105157. /**
  105158. * Prevents texture cache collision
  105159. */
  105160. private static _instanceNumber;
  105161. /**
  105162. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105163. * @param scene defines the hosting scene
  105164. * @returns the environment BRDF texture
  105165. */
  105166. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105167. private static _environmentBRDFBase64Texture;
  105168. }
  105169. }
  105170. declare module BABYLON {
  105171. /**
  105172. * @hidden
  105173. */
  105174. export interface IMaterialClearCoatDefines {
  105175. CLEARCOAT: boolean;
  105176. CLEARCOAT_DEFAULTIOR: boolean;
  105177. CLEARCOAT_TEXTURE: boolean;
  105178. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  105179. CLEARCOAT_TEXTUREDIRECTUV: number;
  105180. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  105181. CLEARCOAT_BUMP: boolean;
  105182. CLEARCOAT_BUMPDIRECTUV: number;
  105183. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105184. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105185. CLEARCOAT_REMAP_F0: boolean;
  105186. CLEARCOAT_TINT: boolean;
  105187. CLEARCOAT_TINT_TEXTURE: boolean;
  105188. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105189. /** @hidden */
  105190. _areTexturesDirty: boolean;
  105191. }
  105192. /**
  105193. * Define the code related to the clear coat parameters of the pbr material.
  105194. */
  105195. export class PBRClearCoatConfiguration {
  105196. /**
  105197. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105198. * The default fits with a polyurethane material.
  105199. */
  105200. private static readonly _DefaultIndexOfRefraction;
  105201. private _isEnabled;
  105202. /**
  105203. * Defines if the clear coat is enabled in the material.
  105204. */
  105205. isEnabled: boolean;
  105206. /**
  105207. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105208. */
  105209. intensity: number;
  105210. /**
  105211. * Defines the clear coat layer roughness.
  105212. */
  105213. roughness: number;
  105214. private _indexOfRefraction;
  105215. /**
  105216. * Defines the index of refraction of the clear coat.
  105217. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105218. * The default fits with a polyurethane material.
  105219. * Changing the default value is more performance intensive.
  105220. */
  105221. indexOfRefraction: number;
  105222. private _texture;
  105223. /**
  105224. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  105225. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  105226. * if textureRoughness is not empty, else no texture roughness is used
  105227. */
  105228. texture: Nullable<BaseTexture>;
  105229. private _useRoughnessFromMainTexture;
  105230. /**
  105231. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  105232. * If false, the green channel from textureRoughness is used for roughness
  105233. */
  105234. useRoughnessFromMainTexture: boolean;
  105235. private _textureRoughness;
  105236. /**
  105237. * Stores the clear coat roughness in a texture (green channel)
  105238. * Not used if useRoughnessFromMainTexture is true
  105239. */
  105240. textureRoughness: Nullable<BaseTexture>;
  105241. private _remapF0OnInterfaceChange;
  105242. /**
  105243. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105244. */
  105245. remapF0OnInterfaceChange: boolean;
  105246. private _bumpTexture;
  105247. /**
  105248. * Define the clear coat specific bump texture.
  105249. */
  105250. bumpTexture: Nullable<BaseTexture>;
  105251. private _isTintEnabled;
  105252. /**
  105253. * Defines if the clear coat tint is enabled in the material.
  105254. */
  105255. isTintEnabled: boolean;
  105256. /**
  105257. * Defines the clear coat tint of the material.
  105258. * This is only use if tint is enabled
  105259. */
  105260. tintColor: Color3;
  105261. /**
  105262. * Defines the distance at which the tint color should be found in the
  105263. * clear coat media.
  105264. * This is only use if tint is enabled
  105265. */
  105266. tintColorAtDistance: number;
  105267. /**
  105268. * Defines the clear coat layer thickness.
  105269. * This is only use if tint is enabled
  105270. */
  105271. tintThickness: number;
  105272. private _tintTexture;
  105273. /**
  105274. * Stores the clear tint values in a texture.
  105275. * rgb is tint
  105276. * a is a thickness factor
  105277. */
  105278. tintTexture: Nullable<BaseTexture>;
  105279. /** @hidden */
  105280. private _internalMarkAllSubMeshesAsTexturesDirty;
  105281. /** @hidden */
  105282. _markAllSubMeshesAsTexturesDirty(): void;
  105283. /**
  105284. * Instantiate a new istance of clear coat configuration.
  105285. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105286. */
  105287. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105288. /**
  105289. * Gets wehter the submesh is ready to be used or not.
  105290. * @param defines the list of "defines" to update.
  105291. * @param scene defines the scene the material belongs to.
  105292. * @param engine defines the engine the material belongs to.
  105293. * @param disableBumpMap defines wether the material disables bump or not.
  105294. * @returns - boolean indicating that the submesh is ready or not.
  105295. */
  105296. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  105297. /**
  105298. * Checks to see if a texture is used in the material.
  105299. * @param defines the list of "defines" to update.
  105300. * @param scene defines the scene to the material belongs to.
  105301. */
  105302. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  105303. /**
  105304. * Binds the material data.
  105305. * @param uniformBuffer defines the Uniform buffer to fill in.
  105306. * @param scene defines the scene the material belongs to.
  105307. * @param engine defines the engine the material belongs to.
  105308. * @param disableBumpMap defines wether the material disables bump or not.
  105309. * @param isFrozen defines wether the material is frozen or not.
  105310. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105311. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105312. * @param subMesh the submesh to bind data for
  105313. */
  105314. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  105315. /**
  105316. * Checks to see if a texture is used in the material.
  105317. * @param texture - Base texture to use.
  105318. * @returns - Boolean specifying if a texture is used in the material.
  105319. */
  105320. hasTexture(texture: BaseTexture): boolean;
  105321. /**
  105322. * Returns an array of the actively used textures.
  105323. * @param activeTextures Array of BaseTextures
  105324. */
  105325. getActiveTextures(activeTextures: BaseTexture[]): void;
  105326. /**
  105327. * Returns the animatable textures.
  105328. * @param animatables Array of animatable textures.
  105329. */
  105330. getAnimatables(animatables: IAnimatable[]): void;
  105331. /**
  105332. * Disposes the resources of the material.
  105333. * @param forceDisposeTextures - Forces the disposal of all textures.
  105334. */
  105335. dispose(forceDisposeTextures?: boolean): void;
  105336. /**
  105337. * Get the current class name of the texture useful for serialization or dynamic coding.
  105338. * @returns "PBRClearCoatConfiguration"
  105339. */
  105340. getClassName(): string;
  105341. /**
  105342. * Add fallbacks to the effect fallbacks list.
  105343. * @param defines defines the Base texture to use.
  105344. * @param fallbacks defines the current fallback list.
  105345. * @param currentRank defines the current fallback rank.
  105346. * @returns the new fallback rank.
  105347. */
  105348. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105349. /**
  105350. * Add the required uniforms to the current list.
  105351. * @param uniforms defines the current uniform list.
  105352. */
  105353. static AddUniforms(uniforms: string[]): void;
  105354. /**
  105355. * Add the required samplers to the current list.
  105356. * @param samplers defines the current sampler list.
  105357. */
  105358. static AddSamplers(samplers: string[]): void;
  105359. /**
  105360. * Add the required uniforms to the current buffer.
  105361. * @param uniformBuffer defines the current uniform buffer.
  105362. */
  105363. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105364. /**
  105365. * Makes a duplicate of the current configuration into another one.
  105366. * @param clearCoatConfiguration define the config where to copy the info
  105367. */
  105368. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  105369. /**
  105370. * Serializes this clear coat configuration.
  105371. * @returns - An object with the serialized config.
  105372. */
  105373. serialize(): any;
  105374. /**
  105375. * Parses a anisotropy Configuration from a serialized object.
  105376. * @param source - Serialized object.
  105377. * @param scene Defines the scene we are parsing for
  105378. * @param rootUrl Defines the rootUrl to load from
  105379. */
  105380. parse(source: any, scene: Scene, rootUrl: string): void;
  105381. }
  105382. }
  105383. declare module BABYLON {
  105384. /**
  105385. * @hidden
  105386. */
  105387. export interface IMaterialAnisotropicDefines {
  105388. ANISOTROPIC: boolean;
  105389. ANISOTROPIC_TEXTURE: boolean;
  105390. ANISOTROPIC_TEXTUREDIRECTUV: number;
  105391. MAINUV1: boolean;
  105392. _areTexturesDirty: boolean;
  105393. _needUVs: boolean;
  105394. }
  105395. /**
  105396. * Define the code related to the anisotropic parameters of the pbr material.
  105397. */
  105398. export class PBRAnisotropicConfiguration {
  105399. private _isEnabled;
  105400. /**
  105401. * Defines if the anisotropy is enabled in the material.
  105402. */
  105403. isEnabled: boolean;
  105404. /**
  105405. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  105406. */
  105407. intensity: number;
  105408. /**
  105409. * Defines if the effect is along the tangents, bitangents or in between.
  105410. * By default, the effect is "strectching" the highlights along the tangents.
  105411. */
  105412. direction: Vector2;
  105413. private _texture;
  105414. /**
  105415. * Stores the anisotropy values in a texture.
  105416. * rg is direction (like normal from -1 to 1)
  105417. * b is a intensity
  105418. */
  105419. texture: Nullable<BaseTexture>;
  105420. /** @hidden */
  105421. private _internalMarkAllSubMeshesAsTexturesDirty;
  105422. /** @hidden */
  105423. _markAllSubMeshesAsTexturesDirty(): void;
  105424. /**
  105425. * Instantiate a new istance of anisotropy configuration.
  105426. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105427. */
  105428. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105429. /**
  105430. * Specifies that the submesh is ready to be used.
  105431. * @param defines the list of "defines" to update.
  105432. * @param scene defines the scene the material belongs to.
  105433. * @returns - boolean indicating that the submesh is ready or not.
  105434. */
  105435. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  105436. /**
  105437. * Checks to see if a texture is used in the material.
  105438. * @param defines the list of "defines" to update.
  105439. * @param mesh the mesh we are preparing the defines for.
  105440. * @param scene defines the scene the material belongs to.
  105441. */
  105442. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  105443. /**
  105444. * Binds the material data.
  105445. * @param uniformBuffer defines the Uniform buffer to fill in.
  105446. * @param scene defines the scene the material belongs to.
  105447. * @param isFrozen defines wether the material is frozen or not.
  105448. */
  105449. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105450. /**
  105451. * Checks to see if a texture is used in the material.
  105452. * @param texture - Base texture to use.
  105453. * @returns - Boolean specifying if a texture is used in the material.
  105454. */
  105455. hasTexture(texture: BaseTexture): boolean;
  105456. /**
  105457. * Returns an array of the actively used textures.
  105458. * @param activeTextures Array of BaseTextures
  105459. */
  105460. getActiveTextures(activeTextures: BaseTexture[]): void;
  105461. /**
  105462. * Returns the animatable textures.
  105463. * @param animatables Array of animatable textures.
  105464. */
  105465. getAnimatables(animatables: IAnimatable[]): void;
  105466. /**
  105467. * Disposes the resources of the material.
  105468. * @param forceDisposeTextures - Forces the disposal of all textures.
  105469. */
  105470. dispose(forceDisposeTextures?: boolean): void;
  105471. /**
  105472. * Get the current class name of the texture useful for serialization or dynamic coding.
  105473. * @returns "PBRAnisotropicConfiguration"
  105474. */
  105475. getClassName(): string;
  105476. /**
  105477. * Add fallbacks to the effect fallbacks list.
  105478. * @param defines defines the Base texture to use.
  105479. * @param fallbacks defines the current fallback list.
  105480. * @param currentRank defines the current fallback rank.
  105481. * @returns the new fallback rank.
  105482. */
  105483. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105484. /**
  105485. * Add the required uniforms to the current list.
  105486. * @param uniforms defines the current uniform list.
  105487. */
  105488. static AddUniforms(uniforms: string[]): void;
  105489. /**
  105490. * Add the required uniforms to the current buffer.
  105491. * @param uniformBuffer defines the current uniform buffer.
  105492. */
  105493. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105494. /**
  105495. * Add the required samplers to the current list.
  105496. * @param samplers defines the current sampler list.
  105497. */
  105498. static AddSamplers(samplers: string[]): void;
  105499. /**
  105500. * Makes a duplicate of the current configuration into another one.
  105501. * @param anisotropicConfiguration define the config where to copy the info
  105502. */
  105503. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  105504. /**
  105505. * Serializes this anisotropy configuration.
  105506. * @returns - An object with the serialized config.
  105507. */
  105508. serialize(): any;
  105509. /**
  105510. * Parses a anisotropy Configuration from a serialized object.
  105511. * @param source - Serialized object.
  105512. * @param scene Defines the scene we are parsing for
  105513. * @param rootUrl Defines the rootUrl to load from
  105514. */
  105515. parse(source: any, scene: Scene, rootUrl: string): void;
  105516. }
  105517. }
  105518. declare module BABYLON {
  105519. /**
  105520. * @hidden
  105521. */
  105522. export interface IMaterialBRDFDefines {
  105523. BRDF_V_HEIGHT_CORRELATED: boolean;
  105524. MS_BRDF_ENERGY_CONSERVATION: boolean;
  105525. SPHERICAL_HARMONICS: boolean;
  105526. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  105527. /** @hidden */
  105528. _areMiscDirty: boolean;
  105529. }
  105530. /**
  105531. * Define the code related to the BRDF parameters of the pbr material.
  105532. */
  105533. export class PBRBRDFConfiguration {
  105534. /**
  105535. * Default value used for the energy conservation.
  105536. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105537. */
  105538. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  105539. /**
  105540. * Default value used for the Smith Visibility Height Correlated mode.
  105541. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  105542. */
  105543. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  105544. /**
  105545. * Default value used for the IBL diffuse part.
  105546. * This can help switching back to the polynomials mode globally which is a tiny bit
  105547. * less GPU intensive at the drawback of a lower quality.
  105548. */
  105549. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  105550. /**
  105551. * Default value used for activating energy conservation for the specular workflow.
  105552. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105553. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105554. */
  105555. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  105556. private _useEnergyConservation;
  105557. /**
  105558. * Defines if the material uses energy conservation.
  105559. */
  105560. useEnergyConservation: boolean;
  105561. private _useSmithVisibilityHeightCorrelated;
  105562. /**
  105563. * LEGACY Mode set to false
  105564. * Defines if the material uses height smith correlated visibility term.
  105565. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  105566. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105567. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  105568. * Not relying on height correlated will also disable energy conservation.
  105569. */
  105570. useSmithVisibilityHeightCorrelated: boolean;
  105571. private _useSphericalHarmonics;
  105572. /**
  105573. * LEGACY Mode set to false
  105574. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  105575. * diffuse part of the IBL.
  105576. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  105577. * to the ground truth.
  105578. */
  105579. useSphericalHarmonics: boolean;
  105580. private _useSpecularGlossinessInputEnergyConservation;
  105581. /**
  105582. * Defines if the material uses energy conservation, when the specular workflow is active.
  105583. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  105584. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  105585. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  105586. */
  105587. useSpecularGlossinessInputEnergyConservation: boolean;
  105588. /** @hidden */
  105589. private _internalMarkAllSubMeshesAsMiscDirty;
  105590. /** @hidden */
  105591. _markAllSubMeshesAsMiscDirty(): void;
  105592. /**
  105593. * Instantiate a new istance of clear coat configuration.
  105594. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  105595. */
  105596. constructor(markAllSubMeshesAsMiscDirty: () => void);
  105597. /**
  105598. * Checks to see if a texture is used in the material.
  105599. * @param defines the list of "defines" to update.
  105600. */
  105601. prepareDefines(defines: IMaterialBRDFDefines): void;
  105602. /**
  105603. * Get the current class name of the texture useful for serialization or dynamic coding.
  105604. * @returns "PBRClearCoatConfiguration"
  105605. */
  105606. getClassName(): string;
  105607. /**
  105608. * Makes a duplicate of the current configuration into another one.
  105609. * @param brdfConfiguration define the config where to copy the info
  105610. */
  105611. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  105612. /**
  105613. * Serializes this BRDF configuration.
  105614. * @returns - An object with the serialized config.
  105615. */
  105616. serialize(): any;
  105617. /**
  105618. * Parses a anisotropy Configuration from a serialized object.
  105619. * @param source - Serialized object.
  105620. * @param scene Defines the scene we are parsing for
  105621. * @param rootUrl Defines the rootUrl to load from
  105622. */
  105623. parse(source: any, scene: Scene, rootUrl: string): void;
  105624. }
  105625. }
  105626. declare module BABYLON {
  105627. /**
  105628. * @hidden
  105629. */
  105630. export interface IMaterialSheenDefines {
  105631. SHEEN: boolean;
  105632. SHEEN_TEXTURE: boolean;
  105633. SHEEN_TEXTURE_ROUGHNESS: boolean;
  105634. SHEEN_TEXTUREDIRECTUV: number;
  105635. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  105636. SHEEN_LINKWITHALBEDO: boolean;
  105637. SHEEN_ROUGHNESS: boolean;
  105638. SHEEN_ALBEDOSCALING: boolean;
  105639. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105640. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105641. /** @hidden */
  105642. _areTexturesDirty: boolean;
  105643. }
  105644. /**
  105645. * Define the code related to the Sheen parameters of the pbr material.
  105646. */
  105647. export class PBRSheenConfiguration {
  105648. private _isEnabled;
  105649. /**
  105650. * Defines if the material uses sheen.
  105651. */
  105652. isEnabled: boolean;
  105653. private _linkSheenWithAlbedo;
  105654. /**
  105655. * Defines if the sheen is linked to the sheen color.
  105656. */
  105657. linkSheenWithAlbedo: boolean;
  105658. /**
  105659. * Defines the sheen intensity.
  105660. */
  105661. intensity: number;
  105662. /**
  105663. * Defines the sheen color.
  105664. */
  105665. color: Color3;
  105666. private _texture;
  105667. /**
  105668. * Stores the sheen tint values in a texture.
  105669. * rgb is tint
  105670. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  105671. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  105672. */
  105673. texture: Nullable<BaseTexture>;
  105674. private _useRoughnessFromMainTexture;
  105675. /**
  105676. * Indicates that the alpha channel of the texture property will be used for roughness.
  105677. * Has no effect if the roughness (and texture!) property is not defined
  105678. */
  105679. useRoughnessFromMainTexture: boolean;
  105680. private _roughness;
  105681. /**
  105682. * Defines the sheen roughness.
  105683. * It is not taken into account if linkSheenWithAlbedo is true.
  105684. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105685. */
  105686. roughness: Nullable<number>;
  105687. private _textureRoughness;
  105688. /**
  105689. * Stores the sheen roughness in a texture.
  105690. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  105691. */
  105692. textureRoughness: Nullable<BaseTexture>;
  105693. private _albedoScaling;
  105694. /**
  105695. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105696. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105697. * making it easier to setup and tweak the effect
  105698. */
  105699. albedoScaling: boolean;
  105700. /** @hidden */
  105701. private _internalMarkAllSubMeshesAsTexturesDirty;
  105702. /** @hidden */
  105703. _markAllSubMeshesAsTexturesDirty(): void;
  105704. /**
  105705. * Instantiate a new istance of clear coat configuration.
  105706. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105707. */
  105708. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105709. /**
  105710. * Specifies that the submesh is ready to be used.
  105711. * @param defines the list of "defines" to update.
  105712. * @param scene defines the scene the material belongs to.
  105713. * @returns - boolean indicating that the submesh is ready or not.
  105714. */
  105715. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105716. /**
  105717. * Checks to see if a texture is used in the material.
  105718. * @param defines the list of "defines" to update.
  105719. * @param scene defines the scene the material belongs to.
  105720. */
  105721. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105722. /**
  105723. * Binds the material data.
  105724. * @param uniformBuffer defines the Uniform buffer to fill in.
  105725. * @param scene defines the scene the material belongs to.
  105726. * @param isFrozen defines wether the material is frozen or not.
  105727. * @param subMesh the submesh to bind data for
  105728. */
  105729. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  105730. /**
  105731. * Checks to see if a texture is used in the material.
  105732. * @param texture - Base texture to use.
  105733. * @returns - Boolean specifying if a texture is used in the material.
  105734. */
  105735. hasTexture(texture: BaseTexture): boolean;
  105736. /**
  105737. * Returns an array of the actively used textures.
  105738. * @param activeTextures Array of BaseTextures
  105739. */
  105740. getActiveTextures(activeTextures: BaseTexture[]): void;
  105741. /**
  105742. * Returns the animatable textures.
  105743. * @param animatables Array of animatable textures.
  105744. */
  105745. getAnimatables(animatables: IAnimatable[]): void;
  105746. /**
  105747. * Disposes the resources of the material.
  105748. * @param forceDisposeTextures - Forces the disposal of all textures.
  105749. */
  105750. dispose(forceDisposeTextures?: boolean): void;
  105751. /**
  105752. * Get the current class name of the texture useful for serialization or dynamic coding.
  105753. * @returns "PBRSheenConfiguration"
  105754. */
  105755. getClassName(): string;
  105756. /**
  105757. * Add fallbacks to the effect fallbacks list.
  105758. * @param defines defines the Base texture to use.
  105759. * @param fallbacks defines the current fallback list.
  105760. * @param currentRank defines the current fallback rank.
  105761. * @returns the new fallback rank.
  105762. */
  105763. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105764. /**
  105765. * Add the required uniforms to the current list.
  105766. * @param uniforms defines the current uniform list.
  105767. */
  105768. static AddUniforms(uniforms: string[]): void;
  105769. /**
  105770. * Add the required uniforms to the current buffer.
  105771. * @param uniformBuffer defines the current uniform buffer.
  105772. */
  105773. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105774. /**
  105775. * Add the required samplers to the current list.
  105776. * @param samplers defines the current sampler list.
  105777. */
  105778. static AddSamplers(samplers: string[]): void;
  105779. /**
  105780. * Makes a duplicate of the current configuration into another one.
  105781. * @param sheenConfiguration define the config where to copy the info
  105782. */
  105783. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105784. /**
  105785. * Serializes this BRDF configuration.
  105786. * @returns - An object with the serialized config.
  105787. */
  105788. serialize(): any;
  105789. /**
  105790. * Parses a anisotropy Configuration from a serialized object.
  105791. * @param source - Serialized object.
  105792. * @param scene Defines the scene we are parsing for
  105793. * @param rootUrl Defines the rootUrl to load from
  105794. */
  105795. parse(source: any, scene: Scene, rootUrl: string): void;
  105796. }
  105797. }
  105798. declare module BABYLON {
  105799. /**
  105800. * @hidden
  105801. */
  105802. export interface IMaterialSubSurfaceDefines {
  105803. SUBSURFACE: boolean;
  105804. SS_REFRACTION: boolean;
  105805. SS_TRANSLUCENCY: boolean;
  105806. SS_SCATTERING: boolean;
  105807. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105808. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105809. SS_REFRACTIONMAP_3D: boolean;
  105810. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105811. SS_LODINREFRACTIONALPHA: boolean;
  105812. SS_GAMMAREFRACTION: boolean;
  105813. SS_RGBDREFRACTION: boolean;
  105814. SS_LINEARSPECULARREFRACTION: boolean;
  105815. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105816. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105817. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105818. /** @hidden */
  105819. _areTexturesDirty: boolean;
  105820. }
  105821. /**
  105822. * Define the code related to the sub surface parameters of the pbr material.
  105823. */
  105824. export class PBRSubSurfaceConfiguration {
  105825. private _isRefractionEnabled;
  105826. /**
  105827. * Defines if the refraction is enabled in the material.
  105828. */
  105829. isRefractionEnabled: boolean;
  105830. private _isTranslucencyEnabled;
  105831. /**
  105832. * Defines if the translucency is enabled in the material.
  105833. */
  105834. isTranslucencyEnabled: boolean;
  105835. private _isScatteringEnabled;
  105836. /**
  105837. * Defines if the sub surface scattering is enabled in the material.
  105838. */
  105839. isScatteringEnabled: boolean;
  105840. private _scatteringDiffusionProfileIndex;
  105841. /**
  105842. * Diffusion profile for subsurface scattering.
  105843. * Useful for better scattering in the skins or foliages.
  105844. */
  105845. get scatteringDiffusionProfile(): Nullable<Color3>;
  105846. set scatteringDiffusionProfile(c: Nullable<Color3>);
  105847. /**
  105848. * Defines the refraction intensity of the material.
  105849. * The refraction when enabled replaces the Diffuse part of the material.
  105850. * The intensity helps transitionning between diffuse and refraction.
  105851. */
  105852. refractionIntensity: number;
  105853. /**
  105854. * Defines the translucency intensity of the material.
  105855. * When translucency has been enabled, this defines how much of the "translucency"
  105856. * is addded to the diffuse part of the material.
  105857. */
  105858. translucencyIntensity: number;
  105859. /**
  105860. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  105861. */
  105862. useAlbedoToTintRefraction: boolean;
  105863. private _thicknessTexture;
  105864. /**
  105865. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  105866. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  105867. * 0 would mean minimumThickness
  105868. * 1 would mean maximumThickness
  105869. * The other channels might be use as a mask to vary the different effects intensity.
  105870. */
  105871. thicknessTexture: Nullable<BaseTexture>;
  105872. private _refractionTexture;
  105873. /**
  105874. * Defines the texture to use for refraction.
  105875. */
  105876. refractionTexture: Nullable<BaseTexture>;
  105877. private _indexOfRefraction;
  105878. /**
  105879. * Index of refraction of the material base layer.
  105880. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105881. *
  105882. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  105883. *
  105884. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  105885. */
  105886. indexOfRefraction: number;
  105887. private _volumeIndexOfRefraction;
  105888. /**
  105889. * Index of refraction of the material's volume.
  105890. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105891. *
  105892. * This ONLY impacts refraction. If not provided or given a non-valid value,
  105893. * the volume will use the same IOR as the surface.
  105894. */
  105895. get volumeIndexOfRefraction(): number;
  105896. set volumeIndexOfRefraction(value: number);
  105897. private _invertRefractionY;
  105898. /**
  105899. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105900. */
  105901. invertRefractionY: boolean;
  105902. private _linkRefractionWithTransparency;
  105903. /**
  105904. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105905. * Materials half opaque for instance using refraction could benefit from this control.
  105906. */
  105907. linkRefractionWithTransparency: boolean;
  105908. /**
  105909. * Defines the minimum thickness stored in the thickness map.
  105910. * If no thickness map is defined, this value will be used to simulate thickness.
  105911. */
  105912. minimumThickness: number;
  105913. /**
  105914. * Defines the maximum thickness stored in the thickness map.
  105915. */
  105916. maximumThickness: number;
  105917. /**
  105918. * Defines the volume tint of the material.
  105919. * This is used for both translucency and scattering.
  105920. */
  105921. tintColor: Color3;
  105922. /**
  105923. * Defines the distance at which the tint color should be found in the media.
  105924. * This is used for refraction only.
  105925. */
  105926. tintColorAtDistance: number;
  105927. /**
  105928. * Defines how far each channel transmit through the media.
  105929. * It is defined as a color to simplify it selection.
  105930. */
  105931. diffusionDistance: Color3;
  105932. private _useMaskFromThicknessTexture;
  105933. /**
  105934. * Stores the intensity of the different subsurface effects in the thickness texture.
  105935. * * the green channel is the translucency intensity.
  105936. * * the blue channel is the scattering intensity.
  105937. * * the alpha channel is the refraction intensity.
  105938. */
  105939. useMaskFromThicknessTexture: boolean;
  105940. private _scene;
  105941. /** @hidden */
  105942. private _internalMarkAllSubMeshesAsTexturesDirty;
  105943. private _internalMarkScenePrePassDirty;
  105944. /** @hidden */
  105945. _markAllSubMeshesAsTexturesDirty(): void;
  105946. /** @hidden */
  105947. _markScenePrePassDirty(): void;
  105948. /**
  105949. * Instantiate a new istance of sub surface configuration.
  105950. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105951. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  105952. * @param scene The scene
  105953. */
  105954. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  105955. /**
  105956. * Gets wehter the submesh is ready to be used or not.
  105957. * @param defines the list of "defines" to update.
  105958. * @param scene defines the scene the material belongs to.
  105959. * @returns - boolean indicating that the submesh is ready or not.
  105960. */
  105961. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  105962. /**
  105963. * Checks to see if a texture is used in the material.
  105964. * @param defines the list of "defines" to update.
  105965. * @param scene defines the scene to the material belongs to.
  105966. */
  105967. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  105968. /**
  105969. * Binds the material data.
  105970. * @param uniformBuffer defines the Uniform buffer to fill in.
  105971. * @param scene defines the scene the material belongs to.
  105972. * @param engine defines the engine the material belongs to.
  105973. * @param isFrozen defines whether the material is frozen or not.
  105974. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  105975. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  105976. */
  105977. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  105978. /**
  105979. * Unbinds the material from the mesh.
  105980. * @param activeEffect defines the effect that should be unbound from.
  105981. * @returns true if unbound, otherwise false
  105982. */
  105983. unbind(activeEffect: Effect): boolean;
  105984. /**
  105985. * Returns the texture used for refraction or null if none is used.
  105986. * @param scene defines the scene the material belongs to.
  105987. * @returns - Refraction texture if present. If no refraction texture and refraction
  105988. * is linked with transparency, returns environment texture. Otherwise, returns null.
  105989. */
  105990. private _getRefractionTexture;
  105991. /**
  105992. * Returns true if alpha blending should be disabled.
  105993. */
  105994. get disableAlphaBlending(): boolean;
  105995. /**
  105996. * Fills the list of render target textures.
  105997. * @param renderTargets the list of render targets to update
  105998. */
  105999. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  106000. /**
  106001. * Checks to see if a texture is used in the material.
  106002. * @param texture - Base texture to use.
  106003. * @returns - Boolean specifying if a texture is used in the material.
  106004. */
  106005. hasTexture(texture: BaseTexture): boolean;
  106006. /**
  106007. * Gets a boolean indicating that current material needs to register RTT
  106008. * @returns true if this uses a render target otherwise false.
  106009. */
  106010. hasRenderTargetTextures(): boolean;
  106011. /**
  106012. * Returns an array of the actively used textures.
  106013. * @param activeTextures Array of BaseTextures
  106014. */
  106015. getActiveTextures(activeTextures: BaseTexture[]): void;
  106016. /**
  106017. * Returns the animatable textures.
  106018. * @param animatables Array of animatable textures.
  106019. */
  106020. getAnimatables(animatables: IAnimatable[]): void;
  106021. /**
  106022. * Disposes the resources of the material.
  106023. * @param forceDisposeTextures - Forces the disposal of all textures.
  106024. */
  106025. dispose(forceDisposeTextures?: boolean): void;
  106026. /**
  106027. * Get the current class name of the texture useful for serialization or dynamic coding.
  106028. * @returns "PBRSubSurfaceConfiguration"
  106029. */
  106030. getClassName(): string;
  106031. /**
  106032. * Add fallbacks to the effect fallbacks list.
  106033. * @param defines defines the Base texture to use.
  106034. * @param fallbacks defines the current fallback list.
  106035. * @param currentRank defines the current fallback rank.
  106036. * @returns the new fallback rank.
  106037. */
  106038. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106039. /**
  106040. * Add the required uniforms to the current list.
  106041. * @param uniforms defines the current uniform list.
  106042. */
  106043. static AddUniforms(uniforms: string[]): void;
  106044. /**
  106045. * Add the required samplers to the current list.
  106046. * @param samplers defines the current sampler list.
  106047. */
  106048. static AddSamplers(samplers: string[]): void;
  106049. /**
  106050. * Add the required uniforms to the current buffer.
  106051. * @param uniformBuffer defines the current uniform buffer.
  106052. */
  106053. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106054. /**
  106055. * Makes a duplicate of the current configuration into another one.
  106056. * @param configuration define the config where to copy the info
  106057. */
  106058. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106059. /**
  106060. * Serializes this Sub Surface configuration.
  106061. * @returns - An object with the serialized config.
  106062. */
  106063. serialize(): any;
  106064. /**
  106065. * Parses a anisotropy Configuration from a serialized object.
  106066. * @param source - Serialized object.
  106067. * @param scene Defines the scene we are parsing for
  106068. * @param rootUrl Defines the rootUrl to load from
  106069. */
  106070. parse(source: any, scene: Scene, rootUrl: string): void;
  106071. }
  106072. }
  106073. declare module BABYLON {
  106074. /**
  106075. * Class representing spherical harmonics coefficients to the 3rd degree
  106076. */
  106077. export class SphericalHarmonics {
  106078. /**
  106079. * Defines whether or not the harmonics have been prescaled for rendering.
  106080. */
  106081. preScaled: boolean;
  106082. /**
  106083. * The l0,0 coefficients of the spherical harmonics
  106084. */
  106085. l00: Vector3;
  106086. /**
  106087. * The l1,-1 coefficients of the spherical harmonics
  106088. */
  106089. l1_1: Vector3;
  106090. /**
  106091. * The l1,0 coefficients of the spherical harmonics
  106092. */
  106093. l10: Vector3;
  106094. /**
  106095. * The l1,1 coefficients of the spherical harmonics
  106096. */
  106097. l11: Vector3;
  106098. /**
  106099. * The l2,-2 coefficients of the spherical harmonics
  106100. */
  106101. l2_2: Vector3;
  106102. /**
  106103. * The l2,-1 coefficients of the spherical harmonics
  106104. */
  106105. l2_1: Vector3;
  106106. /**
  106107. * The l2,0 coefficients of the spherical harmonics
  106108. */
  106109. l20: Vector3;
  106110. /**
  106111. * The l2,1 coefficients of the spherical harmonics
  106112. */
  106113. l21: Vector3;
  106114. /**
  106115. * The l2,2 coefficients of the spherical harmonics
  106116. */
  106117. l22: Vector3;
  106118. /**
  106119. * Adds a light to the spherical harmonics
  106120. * @param direction the direction of the light
  106121. * @param color the color of the light
  106122. * @param deltaSolidAngle the delta solid angle of the light
  106123. */
  106124. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106125. /**
  106126. * Scales the spherical harmonics by the given amount
  106127. * @param scale the amount to scale
  106128. */
  106129. scaleInPlace(scale: number): void;
  106130. /**
  106131. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106132. *
  106133. * ```
  106134. * E_lm = A_l * L_lm
  106135. * ```
  106136. *
  106137. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106138. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106139. * the scaling factors are given in equation 9.
  106140. */
  106141. convertIncidentRadianceToIrradiance(): void;
  106142. /**
  106143. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106144. *
  106145. * ```
  106146. * L = (1/pi) * E * rho
  106147. * ```
  106148. *
  106149. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106150. */
  106151. convertIrradianceToLambertianRadiance(): void;
  106152. /**
  106153. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106154. * required operations at run time.
  106155. *
  106156. * This is simply done by scaling back the SH with Ylm constants parameter.
  106157. * The trigonometric part being applied by the shader at run time.
  106158. */
  106159. preScaleForRendering(): void;
  106160. /**
  106161. * Constructs a spherical harmonics from an array.
  106162. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106163. * @returns the spherical harmonics
  106164. */
  106165. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106166. /**
  106167. * Gets the spherical harmonics from polynomial
  106168. * @param polynomial the spherical polynomial
  106169. * @returns the spherical harmonics
  106170. */
  106171. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106172. }
  106173. /**
  106174. * Class representing spherical polynomial coefficients to the 3rd degree
  106175. */
  106176. export class SphericalPolynomial {
  106177. private _harmonics;
  106178. /**
  106179. * The spherical harmonics used to create the polynomials.
  106180. */
  106181. get preScaledHarmonics(): SphericalHarmonics;
  106182. /**
  106183. * The x coefficients of the spherical polynomial
  106184. */
  106185. x: Vector3;
  106186. /**
  106187. * The y coefficients of the spherical polynomial
  106188. */
  106189. y: Vector3;
  106190. /**
  106191. * The z coefficients of the spherical polynomial
  106192. */
  106193. z: Vector3;
  106194. /**
  106195. * The xx coefficients of the spherical polynomial
  106196. */
  106197. xx: Vector3;
  106198. /**
  106199. * The yy coefficients of the spherical polynomial
  106200. */
  106201. yy: Vector3;
  106202. /**
  106203. * The zz coefficients of the spherical polynomial
  106204. */
  106205. zz: Vector3;
  106206. /**
  106207. * The xy coefficients of the spherical polynomial
  106208. */
  106209. xy: Vector3;
  106210. /**
  106211. * The yz coefficients of the spherical polynomial
  106212. */
  106213. yz: Vector3;
  106214. /**
  106215. * The zx coefficients of the spherical polynomial
  106216. */
  106217. zx: Vector3;
  106218. /**
  106219. * Adds an ambient color to the spherical polynomial
  106220. * @param color the color to add
  106221. */
  106222. addAmbient(color: Color3): void;
  106223. /**
  106224. * Scales the spherical polynomial by the given amount
  106225. * @param scale the amount to scale
  106226. */
  106227. scaleInPlace(scale: number): void;
  106228. /**
  106229. * Gets the spherical polynomial from harmonics
  106230. * @param harmonics the spherical harmonics
  106231. * @returns the spherical polynomial
  106232. */
  106233. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106234. /**
  106235. * Constructs a spherical polynomial from an array.
  106236. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106237. * @returns the spherical polynomial
  106238. */
  106239. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106240. }
  106241. }
  106242. declare module BABYLON {
  106243. /**
  106244. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106245. */
  106246. export interface CubeMapInfo {
  106247. /**
  106248. * The pixel array for the front face.
  106249. * This is stored in format, left to right, up to down format.
  106250. */
  106251. front: Nullable<ArrayBufferView>;
  106252. /**
  106253. * The pixel array for the back face.
  106254. * This is stored in format, left to right, up to down format.
  106255. */
  106256. back: Nullable<ArrayBufferView>;
  106257. /**
  106258. * The pixel array for the left face.
  106259. * This is stored in format, left to right, up to down format.
  106260. */
  106261. left: Nullable<ArrayBufferView>;
  106262. /**
  106263. * The pixel array for the right face.
  106264. * This is stored in format, left to right, up to down format.
  106265. */
  106266. right: Nullable<ArrayBufferView>;
  106267. /**
  106268. * The pixel array for the up face.
  106269. * This is stored in format, left to right, up to down format.
  106270. */
  106271. up: Nullable<ArrayBufferView>;
  106272. /**
  106273. * The pixel array for the down face.
  106274. * This is stored in format, left to right, up to down format.
  106275. */
  106276. down: Nullable<ArrayBufferView>;
  106277. /**
  106278. * The size of the cubemap stored.
  106279. *
  106280. * Each faces will be size * size pixels.
  106281. */
  106282. size: number;
  106283. /**
  106284. * The format of the texture.
  106285. *
  106286. * RGBA, RGB.
  106287. */
  106288. format: number;
  106289. /**
  106290. * The type of the texture data.
  106291. *
  106292. * UNSIGNED_INT, FLOAT.
  106293. */
  106294. type: number;
  106295. /**
  106296. * Specifies whether the texture is in gamma space.
  106297. */
  106298. gammaSpace: boolean;
  106299. }
  106300. /**
  106301. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  106302. */
  106303. export class PanoramaToCubeMapTools {
  106304. private static FACE_LEFT;
  106305. private static FACE_RIGHT;
  106306. private static FACE_FRONT;
  106307. private static FACE_BACK;
  106308. private static FACE_DOWN;
  106309. private static FACE_UP;
  106310. /**
  106311. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  106312. *
  106313. * @param float32Array The source data.
  106314. * @param inputWidth The width of the input panorama.
  106315. * @param inputHeight The height of the input panorama.
  106316. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  106317. * @return The cubemap data
  106318. */
  106319. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  106320. private static CreateCubemapTexture;
  106321. private static CalcProjectionSpherical;
  106322. }
  106323. }
  106324. declare module BABYLON {
  106325. /**
  106326. * Helper class dealing with the extraction of spherical polynomial dataArray
  106327. * from a cube map.
  106328. */
  106329. export class CubeMapToSphericalPolynomialTools {
  106330. private static FileFaces;
  106331. /**
  106332. * Converts a texture to the according Spherical Polynomial data.
  106333. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106334. *
  106335. * @param texture The texture to extract the information from.
  106336. * @return The Spherical Polynomial data.
  106337. */
  106338. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  106339. /**
  106340. * Converts a cubemap to the according Spherical Polynomial data.
  106341. * This extracts the first 3 orders only as they are the only one used in the lighting.
  106342. *
  106343. * @param cubeInfo The Cube map to extract the information from.
  106344. * @return The Spherical Polynomial data.
  106345. */
  106346. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  106347. }
  106348. }
  106349. declare module BABYLON {
  106350. interface BaseTexture {
  106351. /**
  106352. * Get the polynomial representation of the texture data.
  106353. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  106354. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  106355. */
  106356. sphericalPolynomial: Nullable<SphericalPolynomial>;
  106357. }
  106358. }
  106359. declare module BABYLON {
  106360. /** @hidden */
  106361. export var pbrFragmentDeclaration: {
  106362. name: string;
  106363. shader: string;
  106364. };
  106365. }
  106366. declare module BABYLON {
  106367. /** @hidden */
  106368. export var pbrUboDeclaration: {
  106369. name: string;
  106370. shader: string;
  106371. };
  106372. }
  106373. declare module BABYLON {
  106374. /** @hidden */
  106375. export var pbrFragmentExtraDeclaration: {
  106376. name: string;
  106377. shader: string;
  106378. };
  106379. }
  106380. declare module BABYLON {
  106381. /** @hidden */
  106382. export var pbrFragmentSamplersDeclaration: {
  106383. name: string;
  106384. shader: string;
  106385. };
  106386. }
  106387. declare module BABYLON {
  106388. /** @hidden */
  106389. export var subSurfaceScatteringFunctions: {
  106390. name: string;
  106391. shader: string;
  106392. };
  106393. }
  106394. declare module BABYLON {
  106395. /** @hidden */
  106396. export var importanceSampling: {
  106397. name: string;
  106398. shader: string;
  106399. };
  106400. }
  106401. declare module BABYLON {
  106402. /** @hidden */
  106403. export var pbrHelperFunctions: {
  106404. name: string;
  106405. shader: string;
  106406. };
  106407. }
  106408. declare module BABYLON {
  106409. /** @hidden */
  106410. export var harmonicsFunctions: {
  106411. name: string;
  106412. shader: string;
  106413. };
  106414. }
  106415. declare module BABYLON {
  106416. /** @hidden */
  106417. export var pbrDirectLightingSetupFunctions: {
  106418. name: string;
  106419. shader: string;
  106420. };
  106421. }
  106422. declare module BABYLON {
  106423. /** @hidden */
  106424. export var pbrDirectLightingFalloffFunctions: {
  106425. name: string;
  106426. shader: string;
  106427. };
  106428. }
  106429. declare module BABYLON {
  106430. /** @hidden */
  106431. export var pbrBRDFFunctions: {
  106432. name: string;
  106433. shader: string;
  106434. };
  106435. }
  106436. declare module BABYLON {
  106437. /** @hidden */
  106438. export var hdrFilteringFunctions: {
  106439. name: string;
  106440. shader: string;
  106441. };
  106442. }
  106443. declare module BABYLON {
  106444. /** @hidden */
  106445. export var pbrDirectLightingFunctions: {
  106446. name: string;
  106447. shader: string;
  106448. };
  106449. }
  106450. declare module BABYLON {
  106451. /** @hidden */
  106452. export var pbrIBLFunctions: {
  106453. name: string;
  106454. shader: string;
  106455. };
  106456. }
  106457. declare module BABYLON {
  106458. /** @hidden */
  106459. export var pbrBlockAlbedoOpacity: {
  106460. name: string;
  106461. shader: string;
  106462. };
  106463. }
  106464. declare module BABYLON {
  106465. /** @hidden */
  106466. export var pbrBlockReflectivity: {
  106467. name: string;
  106468. shader: string;
  106469. };
  106470. }
  106471. declare module BABYLON {
  106472. /** @hidden */
  106473. export var pbrBlockAmbientOcclusion: {
  106474. name: string;
  106475. shader: string;
  106476. };
  106477. }
  106478. declare module BABYLON {
  106479. /** @hidden */
  106480. export var pbrBlockAlphaFresnel: {
  106481. name: string;
  106482. shader: string;
  106483. };
  106484. }
  106485. declare module BABYLON {
  106486. /** @hidden */
  106487. export var pbrBlockAnisotropic: {
  106488. name: string;
  106489. shader: string;
  106490. };
  106491. }
  106492. declare module BABYLON {
  106493. /** @hidden */
  106494. export var pbrBlockReflection: {
  106495. name: string;
  106496. shader: string;
  106497. };
  106498. }
  106499. declare module BABYLON {
  106500. /** @hidden */
  106501. export var pbrBlockSheen: {
  106502. name: string;
  106503. shader: string;
  106504. };
  106505. }
  106506. declare module BABYLON {
  106507. /** @hidden */
  106508. export var pbrBlockClearcoat: {
  106509. name: string;
  106510. shader: string;
  106511. };
  106512. }
  106513. declare module BABYLON {
  106514. /** @hidden */
  106515. export var pbrBlockSubSurface: {
  106516. name: string;
  106517. shader: string;
  106518. };
  106519. }
  106520. declare module BABYLON {
  106521. /** @hidden */
  106522. export var pbrBlockNormalGeometric: {
  106523. name: string;
  106524. shader: string;
  106525. };
  106526. }
  106527. declare module BABYLON {
  106528. /** @hidden */
  106529. export var pbrBlockNormalFinal: {
  106530. name: string;
  106531. shader: string;
  106532. };
  106533. }
  106534. declare module BABYLON {
  106535. /** @hidden */
  106536. export var pbrBlockLightmapInit: {
  106537. name: string;
  106538. shader: string;
  106539. };
  106540. }
  106541. declare module BABYLON {
  106542. /** @hidden */
  106543. export var pbrBlockGeometryInfo: {
  106544. name: string;
  106545. shader: string;
  106546. };
  106547. }
  106548. declare module BABYLON {
  106549. /** @hidden */
  106550. export var pbrBlockReflectance0: {
  106551. name: string;
  106552. shader: string;
  106553. };
  106554. }
  106555. declare module BABYLON {
  106556. /** @hidden */
  106557. export var pbrBlockReflectance: {
  106558. name: string;
  106559. shader: string;
  106560. };
  106561. }
  106562. declare module BABYLON {
  106563. /** @hidden */
  106564. export var pbrBlockDirectLighting: {
  106565. name: string;
  106566. shader: string;
  106567. };
  106568. }
  106569. declare module BABYLON {
  106570. /** @hidden */
  106571. export var pbrBlockFinalLitComponents: {
  106572. name: string;
  106573. shader: string;
  106574. };
  106575. }
  106576. declare module BABYLON {
  106577. /** @hidden */
  106578. export var pbrBlockFinalUnlitComponents: {
  106579. name: string;
  106580. shader: string;
  106581. };
  106582. }
  106583. declare module BABYLON {
  106584. /** @hidden */
  106585. export var pbrBlockFinalColorComposition: {
  106586. name: string;
  106587. shader: string;
  106588. };
  106589. }
  106590. declare module BABYLON {
  106591. /** @hidden */
  106592. export var pbrBlockImageProcessing: {
  106593. name: string;
  106594. shader: string;
  106595. };
  106596. }
  106597. declare module BABYLON {
  106598. /** @hidden */
  106599. export var pbrDebug: {
  106600. name: string;
  106601. shader: string;
  106602. };
  106603. }
  106604. declare module BABYLON {
  106605. /** @hidden */
  106606. export var pbrPixelShader: {
  106607. name: string;
  106608. shader: string;
  106609. };
  106610. }
  106611. declare module BABYLON {
  106612. /** @hidden */
  106613. export var pbrVertexDeclaration: {
  106614. name: string;
  106615. shader: string;
  106616. };
  106617. }
  106618. declare module BABYLON {
  106619. /** @hidden */
  106620. export var pbrVertexShader: {
  106621. name: string;
  106622. shader: string;
  106623. };
  106624. }
  106625. declare module BABYLON {
  106626. /**
  106627. * Manages the defines for the PBR Material.
  106628. * @hidden
  106629. */
  106630. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  106631. PBR: boolean;
  106632. NUM_SAMPLES: string;
  106633. REALTIME_FILTERING: boolean;
  106634. MAINUV1: boolean;
  106635. MAINUV2: boolean;
  106636. UV1: boolean;
  106637. UV2: boolean;
  106638. ALBEDO: boolean;
  106639. GAMMAALBEDO: boolean;
  106640. ALBEDODIRECTUV: number;
  106641. VERTEXCOLOR: boolean;
  106642. DETAIL: boolean;
  106643. DETAILDIRECTUV: number;
  106644. DETAIL_NORMALBLENDMETHOD: number;
  106645. AMBIENT: boolean;
  106646. AMBIENTDIRECTUV: number;
  106647. AMBIENTINGRAYSCALE: boolean;
  106648. OPACITY: boolean;
  106649. VERTEXALPHA: boolean;
  106650. OPACITYDIRECTUV: number;
  106651. OPACITYRGB: boolean;
  106652. ALPHATEST: boolean;
  106653. DEPTHPREPASS: boolean;
  106654. ALPHABLEND: boolean;
  106655. ALPHAFROMALBEDO: boolean;
  106656. ALPHATESTVALUE: string;
  106657. SPECULAROVERALPHA: boolean;
  106658. RADIANCEOVERALPHA: boolean;
  106659. ALPHAFRESNEL: boolean;
  106660. LINEARALPHAFRESNEL: boolean;
  106661. PREMULTIPLYALPHA: boolean;
  106662. EMISSIVE: boolean;
  106663. EMISSIVEDIRECTUV: number;
  106664. REFLECTIVITY: boolean;
  106665. REFLECTIVITYDIRECTUV: number;
  106666. SPECULARTERM: boolean;
  106667. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  106668. MICROSURFACEAUTOMATIC: boolean;
  106669. LODBASEDMICROSFURACE: boolean;
  106670. MICROSURFACEMAP: boolean;
  106671. MICROSURFACEMAPDIRECTUV: number;
  106672. METALLICWORKFLOW: boolean;
  106673. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106674. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106675. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106676. AOSTOREINMETALMAPRED: boolean;
  106677. METALLIC_REFLECTANCE: boolean;
  106678. METALLIC_REFLECTANCEDIRECTUV: number;
  106679. ENVIRONMENTBRDF: boolean;
  106680. ENVIRONMENTBRDF_RGBD: boolean;
  106681. NORMAL: boolean;
  106682. TANGENT: boolean;
  106683. BUMP: boolean;
  106684. BUMPDIRECTUV: number;
  106685. OBJECTSPACE_NORMALMAP: boolean;
  106686. PARALLAX: boolean;
  106687. PARALLAXOCCLUSION: boolean;
  106688. NORMALXYSCALE: boolean;
  106689. LIGHTMAP: boolean;
  106690. LIGHTMAPDIRECTUV: number;
  106691. USELIGHTMAPASSHADOWMAP: boolean;
  106692. GAMMALIGHTMAP: boolean;
  106693. RGBDLIGHTMAP: boolean;
  106694. REFLECTION: boolean;
  106695. REFLECTIONMAP_3D: boolean;
  106696. REFLECTIONMAP_SPHERICAL: boolean;
  106697. REFLECTIONMAP_PLANAR: boolean;
  106698. REFLECTIONMAP_CUBIC: boolean;
  106699. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106700. REFLECTIONMAP_PROJECTION: boolean;
  106701. REFLECTIONMAP_SKYBOX: boolean;
  106702. REFLECTIONMAP_EXPLICIT: boolean;
  106703. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106704. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106705. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106706. INVERTCUBICMAP: boolean;
  106707. USESPHERICALFROMREFLECTIONMAP: boolean;
  106708. USEIRRADIANCEMAP: boolean;
  106709. SPHERICAL_HARMONICS: boolean;
  106710. USESPHERICALINVERTEX: boolean;
  106711. REFLECTIONMAP_OPPOSITEZ: boolean;
  106712. LODINREFLECTIONALPHA: boolean;
  106713. GAMMAREFLECTION: boolean;
  106714. RGBDREFLECTION: boolean;
  106715. LINEARSPECULARREFLECTION: boolean;
  106716. RADIANCEOCCLUSION: boolean;
  106717. HORIZONOCCLUSION: boolean;
  106718. INSTANCES: boolean;
  106719. THIN_INSTANCES: boolean;
  106720. PREPASS: boolean;
  106721. PREPASS_IRRADIANCE: boolean;
  106722. PREPASS_IRRADIANCE_INDEX: number;
  106723. PREPASS_ALBEDO: boolean;
  106724. PREPASS_ALBEDO_INDEX: number;
  106725. PREPASS_DEPTHNORMAL: boolean;
  106726. PREPASS_DEPTHNORMAL_INDEX: number;
  106727. PREPASS_POSITION: boolean;
  106728. PREPASS_POSITION_INDEX: number;
  106729. PREPASS_VELOCITY: boolean;
  106730. PREPASS_VELOCITY_INDEX: number;
  106731. PREPASS_REFLECTIVITY: boolean;
  106732. PREPASS_REFLECTIVITY_INDEX: number;
  106733. SCENE_MRT_COUNT: number;
  106734. NUM_BONE_INFLUENCERS: number;
  106735. BonesPerMesh: number;
  106736. BONETEXTURE: boolean;
  106737. BONES_VELOCITY_ENABLED: boolean;
  106738. NONUNIFORMSCALING: boolean;
  106739. MORPHTARGETS: boolean;
  106740. MORPHTARGETS_NORMAL: boolean;
  106741. MORPHTARGETS_TANGENT: boolean;
  106742. MORPHTARGETS_UV: boolean;
  106743. NUM_MORPH_INFLUENCERS: number;
  106744. IMAGEPROCESSING: boolean;
  106745. VIGNETTE: boolean;
  106746. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106747. VIGNETTEBLENDMODEOPAQUE: boolean;
  106748. TONEMAPPING: boolean;
  106749. TONEMAPPING_ACES: boolean;
  106750. CONTRAST: boolean;
  106751. COLORCURVES: boolean;
  106752. COLORGRADING: boolean;
  106753. COLORGRADING3D: boolean;
  106754. SAMPLER3DGREENDEPTH: boolean;
  106755. SAMPLER3DBGRMAP: boolean;
  106756. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106757. EXPOSURE: boolean;
  106758. MULTIVIEW: boolean;
  106759. USEPHYSICALLIGHTFALLOFF: boolean;
  106760. USEGLTFLIGHTFALLOFF: boolean;
  106761. TWOSIDEDLIGHTING: boolean;
  106762. SHADOWFLOAT: boolean;
  106763. CLIPPLANE: boolean;
  106764. CLIPPLANE2: boolean;
  106765. CLIPPLANE3: boolean;
  106766. CLIPPLANE4: boolean;
  106767. CLIPPLANE5: boolean;
  106768. CLIPPLANE6: boolean;
  106769. POINTSIZE: boolean;
  106770. FOG: boolean;
  106771. LOGARITHMICDEPTH: boolean;
  106772. FORCENORMALFORWARD: boolean;
  106773. SPECULARAA: boolean;
  106774. CLEARCOAT: boolean;
  106775. CLEARCOAT_DEFAULTIOR: boolean;
  106776. CLEARCOAT_TEXTURE: boolean;
  106777. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  106778. CLEARCOAT_TEXTUREDIRECTUV: number;
  106779. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  106780. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106781. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106782. CLEARCOAT_BUMP: boolean;
  106783. CLEARCOAT_BUMPDIRECTUV: number;
  106784. CLEARCOAT_REMAP_F0: boolean;
  106785. CLEARCOAT_TINT: boolean;
  106786. CLEARCOAT_TINT_TEXTURE: boolean;
  106787. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106788. ANISOTROPIC: boolean;
  106789. ANISOTROPIC_TEXTURE: boolean;
  106790. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106791. BRDF_V_HEIGHT_CORRELATED: boolean;
  106792. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106793. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106794. SHEEN: boolean;
  106795. SHEEN_TEXTURE: boolean;
  106796. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106797. SHEEN_TEXTUREDIRECTUV: number;
  106798. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106799. SHEEN_LINKWITHALBEDO: boolean;
  106800. SHEEN_ROUGHNESS: boolean;
  106801. SHEEN_ALBEDOSCALING: boolean;
  106802. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106803. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106804. SUBSURFACE: boolean;
  106805. SS_REFRACTION: boolean;
  106806. SS_TRANSLUCENCY: boolean;
  106807. SS_SCATTERING: boolean;
  106808. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106809. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106810. SS_REFRACTIONMAP_3D: boolean;
  106811. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106812. SS_LODINREFRACTIONALPHA: boolean;
  106813. SS_GAMMAREFRACTION: boolean;
  106814. SS_RGBDREFRACTION: boolean;
  106815. SS_LINEARSPECULARREFRACTION: boolean;
  106816. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106817. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106818. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106819. UNLIT: boolean;
  106820. DEBUGMODE: number;
  106821. /**
  106822. * Initializes the PBR Material defines.
  106823. */
  106824. constructor();
  106825. /**
  106826. * Resets the PBR Material defines.
  106827. */
  106828. reset(): void;
  106829. }
  106830. /**
  106831. * The Physically based material base class of BJS.
  106832. *
  106833. * This offers the main features of a standard PBR material.
  106834. * For more information, please refer to the documentation :
  106835. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106836. */
  106837. export abstract class PBRBaseMaterial extends PushMaterial {
  106838. /**
  106839. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106840. */
  106841. static readonly PBRMATERIAL_OPAQUE: number;
  106842. /**
  106843. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106844. */
  106845. static readonly PBRMATERIAL_ALPHATEST: number;
  106846. /**
  106847. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106848. */
  106849. static readonly PBRMATERIAL_ALPHABLEND: number;
  106850. /**
  106851. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106852. * They are also discarded below the alpha cutoff threshold to improve performances.
  106853. */
  106854. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106855. /**
  106856. * Defines the default value of how much AO map is occluding the analytical lights
  106857. * (point spot...).
  106858. */
  106859. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106860. /**
  106861. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  106862. */
  106863. static readonly LIGHTFALLOFF_PHYSICAL: number;
  106864. /**
  106865. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  106866. * to enhance interoperability with other engines.
  106867. */
  106868. static readonly LIGHTFALLOFF_GLTF: number;
  106869. /**
  106870. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  106871. * to enhance interoperability with other materials.
  106872. */
  106873. static readonly LIGHTFALLOFF_STANDARD: number;
  106874. /**
  106875. * Intensity of the direct lights e.g. the four lights available in your scene.
  106876. * This impacts both the direct diffuse and specular highlights.
  106877. */
  106878. protected _directIntensity: number;
  106879. /**
  106880. * Intensity of the emissive part of the material.
  106881. * This helps controlling the emissive effect without modifying the emissive color.
  106882. */
  106883. protected _emissiveIntensity: number;
  106884. /**
  106885. * Intensity of the environment e.g. how much the environment will light the object
  106886. * either through harmonics for rough material or through the refelction for shiny ones.
  106887. */
  106888. protected _environmentIntensity: number;
  106889. /**
  106890. * This is a special control allowing the reduction of the specular highlights coming from the
  106891. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106892. */
  106893. protected _specularIntensity: number;
  106894. /**
  106895. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  106896. */
  106897. private _lightingInfos;
  106898. /**
  106899. * Debug Control allowing disabling the bump map on this material.
  106900. */
  106901. protected _disableBumpMap: boolean;
  106902. /**
  106903. * AKA Diffuse Texture in standard nomenclature.
  106904. */
  106905. protected _albedoTexture: Nullable<BaseTexture>;
  106906. /**
  106907. * AKA Occlusion Texture in other nomenclature.
  106908. */
  106909. protected _ambientTexture: Nullable<BaseTexture>;
  106910. /**
  106911. * AKA Occlusion Texture Intensity in other nomenclature.
  106912. */
  106913. protected _ambientTextureStrength: number;
  106914. /**
  106915. * Defines how much the AO map is occluding the analytical lights (point spot...).
  106916. * 1 means it completely occludes it
  106917. * 0 mean it has no impact
  106918. */
  106919. protected _ambientTextureImpactOnAnalyticalLights: number;
  106920. /**
  106921. * Stores the alpha values in a texture.
  106922. */
  106923. protected _opacityTexture: Nullable<BaseTexture>;
  106924. /**
  106925. * Stores the reflection values in a texture.
  106926. */
  106927. protected _reflectionTexture: Nullable<BaseTexture>;
  106928. /**
  106929. * Stores the emissive values in a texture.
  106930. */
  106931. protected _emissiveTexture: Nullable<BaseTexture>;
  106932. /**
  106933. * AKA Specular texture in other nomenclature.
  106934. */
  106935. protected _reflectivityTexture: Nullable<BaseTexture>;
  106936. /**
  106937. * Used to switch from specular/glossiness to metallic/roughness workflow.
  106938. */
  106939. protected _metallicTexture: Nullable<BaseTexture>;
  106940. /**
  106941. * Specifies the metallic scalar of the metallic/roughness workflow.
  106942. * Can also be used to scale the metalness values of the metallic texture.
  106943. */
  106944. protected _metallic: Nullable<number>;
  106945. /**
  106946. * Specifies the roughness scalar of the metallic/roughness workflow.
  106947. * Can also be used to scale the roughness values of the metallic texture.
  106948. */
  106949. protected _roughness: Nullable<number>;
  106950. /**
  106951. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  106952. * By default the indexOfrefraction is used to compute F0;
  106953. *
  106954. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  106955. *
  106956. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  106957. * F90 = metallicReflectanceColor;
  106958. */
  106959. protected _metallicF0Factor: number;
  106960. /**
  106961. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  106962. * By default the F90 is always 1;
  106963. *
  106964. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  106965. *
  106966. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  106967. * F90 = metallicReflectanceColor;
  106968. */
  106969. protected _metallicReflectanceColor: Color3;
  106970. /**
  106971. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  106972. * This is multiply against the scalar values defined in the material.
  106973. */
  106974. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  106975. /**
  106976. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  106977. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  106978. */
  106979. protected _microSurfaceTexture: Nullable<BaseTexture>;
  106980. /**
  106981. * Stores surface normal data used to displace a mesh in a texture.
  106982. */
  106983. protected _bumpTexture: Nullable<BaseTexture>;
  106984. /**
  106985. * Stores the pre-calculated light information of a mesh in a texture.
  106986. */
  106987. protected _lightmapTexture: Nullable<BaseTexture>;
  106988. /**
  106989. * The color of a material in ambient lighting.
  106990. */
  106991. protected _ambientColor: Color3;
  106992. /**
  106993. * AKA Diffuse Color in other nomenclature.
  106994. */
  106995. protected _albedoColor: Color3;
  106996. /**
  106997. * AKA Specular Color in other nomenclature.
  106998. */
  106999. protected _reflectivityColor: Color3;
  107000. /**
  107001. * The color applied when light is reflected from a material.
  107002. */
  107003. protected _reflectionColor: Color3;
  107004. /**
  107005. * The color applied when light is emitted from a material.
  107006. */
  107007. protected _emissiveColor: Color3;
  107008. /**
  107009. * AKA Glossiness in other nomenclature.
  107010. */
  107011. protected _microSurface: number;
  107012. /**
  107013. * Specifies that the material will use the light map as a show map.
  107014. */
  107015. protected _useLightmapAsShadowmap: boolean;
  107016. /**
  107017. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107018. * makes the reflect vector face the model (under horizon).
  107019. */
  107020. protected _useHorizonOcclusion: boolean;
  107021. /**
  107022. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107023. * too much the area relying on ambient texture to define their ambient occlusion.
  107024. */
  107025. protected _useRadianceOcclusion: boolean;
  107026. /**
  107027. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107028. */
  107029. protected _useAlphaFromAlbedoTexture: boolean;
  107030. /**
  107031. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107032. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107033. */
  107034. protected _useSpecularOverAlpha: boolean;
  107035. /**
  107036. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107037. */
  107038. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107039. /**
  107040. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107041. */
  107042. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107043. /**
  107044. * Specifies if the metallic texture contains the roughness information in its green channel.
  107045. */
  107046. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107047. /**
  107048. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107049. */
  107050. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107051. /**
  107052. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107053. */
  107054. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107055. /**
  107056. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107057. */
  107058. protected _useAmbientInGrayScale: boolean;
  107059. /**
  107060. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107061. * The material will try to infer what glossiness each pixel should be.
  107062. */
  107063. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107064. /**
  107065. * Defines the falloff type used in this material.
  107066. * It by default is Physical.
  107067. */
  107068. protected _lightFalloff: number;
  107069. /**
  107070. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107071. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107072. */
  107073. protected _useRadianceOverAlpha: boolean;
  107074. /**
  107075. * Allows using an object space normal map (instead of tangent space).
  107076. */
  107077. protected _useObjectSpaceNormalMap: boolean;
  107078. /**
  107079. * Allows using the bump map in parallax mode.
  107080. */
  107081. protected _useParallax: boolean;
  107082. /**
  107083. * Allows using the bump map in parallax occlusion mode.
  107084. */
  107085. protected _useParallaxOcclusion: boolean;
  107086. /**
  107087. * Controls the scale bias of the parallax mode.
  107088. */
  107089. protected _parallaxScaleBias: number;
  107090. /**
  107091. * If sets to true, disables all the lights affecting the material.
  107092. */
  107093. protected _disableLighting: boolean;
  107094. /**
  107095. * Number of Simultaneous lights allowed on the material.
  107096. */
  107097. protected _maxSimultaneousLights: number;
  107098. /**
  107099. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107100. */
  107101. protected _invertNormalMapX: boolean;
  107102. /**
  107103. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107104. */
  107105. protected _invertNormalMapY: boolean;
  107106. /**
  107107. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107108. */
  107109. protected _twoSidedLighting: boolean;
  107110. /**
  107111. * Defines the alpha limits in alpha test mode.
  107112. */
  107113. protected _alphaCutOff: number;
  107114. /**
  107115. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107116. */
  107117. protected _forceAlphaTest: boolean;
  107118. /**
  107119. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107120. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107121. */
  107122. protected _useAlphaFresnel: boolean;
  107123. /**
  107124. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107125. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107126. */
  107127. protected _useLinearAlphaFresnel: boolean;
  107128. /**
  107129. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107130. * from cos thetav and roughness:
  107131. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107132. */
  107133. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107134. /**
  107135. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107136. */
  107137. protected _forceIrradianceInFragment: boolean;
  107138. private _realTimeFiltering;
  107139. /**
  107140. * Enables realtime filtering on the texture.
  107141. */
  107142. get realTimeFiltering(): boolean;
  107143. set realTimeFiltering(b: boolean);
  107144. private _realTimeFilteringQuality;
  107145. /**
  107146. * Quality switch for realtime filtering
  107147. */
  107148. get realTimeFilteringQuality(): number;
  107149. set realTimeFilteringQuality(n: number);
  107150. /**
  107151. * Can this material render to several textures at once
  107152. */
  107153. get canRenderToMRT(): boolean;
  107154. /**
  107155. * Force normal to face away from face.
  107156. */
  107157. protected _forceNormalForward: boolean;
  107158. /**
  107159. * Enables specular anti aliasing in the PBR shader.
  107160. * It will both interacts on the Geometry for analytical and IBL lighting.
  107161. * It also prefilter the roughness map based on the bump values.
  107162. */
  107163. protected _enableSpecularAntiAliasing: boolean;
  107164. /**
  107165. * Default configuration related to image processing available in the PBR Material.
  107166. */
  107167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107168. /**
  107169. * Keep track of the image processing observer to allow dispose and replace.
  107170. */
  107171. private _imageProcessingObserver;
  107172. /**
  107173. * Attaches a new image processing configuration to the PBR Material.
  107174. * @param configuration
  107175. */
  107176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107177. /**
  107178. * Stores the available render targets.
  107179. */
  107180. private _renderTargets;
  107181. /**
  107182. * Sets the global ambient color for the material used in lighting calculations.
  107183. */
  107184. private _globalAmbientColor;
  107185. /**
  107186. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107187. */
  107188. private _useLogarithmicDepth;
  107189. /**
  107190. * If set to true, no lighting calculations will be applied.
  107191. */
  107192. private _unlit;
  107193. private _debugMode;
  107194. /**
  107195. * @hidden
  107196. * This is reserved for the inspector.
  107197. * Defines the material debug mode.
  107198. * It helps seeing only some components of the material while troubleshooting.
  107199. */
  107200. debugMode: number;
  107201. /**
  107202. * @hidden
  107203. * This is reserved for the inspector.
  107204. * Specify from where on screen the debug mode should start.
  107205. * The value goes from -1 (full screen) to 1 (not visible)
  107206. * It helps with side by side comparison against the final render
  107207. * This defaults to -1
  107208. */
  107209. private debugLimit;
  107210. /**
  107211. * @hidden
  107212. * This is reserved for the inspector.
  107213. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107214. * You can use the factor to better multiply the final value.
  107215. */
  107216. private debugFactor;
  107217. /**
  107218. * Defines the clear coat layer parameters for the material.
  107219. */
  107220. readonly clearCoat: PBRClearCoatConfiguration;
  107221. /**
  107222. * Defines the anisotropic parameters for the material.
  107223. */
  107224. readonly anisotropy: PBRAnisotropicConfiguration;
  107225. /**
  107226. * Defines the BRDF parameters for the material.
  107227. */
  107228. readonly brdf: PBRBRDFConfiguration;
  107229. /**
  107230. * Defines the Sheen parameters for the material.
  107231. */
  107232. readonly sheen: PBRSheenConfiguration;
  107233. /**
  107234. * Defines the SubSurface parameters for the material.
  107235. */
  107236. readonly subSurface: PBRSubSurfaceConfiguration;
  107237. /**
  107238. * Defines additionnal PrePass parameters for the material.
  107239. */
  107240. readonly prePassConfiguration: PrePassConfiguration;
  107241. /**
  107242. * Defines the detail map parameters for the material.
  107243. */
  107244. readonly detailMap: DetailMapConfiguration;
  107245. protected _rebuildInParallel: boolean;
  107246. /**
  107247. * Instantiates a new PBRMaterial instance.
  107248. *
  107249. * @param name The material name
  107250. * @param scene The scene the material will be use in.
  107251. */
  107252. constructor(name: string, scene: Scene);
  107253. /**
  107254. * Gets a boolean indicating that current material needs to register RTT
  107255. */
  107256. get hasRenderTargetTextures(): boolean;
  107257. /**
  107258. * Gets the name of the material class.
  107259. */
  107260. getClassName(): string;
  107261. /**
  107262. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107263. */
  107264. get useLogarithmicDepth(): boolean;
  107265. /**
  107266. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107267. */
  107268. set useLogarithmicDepth(value: boolean);
  107269. /**
  107270. * Returns true if alpha blending should be disabled.
  107271. */
  107272. protected get _disableAlphaBlending(): boolean;
  107273. /**
  107274. * Specifies whether or not this material should be rendered in alpha blend mode.
  107275. */
  107276. needAlphaBlending(): boolean;
  107277. /**
  107278. * Specifies whether or not this material should be rendered in alpha test mode.
  107279. */
  107280. needAlphaTesting(): boolean;
  107281. /**
  107282. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107283. */
  107284. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107285. /**
  107286. * Gets the texture used for the alpha test.
  107287. */
  107288. getAlphaTestTexture(): Nullable<BaseTexture>;
  107289. /**
  107290. * Specifies that the submesh is ready to be used.
  107291. * @param mesh - BJS mesh.
  107292. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107293. * @param useInstances - Specifies that instances should be used.
  107294. * @returns - boolean indicating that the submesh is ready or not.
  107295. */
  107296. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107297. /**
  107298. * Specifies if the material uses metallic roughness workflow.
  107299. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107300. */
  107301. isMetallicWorkflow(): boolean;
  107302. private _prepareEffect;
  107303. private _prepareDefines;
  107304. /**
  107305. * Force shader compilation
  107306. */
  107307. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  107308. /**
  107309. * Initializes the uniform buffer layout for the shader.
  107310. */
  107311. buildUniformLayout(): void;
  107312. /**
  107313. * Unbinds the material from the mesh
  107314. */
  107315. unbind(): void;
  107316. /**
  107317. * Binds the submesh data.
  107318. * @param world - The world matrix.
  107319. * @param mesh - The BJS mesh.
  107320. * @param subMesh - A submesh of the BJS mesh.
  107321. */
  107322. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107323. /**
  107324. * Returns the animatable textures.
  107325. * @returns - Array of animatable textures.
  107326. */
  107327. getAnimatables(): IAnimatable[];
  107328. /**
  107329. * Returns the texture used for reflections.
  107330. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107331. */
  107332. private _getReflectionTexture;
  107333. /**
  107334. * Returns an array of the actively used textures.
  107335. * @returns - Array of BaseTextures
  107336. */
  107337. getActiveTextures(): BaseTexture[];
  107338. /**
  107339. * Checks to see if a texture is used in the material.
  107340. * @param texture - Base texture to use.
  107341. * @returns - Boolean specifying if a texture is used in the material.
  107342. */
  107343. hasTexture(texture: BaseTexture): boolean;
  107344. /**
  107345. * Sets the required values to the prepass renderer.
  107346. * @param prePassRenderer defines the prepass renderer to setup
  107347. */
  107348. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107349. /**
  107350. * Disposes the resources of the material.
  107351. * @param forceDisposeEffect - Forces the disposal of effects.
  107352. * @param forceDisposeTextures - Forces the disposal of all textures.
  107353. */
  107354. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107355. }
  107356. }
  107357. declare module BABYLON {
  107358. /**
  107359. * The Physically based material of BJS.
  107360. *
  107361. * This offers the main features of a standard PBR material.
  107362. * For more information, please refer to the documentation :
  107363. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107364. */
  107365. export class PBRMaterial extends PBRBaseMaterial {
  107366. /**
  107367. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107368. */
  107369. static readonly PBRMATERIAL_OPAQUE: number;
  107370. /**
  107371. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107372. */
  107373. static readonly PBRMATERIAL_ALPHATEST: number;
  107374. /**
  107375. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107376. */
  107377. static readonly PBRMATERIAL_ALPHABLEND: number;
  107378. /**
  107379. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107380. * They are also discarded below the alpha cutoff threshold to improve performances.
  107381. */
  107382. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107383. /**
  107384. * Defines the default value of how much AO map is occluding the analytical lights
  107385. * (point spot...).
  107386. */
  107387. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107388. /**
  107389. * Intensity of the direct lights e.g. the four lights available in your scene.
  107390. * This impacts both the direct diffuse and specular highlights.
  107391. */
  107392. directIntensity: number;
  107393. /**
  107394. * Intensity of the emissive part of the material.
  107395. * This helps controlling the emissive effect without modifying the emissive color.
  107396. */
  107397. emissiveIntensity: number;
  107398. /**
  107399. * Intensity of the environment e.g. how much the environment will light the object
  107400. * either through harmonics for rough material or through the refelction for shiny ones.
  107401. */
  107402. environmentIntensity: number;
  107403. /**
  107404. * This is a special control allowing the reduction of the specular highlights coming from the
  107405. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107406. */
  107407. specularIntensity: number;
  107408. /**
  107409. * Debug Control allowing disabling the bump map on this material.
  107410. */
  107411. disableBumpMap: boolean;
  107412. /**
  107413. * AKA Diffuse Texture in standard nomenclature.
  107414. */
  107415. albedoTexture: BaseTexture;
  107416. /**
  107417. * AKA Occlusion Texture in other nomenclature.
  107418. */
  107419. ambientTexture: BaseTexture;
  107420. /**
  107421. * AKA Occlusion Texture Intensity in other nomenclature.
  107422. */
  107423. ambientTextureStrength: number;
  107424. /**
  107425. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107426. * 1 means it completely occludes it
  107427. * 0 mean it has no impact
  107428. */
  107429. ambientTextureImpactOnAnalyticalLights: number;
  107430. /**
  107431. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  107432. */
  107433. opacityTexture: BaseTexture;
  107434. /**
  107435. * Stores the reflection values in a texture.
  107436. */
  107437. reflectionTexture: Nullable<BaseTexture>;
  107438. /**
  107439. * Stores the emissive values in a texture.
  107440. */
  107441. emissiveTexture: BaseTexture;
  107442. /**
  107443. * AKA Specular texture in other nomenclature.
  107444. */
  107445. reflectivityTexture: BaseTexture;
  107446. /**
  107447. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107448. */
  107449. metallicTexture: BaseTexture;
  107450. /**
  107451. * Specifies the metallic scalar of the metallic/roughness workflow.
  107452. * Can also be used to scale the metalness values of the metallic texture.
  107453. */
  107454. metallic: Nullable<number>;
  107455. /**
  107456. * Specifies the roughness scalar of the metallic/roughness workflow.
  107457. * Can also be used to scale the roughness values of the metallic texture.
  107458. */
  107459. roughness: Nullable<number>;
  107460. /**
  107461. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107462. * By default the indexOfrefraction is used to compute F0;
  107463. *
  107464. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107465. *
  107466. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107467. * F90 = metallicReflectanceColor;
  107468. */
  107469. metallicF0Factor: number;
  107470. /**
  107471. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107472. * By default the F90 is always 1;
  107473. *
  107474. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107475. *
  107476. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107477. * F90 = metallicReflectanceColor;
  107478. */
  107479. metallicReflectanceColor: Color3;
  107480. /**
  107481. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107482. * This is multiply against the scalar values defined in the material.
  107483. */
  107484. metallicReflectanceTexture: Nullable<BaseTexture>;
  107485. /**
  107486. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107487. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107488. */
  107489. microSurfaceTexture: BaseTexture;
  107490. /**
  107491. * Stores surface normal data used to displace a mesh in a texture.
  107492. */
  107493. bumpTexture: BaseTexture;
  107494. /**
  107495. * Stores the pre-calculated light information of a mesh in a texture.
  107496. */
  107497. lightmapTexture: BaseTexture;
  107498. /**
  107499. * Stores the refracted light information in a texture.
  107500. */
  107501. get refractionTexture(): Nullable<BaseTexture>;
  107502. set refractionTexture(value: Nullable<BaseTexture>);
  107503. /**
  107504. * The color of a material in ambient lighting.
  107505. */
  107506. ambientColor: Color3;
  107507. /**
  107508. * AKA Diffuse Color in other nomenclature.
  107509. */
  107510. albedoColor: Color3;
  107511. /**
  107512. * AKA Specular Color in other nomenclature.
  107513. */
  107514. reflectivityColor: Color3;
  107515. /**
  107516. * The color reflected from the material.
  107517. */
  107518. reflectionColor: Color3;
  107519. /**
  107520. * The color emitted from the material.
  107521. */
  107522. emissiveColor: Color3;
  107523. /**
  107524. * AKA Glossiness in other nomenclature.
  107525. */
  107526. microSurface: number;
  107527. /**
  107528. * Index of refraction of the material base layer.
  107529. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107530. *
  107531. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  107532. *
  107533. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  107534. */
  107535. get indexOfRefraction(): number;
  107536. set indexOfRefraction(value: number);
  107537. /**
  107538. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107539. */
  107540. get invertRefractionY(): boolean;
  107541. set invertRefractionY(value: boolean);
  107542. /**
  107543. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107544. * Materials half opaque for instance using refraction could benefit from this control.
  107545. */
  107546. get linkRefractionWithTransparency(): boolean;
  107547. set linkRefractionWithTransparency(value: boolean);
  107548. /**
  107549. * If true, the light map contains occlusion information instead of lighting info.
  107550. */
  107551. useLightmapAsShadowmap: boolean;
  107552. /**
  107553. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107554. */
  107555. useAlphaFromAlbedoTexture: boolean;
  107556. /**
  107557. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107558. */
  107559. forceAlphaTest: boolean;
  107560. /**
  107561. * Defines the alpha limits in alpha test mode.
  107562. */
  107563. alphaCutOff: number;
  107564. /**
  107565. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107566. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107567. */
  107568. useSpecularOverAlpha: boolean;
  107569. /**
  107570. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107571. */
  107572. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107573. /**
  107574. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107575. */
  107576. useRoughnessFromMetallicTextureAlpha: boolean;
  107577. /**
  107578. * Specifies if the metallic texture contains the roughness information in its green channel.
  107579. */
  107580. useRoughnessFromMetallicTextureGreen: boolean;
  107581. /**
  107582. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107583. */
  107584. useMetallnessFromMetallicTextureBlue: boolean;
  107585. /**
  107586. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107587. */
  107588. useAmbientOcclusionFromMetallicTextureRed: boolean;
  107589. /**
  107590. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107591. */
  107592. useAmbientInGrayScale: boolean;
  107593. /**
  107594. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107595. * The material will try to infer what glossiness each pixel should be.
  107596. */
  107597. useAutoMicroSurfaceFromReflectivityMap: boolean;
  107598. /**
  107599. * BJS is using an harcoded light falloff based on a manually sets up range.
  107600. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107601. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107602. */
  107603. get usePhysicalLightFalloff(): boolean;
  107604. /**
  107605. * BJS is using an harcoded light falloff based on a manually sets up range.
  107606. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  107607. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  107608. */
  107609. set usePhysicalLightFalloff(value: boolean);
  107610. /**
  107611. * In order to support the falloff compatibility with gltf, a special mode has been added
  107612. * to reproduce the gltf light falloff.
  107613. */
  107614. get useGLTFLightFalloff(): boolean;
  107615. /**
  107616. * In order to support the falloff compatibility with gltf, a special mode has been added
  107617. * to reproduce the gltf light falloff.
  107618. */
  107619. set useGLTFLightFalloff(value: boolean);
  107620. /**
  107621. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107622. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107623. */
  107624. useRadianceOverAlpha: boolean;
  107625. /**
  107626. * Allows using an object space normal map (instead of tangent space).
  107627. */
  107628. useObjectSpaceNormalMap: boolean;
  107629. /**
  107630. * Allows using the bump map in parallax mode.
  107631. */
  107632. useParallax: boolean;
  107633. /**
  107634. * Allows using the bump map in parallax occlusion mode.
  107635. */
  107636. useParallaxOcclusion: boolean;
  107637. /**
  107638. * Controls the scale bias of the parallax mode.
  107639. */
  107640. parallaxScaleBias: number;
  107641. /**
  107642. * If sets to true, disables all the lights affecting the material.
  107643. */
  107644. disableLighting: boolean;
  107645. /**
  107646. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107647. */
  107648. forceIrradianceInFragment: boolean;
  107649. /**
  107650. * Number of Simultaneous lights allowed on the material.
  107651. */
  107652. maxSimultaneousLights: number;
  107653. /**
  107654. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107655. */
  107656. invertNormalMapX: boolean;
  107657. /**
  107658. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107659. */
  107660. invertNormalMapY: boolean;
  107661. /**
  107662. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107663. */
  107664. twoSidedLighting: boolean;
  107665. /**
  107666. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107667. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107668. */
  107669. useAlphaFresnel: boolean;
  107670. /**
  107671. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107672. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107673. */
  107674. useLinearAlphaFresnel: boolean;
  107675. /**
  107676. * Let user defines the brdf lookup texture used for IBL.
  107677. * A default 8bit version is embedded but you could point at :
  107678. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107679. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107680. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107681. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107682. */
  107683. environmentBRDFTexture: Nullable<BaseTexture>;
  107684. /**
  107685. * Force normal to face away from face.
  107686. */
  107687. forceNormalForward: boolean;
  107688. /**
  107689. * Enables specular anti aliasing in the PBR shader.
  107690. * It will both interacts on the Geometry for analytical and IBL lighting.
  107691. * It also prefilter the roughness map based on the bump values.
  107692. */
  107693. enableSpecularAntiAliasing: boolean;
  107694. /**
  107695. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107696. * makes the reflect vector face the model (under horizon).
  107697. */
  107698. useHorizonOcclusion: boolean;
  107699. /**
  107700. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107701. * too much the area relying on ambient texture to define their ambient occlusion.
  107702. */
  107703. useRadianceOcclusion: boolean;
  107704. /**
  107705. * If set to true, no lighting calculations will be applied.
  107706. */
  107707. unlit: boolean;
  107708. /**
  107709. * Gets the image processing configuration used either in this material.
  107710. */
  107711. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107712. /**
  107713. * Sets the Default image processing configuration used either in the this material.
  107714. *
  107715. * If sets to null, the scene one is in use.
  107716. */
  107717. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107718. /**
  107719. * Gets wether the color curves effect is enabled.
  107720. */
  107721. get cameraColorCurvesEnabled(): boolean;
  107722. /**
  107723. * Sets wether the color curves effect is enabled.
  107724. */
  107725. set cameraColorCurvesEnabled(value: boolean);
  107726. /**
  107727. * Gets wether the color grading effect is enabled.
  107728. */
  107729. get cameraColorGradingEnabled(): boolean;
  107730. /**
  107731. * Gets wether the color grading effect is enabled.
  107732. */
  107733. set cameraColorGradingEnabled(value: boolean);
  107734. /**
  107735. * Gets wether tonemapping is enabled or not.
  107736. */
  107737. get cameraToneMappingEnabled(): boolean;
  107738. /**
  107739. * Sets wether tonemapping is enabled or not
  107740. */
  107741. set cameraToneMappingEnabled(value: boolean);
  107742. /**
  107743. * The camera exposure used on this material.
  107744. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107745. * This corresponds to a photographic exposure.
  107746. */
  107747. get cameraExposure(): number;
  107748. /**
  107749. * The camera exposure used on this material.
  107750. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107751. * This corresponds to a photographic exposure.
  107752. */
  107753. set cameraExposure(value: number);
  107754. /**
  107755. * Gets The camera contrast used on this material.
  107756. */
  107757. get cameraContrast(): number;
  107758. /**
  107759. * Sets The camera contrast used on this material.
  107760. */
  107761. set cameraContrast(value: number);
  107762. /**
  107763. * Gets the Color Grading 2D Lookup Texture.
  107764. */
  107765. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107766. /**
  107767. * Sets the Color Grading 2D Lookup Texture.
  107768. */
  107769. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107770. /**
  107771. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107772. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107773. * 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;
  107774. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107775. */
  107776. get cameraColorCurves(): Nullable<ColorCurves>;
  107777. /**
  107778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107780. * 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;
  107781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107782. */
  107783. set cameraColorCurves(value: Nullable<ColorCurves>);
  107784. /**
  107785. * Instantiates a new PBRMaterial instance.
  107786. *
  107787. * @param name The material name
  107788. * @param scene The scene the material will be use in.
  107789. */
  107790. constructor(name: string, scene: Scene);
  107791. /**
  107792. * Returns the name of this material class.
  107793. */
  107794. getClassName(): string;
  107795. /**
  107796. * Makes a duplicate of the current material.
  107797. * @param name - name to use for the new material.
  107798. */
  107799. clone(name: string): PBRMaterial;
  107800. /**
  107801. * Serializes this PBR Material.
  107802. * @returns - An object with the serialized material.
  107803. */
  107804. serialize(): any;
  107805. /**
  107806. * Parses a PBR Material from a serialized object.
  107807. * @param source - Serialized object.
  107808. * @param scene - BJS scene instance.
  107809. * @param rootUrl - url for the scene object
  107810. * @returns - PBRMaterial
  107811. */
  107812. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107813. }
  107814. }
  107815. declare module BABYLON {
  107816. /** @hidden */
  107817. export var mrtFragmentDeclaration: {
  107818. name: string;
  107819. shader: string;
  107820. };
  107821. }
  107822. declare module BABYLON {
  107823. /** @hidden */
  107824. export var geometryPixelShader: {
  107825. name: string;
  107826. shader: string;
  107827. };
  107828. }
  107829. declare module BABYLON {
  107830. /** @hidden */
  107831. export var geometryVertexShader: {
  107832. name: string;
  107833. shader: string;
  107834. };
  107835. }
  107836. declare module BABYLON {
  107837. /** @hidden */
  107838. interface ISavedTransformationMatrix {
  107839. world: Matrix;
  107840. viewProjection: Matrix;
  107841. }
  107842. /**
  107843. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107844. */
  107845. export class GeometryBufferRenderer {
  107846. /**
  107847. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  107848. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  107849. */
  107850. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  107851. /**
  107852. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107853. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107854. */
  107855. static readonly POSITION_TEXTURE_TYPE: number;
  107856. /**
  107857. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107858. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107859. */
  107860. static readonly VELOCITY_TEXTURE_TYPE: number;
  107861. /**
  107862. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  107863. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  107864. */
  107865. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  107866. /**
  107867. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107868. * in order to compute objects velocities when enableVelocity is set to "true"
  107869. * @hidden
  107870. */
  107871. _previousTransformationMatrices: {
  107872. [index: number]: ISavedTransformationMatrix;
  107873. };
  107874. /**
  107875. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  107876. * in order to compute objects velocities when enableVelocity is set to "true"
  107877. * @hidden
  107878. */
  107879. _previousBonesTransformationMatrices: {
  107880. [index: number]: Float32Array;
  107881. };
  107882. /**
  107883. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  107884. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  107885. */
  107886. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  107887. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  107888. renderTransparentMeshes: boolean;
  107889. private _scene;
  107890. private _resizeObserver;
  107891. private _multiRenderTarget;
  107892. private _ratio;
  107893. private _enablePosition;
  107894. private _enableVelocity;
  107895. private _enableReflectivity;
  107896. private _positionIndex;
  107897. private _velocityIndex;
  107898. private _reflectivityIndex;
  107899. private _depthNormalIndex;
  107900. private _linkedWithPrePass;
  107901. private _prePassRenderer;
  107902. private _attachments;
  107903. protected _effect: Effect;
  107904. protected _cachedDefines: string;
  107905. /**
  107906. * @hidden
  107907. * Sets up internal structures to share outputs with PrePassRenderer
  107908. * This method should only be called by the PrePassRenderer itself
  107909. */
  107910. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  107911. /**
  107912. * @hidden
  107913. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  107914. * This method should only be called by the PrePassRenderer itself
  107915. */
  107916. _unlinkPrePassRenderer(): void;
  107917. /**
  107918. * @hidden
  107919. * Resets the geometry buffer layout
  107920. */
  107921. _resetLayout(): void;
  107922. /**
  107923. * @hidden
  107924. * Replaces a texture in the geometry buffer renderer
  107925. * Useful when linking textures of the prepass renderer
  107926. */
  107927. _forceTextureType(geometryBufferType: number, index: number): void;
  107928. /**
  107929. * @hidden
  107930. * Sets texture attachments
  107931. * Useful when linking textures of the prepass renderer
  107932. */
  107933. _setAttachments(attachments: number[]): void;
  107934. /**
  107935. * @hidden
  107936. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  107937. * Useful when linking textures of the prepass renderer
  107938. */
  107939. _linkInternalTexture(internalTexture: InternalTexture): void;
  107940. /**
  107941. * Gets the render list (meshes to be rendered) used in the G buffer.
  107942. */
  107943. get renderList(): Nullable<AbstractMesh[]>;
  107944. /**
  107945. * Set the render list (meshes to be rendered) used in the G buffer.
  107946. */
  107947. set renderList(meshes: Nullable<AbstractMesh[]>);
  107948. /**
  107949. * Gets wether or not G buffer are supported by the running hardware.
  107950. * This requires draw buffer supports
  107951. */
  107952. get isSupported(): boolean;
  107953. /**
  107954. * Returns the index of the given texture type in the G-Buffer textures array
  107955. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  107956. * @returns the index of the given texture type in the G-Buffer textures array
  107957. */
  107958. getTextureIndex(textureType: number): number;
  107959. /**
  107960. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  107961. */
  107962. get enablePosition(): boolean;
  107963. /**
  107964. * Sets whether or not objects positions are enabled for the G buffer.
  107965. */
  107966. set enablePosition(enable: boolean);
  107967. /**
  107968. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  107969. */
  107970. get enableVelocity(): boolean;
  107971. /**
  107972. * Sets wether or not objects velocities are enabled for the G buffer.
  107973. */
  107974. set enableVelocity(enable: boolean);
  107975. /**
  107976. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  107977. */
  107978. get enableReflectivity(): boolean;
  107979. /**
  107980. * Sets wether or not objects roughness are enabled for the G buffer.
  107981. */
  107982. set enableReflectivity(enable: boolean);
  107983. /**
  107984. * Gets the scene associated with the buffer.
  107985. */
  107986. get scene(): Scene;
  107987. /**
  107988. * Gets the ratio used by the buffer during its creation.
  107989. * How big is the buffer related to the main canvas.
  107990. */
  107991. get ratio(): number;
  107992. /** @hidden */
  107993. static _SceneComponentInitialization: (scene: Scene) => void;
  107994. /**
  107995. * Creates a new G Buffer for the scene
  107996. * @param scene The scene the buffer belongs to
  107997. * @param ratio How big is the buffer related to the main canvas.
  107998. */
  107999. constructor(scene: Scene, ratio?: number);
  108000. /**
  108001. * Checks wether everything is ready to render a submesh to the G buffer.
  108002. * @param subMesh the submesh to check readiness for
  108003. * @param useInstances is the mesh drawn using instance or not
  108004. * @returns true if ready otherwise false
  108005. */
  108006. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108007. /**
  108008. * Gets the current underlying G Buffer.
  108009. * @returns the buffer
  108010. */
  108011. getGBuffer(): MultiRenderTarget;
  108012. /**
  108013. * Gets the number of samples used to render the buffer (anti aliasing).
  108014. */
  108015. get samples(): number;
  108016. /**
  108017. * Sets the number of samples used to render the buffer (anti aliasing).
  108018. */
  108019. set samples(value: number);
  108020. /**
  108021. * Disposes the renderer and frees up associated resources.
  108022. */
  108023. dispose(): void;
  108024. private _assignRenderTargetIndices;
  108025. protected _createRenderTargets(): void;
  108026. private _copyBonesTransformationMatrices;
  108027. }
  108028. }
  108029. declare module BABYLON {
  108030. /**
  108031. * Renders a pre pass of the scene
  108032. * This means every mesh in the scene will be rendered to a render target texture
  108033. * And then this texture will be composited to the rendering canvas with post processes
  108034. * It is necessary for effects like subsurface scattering or deferred shading
  108035. */
  108036. export class PrePassRenderer {
  108037. /** @hidden */
  108038. static _SceneComponentInitialization: (scene: Scene) => void;
  108039. private _textureFormats;
  108040. /**
  108041. * To save performance, we can excluded skinned meshes from the prepass
  108042. */
  108043. excludedSkinnedMesh: AbstractMesh[];
  108044. /**
  108045. * Force material to be excluded from the prepass
  108046. * Can be useful when `useGeometryBufferFallback` is set to `true`
  108047. * and you don't want a material to show in the effect.
  108048. */
  108049. excludedMaterials: Material[];
  108050. private _textureIndices;
  108051. private _scene;
  108052. private _engine;
  108053. private _isDirty;
  108054. /**
  108055. * Number of textures in the multi render target texture where the scene is directly rendered
  108056. */
  108057. mrtCount: number;
  108058. /**
  108059. * The render target where the scene is directly rendered
  108060. */
  108061. prePassRT: MultiRenderTarget;
  108062. private _multiRenderAttachments;
  108063. private _defaultAttachments;
  108064. private _clearAttachments;
  108065. private _postProcesses;
  108066. private readonly _clearColor;
  108067. /**
  108068. * Image processing post process for composition
  108069. */
  108070. imageProcessingPostProcess: ImageProcessingPostProcess;
  108071. /**
  108072. * Configuration for prepass effects
  108073. */
  108074. private _effectConfigurations;
  108075. private _mrtFormats;
  108076. private _mrtLayout;
  108077. private _enabled;
  108078. /**
  108079. * Indicates if the prepass is enabled
  108080. */
  108081. get enabled(): boolean;
  108082. /**
  108083. * How many samples are used for MSAA of the scene render target
  108084. */
  108085. get samples(): number;
  108086. set samples(n: number);
  108087. private _geometryBuffer;
  108088. private _useGeometryBufferFallback;
  108089. /**
  108090. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  108091. */
  108092. get useGeometryBufferFallback(): boolean;
  108093. set useGeometryBufferFallback(value: boolean);
  108094. /**
  108095. * Instanciates a prepass renderer
  108096. * @param scene The scene
  108097. */
  108098. constructor(scene: Scene);
  108099. private _initializeAttachments;
  108100. private _createCompositionEffect;
  108101. /**
  108102. * Indicates if rendering a prepass is supported
  108103. */
  108104. get isSupported(): boolean;
  108105. /**
  108106. * Sets the proper output textures to draw in the engine.
  108107. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108108. * @param subMesh Submesh on which the effect is applied
  108109. */
  108110. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108111. /**
  108112. * @hidden
  108113. */
  108114. _beforeCameraDraw(): void;
  108115. /**
  108116. * @hidden
  108117. */
  108118. _afterCameraDraw(): void;
  108119. private _checkRTSize;
  108120. private _bindFrameBuffer;
  108121. /**
  108122. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  108123. */
  108124. clear(): void;
  108125. private _setState;
  108126. private _updateGeometryBufferLayout;
  108127. /**
  108128. * Adds an effect configuration to the prepass.
  108129. * If an effect has already been added, it won't add it twice and will return the configuration
  108130. * already present.
  108131. * @param cfg the effect configuration
  108132. * @return the effect configuration now used by the prepass
  108133. */
  108134. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108135. /**
  108136. * Returns the index of a texture in the multi render target texture array.
  108137. * @param type Texture type
  108138. * @return The index
  108139. */
  108140. getIndex(type: number): number;
  108141. private _enable;
  108142. private _disable;
  108143. private _resetLayout;
  108144. private _resetPostProcessChain;
  108145. private _bindPostProcessChain;
  108146. /**
  108147. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108148. */
  108149. markAsDirty(): void;
  108150. /**
  108151. * Enables a texture on the MultiRenderTarget for prepass
  108152. */
  108153. private _enableTextures;
  108154. private _update;
  108155. private _markAllMaterialsAsPrePassDirty;
  108156. /**
  108157. * Disposes the prepass renderer.
  108158. */
  108159. dispose(): void;
  108160. }
  108161. }
  108162. declare module BABYLON {
  108163. /**
  108164. * Size options for a post process
  108165. */
  108166. export type PostProcessOptions = {
  108167. width: number;
  108168. height: number;
  108169. };
  108170. /**
  108171. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108172. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108173. */
  108174. export class PostProcess {
  108175. /**
  108176. * Gets or sets the unique id of the post process
  108177. */
  108178. uniqueId: number;
  108179. /** Name of the PostProcess. */
  108180. name: string;
  108181. /**
  108182. * Width of the texture to apply the post process on
  108183. */
  108184. width: number;
  108185. /**
  108186. * Height of the texture to apply the post process on
  108187. */
  108188. height: number;
  108189. /**
  108190. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108191. */
  108192. nodeMaterialSource: Nullable<NodeMaterial>;
  108193. /**
  108194. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108195. * @hidden
  108196. */
  108197. _outputTexture: Nullable<InternalTexture>;
  108198. /**
  108199. * Sampling mode used by the shader
  108200. * See https://doc.babylonjs.com/classes/3.1/texture
  108201. */
  108202. renderTargetSamplingMode: number;
  108203. /**
  108204. * Clear color to use when screen clearing
  108205. */
  108206. clearColor: Color4;
  108207. /**
  108208. * If the buffer needs to be cleared before applying the post process. (default: true)
  108209. * Should be set to false if shader will overwrite all previous pixels.
  108210. */
  108211. autoClear: boolean;
  108212. /**
  108213. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108214. */
  108215. alphaMode: number;
  108216. /**
  108217. * Sets the setAlphaBlendConstants of the babylon engine
  108218. */
  108219. alphaConstants: Color4;
  108220. /**
  108221. * Animations to be used for the post processing
  108222. */
  108223. animations: Animation[];
  108224. /**
  108225. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108226. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108227. */
  108228. enablePixelPerfectMode: boolean;
  108229. /**
  108230. * Force the postprocess to be applied without taking in account viewport
  108231. */
  108232. forceFullscreenViewport: boolean;
  108233. /**
  108234. * List of inspectable custom properties (used by the Inspector)
  108235. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108236. */
  108237. inspectableCustomProperties: IInspectable[];
  108238. /**
  108239. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108240. *
  108241. * | Value | Type | Description |
  108242. * | ----- | ----------------------------------- | ----------- |
  108243. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108244. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108245. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108246. *
  108247. */
  108248. scaleMode: number;
  108249. /**
  108250. * Force textures to be a power of two (default: false)
  108251. */
  108252. alwaysForcePOT: boolean;
  108253. private _samples;
  108254. /**
  108255. * Number of sample textures (default: 1)
  108256. */
  108257. get samples(): number;
  108258. set samples(n: number);
  108259. /**
  108260. * Modify the scale of the post process to be the same as the viewport (default: false)
  108261. */
  108262. adaptScaleToCurrentViewport: boolean;
  108263. private _camera;
  108264. protected _scene: Scene;
  108265. private _engine;
  108266. private _options;
  108267. private _reusable;
  108268. private _textureType;
  108269. private _textureFormat;
  108270. /**
  108271. * Smart array of input and output textures for the post process.
  108272. * @hidden
  108273. */
  108274. _textures: SmartArray<InternalTexture>;
  108275. /**
  108276. * The index in _textures that corresponds to the output texture.
  108277. * @hidden
  108278. */
  108279. _currentRenderTextureInd: number;
  108280. private _effect;
  108281. private _samplers;
  108282. private _fragmentUrl;
  108283. private _vertexUrl;
  108284. private _parameters;
  108285. private _scaleRatio;
  108286. protected _indexParameters: any;
  108287. private _shareOutputWithPostProcess;
  108288. private _texelSize;
  108289. private _forcedOutputTexture;
  108290. /**
  108291. * Prepass configuration in case this post process needs a texture from prepass
  108292. * @hidden
  108293. */
  108294. _prePassEffectConfiguration: PrePassEffectConfiguration;
  108295. /**
  108296. * Returns the fragment url or shader name used in the post process.
  108297. * @returns the fragment url or name in the shader store.
  108298. */
  108299. getEffectName(): string;
  108300. /**
  108301. * An event triggered when the postprocess is activated.
  108302. */
  108303. onActivateObservable: Observable<Camera>;
  108304. private _onActivateObserver;
  108305. /**
  108306. * A function that is added to the onActivateObservable
  108307. */
  108308. set onActivate(callback: Nullable<(camera: Camera) => void>);
  108309. /**
  108310. * An event triggered when the postprocess changes its size.
  108311. */
  108312. onSizeChangedObservable: Observable<PostProcess>;
  108313. private _onSizeChangedObserver;
  108314. /**
  108315. * A function that is added to the onSizeChangedObservable
  108316. */
  108317. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  108318. /**
  108319. * An event triggered when the postprocess applies its effect.
  108320. */
  108321. onApplyObservable: Observable<Effect>;
  108322. private _onApplyObserver;
  108323. /**
  108324. * A function that is added to the onApplyObservable
  108325. */
  108326. set onApply(callback: (effect: Effect) => void);
  108327. /**
  108328. * An event triggered before rendering the postprocess
  108329. */
  108330. onBeforeRenderObservable: Observable<Effect>;
  108331. private _onBeforeRenderObserver;
  108332. /**
  108333. * A function that is added to the onBeforeRenderObservable
  108334. */
  108335. set onBeforeRender(callback: (effect: Effect) => void);
  108336. /**
  108337. * An event triggered after rendering the postprocess
  108338. */
  108339. onAfterRenderObservable: Observable<Effect>;
  108340. private _onAfterRenderObserver;
  108341. /**
  108342. * A function that is added to the onAfterRenderObservable
  108343. */
  108344. set onAfterRender(callback: (efect: Effect) => void);
  108345. /**
  108346. * 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
  108347. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  108348. */
  108349. get inputTexture(): InternalTexture;
  108350. set inputTexture(value: InternalTexture);
  108351. /**
  108352. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  108353. * the only way to unset it is to use this function to restore its internal state
  108354. */
  108355. restoreDefaultInputTexture(): void;
  108356. /**
  108357. * Gets the camera which post process is applied to.
  108358. * @returns The camera the post process is applied to.
  108359. */
  108360. getCamera(): Camera;
  108361. /**
  108362. * Gets the texel size of the postprocess.
  108363. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  108364. */
  108365. get texelSize(): Vector2;
  108366. /**
  108367. * Creates a new instance PostProcess
  108368. * @param name The name of the PostProcess.
  108369. * @param fragmentUrl The url of the fragment shader to be used.
  108370. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  108371. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  108372. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108373. * @param camera The camera to apply the render pass to.
  108374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108375. * @param engine The engine which the post process will be applied. (default: current engine)
  108376. * @param reusable If the post process can be reused on the same frame. (default: false)
  108377. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  108378. * @param textureType Type of textures used when performing the post process. (default: 0)
  108379. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  108380. * @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
  108381. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  108382. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  108383. */
  108384. 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);
  108385. /**
  108386. * Gets a string identifying the name of the class
  108387. * @returns "PostProcess" string
  108388. */
  108389. getClassName(): string;
  108390. /**
  108391. * Gets the engine which this post process belongs to.
  108392. * @returns The engine the post process was enabled with.
  108393. */
  108394. getEngine(): Engine;
  108395. /**
  108396. * The effect that is created when initializing the post process.
  108397. * @returns The created effect corresponding the the postprocess.
  108398. */
  108399. getEffect(): Effect;
  108400. /**
  108401. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  108402. * @param postProcess The post process to share the output with.
  108403. * @returns This post process.
  108404. */
  108405. shareOutputWith(postProcess: PostProcess): PostProcess;
  108406. /**
  108407. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  108408. * This should be called if the post process that shares output with this post process is disabled/disposed.
  108409. */
  108410. useOwnOutput(): void;
  108411. /**
  108412. * Updates the effect with the current post process compile time values and recompiles the shader.
  108413. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108414. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108415. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108416. * @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
  108417. * @param onCompiled Called when the shader has been compiled.
  108418. * @param onError Called if there is an error when compiling a shader.
  108419. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  108420. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  108421. */
  108422. 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;
  108423. /**
  108424. * The post process is reusable if it can be used multiple times within one frame.
  108425. * @returns If the post process is reusable
  108426. */
  108427. isReusable(): boolean;
  108428. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  108429. markTextureDirty(): void;
  108430. /**
  108431. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  108432. * 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.
  108433. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  108434. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  108435. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  108436. * @returns The target texture that was bound to be written to.
  108437. */
  108438. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  108439. /**
  108440. * If the post process is supported.
  108441. */
  108442. get isSupported(): boolean;
  108443. /**
  108444. * The aspect ratio of the output texture.
  108445. */
  108446. get aspectRatio(): number;
  108447. /**
  108448. * Get a value indicating if the post-process is ready to be used
  108449. * @returns true if the post-process is ready (shader is compiled)
  108450. */
  108451. isReady(): boolean;
  108452. /**
  108453. * Binds all textures and uniforms to the shader, this will be run on every pass.
  108454. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  108455. */
  108456. apply(): Nullable<Effect>;
  108457. private _disposeTextures;
  108458. /**
  108459. * Sets the required values to the prepass renderer.
  108460. * @param prePassRenderer defines the prepass renderer to setup.
  108461. * @returns true if the pre pass is needed.
  108462. */
  108463. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108464. /**
  108465. * Disposes the post process.
  108466. * @param camera The camera to dispose the post process on.
  108467. */
  108468. dispose(camera?: Camera): void;
  108469. /**
  108470. * Serializes the particle system to a JSON object
  108471. * @returns the JSON object
  108472. */
  108473. serialize(): any;
  108474. /**
  108475. * Creates a material from parsed material data
  108476. * @param parsedPostProcess defines parsed post process data
  108477. * @param scene defines the hosting scene
  108478. * @param rootUrl defines the root URL to use to load textures
  108479. * @returns a new post process
  108480. */
  108481. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  108482. }
  108483. }
  108484. declare module BABYLON {
  108485. /** @hidden */
  108486. export var kernelBlurVaryingDeclaration: {
  108487. name: string;
  108488. shader: string;
  108489. };
  108490. }
  108491. declare module BABYLON {
  108492. /** @hidden */
  108493. export var kernelBlurFragment: {
  108494. name: string;
  108495. shader: string;
  108496. };
  108497. }
  108498. declare module BABYLON {
  108499. /** @hidden */
  108500. export var kernelBlurFragment2: {
  108501. name: string;
  108502. shader: string;
  108503. };
  108504. }
  108505. declare module BABYLON {
  108506. /** @hidden */
  108507. export var kernelBlurPixelShader: {
  108508. name: string;
  108509. shader: string;
  108510. };
  108511. }
  108512. declare module BABYLON {
  108513. /** @hidden */
  108514. export var kernelBlurVertex: {
  108515. name: string;
  108516. shader: string;
  108517. };
  108518. }
  108519. declare module BABYLON {
  108520. /** @hidden */
  108521. export var kernelBlurVertexShader: {
  108522. name: string;
  108523. shader: string;
  108524. };
  108525. }
  108526. declare module BABYLON {
  108527. /**
  108528. * The Blur Post Process which blurs an image based on a kernel and direction.
  108529. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  108530. */
  108531. export class BlurPostProcess extends PostProcess {
  108532. private blockCompilation;
  108533. protected _kernel: number;
  108534. protected _idealKernel: number;
  108535. protected _packedFloat: boolean;
  108536. private _staticDefines;
  108537. /** The direction in which to blur the image. */
  108538. direction: Vector2;
  108539. /**
  108540. * Sets the length in pixels of the blur sample region
  108541. */
  108542. set kernel(v: number);
  108543. /**
  108544. * Gets the length in pixels of the blur sample region
  108545. */
  108546. get kernel(): number;
  108547. /**
  108548. * Sets wether or not the blur needs to unpack/repack floats
  108549. */
  108550. set packedFloat(v: boolean);
  108551. /**
  108552. * Gets wether or not the blur is unpacking/repacking floats
  108553. */
  108554. get packedFloat(): boolean;
  108555. /**
  108556. * Gets a string identifying the name of the class
  108557. * @returns "BlurPostProcess" string
  108558. */
  108559. getClassName(): string;
  108560. /**
  108561. * Creates a new instance BlurPostProcess
  108562. * @param name The name of the effect.
  108563. * @param direction The direction in which to blur the image.
  108564. * @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.
  108565. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  108566. * @param camera The camera to apply the render pass to.
  108567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108568. * @param engine The engine which the post process will be applied. (default: current engine)
  108569. * @param reusable If the post process can be reused on the same frame. (default: false)
  108570. * @param textureType Type of textures used when performing the post process. (default: 0)
  108571. * @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)
  108572. */
  108573. 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);
  108574. /**
  108575. * Updates the effect with the current post process compile time values and recompiles the shader.
  108576. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108577. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108578. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108579. * @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
  108580. * @param onCompiled Called when the shader has been compiled.
  108581. * @param onError Called if there is an error when compiling a shader.
  108582. */
  108583. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108584. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108585. /**
  108586. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  108587. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  108588. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  108589. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  108590. * The gaps between physical kernels are compensated for in the weighting of the samples
  108591. * @param idealKernel Ideal blur kernel.
  108592. * @return Nearest best kernel.
  108593. */
  108594. protected _nearestBestKernel(idealKernel: number): number;
  108595. /**
  108596. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  108597. * @param x The point on the Gaussian distribution to sample.
  108598. * @return the value of the Gaussian function at x.
  108599. */
  108600. protected _gaussianWeight(x: number): number;
  108601. /**
  108602. * Generates a string that can be used as a floating point number in GLSL.
  108603. * @param x Value to print.
  108604. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  108605. * @return GLSL float string.
  108606. */
  108607. protected _glslFloat(x: number, decimalFigures?: number): string;
  108608. /** @hidden */
  108609. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  108610. }
  108611. }
  108612. declare module BABYLON {
  108613. /**
  108614. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108615. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108616. * You can then easily use it as a reflectionTexture on a flat surface.
  108617. * In case the surface is not a plane, please consider relying on reflection probes.
  108618. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108619. */
  108620. export class MirrorTexture extends RenderTargetTexture {
  108621. private scene;
  108622. /**
  108623. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  108624. * 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.
  108625. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108626. */
  108627. mirrorPlane: Plane;
  108628. /**
  108629. * Define the blur ratio used to blur the reflection if needed.
  108630. */
  108631. set blurRatio(value: number);
  108632. get blurRatio(): number;
  108633. /**
  108634. * Define the adaptive blur kernel used to blur the reflection if needed.
  108635. * This will autocompute the closest best match for the `blurKernel`
  108636. */
  108637. set adaptiveBlurKernel(value: number);
  108638. /**
  108639. * Define the blur kernel used to blur the reflection if needed.
  108640. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108641. */
  108642. set blurKernel(value: number);
  108643. /**
  108644. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108645. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108646. */
  108647. set blurKernelX(value: number);
  108648. get blurKernelX(): number;
  108649. /**
  108650. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108651. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108652. */
  108653. set blurKernelY(value: number);
  108654. get blurKernelY(): number;
  108655. private _autoComputeBlurKernel;
  108656. protected _onRatioRescale(): void;
  108657. private _updateGammaSpace;
  108658. private _imageProcessingConfigChangeObserver;
  108659. private _transformMatrix;
  108660. private _mirrorMatrix;
  108661. private _savedViewMatrix;
  108662. private _blurX;
  108663. private _blurY;
  108664. private _adaptiveBlurKernel;
  108665. private _blurKernelX;
  108666. private _blurKernelY;
  108667. private _blurRatio;
  108668. /**
  108669. * Instantiates a Mirror Texture.
  108670. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108671. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108672. * You can then easily use it as a reflectionTexture on a flat surface.
  108673. * In case the surface is not a plane, please consider relying on reflection probes.
  108674. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108675. * @param name
  108676. * @param size
  108677. * @param scene
  108678. * @param generateMipMaps
  108679. * @param type
  108680. * @param samplingMode
  108681. * @param generateDepthBuffer
  108682. */
  108683. constructor(name: string, size: number | {
  108684. width: number;
  108685. height: number;
  108686. } | {
  108687. ratio: number;
  108688. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108689. private _preparePostProcesses;
  108690. /**
  108691. * Clone the mirror texture.
  108692. * @returns the cloned texture
  108693. */
  108694. clone(): MirrorTexture;
  108695. /**
  108696. * Serialize the texture to a JSON representation you could use in Parse later on
  108697. * @returns the serialized JSON representation
  108698. */
  108699. serialize(): any;
  108700. /**
  108701. * Dispose the texture and release its associated resources.
  108702. */
  108703. dispose(): void;
  108704. }
  108705. }
  108706. declare module BABYLON {
  108707. /**
  108708. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108709. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108710. */
  108711. export class Texture extends BaseTexture {
  108712. /**
  108713. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108714. */
  108715. static SerializeBuffers: boolean;
  108716. /** @hidden */
  108717. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108718. /** @hidden */
  108719. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108720. /** @hidden */
  108721. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108722. /** nearest is mag = nearest and min = nearest and mip = linear */
  108723. static readonly NEAREST_SAMPLINGMODE: number;
  108724. /** nearest is mag = nearest and min = nearest and mip = linear */
  108725. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108726. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108727. static readonly BILINEAR_SAMPLINGMODE: number;
  108728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108729. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108730. /** Trilinear is mag = linear and min = linear and mip = linear */
  108731. static readonly TRILINEAR_SAMPLINGMODE: number;
  108732. /** Trilinear is mag = linear and min = linear and mip = linear */
  108733. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108734. /** mag = nearest and min = nearest and mip = nearest */
  108735. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108736. /** mag = nearest and min = linear and mip = nearest */
  108737. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108738. /** mag = nearest and min = linear and mip = linear */
  108739. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108740. /** mag = nearest and min = linear and mip = none */
  108741. static readonly NEAREST_LINEAR: number;
  108742. /** mag = nearest and min = nearest and mip = none */
  108743. static readonly NEAREST_NEAREST: number;
  108744. /** mag = linear and min = nearest and mip = nearest */
  108745. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108746. /** mag = linear and min = nearest and mip = linear */
  108747. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108748. /** mag = linear and min = linear and mip = none */
  108749. static readonly LINEAR_LINEAR: number;
  108750. /** mag = linear and min = nearest and mip = none */
  108751. static readonly LINEAR_NEAREST: number;
  108752. /** Explicit coordinates mode */
  108753. static readonly EXPLICIT_MODE: number;
  108754. /** Spherical coordinates mode */
  108755. static readonly SPHERICAL_MODE: number;
  108756. /** Planar coordinates mode */
  108757. static readonly PLANAR_MODE: number;
  108758. /** Cubic coordinates mode */
  108759. static readonly CUBIC_MODE: number;
  108760. /** Projection coordinates mode */
  108761. static readonly PROJECTION_MODE: number;
  108762. /** Inverse Cubic coordinates mode */
  108763. static readonly SKYBOX_MODE: number;
  108764. /** Inverse Cubic coordinates mode */
  108765. static readonly INVCUBIC_MODE: number;
  108766. /** Equirectangular coordinates mode */
  108767. static readonly EQUIRECTANGULAR_MODE: number;
  108768. /** Equirectangular Fixed coordinates mode */
  108769. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108770. /** Equirectangular Fixed Mirrored coordinates mode */
  108771. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108772. /** Texture is not repeating outside of 0..1 UVs */
  108773. static readonly CLAMP_ADDRESSMODE: number;
  108774. /** Texture is repeating outside of 0..1 UVs */
  108775. static readonly WRAP_ADDRESSMODE: number;
  108776. /** Texture is repeating and mirrored */
  108777. static readonly MIRROR_ADDRESSMODE: number;
  108778. /**
  108779. * 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
  108780. */
  108781. static UseSerializedUrlIfAny: boolean;
  108782. /**
  108783. * Define the url of the texture.
  108784. */
  108785. url: Nullable<string>;
  108786. /**
  108787. * Define an offset on the texture to offset the u coordinates of the UVs
  108788. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108789. */
  108790. uOffset: number;
  108791. /**
  108792. * Define an offset on the texture to offset the v coordinates of the UVs
  108793. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108794. */
  108795. vOffset: number;
  108796. /**
  108797. * Define an offset on the texture to scale the u coordinates of the UVs
  108798. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108799. */
  108800. uScale: number;
  108801. /**
  108802. * Define an offset on the texture to scale the v coordinates of the UVs
  108803. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108804. */
  108805. vScale: number;
  108806. /**
  108807. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108808. * @see https://doc.babylonjs.com/how_to/more_materials
  108809. */
  108810. uAng: number;
  108811. /**
  108812. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108813. * @see https://doc.babylonjs.com/how_to/more_materials
  108814. */
  108815. vAng: number;
  108816. /**
  108817. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108818. * @see https://doc.babylonjs.com/how_to/more_materials
  108819. */
  108820. wAng: number;
  108821. /**
  108822. * Defines the center of rotation (U)
  108823. */
  108824. uRotationCenter: number;
  108825. /**
  108826. * Defines the center of rotation (V)
  108827. */
  108828. vRotationCenter: number;
  108829. /**
  108830. * Defines the center of rotation (W)
  108831. */
  108832. wRotationCenter: number;
  108833. /**
  108834. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108835. */
  108836. homogeneousRotationInUVTransform: boolean;
  108837. /**
  108838. * Are mip maps generated for this texture or not.
  108839. */
  108840. get noMipmap(): boolean;
  108841. /**
  108842. * List of inspectable custom properties (used by the Inspector)
  108843. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108844. */
  108845. inspectableCustomProperties: Nullable<IInspectable[]>;
  108846. private _noMipmap;
  108847. /** @hidden */
  108848. _invertY: boolean;
  108849. private _rowGenerationMatrix;
  108850. private _cachedTextureMatrix;
  108851. private _projectionModeMatrix;
  108852. private _t0;
  108853. private _t1;
  108854. private _t2;
  108855. private _cachedUOffset;
  108856. private _cachedVOffset;
  108857. private _cachedUScale;
  108858. private _cachedVScale;
  108859. private _cachedUAng;
  108860. private _cachedVAng;
  108861. private _cachedWAng;
  108862. private _cachedProjectionMatrixId;
  108863. private _cachedURotationCenter;
  108864. private _cachedVRotationCenter;
  108865. private _cachedWRotationCenter;
  108866. private _cachedHomogeneousRotationInUVTransform;
  108867. private _cachedCoordinatesMode;
  108868. /** @hidden */
  108869. protected _initialSamplingMode: number;
  108870. /** @hidden */
  108871. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108872. private _deleteBuffer;
  108873. protected _format: Nullable<number>;
  108874. private _delayedOnLoad;
  108875. private _delayedOnError;
  108876. private _mimeType?;
  108877. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  108878. get mimeType(): string | undefined;
  108879. /**
  108880. * Observable triggered once the texture has been loaded.
  108881. */
  108882. onLoadObservable: Observable<Texture>;
  108883. protected _isBlocking: boolean;
  108884. /**
  108885. * Is the texture preventing material to render while loading.
  108886. * If false, a default texture will be used instead of the loading one during the preparation step.
  108887. */
  108888. set isBlocking(value: boolean);
  108889. get isBlocking(): boolean;
  108890. /**
  108891. * Get the current sampling mode associated with the texture.
  108892. */
  108893. get samplingMode(): number;
  108894. /**
  108895. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  108896. */
  108897. get invertY(): boolean;
  108898. /**
  108899. * Instantiates a new texture.
  108900. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108901. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108902. * @param url defines the url of the picture to load as a texture
  108903. * @param sceneOrEngine defines the scene or engine the texture will belong to
  108904. * @param noMipmap defines if the texture will require mip maps or not
  108905. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  108906. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108907. * @param onLoad defines a callback triggered when the texture has been loaded
  108908. * @param onError defines a callback triggered when an error occurred during the loading session
  108909. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  108910. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  108911. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108912. * @param mimeType defines an optional mime type information
  108913. */
  108914. 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);
  108915. /**
  108916. * Update the url (and optional buffer) of this texture if url was null during construction.
  108917. * @param url the url of the texture
  108918. * @param buffer the buffer of the texture (defaults to null)
  108919. * @param onLoad callback called when the texture is loaded (defaults to null)
  108920. */
  108921. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  108922. /**
  108923. * Finish the loading sequence of a texture flagged as delayed load.
  108924. * @hidden
  108925. */
  108926. delayLoad(): void;
  108927. private _prepareRowForTextureGeneration;
  108928. /**
  108929. * Checks if the texture has the same transform matrix than another texture
  108930. * @param texture texture to check against
  108931. * @returns true if the transforms are the same, else false
  108932. */
  108933. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  108934. /**
  108935. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  108936. * @returns the transform matrix of the texture.
  108937. */
  108938. getTextureMatrix(uBase?: number): Matrix;
  108939. /**
  108940. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  108941. * @returns The reflection texture transform
  108942. */
  108943. getReflectionTextureMatrix(): Matrix;
  108944. /**
  108945. * Clones the texture.
  108946. * @returns the cloned texture
  108947. */
  108948. clone(): Texture;
  108949. /**
  108950. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  108951. * @returns The JSON representation of the texture
  108952. */
  108953. serialize(): any;
  108954. /**
  108955. * Get the current class name of the texture useful for serialization or dynamic coding.
  108956. * @returns "Texture"
  108957. */
  108958. getClassName(): string;
  108959. /**
  108960. * Dispose the texture and release its associated resources.
  108961. */
  108962. dispose(): void;
  108963. /**
  108964. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  108965. * @param parsedTexture Define the JSON representation of the texture
  108966. * @param scene Define the scene the parsed texture should be instantiated in
  108967. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108968. * @returns The parsed texture if successful
  108969. */
  108970. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  108971. /**
  108972. * Creates a texture from its base 64 representation.
  108973. * @param data Define the base64 payload without the data: prefix
  108974. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108975. * @param scene Define the scene the texture should belong to
  108976. * @param noMipmap Forces the texture to not create mip map information if true
  108977. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108978. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108979. * @param onLoad define a callback triggered when the texture has been loaded
  108980. * @param onError define a callback triggered when an error occurred during the loading session
  108981. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108982. * @returns the created texture
  108983. */
  108984. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  108985. /**
  108986. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  108987. * @param data Define the base64 payload without the data: prefix
  108988. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108989. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  108990. * @param scene Define the scene the texture should belong to
  108991. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  108992. * @param noMipmap Forces the texture to not create mip map information if true
  108993. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108994. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108995. * @param onLoad define a callback triggered when the texture has been loaded
  108996. * @param onError define a callback triggered when an error occurred during the loading session
  108997. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108998. * @returns the created texture
  108999. */
  109000. 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;
  109001. }
  109002. }
  109003. declare module BABYLON {
  109004. /**
  109005. * PostProcessManager is used to manage one or more post processes or post process pipelines
  109006. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109007. */
  109008. export class PostProcessManager {
  109009. private _scene;
  109010. private _indexBuffer;
  109011. private _vertexBuffers;
  109012. /**
  109013. * Creates a new instance PostProcess
  109014. * @param scene The scene that the post process is associated with.
  109015. */
  109016. constructor(scene: Scene);
  109017. private _prepareBuffers;
  109018. private _buildIndexBuffer;
  109019. /**
  109020. * Rebuilds the vertex buffers of the manager.
  109021. * @hidden
  109022. */
  109023. _rebuild(): void;
  109024. /**
  109025. * Prepares a frame to be run through a post process.
  109026. * @param sourceTexture The input texture to the post procesess. (default: null)
  109027. * @param postProcesses An array of post processes to be run. (default: null)
  109028. * @returns True if the post processes were able to be run.
  109029. * @hidden
  109030. */
  109031. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  109032. /**
  109033. * Manually render a set of post processes to a texture.
  109034. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  109035. * @param postProcesses An array of post processes to be run.
  109036. * @param targetTexture The target texture to render to.
  109037. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  109038. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  109039. * @param lodLevel defines which lod of the texture to render to
  109040. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  109041. */
  109042. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  109043. /**
  109044. * Finalize the result of the output of the postprocesses.
  109045. * @param doNotPresent If true the result will not be displayed to the screen.
  109046. * @param targetTexture The target texture to render to.
  109047. * @param faceIndex The index of the face to bind the target texture to.
  109048. * @param postProcesses The array of post processes to render.
  109049. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  109050. * @hidden
  109051. */
  109052. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  109053. /**
  109054. * Disposes of the post process manager.
  109055. */
  109056. dispose(): void;
  109057. }
  109058. }
  109059. declare module BABYLON {
  109060. /**
  109061. * This Helps creating a texture that will be created from a camera in your scene.
  109062. * It is basically a dynamic texture that could be used to create special effects for instance.
  109063. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  109064. */
  109065. export class RenderTargetTexture extends Texture {
  109066. /**
  109067. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  109068. */
  109069. static readonly REFRESHRATE_RENDER_ONCE: number;
  109070. /**
  109071. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  109072. */
  109073. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  109074. /**
  109075. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  109076. * the central point of your effect and can save a lot of performances.
  109077. */
  109078. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  109079. /**
  109080. * Use this predicate to dynamically define the list of mesh you want to render.
  109081. * If set, the renderList property will be overwritten.
  109082. */
  109083. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  109084. private _renderList;
  109085. /**
  109086. * Use this list to define the list of mesh you want to render.
  109087. */
  109088. get renderList(): Nullable<Array<AbstractMesh>>;
  109089. set renderList(value: Nullable<Array<AbstractMesh>>);
  109090. /**
  109091. * Use this function to overload the renderList array at rendering time.
  109092. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  109093. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  109094. * the cube (if the RTT is a cube, else layerOrFace=0).
  109095. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  109096. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  109097. * hold dummy elements!
  109098. */
  109099. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  109100. private _hookArray;
  109101. /**
  109102. * Define if particles should be rendered in your texture.
  109103. */
  109104. renderParticles: boolean;
  109105. /**
  109106. * Define if sprites should be rendered in your texture.
  109107. */
  109108. renderSprites: boolean;
  109109. /**
  109110. * Define the camera used to render the texture.
  109111. */
  109112. activeCamera: Nullable<Camera>;
  109113. /**
  109114. * Override the mesh isReady function with your own one.
  109115. */
  109116. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  109117. /**
  109118. * Override the render function of the texture with your own one.
  109119. */
  109120. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  109121. /**
  109122. * Define if camera post processes should be use while rendering the texture.
  109123. */
  109124. useCameraPostProcesses: boolean;
  109125. /**
  109126. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  109127. */
  109128. ignoreCameraViewport: boolean;
  109129. private _postProcessManager;
  109130. private _postProcesses;
  109131. private _resizeObserver;
  109132. /**
  109133. * An event triggered when the texture is unbind.
  109134. */
  109135. onBeforeBindObservable: Observable<RenderTargetTexture>;
  109136. /**
  109137. * An event triggered when the texture is unbind.
  109138. */
  109139. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  109140. private _onAfterUnbindObserver;
  109141. /**
  109142. * Set a after unbind callback in the texture.
  109143. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109144. */
  109145. set onAfterUnbind(callback: () => void);
  109146. /**
  109147. * An event triggered before rendering the texture
  109148. */
  109149. onBeforeRenderObservable: Observable<number>;
  109150. private _onBeforeRenderObserver;
  109151. /**
  109152. * Set a before render callback in the texture.
  109153. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109154. */
  109155. set onBeforeRender(callback: (faceIndex: number) => void);
  109156. /**
  109157. * An event triggered after rendering the texture
  109158. */
  109159. onAfterRenderObservable: Observable<number>;
  109160. private _onAfterRenderObserver;
  109161. /**
  109162. * Set a after render callback in the texture.
  109163. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109164. */
  109165. set onAfterRender(callback: (faceIndex: number) => void);
  109166. /**
  109167. * An event triggered after the texture clear
  109168. */
  109169. onClearObservable: Observable<Engine>;
  109170. private _onClearObserver;
  109171. /**
  109172. * Set a clear callback in the texture.
  109173. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  109174. */
  109175. set onClear(callback: (Engine: Engine) => void);
  109176. /**
  109177. * An event triggered when the texture is resized.
  109178. */
  109179. onResizeObservable: Observable<RenderTargetTexture>;
  109180. /**
  109181. * Define the clear color of the Render Target if it should be different from the scene.
  109182. */
  109183. clearColor: Color4;
  109184. protected _size: number | {
  109185. width: number;
  109186. height: number;
  109187. layers?: number;
  109188. };
  109189. protected _initialSizeParameter: number | {
  109190. width: number;
  109191. height: number;
  109192. } | {
  109193. ratio: number;
  109194. };
  109195. protected _sizeRatio: Nullable<number>;
  109196. /** @hidden */
  109197. _generateMipMaps: boolean;
  109198. protected _renderingManager: RenderingManager;
  109199. /** @hidden */
  109200. _waitingRenderList?: string[];
  109201. protected _doNotChangeAspectRatio: boolean;
  109202. protected _currentRefreshId: number;
  109203. protected _refreshRate: number;
  109204. protected _textureMatrix: Matrix;
  109205. protected _samples: number;
  109206. protected _renderTargetOptions: RenderTargetCreationOptions;
  109207. /**
  109208. * Gets render target creation options that were used.
  109209. */
  109210. get renderTargetOptions(): RenderTargetCreationOptions;
  109211. protected _onRatioRescale(): void;
  109212. /**
  109213. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  109214. * It must define where the camera used to render the texture is set
  109215. */
  109216. boundingBoxPosition: Vector3;
  109217. private _boundingBoxSize;
  109218. /**
  109219. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  109220. * When defined, the cubemap will switch to local mode
  109221. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  109222. * @example https://www.babylonjs-playground.com/#RNASML
  109223. */
  109224. set boundingBoxSize(value: Vector3);
  109225. get boundingBoxSize(): Vector3;
  109226. /**
  109227. * In case the RTT has been created with a depth texture, get the associated
  109228. * depth texture.
  109229. * Otherwise, return null.
  109230. */
  109231. get depthStencilTexture(): Nullable<InternalTexture>;
  109232. /**
  109233. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  109234. * or used a shadow, depth texture...
  109235. * @param name The friendly name of the texture
  109236. * @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)
  109237. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  109238. * @param generateMipMaps True if mip maps need to be generated after render.
  109239. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  109240. * @param type The type of the buffer in the RTT (int, half float, float...)
  109241. * @param isCube True if a cube texture needs to be created
  109242. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  109243. * @param generateDepthBuffer True to generate a depth buffer
  109244. * @param generateStencilBuffer True to generate a stencil buffer
  109245. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  109246. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  109247. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109248. */
  109249. constructor(name: string, size: number | {
  109250. width: number;
  109251. height: number;
  109252. layers?: number;
  109253. } | {
  109254. ratio: number;
  109255. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  109256. /**
  109257. * Creates a depth stencil texture.
  109258. * This is only available in WebGL 2 or with the depth texture extension available.
  109259. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  109260. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  109261. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  109262. */
  109263. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  109264. private _processSizeParameter;
  109265. /**
  109266. * Define the number of samples to use in case of MSAA.
  109267. * It defaults to one meaning no MSAA has been enabled.
  109268. */
  109269. get samples(): number;
  109270. set samples(value: number);
  109271. /**
  109272. * Resets the refresh counter of the texture and start bak from scratch.
  109273. * Could be useful to regenerate the texture if it is setup to render only once.
  109274. */
  109275. resetRefreshCounter(): void;
  109276. /**
  109277. * Define the refresh rate of the texture or the rendering frequency.
  109278. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  109279. */
  109280. get refreshRate(): number;
  109281. set refreshRate(value: number);
  109282. /**
  109283. * Adds a post process to the render target rendering passes.
  109284. * @param postProcess define the post process to add
  109285. */
  109286. addPostProcess(postProcess: PostProcess): void;
  109287. /**
  109288. * Clear all the post processes attached to the render target
  109289. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  109290. */
  109291. clearPostProcesses(dispose?: boolean): void;
  109292. /**
  109293. * Remove one of the post process from the list of attached post processes to the texture
  109294. * @param postProcess define the post process to remove from the list
  109295. */
  109296. removePostProcess(postProcess: PostProcess): void;
  109297. /** @hidden */
  109298. _shouldRender(): boolean;
  109299. /**
  109300. * Gets the actual render size of the texture.
  109301. * @returns the width of the render size
  109302. */
  109303. getRenderSize(): number;
  109304. /**
  109305. * Gets the actual render width of the texture.
  109306. * @returns the width of the render size
  109307. */
  109308. getRenderWidth(): number;
  109309. /**
  109310. * Gets the actual render height of the texture.
  109311. * @returns the height of the render size
  109312. */
  109313. getRenderHeight(): number;
  109314. /**
  109315. * Gets the actual number of layers of the texture.
  109316. * @returns the number of layers
  109317. */
  109318. getRenderLayers(): number;
  109319. /**
  109320. * Get if the texture can be rescaled or not.
  109321. */
  109322. get canRescale(): boolean;
  109323. /**
  109324. * Resize the texture using a ratio.
  109325. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  109326. */
  109327. scale(ratio: number): void;
  109328. /**
  109329. * Get the texture reflection matrix used to rotate/transform the reflection.
  109330. * @returns the reflection matrix
  109331. */
  109332. getReflectionTextureMatrix(): Matrix;
  109333. /**
  109334. * Resize the texture to a new desired size.
  109335. * Be carrefull as it will recreate all the data in the new texture.
  109336. * @param size Define the new size. It can be:
  109337. * - a number for squared texture,
  109338. * - an object containing { width: number, height: number }
  109339. * - or an object containing a ratio { ratio: number }
  109340. */
  109341. resize(size: number | {
  109342. width: number;
  109343. height: number;
  109344. } | {
  109345. ratio: number;
  109346. }): void;
  109347. private _defaultRenderListPrepared;
  109348. /**
  109349. * Renders all the objects from the render list into the texture.
  109350. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  109351. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  109352. */
  109353. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  109354. private _bestReflectionRenderTargetDimension;
  109355. private _prepareRenderingManager;
  109356. /**
  109357. * @hidden
  109358. * @param faceIndex face index to bind to if this is a cubetexture
  109359. * @param layer defines the index of the texture to bind in the array
  109360. */
  109361. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  109362. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109363. private renderToTarget;
  109364. /**
  109365. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109366. * This allowed control for front to back rendering or reversly depending of the special needs.
  109367. *
  109368. * @param renderingGroupId The rendering group id corresponding to its index
  109369. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109370. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109371. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109372. */
  109373. 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;
  109374. /**
  109375. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109376. *
  109377. * @param renderingGroupId The rendering group id corresponding to its index
  109378. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109379. */
  109380. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  109381. /**
  109382. * Clones the texture.
  109383. * @returns the cloned texture
  109384. */
  109385. clone(): RenderTargetTexture;
  109386. /**
  109387. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109388. * @returns The JSON representation of the texture
  109389. */
  109390. serialize(): any;
  109391. /**
  109392. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  109393. */
  109394. disposeFramebufferObjects(): void;
  109395. /**
  109396. * Dispose the texture and release its associated resources.
  109397. */
  109398. dispose(): void;
  109399. /** @hidden */
  109400. _rebuild(): void;
  109401. /**
  109402. * Clear the info related to rendering groups preventing retention point in material dispose.
  109403. */
  109404. freeRenderingGroups(): void;
  109405. /**
  109406. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  109407. * @returns the view count
  109408. */
  109409. getViewCount(): number;
  109410. }
  109411. }
  109412. declare module BABYLON {
  109413. /**
  109414. * Class used to manipulate GUIDs
  109415. */
  109416. export class GUID {
  109417. /**
  109418. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  109419. * Be aware Math.random() could cause collisions, but:
  109420. * "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"
  109421. * @returns a pseudo random id
  109422. */
  109423. static RandomId(): string;
  109424. }
  109425. }
  109426. declare module BABYLON {
  109427. /**
  109428. * Options to be used when creating a shadow depth material
  109429. */
  109430. export interface IIOptionShadowDepthMaterial {
  109431. /** Variables in the vertex shader code that need to have their names remapped.
  109432. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  109433. * "var_name" should be either: worldPos or vNormalW
  109434. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  109435. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  109436. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  109437. */
  109438. remappedVariables?: string[];
  109439. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  109440. standalone?: boolean;
  109441. }
  109442. /**
  109443. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  109444. */
  109445. export class ShadowDepthWrapper {
  109446. private _scene;
  109447. private _options?;
  109448. private _baseMaterial;
  109449. private _onEffectCreatedObserver;
  109450. private _subMeshToEffect;
  109451. private _subMeshToDepthEffect;
  109452. private _meshes;
  109453. /** @hidden */
  109454. _matriceNames: any;
  109455. /** Gets the standalone status of the wrapper */
  109456. get standalone(): boolean;
  109457. /** Gets the base material the wrapper is built upon */
  109458. get baseMaterial(): Material;
  109459. /**
  109460. * Instantiate a new shadow depth wrapper.
  109461. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  109462. * generate the shadow depth map. For more information, please refer to the documentation:
  109463. * https://doc.babylonjs.com/babylon101/shadows
  109464. * @param baseMaterial Material to wrap
  109465. * @param scene Define the scene the material belongs to
  109466. * @param options Options used to create the wrapper
  109467. */
  109468. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  109469. /**
  109470. * Gets the effect to use to generate the depth map
  109471. * @param subMesh subMesh to get the effect for
  109472. * @param shadowGenerator shadow generator to get the effect for
  109473. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  109474. */
  109475. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  109476. /**
  109477. * Specifies that the submesh is ready to be used for depth rendering
  109478. * @param subMesh submesh to check
  109479. * @param defines the list of defines to take into account when checking the effect
  109480. * @param shadowGenerator combined with subMesh, it defines the effect to check
  109481. * @param useInstances specifies that instances should be used
  109482. * @returns a boolean indicating that the submesh is ready or not
  109483. */
  109484. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  109485. /**
  109486. * Disposes the resources
  109487. */
  109488. dispose(): void;
  109489. private _makeEffect;
  109490. }
  109491. }
  109492. declare module BABYLON {
  109493. /**
  109494. * Options for compiling materials.
  109495. */
  109496. export interface IMaterialCompilationOptions {
  109497. /**
  109498. * Defines whether clip planes are enabled.
  109499. */
  109500. clipPlane: boolean;
  109501. /**
  109502. * Defines whether instances are enabled.
  109503. */
  109504. useInstances: boolean;
  109505. }
  109506. /**
  109507. * Options passed when calling customShaderNameResolve
  109508. */
  109509. export interface ICustomShaderNameResolveOptions {
  109510. /**
  109511. * 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
  109512. */
  109513. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  109514. }
  109515. /**
  109516. * Base class for the main features of a material in Babylon.js
  109517. */
  109518. export class Material implements IAnimatable {
  109519. /**
  109520. * Returns the triangle fill mode
  109521. */
  109522. static readonly TriangleFillMode: number;
  109523. /**
  109524. * Returns the wireframe mode
  109525. */
  109526. static readonly WireFrameFillMode: number;
  109527. /**
  109528. * Returns the point fill mode
  109529. */
  109530. static readonly PointFillMode: number;
  109531. /**
  109532. * Returns the point list draw mode
  109533. */
  109534. static readonly PointListDrawMode: number;
  109535. /**
  109536. * Returns the line list draw mode
  109537. */
  109538. static readonly LineListDrawMode: number;
  109539. /**
  109540. * Returns the line loop draw mode
  109541. */
  109542. static readonly LineLoopDrawMode: number;
  109543. /**
  109544. * Returns the line strip draw mode
  109545. */
  109546. static readonly LineStripDrawMode: number;
  109547. /**
  109548. * Returns the triangle strip draw mode
  109549. */
  109550. static readonly TriangleStripDrawMode: number;
  109551. /**
  109552. * Returns the triangle fan draw mode
  109553. */
  109554. static readonly TriangleFanDrawMode: number;
  109555. /**
  109556. * Stores the clock-wise side orientation
  109557. */
  109558. static readonly ClockWiseSideOrientation: number;
  109559. /**
  109560. * Stores the counter clock-wise side orientation
  109561. */
  109562. static readonly CounterClockWiseSideOrientation: number;
  109563. /**
  109564. * The dirty texture flag value
  109565. */
  109566. static readonly TextureDirtyFlag: number;
  109567. /**
  109568. * The dirty light flag value
  109569. */
  109570. static readonly LightDirtyFlag: number;
  109571. /**
  109572. * The dirty fresnel flag value
  109573. */
  109574. static readonly FresnelDirtyFlag: number;
  109575. /**
  109576. * The dirty attribute flag value
  109577. */
  109578. static readonly AttributesDirtyFlag: number;
  109579. /**
  109580. * The dirty misc flag value
  109581. */
  109582. static readonly MiscDirtyFlag: number;
  109583. /**
  109584. * The dirty prepass flag value
  109585. */
  109586. static readonly PrePassDirtyFlag: number;
  109587. /**
  109588. * The all dirty flag value
  109589. */
  109590. static readonly AllDirtyFlag: number;
  109591. /**
  109592. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109593. */
  109594. static readonly MATERIAL_OPAQUE: number;
  109595. /**
  109596. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109597. */
  109598. static readonly MATERIAL_ALPHATEST: number;
  109599. /**
  109600. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109601. */
  109602. static readonly MATERIAL_ALPHABLEND: number;
  109603. /**
  109604. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109605. * They are also discarded below the alpha cutoff threshold to improve performances.
  109606. */
  109607. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  109608. /**
  109609. * The Whiteout method is used to blend normals.
  109610. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109611. */
  109612. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  109613. /**
  109614. * The Reoriented Normal Mapping method is used to blend normals.
  109615. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  109616. */
  109617. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  109618. /**
  109619. * Custom callback helping to override the default shader used in the material.
  109620. */
  109621. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  109622. /**
  109623. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  109624. */
  109625. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  109626. /**
  109627. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  109628. * This means that the material can keep using a previous shader while a new one is being compiled.
  109629. * This is mostly used when shader parallel compilation is supported (true by default)
  109630. */
  109631. allowShaderHotSwapping: boolean;
  109632. /**
  109633. * The ID of the material
  109634. */
  109635. id: string;
  109636. /**
  109637. * Gets or sets the unique id of the material
  109638. */
  109639. uniqueId: number;
  109640. /**
  109641. * The name of the material
  109642. */
  109643. name: string;
  109644. /**
  109645. * Gets or sets user defined metadata
  109646. */
  109647. metadata: any;
  109648. /**
  109649. * For internal use only. Please do not use.
  109650. */
  109651. reservedDataStore: any;
  109652. /**
  109653. * Specifies if the ready state should be checked on each call
  109654. */
  109655. checkReadyOnEveryCall: boolean;
  109656. /**
  109657. * Specifies if the ready state should be checked once
  109658. */
  109659. checkReadyOnlyOnce: boolean;
  109660. /**
  109661. * The state of the material
  109662. */
  109663. state: string;
  109664. /**
  109665. * If the material can be rendered to several textures with MRT extension
  109666. */
  109667. get canRenderToMRT(): boolean;
  109668. /**
  109669. * The alpha value of the material
  109670. */
  109671. protected _alpha: number;
  109672. /**
  109673. * List of inspectable custom properties (used by the Inspector)
  109674. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109675. */
  109676. inspectableCustomProperties: IInspectable[];
  109677. /**
  109678. * Sets the alpha value of the material
  109679. */
  109680. set alpha(value: number);
  109681. /**
  109682. * Gets the alpha value of the material
  109683. */
  109684. get alpha(): number;
  109685. /**
  109686. * Specifies if back face culling is enabled
  109687. */
  109688. protected _backFaceCulling: boolean;
  109689. /**
  109690. * Sets the back-face culling state
  109691. */
  109692. set backFaceCulling(value: boolean);
  109693. /**
  109694. * Gets the back-face culling state
  109695. */
  109696. get backFaceCulling(): boolean;
  109697. /**
  109698. * Stores the value for side orientation
  109699. */
  109700. sideOrientation: number;
  109701. /**
  109702. * Callback triggered when the material is compiled
  109703. */
  109704. onCompiled: Nullable<(effect: Effect) => void>;
  109705. /**
  109706. * Callback triggered when an error occurs
  109707. */
  109708. onError: Nullable<(effect: Effect, errors: string) => void>;
  109709. /**
  109710. * Callback triggered to get the render target textures
  109711. */
  109712. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  109713. /**
  109714. * Gets a boolean indicating that current material needs to register RTT
  109715. */
  109716. get hasRenderTargetTextures(): boolean;
  109717. /**
  109718. * Specifies if the material should be serialized
  109719. */
  109720. doNotSerialize: boolean;
  109721. /**
  109722. * @hidden
  109723. */
  109724. _storeEffectOnSubMeshes: boolean;
  109725. /**
  109726. * Stores the animations for the material
  109727. */
  109728. animations: Nullable<Array<Animation>>;
  109729. /**
  109730. * An event triggered when the material is disposed
  109731. */
  109732. onDisposeObservable: Observable<Material>;
  109733. /**
  109734. * An observer which watches for dispose events
  109735. */
  109736. private _onDisposeObserver;
  109737. private _onUnBindObservable;
  109738. /**
  109739. * Called during a dispose event
  109740. */
  109741. set onDispose(callback: () => void);
  109742. private _onBindObservable;
  109743. /**
  109744. * An event triggered when the material is bound
  109745. */
  109746. get onBindObservable(): Observable<AbstractMesh>;
  109747. /**
  109748. * An observer which watches for bind events
  109749. */
  109750. private _onBindObserver;
  109751. /**
  109752. * Called during a bind event
  109753. */
  109754. set onBind(callback: (Mesh: AbstractMesh) => void);
  109755. /**
  109756. * An event triggered when the material is unbound
  109757. */
  109758. get onUnBindObservable(): Observable<Material>;
  109759. protected _onEffectCreatedObservable: Nullable<Observable<{
  109760. effect: Effect;
  109761. subMesh: Nullable<SubMesh>;
  109762. }>>;
  109763. /**
  109764. * An event triggered when the effect is (re)created
  109765. */
  109766. get onEffectCreatedObservable(): Observable<{
  109767. effect: Effect;
  109768. subMesh: Nullable<SubMesh>;
  109769. }>;
  109770. /**
  109771. * Stores the value of the alpha mode
  109772. */
  109773. private _alphaMode;
  109774. /**
  109775. * Sets the value of the alpha mode.
  109776. *
  109777. * | Value | Type | Description |
  109778. * | --- | --- | --- |
  109779. * | 0 | ALPHA_DISABLE | |
  109780. * | 1 | ALPHA_ADD | |
  109781. * | 2 | ALPHA_COMBINE | |
  109782. * | 3 | ALPHA_SUBTRACT | |
  109783. * | 4 | ALPHA_MULTIPLY | |
  109784. * | 5 | ALPHA_MAXIMIZED | |
  109785. * | 6 | ALPHA_ONEONE | |
  109786. * | 7 | ALPHA_PREMULTIPLIED | |
  109787. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  109788. * | 9 | ALPHA_INTERPOLATE | |
  109789. * | 10 | ALPHA_SCREENMODE | |
  109790. *
  109791. */
  109792. set alphaMode(value: number);
  109793. /**
  109794. * Gets the value of the alpha mode
  109795. */
  109796. get alphaMode(): number;
  109797. /**
  109798. * Stores the state of the need depth pre-pass value
  109799. */
  109800. private _needDepthPrePass;
  109801. /**
  109802. * Sets the need depth pre-pass value
  109803. */
  109804. set needDepthPrePass(value: boolean);
  109805. /**
  109806. * Gets the depth pre-pass value
  109807. */
  109808. get needDepthPrePass(): boolean;
  109809. /**
  109810. * Specifies if depth writing should be disabled
  109811. */
  109812. disableDepthWrite: boolean;
  109813. /**
  109814. * Specifies if color writing should be disabled
  109815. */
  109816. disableColorWrite: boolean;
  109817. /**
  109818. * Specifies if depth writing should be forced
  109819. */
  109820. forceDepthWrite: boolean;
  109821. /**
  109822. * Specifies the depth function that should be used. 0 means the default engine function
  109823. */
  109824. depthFunction: number;
  109825. /**
  109826. * Specifies if there should be a separate pass for culling
  109827. */
  109828. separateCullingPass: boolean;
  109829. /**
  109830. * Stores the state specifing if fog should be enabled
  109831. */
  109832. private _fogEnabled;
  109833. /**
  109834. * Sets the state for enabling fog
  109835. */
  109836. set fogEnabled(value: boolean);
  109837. /**
  109838. * Gets the value of the fog enabled state
  109839. */
  109840. get fogEnabled(): boolean;
  109841. /**
  109842. * Stores the size of points
  109843. */
  109844. pointSize: number;
  109845. /**
  109846. * Stores the z offset value
  109847. */
  109848. zOffset: number;
  109849. get wireframe(): boolean;
  109850. /**
  109851. * Sets the state of wireframe mode
  109852. */
  109853. set wireframe(value: boolean);
  109854. /**
  109855. * Gets the value specifying if point clouds are enabled
  109856. */
  109857. get pointsCloud(): boolean;
  109858. /**
  109859. * Sets the state of point cloud mode
  109860. */
  109861. set pointsCloud(value: boolean);
  109862. /**
  109863. * Gets the material fill mode
  109864. */
  109865. get fillMode(): number;
  109866. /**
  109867. * Sets the material fill mode
  109868. */
  109869. set fillMode(value: number);
  109870. /**
  109871. * @hidden
  109872. * Stores the effects for the material
  109873. */
  109874. _effect: Nullable<Effect>;
  109875. /**
  109876. * Specifies if uniform buffers should be used
  109877. */
  109878. private _useUBO;
  109879. /**
  109880. * Stores a reference to the scene
  109881. */
  109882. private _scene;
  109883. /**
  109884. * Stores the fill mode state
  109885. */
  109886. private _fillMode;
  109887. /**
  109888. * Specifies if the depth write state should be cached
  109889. */
  109890. private _cachedDepthWriteState;
  109891. /**
  109892. * Specifies if the color write state should be cached
  109893. */
  109894. private _cachedColorWriteState;
  109895. /**
  109896. * Specifies if the depth function state should be cached
  109897. */
  109898. private _cachedDepthFunctionState;
  109899. /**
  109900. * Stores the uniform buffer
  109901. */
  109902. protected _uniformBuffer: UniformBuffer;
  109903. /** @hidden */
  109904. _indexInSceneMaterialArray: number;
  109905. /** @hidden */
  109906. meshMap: Nullable<{
  109907. [id: string]: AbstractMesh | undefined;
  109908. }>;
  109909. /**
  109910. * Creates a material instance
  109911. * @param name defines the name of the material
  109912. * @param scene defines the scene to reference
  109913. * @param doNotAdd specifies if the material should be added to the scene
  109914. */
  109915. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  109916. /**
  109917. * Returns a string representation of the current material
  109918. * @param fullDetails defines a boolean indicating which levels of logging is desired
  109919. * @returns a string with material information
  109920. */
  109921. toString(fullDetails?: boolean): string;
  109922. /**
  109923. * Gets the class name of the material
  109924. * @returns a string with the class name of the material
  109925. */
  109926. getClassName(): string;
  109927. /**
  109928. * Specifies if updates for the material been locked
  109929. */
  109930. get isFrozen(): boolean;
  109931. /**
  109932. * Locks updates for the material
  109933. */
  109934. freeze(): void;
  109935. /**
  109936. * Unlocks updates for the material
  109937. */
  109938. unfreeze(): void;
  109939. /**
  109940. * Specifies if the material is ready to be used
  109941. * @param mesh defines the mesh to check
  109942. * @param useInstances specifies if instances should be used
  109943. * @returns a boolean indicating if the material is ready to be used
  109944. */
  109945. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  109946. /**
  109947. * Specifies that the submesh is ready to be used
  109948. * @param mesh defines the mesh to check
  109949. * @param subMesh defines which submesh to check
  109950. * @param useInstances specifies that instances should be used
  109951. * @returns a boolean indicating that the submesh is ready or not
  109952. */
  109953. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109954. /**
  109955. * Returns the material effect
  109956. * @returns the effect associated with the material
  109957. */
  109958. getEffect(): Nullable<Effect>;
  109959. /**
  109960. * Returns the current scene
  109961. * @returns a Scene
  109962. */
  109963. getScene(): Scene;
  109964. /**
  109965. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109966. */
  109967. protected _forceAlphaTest: boolean;
  109968. /**
  109969. * The transparency mode of the material.
  109970. */
  109971. protected _transparencyMode: Nullable<number>;
  109972. /**
  109973. * Gets the current transparency mode.
  109974. */
  109975. get transparencyMode(): Nullable<number>;
  109976. /**
  109977. * Sets the transparency mode of the material.
  109978. *
  109979. * | Value | Type | Description |
  109980. * | ----- | ----------------------------------- | ----------- |
  109981. * | 0 | OPAQUE | |
  109982. * | 1 | ALPHATEST | |
  109983. * | 2 | ALPHABLEND | |
  109984. * | 3 | ALPHATESTANDBLEND | |
  109985. *
  109986. */
  109987. set transparencyMode(value: Nullable<number>);
  109988. /**
  109989. * Returns true if alpha blending should be disabled.
  109990. */
  109991. protected get _disableAlphaBlending(): boolean;
  109992. /**
  109993. * Specifies whether or not this material should be rendered in alpha blend mode.
  109994. * @returns a boolean specifying if alpha blending is needed
  109995. */
  109996. needAlphaBlending(): boolean;
  109997. /**
  109998. * Specifies if the mesh will require alpha blending
  109999. * @param mesh defines the mesh to check
  110000. * @returns a boolean specifying if alpha blending is needed for the mesh
  110001. */
  110002. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110003. /**
  110004. * Specifies whether or not this material should be rendered in alpha test mode.
  110005. * @returns a boolean specifying if an alpha test is needed.
  110006. */
  110007. needAlphaTesting(): boolean;
  110008. /**
  110009. * Specifies if material alpha testing should be turned on for the mesh
  110010. * @param mesh defines the mesh to check
  110011. */
  110012. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  110013. /**
  110014. * Gets the texture used for the alpha test
  110015. * @returns the texture to use for alpha testing
  110016. */
  110017. getAlphaTestTexture(): Nullable<BaseTexture>;
  110018. /**
  110019. * Marks the material to indicate that it needs to be re-calculated
  110020. */
  110021. markDirty(): void;
  110022. /** @hidden */
  110023. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  110024. /**
  110025. * Binds the material to the mesh
  110026. * @param world defines the world transformation matrix
  110027. * @param mesh defines the mesh to bind the material to
  110028. */
  110029. bind(world: Matrix, mesh?: Mesh): void;
  110030. /**
  110031. * Binds the submesh to the material
  110032. * @param world defines the world transformation matrix
  110033. * @param mesh defines the mesh containing the submesh
  110034. * @param subMesh defines the submesh to bind the material to
  110035. */
  110036. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110037. /**
  110038. * Binds the world matrix to the material
  110039. * @param world defines the world transformation matrix
  110040. */
  110041. bindOnlyWorldMatrix(world: Matrix): void;
  110042. /**
  110043. * Binds the scene's uniform buffer to the effect.
  110044. * @param effect defines the effect to bind to the scene uniform buffer
  110045. * @param sceneUbo defines the uniform buffer storing scene data
  110046. */
  110047. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  110048. /**
  110049. * Binds the view matrix to the effect
  110050. * @param effect defines the effect to bind the view matrix to
  110051. */
  110052. bindView(effect: Effect): void;
  110053. /**
  110054. * Binds the view projection matrix to the effect
  110055. * @param effect defines the effect to bind the view projection matrix to
  110056. */
  110057. bindViewProjection(effect: Effect): void;
  110058. /**
  110059. * Processes to execute after binding the material to a mesh
  110060. * @param mesh defines the rendered mesh
  110061. */
  110062. protected _afterBind(mesh?: Mesh): void;
  110063. /**
  110064. * Unbinds the material from the mesh
  110065. */
  110066. unbind(): void;
  110067. /**
  110068. * Gets the active textures from the material
  110069. * @returns an array of textures
  110070. */
  110071. getActiveTextures(): BaseTexture[];
  110072. /**
  110073. * Specifies if the material uses a texture
  110074. * @param texture defines the texture to check against the material
  110075. * @returns a boolean specifying if the material uses the texture
  110076. */
  110077. hasTexture(texture: BaseTexture): boolean;
  110078. /**
  110079. * Makes a duplicate of the material, and gives it a new name
  110080. * @param name defines the new name for the duplicated material
  110081. * @returns the cloned material
  110082. */
  110083. clone(name: string): Nullable<Material>;
  110084. /**
  110085. * Gets the meshes bound to the material
  110086. * @returns an array of meshes bound to the material
  110087. */
  110088. getBindedMeshes(): AbstractMesh[];
  110089. /**
  110090. * Force shader compilation
  110091. * @param mesh defines the mesh associated with this material
  110092. * @param onCompiled defines a function to execute once the material is compiled
  110093. * @param options defines the options to configure the compilation
  110094. * @param onError defines a function to execute if the material fails compiling
  110095. */
  110096. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  110097. /**
  110098. * Force shader compilation
  110099. * @param mesh defines the mesh that will use this material
  110100. * @param options defines additional options for compiling the shaders
  110101. * @returns a promise that resolves when the compilation completes
  110102. */
  110103. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  110104. private static readonly _AllDirtyCallBack;
  110105. private static readonly _ImageProcessingDirtyCallBack;
  110106. private static readonly _TextureDirtyCallBack;
  110107. private static readonly _FresnelDirtyCallBack;
  110108. private static readonly _MiscDirtyCallBack;
  110109. private static readonly _PrePassDirtyCallBack;
  110110. private static readonly _LightsDirtyCallBack;
  110111. private static readonly _AttributeDirtyCallBack;
  110112. private static _FresnelAndMiscDirtyCallBack;
  110113. private static _TextureAndMiscDirtyCallBack;
  110114. private static readonly _DirtyCallbackArray;
  110115. private static readonly _RunDirtyCallBacks;
  110116. /**
  110117. * Marks a define in the material to indicate that it needs to be re-computed
  110118. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  110119. */
  110120. markAsDirty(flag: number): void;
  110121. /**
  110122. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  110123. * @param func defines a function which checks material defines against the submeshes
  110124. */
  110125. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  110126. /**
  110127. * Indicates that the scene should check if the rendering now needs a prepass
  110128. */
  110129. protected _markScenePrePassDirty(): void;
  110130. /**
  110131. * Indicates that we need to re-calculated for all submeshes
  110132. */
  110133. protected _markAllSubMeshesAsAllDirty(): void;
  110134. /**
  110135. * Indicates that image processing needs to be re-calculated for all submeshes
  110136. */
  110137. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  110138. /**
  110139. * Indicates that textures need to be re-calculated for all submeshes
  110140. */
  110141. protected _markAllSubMeshesAsTexturesDirty(): void;
  110142. /**
  110143. * Indicates that fresnel needs to be re-calculated for all submeshes
  110144. */
  110145. protected _markAllSubMeshesAsFresnelDirty(): void;
  110146. /**
  110147. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110148. */
  110149. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110150. /**
  110151. * Indicates that lights need to be re-calculated for all submeshes
  110152. */
  110153. protected _markAllSubMeshesAsLightsDirty(): void;
  110154. /**
  110155. * Indicates that attributes need to be re-calculated for all submeshes
  110156. */
  110157. protected _markAllSubMeshesAsAttributesDirty(): void;
  110158. /**
  110159. * Indicates that misc needs to be re-calculated for all submeshes
  110160. */
  110161. protected _markAllSubMeshesAsMiscDirty(): void;
  110162. /**
  110163. * Indicates that prepass needs to be re-calculated for all submeshes
  110164. */
  110165. protected _markAllSubMeshesAsPrePassDirty(): void;
  110166. /**
  110167. * Indicates that textures and misc need to be re-calculated for all submeshes
  110168. */
  110169. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  110170. /**
  110171. * Sets the required values to the prepass renderer.
  110172. * @param prePassRenderer defines the prepass renderer to setup.
  110173. * @returns true if the pre pass is needed.
  110174. */
  110175. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  110176. /**
  110177. * Disposes the material
  110178. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110179. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110180. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  110181. */
  110182. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  110183. /** @hidden */
  110184. private releaseVertexArrayObject;
  110185. /**
  110186. * Serializes this material
  110187. * @returns the serialized material object
  110188. */
  110189. serialize(): any;
  110190. /**
  110191. * Creates a material from parsed material data
  110192. * @param parsedMaterial defines parsed material data
  110193. * @param scene defines the hosting scene
  110194. * @param rootUrl defines the root URL to use to load textures
  110195. * @returns a new material
  110196. */
  110197. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  110198. }
  110199. }
  110200. declare module BABYLON {
  110201. /**
  110202. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110203. * separate meshes. This can be use to improve performances.
  110204. * @see https://doc.babylonjs.com/how_to/multi_materials
  110205. */
  110206. export class MultiMaterial extends Material {
  110207. private _subMaterials;
  110208. /**
  110209. * Gets or Sets the list of Materials used within the multi material.
  110210. * They need to be ordered according to the submeshes order in the associated mesh
  110211. */
  110212. get subMaterials(): Nullable<Material>[];
  110213. set subMaterials(value: Nullable<Material>[]);
  110214. /**
  110215. * Function used to align with Node.getChildren()
  110216. * @returns the list of Materials used within the multi material
  110217. */
  110218. getChildren(): Nullable<Material>[];
  110219. /**
  110220. * Instantiates a new Multi Material
  110221. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110222. * separate meshes. This can be use to improve performances.
  110223. * @see https://doc.babylonjs.com/how_to/multi_materials
  110224. * @param name Define the name in the scene
  110225. * @param scene Define the scene the material belongs to
  110226. */
  110227. constructor(name: string, scene: Scene);
  110228. private _hookArray;
  110229. /**
  110230. * Get one of the submaterial by its index in the submaterials array
  110231. * @param index The index to look the sub material at
  110232. * @returns The Material if the index has been defined
  110233. */
  110234. getSubMaterial(index: number): Nullable<Material>;
  110235. /**
  110236. * Get the list of active textures for the whole sub materials list.
  110237. * @returns All the textures that will be used during the rendering
  110238. */
  110239. getActiveTextures(): BaseTexture[];
  110240. /**
  110241. * Gets the current class name of the material e.g. "MultiMaterial"
  110242. * Mainly use in serialization.
  110243. * @returns the class name
  110244. */
  110245. getClassName(): string;
  110246. /**
  110247. * Checks if the material is ready to render the requested sub mesh
  110248. * @param mesh Define the mesh the submesh belongs to
  110249. * @param subMesh Define the sub mesh to look readyness for
  110250. * @param useInstances Define whether or not the material is used with instances
  110251. * @returns true if ready, otherwise false
  110252. */
  110253. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110254. /**
  110255. * Clones the current material and its related sub materials
  110256. * @param name Define the name of the newly cloned material
  110257. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  110258. * @returns the cloned material
  110259. */
  110260. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  110261. /**
  110262. * Serializes the materials into a JSON representation.
  110263. * @returns the JSON representation
  110264. */
  110265. serialize(): any;
  110266. /**
  110267. * Dispose the material and release its associated resources
  110268. * @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)
  110269. * @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)
  110270. * @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)
  110271. */
  110272. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  110273. /**
  110274. * Creates a MultiMaterial from parsed MultiMaterial data.
  110275. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  110276. * @param scene defines the hosting scene
  110277. * @returns a new MultiMaterial
  110278. */
  110279. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  110280. }
  110281. }
  110282. declare module BABYLON {
  110283. /**
  110284. * Defines a subdivision inside a mesh
  110285. */
  110286. export class SubMesh implements ICullable {
  110287. /** the material index to use */
  110288. materialIndex: number;
  110289. /** vertex index start */
  110290. verticesStart: number;
  110291. /** vertices count */
  110292. verticesCount: number;
  110293. /** index start */
  110294. indexStart: number;
  110295. /** indices count */
  110296. indexCount: number;
  110297. /** @hidden */
  110298. _materialDefines: Nullable<MaterialDefines>;
  110299. /** @hidden */
  110300. _materialEffect: Nullable<Effect>;
  110301. /** @hidden */
  110302. _effectOverride: Nullable<Effect>;
  110303. /**
  110304. * Gets material defines used by the effect associated to the sub mesh
  110305. */
  110306. get materialDefines(): Nullable<MaterialDefines>;
  110307. /**
  110308. * Sets material defines used by the effect associated to the sub mesh
  110309. */
  110310. set materialDefines(defines: Nullable<MaterialDefines>);
  110311. /**
  110312. * Gets associated effect
  110313. */
  110314. get effect(): Nullable<Effect>;
  110315. /**
  110316. * Sets associated effect (effect used to render this submesh)
  110317. * @param effect defines the effect to associate with
  110318. * @param defines defines the set of defines used to compile this effect
  110319. */
  110320. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  110321. /** @hidden */
  110322. _linesIndexCount: number;
  110323. private _mesh;
  110324. private _renderingMesh;
  110325. private _boundingInfo;
  110326. private _linesIndexBuffer;
  110327. /** @hidden */
  110328. _lastColliderWorldVertices: Nullable<Vector3[]>;
  110329. /** @hidden */
  110330. _trianglePlanes: Plane[];
  110331. /** @hidden */
  110332. _lastColliderTransformMatrix: Nullable<Matrix>;
  110333. /** @hidden */
  110334. _renderId: number;
  110335. /** @hidden */
  110336. _alphaIndex: number;
  110337. /** @hidden */
  110338. _distanceToCamera: number;
  110339. /** @hidden */
  110340. _id: number;
  110341. private _currentMaterial;
  110342. /**
  110343. * Add a new submesh to a mesh
  110344. * @param materialIndex defines the material index to use
  110345. * @param verticesStart defines vertex index start
  110346. * @param verticesCount defines vertices count
  110347. * @param indexStart defines index start
  110348. * @param indexCount defines indices count
  110349. * @param mesh defines the parent mesh
  110350. * @param renderingMesh defines an optional rendering mesh
  110351. * @param createBoundingBox defines if bounding box should be created for this submesh
  110352. * @returns the new submesh
  110353. */
  110354. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  110355. /**
  110356. * Creates a new submesh
  110357. * @param materialIndex defines the material index to use
  110358. * @param verticesStart defines vertex index start
  110359. * @param verticesCount defines vertices count
  110360. * @param indexStart defines index start
  110361. * @param indexCount defines indices count
  110362. * @param mesh defines the parent mesh
  110363. * @param renderingMesh defines an optional rendering mesh
  110364. * @param createBoundingBox defines if bounding box should be created for this submesh
  110365. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  110366. */
  110367. constructor(
  110368. /** the material index to use */
  110369. materialIndex: number,
  110370. /** vertex index start */
  110371. verticesStart: number,
  110372. /** vertices count */
  110373. verticesCount: number,
  110374. /** index start */
  110375. indexStart: number,
  110376. /** indices count */
  110377. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  110378. /**
  110379. * Returns true if this submesh covers the entire parent mesh
  110380. * @ignorenaming
  110381. */
  110382. get IsGlobal(): boolean;
  110383. /**
  110384. * Returns the submesh BoudingInfo object
  110385. * @returns current bounding info (or mesh's one if the submesh is global)
  110386. */
  110387. getBoundingInfo(): BoundingInfo;
  110388. /**
  110389. * Sets the submesh BoundingInfo
  110390. * @param boundingInfo defines the new bounding info to use
  110391. * @returns the SubMesh
  110392. */
  110393. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  110394. /**
  110395. * Returns the mesh of the current submesh
  110396. * @return the parent mesh
  110397. */
  110398. getMesh(): AbstractMesh;
  110399. /**
  110400. * Returns the rendering mesh of the submesh
  110401. * @returns the rendering mesh (could be different from parent mesh)
  110402. */
  110403. getRenderingMesh(): Mesh;
  110404. /**
  110405. * Returns the replacement mesh of the submesh
  110406. * @returns the replacement mesh (could be different from parent mesh)
  110407. */
  110408. getReplacementMesh(): Nullable<AbstractMesh>;
  110409. /**
  110410. * Returns the effective mesh of the submesh
  110411. * @returns the effective mesh (could be different from parent mesh)
  110412. */
  110413. getEffectiveMesh(): AbstractMesh;
  110414. /**
  110415. * Returns the submesh material
  110416. * @returns null or the current material
  110417. */
  110418. getMaterial(): Nullable<Material>;
  110419. private _IsMultiMaterial;
  110420. /**
  110421. * Sets a new updated BoundingInfo object to the submesh
  110422. * @param data defines an optional position array to use to determine the bounding info
  110423. * @returns the SubMesh
  110424. */
  110425. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  110426. /** @hidden */
  110427. _checkCollision(collider: Collider): boolean;
  110428. /**
  110429. * Updates the submesh BoundingInfo
  110430. * @param world defines the world matrix to use to update the bounding info
  110431. * @returns the submesh
  110432. */
  110433. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  110434. /**
  110435. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  110436. * @param frustumPlanes defines the frustum planes
  110437. * @returns true if the submesh is intersecting with the frustum
  110438. */
  110439. isInFrustum(frustumPlanes: Plane[]): boolean;
  110440. /**
  110441. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  110442. * @param frustumPlanes defines the frustum planes
  110443. * @returns true if the submesh is inside the frustum
  110444. */
  110445. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  110446. /**
  110447. * Renders the submesh
  110448. * @param enableAlphaMode defines if alpha needs to be used
  110449. * @returns the submesh
  110450. */
  110451. render(enableAlphaMode: boolean): SubMesh;
  110452. /**
  110453. * @hidden
  110454. */
  110455. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  110456. /**
  110457. * Checks if the submesh intersects with a ray
  110458. * @param ray defines the ray to test
  110459. * @returns true is the passed ray intersects the submesh bounding box
  110460. */
  110461. canIntersects(ray: Ray): boolean;
  110462. /**
  110463. * Intersects current submesh with a ray
  110464. * @param ray defines the ray to test
  110465. * @param positions defines mesh's positions array
  110466. * @param indices defines mesh's indices array
  110467. * @param fastCheck defines if the first intersection will be used (and not the closest)
  110468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110469. * @returns intersection info or null if no intersection
  110470. */
  110471. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  110472. /** @hidden */
  110473. private _intersectLines;
  110474. /** @hidden */
  110475. private _intersectUnIndexedLines;
  110476. /** @hidden */
  110477. private _intersectTriangles;
  110478. /** @hidden */
  110479. private _intersectUnIndexedTriangles;
  110480. /** @hidden */
  110481. _rebuild(): void;
  110482. /**
  110483. * Creates a new submesh from the passed mesh
  110484. * @param newMesh defines the new hosting mesh
  110485. * @param newRenderingMesh defines an optional rendering mesh
  110486. * @returns the new submesh
  110487. */
  110488. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  110489. /**
  110490. * Release associated resources
  110491. */
  110492. dispose(): void;
  110493. /**
  110494. * Gets the class name
  110495. * @returns the string "SubMesh".
  110496. */
  110497. getClassName(): string;
  110498. /**
  110499. * Creates a new submesh from indices data
  110500. * @param materialIndex the index of the main mesh material
  110501. * @param startIndex the index where to start the copy in the mesh indices array
  110502. * @param indexCount the number of indices to copy then from the startIndex
  110503. * @param mesh the main mesh to create the submesh from
  110504. * @param renderingMesh the optional rendering mesh
  110505. * @returns a new submesh
  110506. */
  110507. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  110508. }
  110509. }
  110510. declare module BABYLON {
  110511. /**
  110512. * Class used to represent data loading progression
  110513. */
  110514. export class SceneLoaderFlags {
  110515. private static _ForceFullSceneLoadingForIncremental;
  110516. private static _ShowLoadingScreen;
  110517. private static _CleanBoneMatrixWeights;
  110518. private static _loggingLevel;
  110519. /**
  110520. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110521. */
  110522. static get ForceFullSceneLoadingForIncremental(): boolean;
  110523. static set ForceFullSceneLoadingForIncremental(value: boolean);
  110524. /**
  110525. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110526. */
  110527. static get ShowLoadingScreen(): boolean;
  110528. static set ShowLoadingScreen(value: boolean);
  110529. /**
  110530. * Defines the current logging level (while loading the scene)
  110531. * @ignorenaming
  110532. */
  110533. static get loggingLevel(): number;
  110534. static set loggingLevel(value: number);
  110535. /**
  110536. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110537. */
  110538. static get CleanBoneMatrixWeights(): boolean;
  110539. static set CleanBoneMatrixWeights(value: boolean);
  110540. }
  110541. }
  110542. declare module BABYLON {
  110543. /**
  110544. * Class used to store geometry data (vertex buffers + index buffer)
  110545. */
  110546. export class Geometry implements IGetSetVerticesData {
  110547. /**
  110548. * Gets or sets the ID of the geometry
  110549. */
  110550. id: string;
  110551. /**
  110552. * Gets or sets the unique ID of the geometry
  110553. */
  110554. uniqueId: number;
  110555. /**
  110556. * Gets the delay loading state of the geometry (none by default which means not delayed)
  110557. */
  110558. delayLoadState: number;
  110559. /**
  110560. * Gets the file containing the data to load when running in delay load state
  110561. */
  110562. delayLoadingFile: Nullable<string>;
  110563. /**
  110564. * Callback called when the geometry is updated
  110565. */
  110566. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  110567. private _scene;
  110568. private _engine;
  110569. private _meshes;
  110570. private _totalVertices;
  110571. /** @hidden */
  110572. _indices: IndicesArray;
  110573. /** @hidden */
  110574. _vertexBuffers: {
  110575. [key: string]: VertexBuffer;
  110576. };
  110577. private _isDisposed;
  110578. private _extend;
  110579. private _boundingBias;
  110580. /** @hidden */
  110581. _delayInfo: Array<string>;
  110582. private _indexBuffer;
  110583. private _indexBufferIsUpdatable;
  110584. /** @hidden */
  110585. _boundingInfo: Nullable<BoundingInfo>;
  110586. /** @hidden */
  110587. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  110588. /** @hidden */
  110589. _softwareSkinningFrameId: number;
  110590. private _vertexArrayObjects;
  110591. private _updatable;
  110592. /** @hidden */
  110593. _positions: Nullable<Vector3[]>;
  110594. /**
  110595. * 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
  110596. */
  110597. get boundingBias(): Vector2;
  110598. /**
  110599. * 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
  110600. */
  110601. set boundingBias(value: Vector2);
  110602. /**
  110603. * Static function used to attach a new empty geometry to a mesh
  110604. * @param mesh defines the mesh to attach the geometry to
  110605. * @returns the new Geometry
  110606. */
  110607. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  110608. /** Get the list of meshes using this geometry */
  110609. get meshes(): Mesh[];
  110610. /**
  110611. * 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
  110612. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  110613. */
  110614. useBoundingInfoFromGeometry: boolean;
  110615. /**
  110616. * Creates a new geometry
  110617. * @param id defines the unique ID
  110618. * @param scene defines the hosting scene
  110619. * @param vertexData defines the VertexData used to get geometry data
  110620. * @param updatable defines if geometry must be updatable (false by default)
  110621. * @param mesh defines the mesh that will be associated with the geometry
  110622. */
  110623. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  110624. /**
  110625. * Gets the current extend of the geometry
  110626. */
  110627. get extend(): {
  110628. minimum: Vector3;
  110629. maximum: Vector3;
  110630. };
  110631. /**
  110632. * Gets the hosting scene
  110633. * @returns the hosting Scene
  110634. */
  110635. getScene(): Scene;
  110636. /**
  110637. * Gets the hosting engine
  110638. * @returns the hosting Engine
  110639. */
  110640. getEngine(): Engine;
  110641. /**
  110642. * Defines if the geometry is ready to use
  110643. * @returns true if the geometry is ready to be used
  110644. */
  110645. isReady(): boolean;
  110646. /**
  110647. * Gets a value indicating that the geometry should not be serialized
  110648. */
  110649. get doNotSerialize(): boolean;
  110650. /** @hidden */
  110651. _rebuild(): void;
  110652. /**
  110653. * Affects all geometry data in one call
  110654. * @param vertexData defines the geometry data
  110655. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  110656. */
  110657. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  110658. /**
  110659. * Set specific vertex data
  110660. * @param kind defines the data kind (Position, normal, etc...)
  110661. * @param data defines the vertex data to use
  110662. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110663. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110664. */
  110665. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  110666. /**
  110667. * Removes a specific vertex data
  110668. * @param kind defines the data kind (Position, normal, etc...)
  110669. */
  110670. removeVerticesData(kind: string): void;
  110671. /**
  110672. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  110673. * @param buffer defines the vertex buffer to use
  110674. * @param totalVertices defines the total number of vertices for position kind (could be null)
  110675. */
  110676. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  110677. /**
  110678. * Update a specific vertex buffer
  110679. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  110680. * It will do nothing if the buffer is not updatable
  110681. * @param kind defines the data kind (Position, normal, etc...)
  110682. * @param data defines the data to use
  110683. * @param offset defines the offset in the target buffer where to store the data
  110684. * @param useBytes set to true if the offset is in bytes
  110685. */
  110686. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  110687. /**
  110688. * Update a specific vertex buffer
  110689. * This function will create a new buffer if the current one is not updatable
  110690. * @param kind defines the data kind (Position, normal, etc...)
  110691. * @param data defines the data to use
  110692. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  110693. */
  110694. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  110695. private _updateBoundingInfo;
  110696. /** @hidden */
  110697. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  110698. /**
  110699. * Gets total number of vertices
  110700. * @returns the total number of vertices
  110701. */
  110702. getTotalVertices(): number;
  110703. /**
  110704. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110705. * @param kind defines the data kind (Position, normal, etc...)
  110706. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110707. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110708. * @returns a float array containing vertex data
  110709. */
  110710. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110711. /**
  110712. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  110713. * @param kind defines the data kind (Position, normal, etc...)
  110714. * @returns true if the vertex buffer with the specified kind is updatable
  110715. */
  110716. isVertexBufferUpdatable(kind: string): boolean;
  110717. /**
  110718. * Gets a specific vertex buffer
  110719. * @param kind defines the data kind (Position, normal, etc...)
  110720. * @returns a VertexBuffer
  110721. */
  110722. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  110723. /**
  110724. * Returns all vertex buffers
  110725. * @return an object holding all vertex buffers indexed by kind
  110726. */
  110727. getVertexBuffers(): Nullable<{
  110728. [key: string]: VertexBuffer;
  110729. }>;
  110730. /**
  110731. * Gets a boolean indicating if specific vertex buffer is present
  110732. * @param kind defines the data kind (Position, normal, etc...)
  110733. * @returns true if data is present
  110734. */
  110735. isVerticesDataPresent(kind: string): boolean;
  110736. /**
  110737. * Gets a list of all attached data kinds (Position, normal, etc...)
  110738. * @returns a list of string containing all kinds
  110739. */
  110740. getVerticesDataKinds(): string[];
  110741. /**
  110742. * Update index buffer
  110743. * @param indices defines the indices to store in the index buffer
  110744. * @param offset defines the offset in the target buffer where to store the data
  110745. * @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)
  110746. */
  110747. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  110748. /**
  110749. * Creates a new index buffer
  110750. * @param indices defines the indices to store in the index buffer
  110751. * @param totalVertices defines the total number of vertices (could be null)
  110752. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110753. */
  110754. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  110755. /**
  110756. * Return the total number of indices
  110757. * @returns the total number of indices
  110758. */
  110759. getTotalIndices(): number;
  110760. /**
  110761. * Gets the index buffer array
  110762. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110763. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110764. * @returns the index buffer array
  110765. */
  110766. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110767. /**
  110768. * Gets the index buffer
  110769. * @return the index buffer
  110770. */
  110771. getIndexBuffer(): Nullable<DataBuffer>;
  110772. /** @hidden */
  110773. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  110774. /**
  110775. * Release the associated resources for a specific mesh
  110776. * @param mesh defines the source mesh
  110777. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  110778. */
  110779. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  110780. /**
  110781. * Apply current geometry to a given mesh
  110782. * @param mesh defines the mesh to apply geometry to
  110783. */
  110784. applyToMesh(mesh: Mesh): void;
  110785. private _updateExtend;
  110786. private _applyToMesh;
  110787. private notifyUpdate;
  110788. /**
  110789. * Load the geometry if it was flagged as delay loaded
  110790. * @param scene defines the hosting scene
  110791. * @param onLoaded defines a callback called when the geometry is loaded
  110792. */
  110793. load(scene: Scene, onLoaded?: () => void): void;
  110794. private _queueLoad;
  110795. /**
  110796. * Invert the geometry to move from a right handed system to a left handed one.
  110797. */
  110798. toLeftHanded(): void;
  110799. /** @hidden */
  110800. _resetPointsArrayCache(): void;
  110801. /** @hidden */
  110802. _generatePointsArray(): boolean;
  110803. /**
  110804. * Gets a value indicating if the geometry is disposed
  110805. * @returns true if the geometry was disposed
  110806. */
  110807. isDisposed(): boolean;
  110808. private _disposeVertexArrayObjects;
  110809. /**
  110810. * Free all associated resources
  110811. */
  110812. dispose(): void;
  110813. /**
  110814. * Clone the current geometry into a new geometry
  110815. * @param id defines the unique ID of the new geometry
  110816. * @returns a new geometry object
  110817. */
  110818. copy(id: string): Geometry;
  110819. /**
  110820. * Serialize the current geometry info (and not the vertices data) into a JSON object
  110821. * @return a JSON representation of the current geometry data (without the vertices data)
  110822. */
  110823. serialize(): any;
  110824. private toNumberArray;
  110825. /**
  110826. * Serialize all vertices data into a JSON oject
  110827. * @returns a JSON representation of the current geometry data
  110828. */
  110829. serializeVerticeData(): any;
  110830. /**
  110831. * Extracts a clone of a mesh geometry
  110832. * @param mesh defines the source mesh
  110833. * @param id defines the unique ID of the new geometry object
  110834. * @returns the new geometry object
  110835. */
  110836. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  110837. /**
  110838. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  110839. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110840. * Be aware Math.random() could cause collisions, but:
  110841. * "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"
  110842. * @returns a string containing a new GUID
  110843. */
  110844. static RandomId(): string;
  110845. /** @hidden */
  110846. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  110847. private static _CleanMatricesWeights;
  110848. /**
  110849. * Create a new geometry from persisted data (Using .babylon file format)
  110850. * @param parsedVertexData defines the persisted data
  110851. * @param scene defines the hosting scene
  110852. * @param rootUrl defines the root url to use to load assets (like delayed data)
  110853. * @returns the new geometry object
  110854. */
  110855. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  110856. }
  110857. }
  110858. declare module BABYLON {
  110859. /**
  110860. * Define an interface for all classes that will get and set the data on vertices
  110861. */
  110862. export interface IGetSetVerticesData {
  110863. /**
  110864. * Gets a boolean indicating if specific vertex data is present
  110865. * @param kind defines the vertex data kind to use
  110866. * @returns true is data kind is present
  110867. */
  110868. isVerticesDataPresent(kind: string): boolean;
  110869. /**
  110870. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  110871. * @param kind defines the data kind (Position, normal, etc...)
  110872. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  110873. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110874. * @returns a float array containing vertex data
  110875. */
  110876. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  110877. /**
  110878. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  110879. * @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.
  110880. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  110881. * @returns the indices array or an empty array if the mesh has no geometry
  110882. */
  110883. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  110884. /**
  110885. * Set specific vertex data
  110886. * @param kind defines the data kind (Position, normal, etc...)
  110887. * @param data defines the vertex data to use
  110888. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  110889. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  110890. */
  110891. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  110892. /**
  110893. * Update a specific associated vertex buffer
  110894. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  110895. * - VertexBuffer.PositionKind
  110896. * - VertexBuffer.UVKind
  110897. * - VertexBuffer.UV2Kind
  110898. * - VertexBuffer.UV3Kind
  110899. * - VertexBuffer.UV4Kind
  110900. * - VertexBuffer.UV5Kind
  110901. * - VertexBuffer.UV6Kind
  110902. * - VertexBuffer.ColorKind
  110903. * - VertexBuffer.MatricesIndicesKind
  110904. * - VertexBuffer.MatricesIndicesExtraKind
  110905. * - VertexBuffer.MatricesWeightsKind
  110906. * - VertexBuffer.MatricesWeightsExtraKind
  110907. * @param data defines the data source
  110908. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  110909. * @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)
  110910. */
  110911. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  110912. /**
  110913. * Creates a new index buffer
  110914. * @param indices defines the indices to store in the index buffer
  110915. * @param totalVertices defines the total number of vertices (could be null)
  110916. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  110917. */
  110918. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  110919. }
  110920. /**
  110921. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  110922. */
  110923. export class VertexData {
  110924. /**
  110925. * Mesh side orientation : usually the external or front surface
  110926. */
  110927. static readonly FRONTSIDE: number;
  110928. /**
  110929. * Mesh side orientation : usually the internal or back surface
  110930. */
  110931. static readonly BACKSIDE: number;
  110932. /**
  110933. * Mesh side orientation : both internal and external or front and back surfaces
  110934. */
  110935. static readonly DOUBLESIDE: number;
  110936. /**
  110937. * Mesh side orientation : by default, `FRONTSIDE`
  110938. */
  110939. static readonly DEFAULTSIDE: number;
  110940. /**
  110941. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  110942. */
  110943. positions: Nullable<FloatArray>;
  110944. /**
  110945. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  110946. */
  110947. normals: Nullable<FloatArray>;
  110948. /**
  110949. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  110950. */
  110951. tangents: Nullable<FloatArray>;
  110952. /**
  110953. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110954. */
  110955. uvs: Nullable<FloatArray>;
  110956. /**
  110957. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110958. */
  110959. uvs2: Nullable<FloatArray>;
  110960. /**
  110961. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110962. */
  110963. uvs3: Nullable<FloatArray>;
  110964. /**
  110965. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110966. */
  110967. uvs4: Nullable<FloatArray>;
  110968. /**
  110969. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110970. */
  110971. uvs5: Nullable<FloatArray>;
  110972. /**
  110973. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  110974. */
  110975. uvs6: Nullable<FloatArray>;
  110976. /**
  110977. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  110978. */
  110979. colors: Nullable<FloatArray>;
  110980. /**
  110981. * 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).
  110982. */
  110983. matricesIndices: Nullable<FloatArray>;
  110984. /**
  110985. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  110986. */
  110987. matricesWeights: Nullable<FloatArray>;
  110988. /**
  110989. * An array extending the number of possible indices
  110990. */
  110991. matricesIndicesExtra: Nullable<FloatArray>;
  110992. /**
  110993. * An array extending the number of possible weights when the number of indices is extended
  110994. */
  110995. matricesWeightsExtra: Nullable<FloatArray>;
  110996. /**
  110997. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  110998. */
  110999. indices: Nullable<IndicesArray>;
  111000. /**
  111001. * Uses the passed data array to set the set the values for the specified kind of data
  111002. * @param data a linear array of floating numbers
  111003. * @param kind the type of data that is being set, eg positions, colors etc
  111004. */
  111005. set(data: FloatArray, kind: string): void;
  111006. /**
  111007. * Associates the vertexData to the passed Mesh.
  111008. * Sets it as updatable or not (default `false`)
  111009. * @param mesh the mesh the vertexData is applied to
  111010. * @param updatable when used and having the value true allows new data to update the vertexData
  111011. * @returns the VertexData
  111012. */
  111013. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  111014. /**
  111015. * Associates the vertexData to the passed Geometry.
  111016. * Sets it as updatable or not (default `false`)
  111017. * @param geometry the geometry the vertexData is applied to
  111018. * @param updatable when used and having the value true allows new data to update the vertexData
  111019. * @returns VertexData
  111020. */
  111021. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  111022. /**
  111023. * Updates the associated mesh
  111024. * @param mesh the mesh to be updated
  111025. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111026. * @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
  111027. * @returns VertexData
  111028. */
  111029. updateMesh(mesh: Mesh): VertexData;
  111030. /**
  111031. * Updates the associated geometry
  111032. * @param geometry the geometry to be updated
  111033. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111034. * @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
  111035. * @returns VertexData.
  111036. */
  111037. updateGeometry(geometry: Geometry): VertexData;
  111038. private _applyTo;
  111039. private _update;
  111040. /**
  111041. * Transforms each position and each normal of the vertexData according to the passed Matrix
  111042. * @param matrix the transforming matrix
  111043. * @returns the VertexData
  111044. */
  111045. transform(matrix: Matrix): VertexData;
  111046. /**
  111047. * Merges the passed VertexData into the current one
  111048. * @param other the VertexData to be merged into the current one
  111049. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  111050. * @returns the modified VertexData
  111051. */
  111052. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  111053. private _mergeElement;
  111054. private _validate;
  111055. /**
  111056. * Serializes the VertexData
  111057. * @returns a serialized object
  111058. */
  111059. serialize(): any;
  111060. /**
  111061. * Extracts the vertexData from a mesh
  111062. * @param mesh the mesh from which to extract the VertexData
  111063. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  111064. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111065. * @returns the object VertexData associated to the passed mesh
  111066. */
  111067. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111068. /**
  111069. * Extracts the vertexData from the geometry
  111070. * @param geometry the geometry from which to extract the VertexData
  111071. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  111072. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111073. * @returns the object VertexData associated to the passed mesh
  111074. */
  111075. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111076. private static _ExtractFrom;
  111077. /**
  111078. * Creates the VertexData for a Ribbon
  111079. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  111080. * * pathArray array of paths, each of which an array of successive Vector3
  111081. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  111082. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  111083. * * 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
  111084. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111085. * * 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)
  111086. * * 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)
  111087. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  111088. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  111089. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  111090. * @returns the VertexData of the ribbon
  111091. */
  111092. static CreateRibbon(options: {
  111093. pathArray: Vector3[][];
  111094. closeArray?: boolean;
  111095. closePath?: boolean;
  111096. offset?: number;
  111097. sideOrientation?: number;
  111098. frontUVs?: Vector4;
  111099. backUVs?: Vector4;
  111100. invertUV?: boolean;
  111101. uvs?: Vector2[];
  111102. colors?: Color4[];
  111103. }): VertexData;
  111104. /**
  111105. * Creates the VertexData for a box
  111106. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111107. * * size sets the width, height and depth of the box to the value of size, optional default 1
  111108. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  111109. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  111110. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  111111. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111112. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111114. * * 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)
  111115. * * 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)
  111116. * @returns the VertexData of the box
  111117. */
  111118. static CreateBox(options: {
  111119. size?: number;
  111120. width?: number;
  111121. height?: number;
  111122. depth?: number;
  111123. faceUV?: Vector4[];
  111124. faceColors?: Color4[];
  111125. sideOrientation?: number;
  111126. frontUVs?: Vector4;
  111127. backUVs?: Vector4;
  111128. }): VertexData;
  111129. /**
  111130. * Creates the VertexData for a tiled box
  111131. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111132. * * faceTiles sets the pattern, tile size and number of tiles for a face
  111133. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111134. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111136. * @returns the VertexData of the box
  111137. */
  111138. static CreateTiledBox(options: {
  111139. pattern?: number;
  111140. width?: number;
  111141. height?: number;
  111142. depth?: number;
  111143. tileSize?: number;
  111144. tileWidth?: number;
  111145. tileHeight?: number;
  111146. alignHorizontal?: number;
  111147. alignVertical?: number;
  111148. faceUV?: Vector4[];
  111149. faceColors?: Color4[];
  111150. sideOrientation?: number;
  111151. }): VertexData;
  111152. /**
  111153. * Creates the VertexData for a tiled plane
  111154. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111155. * * pattern a limited pattern arrangement depending on the number
  111156. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111157. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111158. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111160. * * 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)
  111161. * * 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)
  111162. * @returns the VertexData of the tiled plane
  111163. */
  111164. static CreateTiledPlane(options: {
  111165. pattern?: number;
  111166. tileSize?: number;
  111167. tileWidth?: number;
  111168. tileHeight?: number;
  111169. size?: number;
  111170. width?: number;
  111171. height?: number;
  111172. alignHorizontal?: number;
  111173. alignVertical?: number;
  111174. sideOrientation?: number;
  111175. frontUVs?: Vector4;
  111176. backUVs?: Vector4;
  111177. }): VertexData;
  111178. /**
  111179. * Creates the VertexData for an ellipsoid, defaults to a sphere
  111180. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111181. * * segments sets the number of horizontal strips optional, default 32
  111182. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  111183. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  111184. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  111185. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  111186. * * 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
  111187. * * 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
  111188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111189. * * 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)
  111190. * * 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)
  111191. * @returns the VertexData of the ellipsoid
  111192. */
  111193. static CreateSphere(options: {
  111194. segments?: number;
  111195. diameter?: number;
  111196. diameterX?: number;
  111197. diameterY?: number;
  111198. diameterZ?: number;
  111199. arc?: number;
  111200. slice?: number;
  111201. sideOrientation?: number;
  111202. frontUVs?: Vector4;
  111203. backUVs?: Vector4;
  111204. }): VertexData;
  111205. /**
  111206. * Creates the VertexData for a cylinder, cone or prism
  111207. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111208. * * height sets the height (y direction) of the cylinder, optional, default 2
  111209. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  111210. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  111211. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  111212. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111213. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  111214. * * 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
  111215. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111216. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111217. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  111218. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  111219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111220. * * 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)
  111221. * * 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)
  111222. * @returns the VertexData of the cylinder, cone or prism
  111223. */
  111224. static CreateCylinder(options: {
  111225. height?: number;
  111226. diameterTop?: number;
  111227. diameterBottom?: number;
  111228. diameter?: number;
  111229. tessellation?: number;
  111230. subdivisions?: number;
  111231. arc?: number;
  111232. faceColors?: Color4[];
  111233. faceUV?: Vector4[];
  111234. hasRings?: boolean;
  111235. enclose?: boolean;
  111236. sideOrientation?: number;
  111237. frontUVs?: Vector4;
  111238. backUVs?: Vector4;
  111239. }): VertexData;
  111240. /**
  111241. * Creates the VertexData for a torus
  111242. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111243. * * diameter the diameter of the torus, optional default 1
  111244. * * thickness the diameter of the tube forming the torus, optional default 0.5
  111245. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111247. * * 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)
  111248. * * 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)
  111249. * @returns the VertexData of the torus
  111250. */
  111251. static CreateTorus(options: {
  111252. diameter?: number;
  111253. thickness?: number;
  111254. tessellation?: number;
  111255. sideOrientation?: number;
  111256. frontUVs?: Vector4;
  111257. backUVs?: Vector4;
  111258. }): VertexData;
  111259. /**
  111260. * Creates the VertexData of the LineSystem
  111261. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  111262. * - lines an array of lines, each line being an array of successive Vector3
  111263. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  111264. * @returns the VertexData of the LineSystem
  111265. */
  111266. static CreateLineSystem(options: {
  111267. lines: Vector3[][];
  111268. colors?: Nullable<Color4[][]>;
  111269. }): VertexData;
  111270. /**
  111271. * Create the VertexData for a DashedLines
  111272. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  111273. * - points an array successive Vector3
  111274. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  111275. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  111276. * - dashNb the intended total number of dashes, optional, default 200
  111277. * @returns the VertexData for the DashedLines
  111278. */
  111279. static CreateDashedLines(options: {
  111280. points: Vector3[];
  111281. dashSize?: number;
  111282. gapSize?: number;
  111283. dashNb?: number;
  111284. }): VertexData;
  111285. /**
  111286. * Creates the VertexData for a Ground
  111287. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111288. * - width the width (x direction) of the ground, optional, default 1
  111289. * - height the height (z direction) of the ground, optional, default 1
  111290. * - subdivisions the number of subdivisions per side, optional, default 1
  111291. * @returns the VertexData of the Ground
  111292. */
  111293. static CreateGround(options: {
  111294. width?: number;
  111295. height?: number;
  111296. subdivisions?: number;
  111297. subdivisionsX?: number;
  111298. subdivisionsY?: number;
  111299. }): VertexData;
  111300. /**
  111301. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  111302. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  111303. * * xmin the ground minimum X coordinate, optional, default -1
  111304. * * zmin the ground minimum Z coordinate, optional, default -1
  111305. * * xmax the ground maximum X coordinate, optional, default 1
  111306. * * zmax the ground maximum Z coordinate, optional, default 1
  111307. * * 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}
  111308. * * 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}
  111309. * @returns the VertexData of the TiledGround
  111310. */
  111311. static CreateTiledGround(options: {
  111312. xmin: number;
  111313. zmin: number;
  111314. xmax: number;
  111315. zmax: number;
  111316. subdivisions?: {
  111317. w: number;
  111318. h: number;
  111319. };
  111320. precision?: {
  111321. w: number;
  111322. h: number;
  111323. };
  111324. }): VertexData;
  111325. /**
  111326. * Creates the VertexData of the Ground designed from a heightmap
  111327. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  111328. * * width the width (x direction) of the ground
  111329. * * height the height (z direction) of the ground
  111330. * * subdivisions the number of subdivisions per side
  111331. * * minHeight the minimum altitude on the ground, optional, default 0
  111332. * * maxHeight the maximum altitude on the ground, optional default 1
  111333. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  111334. * * buffer the array holding the image color data
  111335. * * bufferWidth the width of image
  111336. * * bufferHeight the height of image
  111337. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  111338. * @returns the VertexData of the Ground designed from a heightmap
  111339. */
  111340. static CreateGroundFromHeightMap(options: {
  111341. width: number;
  111342. height: number;
  111343. subdivisions: number;
  111344. minHeight: number;
  111345. maxHeight: number;
  111346. colorFilter: Color3;
  111347. buffer: Uint8Array;
  111348. bufferWidth: number;
  111349. bufferHeight: number;
  111350. alphaFilter: number;
  111351. }): VertexData;
  111352. /**
  111353. * Creates the VertexData for a Plane
  111354. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  111355. * * size sets the width and height of the plane to the value of size, optional default 1
  111356. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  111357. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  111358. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111359. * * 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)
  111360. * * 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)
  111361. * @returns the VertexData of the box
  111362. */
  111363. static CreatePlane(options: {
  111364. size?: number;
  111365. width?: number;
  111366. height?: number;
  111367. sideOrientation?: number;
  111368. frontUVs?: Vector4;
  111369. backUVs?: Vector4;
  111370. }): VertexData;
  111371. /**
  111372. * Creates the VertexData of the Disc or regular Polygon
  111373. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  111374. * * radius the radius of the disc, optional default 0.5
  111375. * * tessellation the number of polygon sides, optional, default 64
  111376. * * 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
  111377. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111378. * * 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)
  111379. * * 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)
  111380. * @returns the VertexData of the box
  111381. */
  111382. static CreateDisc(options: {
  111383. radius?: number;
  111384. tessellation?: number;
  111385. arc?: number;
  111386. sideOrientation?: number;
  111387. frontUVs?: Vector4;
  111388. backUVs?: Vector4;
  111389. }): VertexData;
  111390. /**
  111391. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  111392. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  111393. * @param polygon a mesh built from polygonTriangulation.build()
  111394. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111395. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111396. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111397. * @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)
  111398. * @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)
  111399. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  111400. * @returns the VertexData of the Polygon
  111401. */
  111402. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  111403. /**
  111404. * Creates the VertexData of the IcoSphere
  111405. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  111406. * * radius the radius of the IcoSphere, optional default 1
  111407. * * radiusX allows stretching in the x direction, optional, default radius
  111408. * * radiusY allows stretching in the y direction, optional, default radius
  111409. * * radiusZ allows stretching in the z direction, optional, default radius
  111410. * * flat when true creates a flat shaded mesh, optional, default true
  111411. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111412. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111413. * * 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)
  111414. * * 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)
  111415. * @returns the VertexData of the IcoSphere
  111416. */
  111417. static CreateIcoSphere(options: {
  111418. radius?: number;
  111419. radiusX?: number;
  111420. radiusY?: number;
  111421. radiusZ?: number;
  111422. flat?: boolean;
  111423. subdivisions?: number;
  111424. sideOrientation?: number;
  111425. frontUVs?: Vector4;
  111426. backUVs?: Vector4;
  111427. }): VertexData;
  111428. /**
  111429. * Creates the VertexData for a Polyhedron
  111430. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  111431. * * type provided types are:
  111432. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  111433. * * 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)
  111434. * * size the size of the IcoSphere, optional default 1
  111435. * * sizeX allows stretching in the x direction, optional, default size
  111436. * * sizeY allows stretching in the y direction, optional, default size
  111437. * * sizeZ allows stretching in the z direction, optional, default size
  111438. * * 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
  111439. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111440. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111441. * * flat when true creates a flat shaded mesh, optional, default true
  111442. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  111443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111444. * * 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)
  111445. * * 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)
  111446. * @returns the VertexData of the Polyhedron
  111447. */
  111448. static CreatePolyhedron(options: {
  111449. type?: number;
  111450. size?: number;
  111451. sizeX?: number;
  111452. sizeY?: number;
  111453. sizeZ?: number;
  111454. custom?: any;
  111455. faceUV?: Vector4[];
  111456. faceColors?: Color4[];
  111457. flat?: boolean;
  111458. sideOrientation?: number;
  111459. frontUVs?: Vector4;
  111460. backUVs?: Vector4;
  111461. }): VertexData;
  111462. /**
  111463. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  111464. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  111465. * @returns the VertexData of the Capsule
  111466. */
  111467. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  111468. /**
  111469. * Creates the VertexData for a TorusKnot
  111470. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  111471. * * radius the radius of the torus knot, optional, default 2
  111472. * * tube the thickness of the tube, optional, default 0.5
  111473. * * radialSegments the number of sides on each tube segments, optional, default 32
  111474. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  111475. * * p the number of windings around the z axis, optional, default 2
  111476. * * q the number of windings around the x axis, optional, default 3
  111477. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111478. * * 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)
  111479. * * 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)
  111480. * @returns the VertexData of the Torus Knot
  111481. */
  111482. static CreateTorusKnot(options: {
  111483. radius?: number;
  111484. tube?: number;
  111485. radialSegments?: number;
  111486. tubularSegments?: number;
  111487. p?: number;
  111488. q?: number;
  111489. sideOrientation?: number;
  111490. frontUVs?: Vector4;
  111491. backUVs?: Vector4;
  111492. }): VertexData;
  111493. /**
  111494. * Compute normals for given positions and indices
  111495. * @param positions an array of vertex positions, [...., x, y, z, ......]
  111496. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  111497. * @param normals an array of vertex normals, [...., x, y, z, ......]
  111498. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  111499. * * facetNormals : optional array of facet normals (vector3)
  111500. * * facetPositions : optional array of facet positions (vector3)
  111501. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  111502. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  111503. * * bInfo : optional bounding info, required for facetPartitioning computation
  111504. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  111505. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  111506. * * useRightHandedSystem: optional boolean to for right handed system computation
  111507. * * depthSort : optional boolean to enable the facet depth sort computation
  111508. * * distanceTo : optional Vector3 to compute the facet depth from this location
  111509. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  111510. */
  111511. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  111512. facetNormals?: any;
  111513. facetPositions?: any;
  111514. facetPartitioning?: any;
  111515. ratio?: number;
  111516. bInfo?: any;
  111517. bbSize?: Vector3;
  111518. subDiv?: any;
  111519. useRightHandedSystem?: boolean;
  111520. depthSort?: boolean;
  111521. distanceTo?: Vector3;
  111522. depthSortedFacets?: any;
  111523. }): void;
  111524. /** @hidden */
  111525. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  111526. /**
  111527. * Applies VertexData created from the imported parameters to the geometry
  111528. * @param parsedVertexData the parsed data from an imported file
  111529. * @param geometry the geometry to apply the VertexData to
  111530. */
  111531. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  111532. }
  111533. }
  111534. declare module BABYLON {
  111535. /**
  111536. * Defines a target to use with MorphTargetManager
  111537. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111538. */
  111539. export class MorphTarget implements IAnimatable {
  111540. /** defines the name of the target */
  111541. name: string;
  111542. /**
  111543. * Gets or sets the list of animations
  111544. */
  111545. animations: Animation[];
  111546. private _scene;
  111547. private _positions;
  111548. private _normals;
  111549. private _tangents;
  111550. private _uvs;
  111551. private _influence;
  111552. private _uniqueId;
  111553. /**
  111554. * Observable raised when the influence changes
  111555. */
  111556. onInfluenceChanged: Observable<boolean>;
  111557. /** @hidden */
  111558. _onDataLayoutChanged: Observable<void>;
  111559. /**
  111560. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  111561. */
  111562. get influence(): number;
  111563. set influence(influence: number);
  111564. /**
  111565. * Gets or sets the id of the morph Target
  111566. */
  111567. id: string;
  111568. private _animationPropertiesOverride;
  111569. /**
  111570. * Gets or sets the animation properties override
  111571. */
  111572. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111573. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111574. /**
  111575. * Creates a new MorphTarget
  111576. * @param name defines the name of the target
  111577. * @param influence defines the influence to use
  111578. * @param scene defines the scene the morphtarget belongs to
  111579. */
  111580. constructor(
  111581. /** defines the name of the target */
  111582. name: string, influence?: number, scene?: Nullable<Scene>);
  111583. /**
  111584. * Gets the unique ID of this manager
  111585. */
  111586. get uniqueId(): number;
  111587. /**
  111588. * Gets a boolean defining if the target contains position data
  111589. */
  111590. get hasPositions(): boolean;
  111591. /**
  111592. * Gets a boolean defining if the target contains normal data
  111593. */
  111594. get hasNormals(): boolean;
  111595. /**
  111596. * Gets a boolean defining if the target contains tangent data
  111597. */
  111598. get hasTangents(): boolean;
  111599. /**
  111600. * Gets a boolean defining if the target contains texture coordinates data
  111601. */
  111602. get hasUVs(): boolean;
  111603. /**
  111604. * Affects position data to this target
  111605. * @param data defines the position data to use
  111606. */
  111607. setPositions(data: Nullable<FloatArray>): void;
  111608. /**
  111609. * Gets the position data stored in this target
  111610. * @returns a FloatArray containing the position data (or null if not present)
  111611. */
  111612. getPositions(): Nullable<FloatArray>;
  111613. /**
  111614. * Affects normal data to this target
  111615. * @param data defines the normal data to use
  111616. */
  111617. setNormals(data: Nullable<FloatArray>): void;
  111618. /**
  111619. * Gets the normal data stored in this target
  111620. * @returns a FloatArray containing the normal data (or null if not present)
  111621. */
  111622. getNormals(): Nullable<FloatArray>;
  111623. /**
  111624. * Affects tangent data to this target
  111625. * @param data defines the tangent data to use
  111626. */
  111627. setTangents(data: Nullable<FloatArray>): void;
  111628. /**
  111629. * Gets the tangent data stored in this target
  111630. * @returns a FloatArray containing the tangent data (or null if not present)
  111631. */
  111632. getTangents(): Nullable<FloatArray>;
  111633. /**
  111634. * Affects texture coordinates data to this target
  111635. * @param data defines the texture coordinates data to use
  111636. */
  111637. setUVs(data: Nullable<FloatArray>): void;
  111638. /**
  111639. * Gets the texture coordinates data stored in this target
  111640. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  111641. */
  111642. getUVs(): Nullable<FloatArray>;
  111643. /**
  111644. * Clone the current target
  111645. * @returns a new MorphTarget
  111646. */
  111647. clone(): MorphTarget;
  111648. /**
  111649. * Serializes the current target into a Serialization object
  111650. * @returns the serialized object
  111651. */
  111652. serialize(): any;
  111653. /**
  111654. * Returns the string "MorphTarget"
  111655. * @returns "MorphTarget"
  111656. */
  111657. getClassName(): string;
  111658. /**
  111659. * Creates a new target from serialized data
  111660. * @param serializationObject defines the serialized data to use
  111661. * @returns a new MorphTarget
  111662. */
  111663. static Parse(serializationObject: any): MorphTarget;
  111664. /**
  111665. * Creates a MorphTarget from mesh data
  111666. * @param mesh defines the source mesh
  111667. * @param name defines the name to use for the new target
  111668. * @param influence defines the influence to attach to the target
  111669. * @returns a new MorphTarget
  111670. */
  111671. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  111672. }
  111673. }
  111674. declare module BABYLON {
  111675. /**
  111676. * This class is used to deform meshes using morphing between different targets
  111677. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  111678. */
  111679. export class MorphTargetManager {
  111680. private _targets;
  111681. private _targetInfluenceChangedObservers;
  111682. private _targetDataLayoutChangedObservers;
  111683. private _activeTargets;
  111684. private _scene;
  111685. private _influences;
  111686. private _supportsNormals;
  111687. private _supportsTangents;
  111688. private _supportsUVs;
  111689. private _vertexCount;
  111690. private _uniqueId;
  111691. private _tempInfluences;
  111692. /**
  111693. * Gets or sets a boolean indicating if normals must be morphed
  111694. */
  111695. enableNormalMorphing: boolean;
  111696. /**
  111697. * Gets or sets a boolean indicating if tangents must be morphed
  111698. */
  111699. enableTangentMorphing: boolean;
  111700. /**
  111701. * Gets or sets a boolean indicating if UV must be morphed
  111702. */
  111703. enableUVMorphing: boolean;
  111704. /**
  111705. * Creates a new MorphTargetManager
  111706. * @param scene defines the current scene
  111707. */
  111708. constructor(scene?: Nullable<Scene>);
  111709. /**
  111710. * Gets the unique ID of this manager
  111711. */
  111712. get uniqueId(): number;
  111713. /**
  111714. * Gets the number of vertices handled by this manager
  111715. */
  111716. get vertexCount(): number;
  111717. /**
  111718. * Gets a boolean indicating if this manager supports morphing of normals
  111719. */
  111720. get supportsNormals(): boolean;
  111721. /**
  111722. * Gets a boolean indicating if this manager supports morphing of tangents
  111723. */
  111724. get supportsTangents(): boolean;
  111725. /**
  111726. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  111727. */
  111728. get supportsUVs(): boolean;
  111729. /**
  111730. * Gets the number of targets stored in this manager
  111731. */
  111732. get numTargets(): number;
  111733. /**
  111734. * Gets the number of influencers (ie. the number of targets with influences > 0)
  111735. */
  111736. get numInfluencers(): number;
  111737. /**
  111738. * Gets the list of influences (one per target)
  111739. */
  111740. get influences(): Float32Array;
  111741. /**
  111742. * Gets the active target at specified index. An active target is a target with an influence > 0
  111743. * @param index defines the index to check
  111744. * @returns the requested target
  111745. */
  111746. getActiveTarget(index: number): MorphTarget;
  111747. /**
  111748. * Gets the target at specified index
  111749. * @param index defines the index to check
  111750. * @returns the requested target
  111751. */
  111752. getTarget(index: number): MorphTarget;
  111753. /**
  111754. * Add a new target to this manager
  111755. * @param target defines the target to add
  111756. */
  111757. addTarget(target: MorphTarget): void;
  111758. /**
  111759. * Removes a target from the manager
  111760. * @param target defines the target to remove
  111761. */
  111762. removeTarget(target: MorphTarget): void;
  111763. /**
  111764. * Clone the current manager
  111765. * @returns a new MorphTargetManager
  111766. */
  111767. clone(): MorphTargetManager;
  111768. /**
  111769. * Serializes the current manager into a Serialization object
  111770. * @returns the serialized object
  111771. */
  111772. serialize(): any;
  111773. private _syncActiveTargets;
  111774. /**
  111775. * Syncrhonize the targets with all the meshes using this morph target manager
  111776. */
  111777. synchronize(): void;
  111778. /**
  111779. * Creates a new MorphTargetManager from serialized data
  111780. * @param serializationObject defines the serialized data
  111781. * @param scene defines the hosting scene
  111782. * @returns the new MorphTargetManager
  111783. */
  111784. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  111785. }
  111786. }
  111787. declare module BABYLON {
  111788. /**
  111789. * Class used to represent a specific level of detail of a mesh
  111790. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  111791. */
  111792. export class MeshLODLevel {
  111793. /** Defines the distance where this level should start being displayed */
  111794. distance: number;
  111795. /** Defines the mesh to use to render this level */
  111796. mesh: Nullable<Mesh>;
  111797. /**
  111798. * Creates a new LOD level
  111799. * @param distance defines the distance where this level should star being displayed
  111800. * @param mesh defines the mesh to use to render this level
  111801. */
  111802. constructor(
  111803. /** Defines the distance where this level should start being displayed */
  111804. distance: number,
  111805. /** Defines the mesh to use to render this level */
  111806. mesh: Nullable<Mesh>);
  111807. }
  111808. }
  111809. declare module BABYLON {
  111810. /**
  111811. * Helper class used to generate a canvas to manipulate images
  111812. */
  111813. export class CanvasGenerator {
  111814. /**
  111815. * Create a new canvas (or offscreen canvas depending on the context)
  111816. * @param width defines the expected width
  111817. * @param height defines the expected height
  111818. * @return a new canvas or offscreen canvas
  111819. */
  111820. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  111821. }
  111822. }
  111823. declare module BABYLON {
  111824. /**
  111825. * Mesh representing the gorund
  111826. */
  111827. export class GroundMesh extends Mesh {
  111828. /** If octree should be generated */
  111829. generateOctree: boolean;
  111830. private _heightQuads;
  111831. /** @hidden */
  111832. _subdivisionsX: number;
  111833. /** @hidden */
  111834. _subdivisionsY: number;
  111835. /** @hidden */
  111836. _width: number;
  111837. /** @hidden */
  111838. _height: number;
  111839. /** @hidden */
  111840. _minX: number;
  111841. /** @hidden */
  111842. _maxX: number;
  111843. /** @hidden */
  111844. _minZ: number;
  111845. /** @hidden */
  111846. _maxZ: number;
  111847. constructor(name: string, scene: Scene);
  111848. /**
  111849. * "GroundMesh"
  111850. * @returns "GroundMesh"
  111851. */
  111852. getClassName(): string;
  111853. /**
  111854. * The minimum of x and y subdivisions
  111855. */
  111856. get subdivisions(): number;
  111857. /**
  111858. * X subdivisions
  111859. */
  111860. get subdivisionsX(): number;
  111861. /**
  111862. * Y subdivisions
  111863. */
  111864. get subdivisionsY(): number;
  111865. /**
  111866. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  111867. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111868. * @param chunksCount the number of subdivisions for x and y
  111869. * @param octreeBlocksSize (Default: 32)
  111870. */
  111871. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  111872. /**
  111873. * Returns a height (y) value in the Worl system :
  111874. * the ground altitude at the coordinates (x, z) expressed in the World system.
  111875. * @param x x coordinate
  111876. * @param z z coordinate
  111877. * @returns the ground y position if (x, z) are outside the ground surface.
  111878. */
  111879. getHeightAtCoordinates(x: number, z: number): number;
  111880. /**
  111881. * Returns a normalized vector (Vector3) orthogonal to the ground
  111882. * at the ground coordinates (x, z) expressed in the World system.
  111883. * @param x x coordinate
  111884. * @param z z coordinate
  111885. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  111886. */
  111887. getNormalAtCoordinates(x: number, z: number): Vector3;
  111888. /**
  111889. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  111890. * at the ground coordinates (x, z) expressed in the World system.
  111891. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  111892. * @param x x coordinate
  111893. * @param z z coordinate
  111894. * @param ref vector to store the result
  111895. * @returns the GroundMesh.
  111896. */
  111897. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  111898. /**
  111899. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  111900. * if the ground has been updated.
  111901. * This can be used in the render loop.
  111902. * @returns the GroundMesh.
  111903. */
  111904. updateCoordinateHeights(): GroundMesh;
  111905. private _getFacetAt;
  111906. private _initHeightQuads;
  111907. private _computeHeightQuads;
  111908. /**
  111909. * Serializes this ground mesh
  111910. * @param serializationObject object to write serialization to
  111911. */
  111912. serialize(serializationObject: any): void;
  111913. /**
  111914. * Parses a serialized ground mesh
  111915. * @param parsedMesh the serialized mesh
  111916. * @param scene the scene to create the ground mesh in
  111917. * @returns the created ground mesh
  111918. */
  111919. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  111920. }
  111921. }
  111922. declare module BABYLON {
  111923. /**
  111924. * Interface for Physics-Joint data
  111925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111926. */
  111927. export interface PhysicsJointData {
  111928. /**
  111929. * The main pivot of the joint
  111930. */
  111931. mainPivot?: Vector3;
  111932. /**
  111933. * The connected pivot of the joint
  111934. */
  111935. connectedPivot?: Vector3;
  111936. /**
  111937. * The main axis of the joint
  111938. */
  111939. mainAxis?: Vector3;
  111940. /**
  111941. * The connected axis of the joint
  111942. */
  111943. connectedAxis?: Vector3;
  111944. /**
  111945. * The collision of the joint
  111946. */
  111947. collision?: boolean;
  111948. /**
  111949. * Native Oimo/Cannon/Energy data
  111950. */
  111951. nativeParams?: any;
  111952. }
  111953. /**
  111954. * This is a holder class for the physics joint created by the physics plugin
  111955. * It holds a set of functions to control the underlying joint
  111956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111957. */
  111958. export class PhysicsJoint {
  111959. /**
  111960. * The type of the physics joint
  111961. */
  111962. type: number;
  111963. /**
  111964. * The data for the physics joint
  111965. */
  111966. jointData: PhysicsJointData;
  111967. private _physicsJoint;
  111968. protected _physicsPlugin: IPhysicsEnginePlugin;
  111969. /**
  111970. * Initializes the physics joint
  111971. * @param type The type of the physics joint
  111972. * @param jointData The data for the physics joint
  111973. */
  111974. constructor(
  111975. /**
  111976. * The type of the physics joint
  111977. */
  111978. type: number,
  111979. /**
  111980. * The data for the physics joint
  111981. */
  111982. jointData: PhysicsJointData);
  111983. /**
  111984. * Gets the physics joint
  111985. */
  111986. get physicsJoint(): any;
  111987. /**
  111988. * Sets the physics joint
  111989. */
  111990. set physicsJoint(newJoint: any);
  111991. /**
  111992. * Sets the physics plugin
  111993. */
  111994. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  111995. /**
  111996. * Execute a function that is physics-plugin specific.
  111997. * @param {Function} func the function that will be executed.
  111998. * It accepts two parameters: the physics world and the physics joint
  111999. */
  112000. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112001. /**
  112002. * Distance-Joint type
  112003. */
  112004. static DistanceJoint: number;
  112005. /**
  112006. * Hinge-Joint type
  112007. */
  112008. static HingeJoint: number;
  112009. /**
  112010. * Ball-and-Socket joint type
  112011. */
  112012. static BallAndSocketJoint: number;
  112013. /**
  112014. * Wheel-Joint type
  112015. */
  112016. static WheelJoint: number;
  112017. /**
  112018. * Slider-Joint type
  112019. */
  112020. static SliderJoint: number;
  112021. /**
  112022. * Prismatic-Joint type
  112023. */
  112024. static PrismaticJoint: number;
  112025. /**
  112026. * Universal-Joint type
  112027. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112028. */
  112029. static UniversalJoint: number;
  112030. /**
  112031. * Hinge-Joint 2 type
  112032. */
  112033. static Hinge2Joint: number;
  112034. /**
  112035. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112036. */
  112037. static PointToPointJoint: number;
  112038. /**
  112039. * Spring-Joint type
  112040. */
  112041. static SpringJoint: number;
  112042. /**
  112043. * Lock-Joint type
  112044. */
  112045. static LockJoint: number;
  112046. }
  112047. /**
  112048. * A class representing a physics distance joint
  112049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112050. */
  112051. export class DistanceJoint extends PhysicsJoint {
  112052. /**
  112053. *
  112054. * @param jointData The data for the Distance-Joint
  112055. */
  112056. constructor(jointData: DistanceJointData);
  112057. /**
  112058. * Update the predefined distance.
  112059. * @param maxDistance The maximum preferred distance
  112060. * @param minDistance The minimum preferred distance
  112061. */
  112062. updateDistance(maxDistance: number, minDistance?: number): void;
  112063. }
  112064. /**
  112065. * Represents a Motor-Enabled Joint
  112066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112067. */
  112068. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112069. /**
  112070. * Initializes the Motor-Enabled Joint
  112071. * @param type The type of the joint
  112072. * @param jointData The physica joint data for the joint
  112073. */
  112074. constructor(type: number, jointData: PhysicsJointData);
  112075. /**
  112076. * Set the motor values.
  112077. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112078. * @param force the force to apply
  112079. * @param maxForce max force for this motor.
  112080. */
  112081. setMotor(force?: number, maxForce?: number): void;
  112082. /**
  112083. * Set the motor's limits.
  112084. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112085. * @param upperLimit The upper limit of the motor
  112086. * @param lowerLimit The lower limit of the motor
  112087. */
  112088. setLimit(upperLimit: number, lowerLimit?: number): void;
  112089. }
  112090. /**
  112091. * This class represents a single physics Hinge-Joint
  112092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112093. */
  112094. export class HingeJoint extends MotorEnabledJoint {
  112095. /**
  112096. * Initializes the Hinge-Joint
  112097. * @param jointData The joint data for the Hinge-Joint
  112098. */
  112099. constructor(jointData: PhysicsJointData);
  112100. /**
  112101. * Set the motor values.
  112102. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112103. * @param {number} force the force to apply
  112104. * @param {number} maxForce max force for this motor.
  112105. */
  112106. setMotor(force?: number, maxForce?: number): void;
  112107. /**
  112108. * Set the motor's limits.
  112109. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112110. * @param upperLimit The upper limit of the motor
  112111. * @param lowerLimit The lower limit of the motor
  112112. */
  112113. setLimit(upperLimit: number, lowerLimit?: number): void;
  112114. }
  112115. /**
  112116. * This class represents a dual hinge physics joint (same as wheel joint)
  112117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112118. */
  112119. export class Hinge2Joint extends MotorEnabledJoint {
  112120. /**
  112121. * Initializes the Hinge2-Joint
  112122. * @param jointData The joint data for the Hinge2-Joint
  112123. */
  112124. constructor(jointData: PhysicsJointData);
  112125. /**
  112126. * Set the motor values.
  112127. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112128. * @param {number} targetSpeed the speed the motor is to reach
  112129. * @param {number} maxForce max force for this motor.
  112130. * @param {motorIndex} the motor's index, 0 or 1.
  112131. */
  112132. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112133. /**
  112134. * Set the motor limits.
  112135. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112136. * @param {number} upperLimit the upper limit
  112137. * @param {number} lowerLimit lower limit
  112138. * @param {motorIndex} the motor's index, 0 or 1.
  112139. */
  112140. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112141. }
  112142. /**
  112143. * Interface for a motor enabled joint
  112144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112145. */
  112146. export interface IMotorEnabledJoint {
  112147. /**
  112148. * Physics joint
  112149. */
  112150. physicsJoint: any;
  112151. /**
  112152. * Sets the motor of the motor-enabled joint
  112153. * @param force The force of the motor
  112154. * @param maxForce The maximum force of the motor
  112155. * @param motorIndex The index of the motor
  112156. */
  112157. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112158. /**
  112159. * Sets the limit of the motor
  112160. * @param upperLimit The upper limit of the motor
  112161. * @param lowerLimit The lower limit of the motor
  112162. * @param motorIndex The index of the motor
  112163. */
  112164. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112165. }
  112166. /**
  112167. * Joint data for a Distance-Joint
  112168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112169. */
  112170. export interface DistanceJointData extends PhysicsJointData {
  112171. /**
  112172. * Max distance the 2 joint objects can be apart
  112173. */
  112174. maxDistance: number;
  112175. }
  112176. /**
  112177. * Joint data from a spring joint
  112178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112179. */
  112180. export interface SpringJointData extends PhysicsJointData {
  112181. /**
  112182. * Length of the spring
  112183. */
  112184. length: number;
  112185. /**
  112186. * Stiffness of the spring
  112187. */
  112188. stiffness: number;
  112189. /**
  112190. * Damping of the spring
  112191. */
  112192. damping: number;
  112193. /** this callback will be called when applying the force to the impostors. */
  112194. forceApplicationCallback: () => void;
  112195. }
  112196. }
  112197. declare module BABYLON {
  112198. /**
  112199. * Holds the data for the raycast result
  112200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112201. */
  112202. export class PhysicsRaycastResult {
  112203. private _hasHit;
  112204. private _hitDistance;
  112205. private _hitNormalWorld;
  112206. private _hitPointWorld;
  112207. private _rayFromWorld;
  112208. private _rayToWorld;
  112209. /**
  112210. * Gets if there was a hit
  112211. */
  112212. get hasHit(): boolean;
  112213. /**
  112214. * Gets the distance from the hit
  112215. */
  112216. get hitDistance(): number;
  112217. /**
  112218. * Gets the hit normal/direction in the world
  112219. */
  112220. get hitNormalWorld(): Vector3;
  112221. /**
  112222. * Gets the hit point in the world
  112223. */
  112224. get hitPointWorld(): Vector3;
  112225. /**
  112226. * Gets the ray "start point" of the ray in the world
  112227. */
  112228. get rayFromWorld(): Vector3;
  112229. /**
  112230. * Gets the ray "end point" of the ray in the world
  112231. */
  112232. get rayToWorld(): Vector3;
  112233. /**
  112234. * Sets the hit data (normal & point in world space)
  112235. * @param hitNormalWorld defines the normal in world space
  112236. * @param hitPointWorld defines the point in world space
  112237. */
  112238. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112239. /**
  112240. * Sets the distance from the start point to the hit point
  112241. * @param distance
  112242. */
  112243. setHitDistance(distance: number): void;
  112244. /**
  112245. * Calculates the distance manually
  112246. */
  112247. calculateHitDistance(): void;
  112248. /**
  112249. * Resets all the values to default
  112250. * @param from The from point on world space
  112251. * @param to The to point on world space
  112252. */
  112253. reset(from?: Vector3, to?: Vector3): void;
  112254. }
  112255. /**
  112256. * Interface for the size containing width and height
  112257. */
  112258. interface IXYZ {
  112259. /**
  112260. * X
  112261. */
  112262. x: number;
  112263. /**
  112264. * Y
  112265. */
  112266. y: number;
  112267. /**
  112268. * Z
  112269. */
  112270. z: number;
  112271. }
  112272. }
  112273. declare module BABYLON {
  112274. /**
  112275. * Interface used to describe a physics joint
  112276. */
  112277. export interface PhysicsImpostorJoint {
  112278. /** Defines the main impostor to which the joint is linked */
  112279. mainImpostor: PhysicsImpostor;
  112280. /** Defines the impostor that is connected to the main impostor using this joint */
  112281. connectedImpostor: PhysicsImpostor;
  112282. /** Defines the joint itself */
  112283. joint: PhysicsJoint;
  112284. }
  112285. /** @hidden */
  112286. export interface IPhysicsEnginePlugin {
  112287. world: any;
  112288. name: string;
  112289. setGravity(gravity: Vector3): void;
  112290. setTimeStep(timeStep: number): void;
  112291. getTimeStep(): number;
  112292. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112293. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112294. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112295. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112296. removePhysicsBody(impostor: PhysicsImpostor): void;
  112297. generateJoint(joint: PhysicsImpostorJoint): void;
  112298. removeJoint(joint: PhysicsImpostorJoint): void;
  112299. isSupported(): boolean;
  112300. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112301. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112302. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112303. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112304. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112305. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112306. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112307. getBodyMass(impostor: PhysicsImpostor): number;
  112308. getBodyFriction(impostor: PhysicsImpostor): number;
  112309. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112310. getBodyRestitution(impostor: PhysicsImpostor): number;
  112311. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112312. getBodyPressure?(impostor: PhysicsImpostor): number;
  112313. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  112314. getBodyStiffness?(impostor: PhysicsImpostor): number;
  112315. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  112316. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  112317. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  112318. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  112319. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  112320. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112321. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112322. sleepBody(impostor: PhysicsImpostor): void;
  112323. wakeUpBody(impostor: PhysicsImpostor): void;
  112324. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112325. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112326. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  112327. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112328. getRadius(impostor: PhysicsImpostor): number;
  112329. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112330. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112331. dispose(): void;
  112332. }
  112333. /**
  112334. * Interface used to define a physics engine
  112335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112336. */
  112337. export interface IPhysicsEngine {
  112338. /**
  112339. * Gets the gravity vector used by the simulation
  112340. */
  112341. gravity: Vector3;
  112342. /**
  112343. * Sets the gravity vector used by the simulation
  112344. * @param gravity defines the gravity vector to use
  112345. */
  112346. setGravity(gravity: Vector3): void;
  112347. /**
  112348. * Set the time step of the physics engine.
  112349. * Default is 1/60.
  112350. * To slow it down, enter 1/600 for example.
  112351. * To speed it up, 1/30
  112352. * @param newTimeStep the new timestep to apply to this world.
  112353. */
  112354. setTimeStep(newTimeStep: number): void;
  112355. /**
  112356. * Get the time step of the physics engine.
  112357. * @returns the current time step
  112358. */
  112359. getTimeStep(): number;
  112360. /**
  112361. * Set the sub time step of the physics engine.
  112362. * Default is 0 meaning there is no sub steps
  112363. * To increase physics resolution precision, set a small value (like 1 ms)
  112364. * @param subTimeStep defines the new sub timestep used for physics resolution.
  112365. */
  112366. setSubTimeStep(subTimeStep: number): void;
  112367. /**
  112368. * Get the sub time step of the physics engine.
  112369. * @returns the current sub time step
  112370. */
  112371. getSubTimeStep(): number;
  112372. /**
  112373. * Release all resources
  112374. */
  112375. dispose(): void;
  112376. /**
  112377. * Gets the name of the current physics plugin
  112378. * @returns the name of the plugin
  112379. */
  112380. getPhysicsPluginName(): string;
  112381. /**
  112382. * Adding a new impostor for the impostor tracking.
  112383. * This will be done by the impostor itself.
  112384. * @param impostor the impostor to add
  112385. */
  112386. addImpostor(impostor: PhysicsImpostor): void;
  112387. /**
  112388. * Remove an impostor from the engine.
  112389. * This impostor and its mesh will not longer be updated by the physics engine.
  112390. * @param impostor the impostor to remove
  112391. */
  112392. removeImpostor(impostor: PhysicsImpostor): void;
  112393. /**
  112394. * Add a joint to the physics engine
  112395. * @param mainImpostor defines the main impostor to which the joint is added.
  112396. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112397. * @param joint defines the joint that will connect both impostors.
  112398. */
  112399. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112400. /**
  112401. * Removes a joint from the simulation
  112402. * @param mainImpostor defines the impostor used with the joint
  112403. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112404. * @param joint defines the joint to remove
  112405. */
  112406. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112407. /**
  112408. * Gets the current plugin used to run the simulation
  112409. * @returns current plugin
  112410. */
  112411. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112412. /**
  112413. * Gets the list of physic impostors
  112414. * @returns an array of PhysicsImpostor
  112415. */
  112416. getImpostors(): Array<PhysicsImpostor>;
  112417. /**
  112418. * Gets the impostor for a physics enabled object
  112419. * @param object defines the object impersonated by the impostor
  112420. * @returns the PhysicsImpostor or null if not found
  112421. */
  112422. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112423. /**
  112424. * Gets the impostor for a physics body object
  112425. * @param body defines physics body used by the impostor
  112426. * @returns the PhysicsImpostor or null if not found
  112427. */
  112428. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112429. /**
  112430. * Does a raycast in the physics world
  112431. * @param from when should the ray start?
  112432. * @param to when should the ray end?
  112433. * @returns PhysicsRaycastResult
  112434. */
  112435. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112436. /**
  112437. * Called by the scene. No need to call it.
  112438. * @param delta defines the timespam between frames
  112439. */
  112440. _step(delta: number): void;
  112441. }
  112442. }
  112443. declare module BABYLON {
  112444. /**
  112445. * The interface for the physics imposter parameters
  112446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112447. */
  112448. export interface PhysicsImpostorParameters {
  112449. /**
  112450. * The mass of the physics imposter
  112451. */
  112452. mass: number;
  112453. /**
  112454. * The friction of the physics imposter
  112455. */
  112456. friction?: number;
  112457. /**
  112458. * The coefficient of restitution of the physics imposter
  112459. */
  112460. restitution?: number;
  112461. /**
  112462. * The native options of the physics imposter
  112463. */
  112464. nativeOptions?: any;
  112465. /**
  112466. * Specifies if the parent should be ignored
  112467. */
  112468. ignoreParent?: boolean;
  112469. /**
  112470. * Specifies if bi-directional transformations should be disabled
  112471. */
  112472. disableBidirectionalTransformation?: boolean;
  112473. /**
  112474. * The pressure inside the physics imposter, soft object only
  112475. */
  112476. pressure?: number;
  112477. /**
  112478. * The stiffness the physics imposter, soft object only
  112479. */
  112480. stiffness?: number;
  112481. /**
  112482. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  112483. */
  112484. velocityIterations?: number;
  112485. /**
  112486. * The number of iterations used in maintaining consistent vertex positions, soft object only
  112487. */
  112488. positionIterations?: number;
  112489. /**
  112490. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  112491. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  112492. * Add to fix multiple points
  112493. */
  112494. fixedPoints?: number;
  112495. /**
  112496. * The collision margin around a soft object
  112497. */
  112498. margin?: number;
  112499. /**
  112500. * The collision margin around a soft object
  112501. */
  112502. damping?: number;
  112503. /**
  112504. * The path for a rope based on an extrusion
  112505. */
  112506. path?: any;
  112507. /**
  112508. * The shape of an extrusion used for a rope based on an extrusion
  112509. */
  112510. shape?: any;
  112511. }
  112512. /**
  112513. * Interface for a physics-enabled object
  112514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112515. */
  112516. export interface IPhysicsEnabledObject {
  112517. /**
  112518. * The position of the physics-enabled object
  112519. */
  112520. position: Vector3;
  112521. /**
  112522. * The rotation of the physics-enabled object
  112523. */
  112524. rotationQuaternion: Nullable<Quaternion>;
  112525. /**
  112526. * The scale of the physics-enabled object
  112527. */
  112528. scaling: Vector3;
  112529. /**
  112530. * The rotation of the physics-enabled object
  112531. */
  112532. rotation?: Vector3;
  112533. /**
  112534. * The parent of the physics-enabled object
  112535. */
  112536. parent?: any;
  112537. /**
  112538. * The bounding info of the physics-enabled object
  112539. * @returns The bounding info of the physics-enabled object
  112540. */
  112541. getBoundingInfo(): BoundingInfo;
  112542. /**
  112543. * Computes the world matrix
  112544. * @param force Specifies if the world matrix should be computed by force
  112545. * @returns A world matrix
  112546. */
  112547. computeWorldMatrix(force: boolean): Matrix;
  112548. /**
  112549. * Gets the world matrix
  112550. * @returns A world matrix
  112551. */
  112552. getWorldMatrix?(): Matrix;
  112553. /**
  112554. * Gets the child meshes
  112555. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  112556. * @returns An array of abstract meshes
  112557. */
  112558. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  112559. /**
  112560. * Gets the vertex data
  112561. * @param kind The type of vertex data
  112562. * @returns A nullable array of numbers, or a float32 array
  112563. */
  112564. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  112565. /**
  112566. * Gets the indices from the mesh
  112567. * @returns A nullable array of index arrays
  112568. */
  112569. getIndices?(): Nullable<IndicesArray>;
  112570. /**
  112571. * Gets the scene from the mesh
  112572. * @returns the indices array or null
  112573. */
  112574. getScene?(): Scene;
  112575. /**
  112576. * Gets the absolute position from the mesh
  112577. * @returns the absolute position
  112578. */
  112579. getAbsolutePosition(): Vector3;
  112580. /**
  112581. * Gets the absolute pivot point from the mesh
  112582. * @returns the absolute pivot point
  112583. */
  112584. getAbsolutePivotPoint(): Vector3;
  112585. /**
  112586. * Rotates the mesh
  112587. * @param axis The axis of rotation
  112588. * @param amount The amount of rotation
  112589. * @param space The space of the rotation
  112590. * @returns The rotation transform node
  112591. */
  112592. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  112593. /**
  112594. * Translates the mesh
  112595. * @param axis The axis of translation
  112596. * @param distance The distance of translation
  112597. * @param space The space of the translation
  112598. * @returns The transform node
  112599. */
  112600. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  112601. /**
  112602. * Sets the absolute position of the mesh
  112603. * @param absolutePosition The absolute position of the mesh
  112604. * @returns The transform node
  112605. */
  112606. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  112607. /**
  112608. * Gets the class name of the mesh
  112609. * @returns The class name
  112610. */
  112611. getClassName(): string;
  112612. }
  112613. /**
  112614. * Represents a physics imposter
  112615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112616. */
  112617. export class PhysicsImpostor {
  112618. /**
  112619. * The physics-enabled object used as the physics imposter
  112620. */
  112621. object: IPhysicsEnabledObject;
  112622. /**
  112623. * The type of the physics imposter
  112624. */
  112625. type: number;
  112626. private _options;
  112627. private _scene?;
  112628. /**
  112629. * The default object size of the imposter
  112630. */
  112631. static DEFAULT_OBJECT_SIZE: Vector3;
  112632. /**
  112633. * The identity quaternion of the imposter
  112634. */
  112635. static IDENTITY_QUATERNION: Quaternion;
  112636. /** @hidden */
  112637. _pluginData: any;
  112638. private _physicsEngine;
  112639. private _physicsBody;
  112640. private _bodyUpdateRequired;
  112641. private _onBeforePhysicsStepCallbacks;
  112642. private _onAfterPhysicsStepCallbacks;
  112643. /** @hidden */
  112644. _onPhysicsCollideCallbacks: Array<{
  112645. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  112646. otherImpostors: Array<PhysicsImpostor>;
  112647. }>;
  112648. private _deltaPosition;
  112649. private _deltaRotation;
  112650. private _deltaRotationConjugated;
  112651. /** @hidden */
  112652. _isFromLine: boolean;
  112653. private _parent;
  112654. private _isDisposed;
  112655. private static _tmpVecs;
  112656. private static _tmpQuat;
  112657. /**
  112658. * Specifies if the physics imposter is disposed
  112659. */
  112660. get isDisposed(): boolean;
  112661. /**
  112662. * Gets the mass of the physics imposter
  112663. */
  112664. get mass(): number;
  112665. set mass(value: number);
  112666. /**
  112667. * Gets the coefficient of friction
  112668. */
  112669. get friction(): number;
  112670. /**
  112671. * Sets the coefficient of friction
  112672. */
  112673. set friction(value: number);
  112674. /**
  112675. * Gets the coefficient of restitution
  112676. */
  112677. get restitution(): number;
  112678. /**
  112679. * Sets the coefficient of restitution
  112680. */
  112681. set restitution(value: number);
  112682. /**
  112683. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  112684. */
  112685. get pressure(): number;
  112686. /**
  112687. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  112688. */
  112689. set pressure(value: number);
  112690. /**
  112691. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112692. */
  112693. get stiffness(): number;
  112694. /**
  112695. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  112696. */
  112697. set stiffness(value: number);
  112698. /**
  112699. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112700. */
  112701. get velocityIterations(): number;
  112702. /**
  112703. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  112704. */
  112705. set velocityIterations(value: number);
  112706. /**
  112707. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112708. */
  112709. get positionIterations(): number;
  112710. /**
  112711. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  112712. */
  112713. set positionIterations(value: number);
  112714. /**
  112715. * The unique id of the physics imposter
  112716. * set by the physics engine when adding this impostor to the array
  112717. */
  112718. uniqueId: number;
  112719. /**
  112720. * @hidden
  112721. */
  112722. soft: boolean;
  112723. /**
  112724. * @hidden
  112725. */
  112726. segments: number;
  112727. private _joints;
  112728. /**
  112729. * Initializes the physics imposter
  112730. * @param object The physics-enabled object used as the physics imposter
  112731. * @param type The type of the physics imposter
  112732. * @param _options The options for the physics imposter
  112733. * @param _scene The Babylon scene
  112734. */
  112735. constructor(
  112736. /**
  112737. * The physics-enabled object used as the physics imposter
  112738. */
  112739. object: IPhysicsEnabledObject,
  112740. /**
  112741. * The type of the physics imposter
  112742. */
  112743. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  112744. /**
  112745. * This function will completly initialize this impostor.
  112746. * It will create a new body - but only if this mesh has no parent.
  112747. * If it has, this impostor will not be used other than to define the impostor
  112748. * of the child mesh.
  112749. * @hidden
  112750. */
  112751. _init(): void;
  112752. private _getPhysicsParent;
  112753. /**
  112754. * Should a new body be generated.
  112755. * @returns boolean specifying if body initialization is required
  112756. */
  112757. isBodyInitRequired(): boolean;
  112758. /**
  112759. * Sets the updated scaling
  112760. * @param updated Specifies if the scaling is updated
  112761. */
  112762. setScalingUpdated(): void;
  112763. /**
  112764. * Force a regeneration of this or the parent's impostor's body.
  112765. * Use under cautious - This will remove all joints already implemented.
  112766. */
  112767. forceUpdate(): void;
  112768. /**
  112769. * Gets the body that holds this impostor. Either its own, or its parent.
  112770. */
  112771. get physicsBody(): any;
  112772. /**
  112773. * Get the parent of the physics imposter
  112774. * @returns Physics imposter or null
  112775. */
  112776. get parent(): Nullable<PhysicsImpostor>;
  112777. /**
  112778. * Sets the parent of the physics imposter
  112779. */
  112780. set parent(value: Nullable<PhysicsImpostor>);
  112781. /**
  112782. * Set the physics body. Used mainly by the physics engine/plugin
  112783. */
  112784. set physicsBody(physicsBody: any);
  112785. /**
  112786. * Resets the update flags
  112787. */
  112788. resetUpdateFlags(): void;
  112789. /**
  112790. * Gets the object extend size
  112791. * @returns the object extend size
  112792. */
  112793. getObjectExtendSize(): Vector3;
  112794. /**
  112795. * Gets the object center
  112796. * @returns The object center
  112797. */
  112798. getObjectCenter(): Vector3;
  112799. /**
  112800. * Get a specific parameter from the options parameters
  112801. * @param paramName The object parameter name
  112802. * @returns The object parameter
  112803. */
  112804. getParam(paramName: string): any;
  112805. /**
  112806. * Sets a specific parameter in the options given to the physics plugin
  112807. * @param paramName The parameter name
  112808. * @param value The value of the parameter
  112809. */
  112810. setParam(paramName: string, value: number): void;
  112811. /**
  112812. * Specifically change the body's mass option. Won't recreate the physics body object
  112813. * @param mass The mass of the physics imposter
  112814. */
  112815. setMass(mass: number): void;
  112816. /**
  112817. * Gets the linear velocity
  112818. * @returns linear velocity or null
  112819. */
  112820. getLinearVelocity(): Nullable<Vector3>;
  112821. /**
  112822. * Sets the linear velocity
  112823. * @param velocity linear velocity or null
  112824. */
  112825. setLinearVelocity(velocity: Nullable<Vector3>): void;
  112826. /**
  112827. * Gets the angular velocity
  112828. * @returns angular velocity or null
  112829. */
  112830. getAngularVelocity(): Nullable<Vector3>;
  112831. /**
  112832. * Sets the angular velocity
  112833. * @param velocity The velocity or null
  112834. */
  112835. setAngularVelocity(velocity: Nullable<Vector3>): void;
  112836. /**
  112837. * Execute a function with the physics plugin native code
  112838. * Provide a function the will have two variables - the world object and the physics body object
  112839. * @param func The function to execute with the physics plugin native code
  112840. */
  112841. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  112842. /**
  112843. * Register a function that will be executed before the physics world is stepping forward
  112844. * @param func The function to execute before the physics world is stepped forward
  112845. */
  112846. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112847. /**
  112848. * Unregister a function that will be executed before the physics world is stepping forward
  112849. * @param func The function to execute before the physics world is stepped forward
  112850. */
  112851. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112852. /**
  112853. * Register a function that will be executed after the physics step
  112854. * @param func The function to execute after physics step
  112855. */
  112856. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112857. /**
  112858. * Unregisters a function that will be executed after the physics step
  112859. * @param func The function to execute after physics step
  112860. */
  112861. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  112862. /**
  112863. * register a function that will be executed when this impostor collides against a different body
  112864. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  112865. * @param func Callback that is executed on collision
  112866. */
  112867. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  112868. /**
  112869. * Unregisters the physics imposter on contact
  112870. * @param collideAgainst The physics object to collide against
  112871. * @param func Callback to execute on collision
  112872. */
  112873. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  112874. private _tmpQuat;
  112875. private _tmpQuat2;
  112876. /**
  112877. * Get the parent rotation
  112878. * @returns The parent rotation
  112879. */
  112880. getParentsRotation(): Quaternion;
  112881. /**
  112882. * this function is executed by the physics engine.
  112883. */
  112884. beforeStep: () => void;
  112885. /**
  112886. * this function is executed by the physics engine
  112887. */
  112888. afterStep: () => void;
  112889. /**
  112890. * Legacy collision detection event support
  112891. */
  112892. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  112893. /**
  112894. * event and body object due to cannon's event-based architecture.
  112895. */
  112896. onCollide: (e: {
  112897. body: any;
  112898. }) => void;
  112899. /**
  112900. * Apply a force
  112901. * @param force The force to apply
  112902. * @param contactPoint The contact point for the force
  112903. * @returns The physics imposter
  112904. */
  112905. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  112906. /**
  112907. * Apply an impulse
  112908. * @param force The impulse force
  112909. * @param contactPoint The contact point for the impulse force
  112910. * @returns The physics imposter
  112911. */
  112912. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  112913. /**
  112914. * A help function to create a joint
  112915. * @param otherImpostor A physics imposter used to create a joint
  112916. * @param jointType The type of joint
  112917. * @param jointData The data for the joint
  112918. * @returns The physics imposter
  112919. */
  112920. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  112921. /**
  112922. * Add a joint to this impostor with a different impostor
  112923. * @param otherImpostor A physics imposter used to add a joint
  112924. * @param joint The joint to add
  112925. * @returns The physics imposter
  112926. */
  112927. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  112928. /**
  112929. * Add an anchor to a cloth impostor
  112930. * @param otherImpostor rigid impostor to anchor to
  112931. * @param width ratio across width from 0 to 1
  112932. * @param height ratio up height from 0 to 1
  112933. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112934. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  112935. * @returns impostor the soft imposter
  112936. */
  112937. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  112938. /**
  112939. * Add a hook to a rope impostor
  112940. * @param otherImpostor rigid impostor to anchor to
  112941. * @param length ratio across rope from 0 to 1
  112942. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  112943. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112944. * @returns impostor the rope imposter
  112945. */
  112946. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  112947. /**
  112948. * Will keep this body still, in a sleep mode.
  112949. * @returns the physics imposter
  112950. */
  112951. sleep(): PhysicsImpostor;
  112952. /**
  112953. * Wake the body up.
  112954. * @returns The physics imposter
  112955. */
  112956. wakeUp(): PhysicsImpostor;
  112957. /**
  112958. * Clones the physics imposter
  112959. * @param newObject The physics imposter clones to this physics-enabled object
  112960. * @returns A nullable physics imposter
  112961. */
  112962. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112963. /**
  112964. * Disposes the physics imposter
  112965. */
  112966. dispose(): void;
  112967. /**
  112968. * Sets the delta position
  112969. * @param position The delta position amount
  112970. */
  112971. setDeltaPosition(position: Vector3): void;
  112972. /**
  112973. * Sets the delta rotation
  112974. * @param rotation The delta rotation amount
  112975. */
  112976. setDeltaRotation(rotation: Quaternion): void;
  112977. /**
  112978. * Gets the box size of the physics imposter and stores the result in the input parameter
  112979. * @param result Stores the box size
  112980. * @returns The physics imposter
  112981. */
  112982. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  112983. /**
  112984. * Gets the radius of the physics imposter
  112985. * @returns Radius of the physics imposter
  112986. */
  112987. getRadius(): number;
  112988. /**
  112989. * Sync a bone with this impostor
  112990. * @param bone The bone to sync to the impostor.
  112991. * @param boneMesh The mesh that the bone is influencing.
  112992. * @param jointPivot The pivot of the joint / bone in local space.
  112993. * @param distToJoint Optional distance from the impostor to the joint.
  112994. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  112995. */
  112996. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  112997. /**
  112998. * Sync impostor to a bone
  112999. * @param bone The bone that the impostor will be synced to.
  113000. * @param boneMesh The mesh that the bone is influencing.
  113001. * @param jointPivot The pivot of the joint / bone in local space.
  113002. * @param distToJoint Optional distance from the impostor to the joint.
  113003. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113004. * @param boneAxis Optional vector3 axis the bone is aligned with
  113005. */
  113006. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113007. /**
  113008. * No-Imposter type
  113009. */
  113010. static NoImpostor: number;
  113011. /**
  113012. * Sphere-Imposter type
  113013. */
  113014. static SphereImpostor: number;
  113015. /**
  113016. * Box-Imposter type
  113017. */
  113018. static BoxImpostor: number;
  113019. /**
  113020. * Plane-Imposter type
  113021. */
  113022. static PlaneImpostor: number;
  113023. /**
  113024. * Mesh-imposter type
  113025. */
  113026. static MeshImpostor: number;
  113027. /**
  113028. * Capsule-Impostor type (Ammo.js plugin only)
  113029. */
  113030. static CapsuleImpostor: number;
  113031. /**
  113032. * Cylinder-Imposter type
  113033. */
  113034. static CylinderImpostor: number;
  113035. /**
  113036. * Particle-Imposter type
  113037. */
  113038. static ParticleImpostor: number;
  113039. /**
  113040. * Heightmap-Imposter type
  113041. */
  113042. static HeightmapImpostor: number;
  113043. /**
  113044. * ConvexHull-Impostor type (Ammo.js plugin only)
  113045. */
  113046. static ConvexHullImpostor: number;
  113047. /**
  113048. * Custom-Imposter type (Ammo.js plugin only)
  113049. */
  113050. static CustomImpostor: number;
  113051. /**
  113052. * Rope-Imposter type
  113053. */
  113054. static RopeImpostor: number;
  113055. /**
  113056. * Cloth-Imposter type
  113057. */
  113058. static ClothImpostor: number;
  113059. /**
  113060. * Softbody-Imposter type
  113061. */
  113062. static SoftbodyImpostor: number;
  113063. }
  113064. }
  113065. declare module BABYLON {
  113066. /**
  113067. * @hidden
  113068. **/
  113069. export class _CreationDataStorage {
  113070. closePath?: boolean;
  113071. closeArray?: boolean;
  113072. idx: number[];
  113073. dashSize: number;
  113074. gapSize: number;
  113075. path3D: Path3D;
  113076. pathArray: Vector3[][];
  113077. arc: number;
  113078. radius: number;
  113079. cap: number;
  113080. tessellation: number;
  113081. }
  113082. /**
  113083. * @hidden
  113084. **/
  113085. class _InstanceDataStorage {
  113086. visibleInstances: any;
  113087. batchCache: _InstancesBatch;
  113088. instancesBufferSize: number;
  113089. instancesBuffer: Nullable<Buffer>;
  113090. instancesData: Float32Array;
  113091. overridenInstanceCount: number;
  113092. isFrozen: boolean;
  113093. previousBatch: Nullable<_InstancesBatch>;
  113094. hardwareInstancedRendering: boolean;
  113095. sideOrientation: number;
  113096. manualUpdate: boolean;
  113097. previousRenderId: number;
  113098. }
  113099. /**
  113100. * @hidden
  113101. **/
  113102. export class _InstancesBatch {
  113103. mustReturn: boolean;
  113104. visibleInstances: Nullable<InstancedMesh[]>[];
  113105. renderSelf: boolean[];
  113106. hardwareInstancedRendering: boolean[];
  113107. }
  113108. /**
  113109. * @hidden
  113110. **/
  113111. class _ThinInstanceDataStorage {
  113112. instancesCount: number;
  113113. matrixBuffer: Nullable<Buffer>;
  113114. matrixBufferSize: number;
  113115. matrixData: Nullable<Float32Array>;
  113116. boundingVectors: Array<Vector3>;
  113117. worldMatrices: Nullable<Matrix[]>;
  113118. }
  113119. /**
  113120. * Class used to represent renderable models
  113121. */
  113122. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113123. /**
  113124. * Mesh side orientation : usually the external or front surface
  113125. */
  113126. static readonly FRONTSIDE: number;
  113127. /**
  113128. * Mesh side orientation : usually the internal or back surface
  113129. */
  113130. static readonly BACKSIDE: number;
  113131. /**
  113132. * Mesh side orientation : both internal and external or front and back surfaces
  113133. */
  113134. static readonly DOUBLESIDE: number;
  113135. /**
  113136. * Mesh side orientation : by default, `FRONTSIDE`
  113137. */
  113138. static readonly DEFAULTSIDE: number;
  113139. /**
  113140. * Mesh cap setting : no cap
  113141. */
  113142. static readonly NO_CAP: number;
  113143. /**
  113144. * Mesh cap setting : one cap at the beginning of the mesh
  113145. */
  113146. static readonly CAP_START: number;
  113147. /**
  113148. * Mesh cap setting : one cap at the end of the mesh
  113149. */
  113150. static readonly CAP_END: number;
  113151. /**
  113152. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113153. */
  113154. static readonly CAP_ALL: number;
  113155. /**
  113156. * Mesh pattern setting : no flip or rotate
  113157. */
  113158. static readonly NO_FLIP: number;
  113159. /**
  113160. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113161. */
  113162. static readonly FLIP_TILE: number;
  113163. /**
  113164. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113165. */
  113166. static readonly ROTATE_TILE: number;
  113167. /**
  113168. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113169. */
  113170. static readonly FLIP_ROW: number;
  113171. /**
  113172. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113173. */
  113174. static readonly ROTATE_ROW: number;
  113175. /**
  113176. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113177. */
  113178. static readonly FLIP_N_ROTATE_TILE: number;
  113179. /**
  113180. * Mesh pattern setting : rotate pattern and rotate
  113181. */
  113182. static readonly FLIP_N_ROTATE_ROW: number;
  113183. /**
  113184. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113185. */
  113186. static readonly CENTER: number;
  113187. /**
  113188. * Mesh tile positioning : part tiles on left
  113189. */
  113190. static readonly LEFT: number;
  113191. /**
  113192. * Mesh tile positioning : part tiles on right
  113193. */
  113194. static readonly RIGHT: number;
  113195. /**
  113196. * Mesh tile positioning : part tiles on top
  113197. */
  113198. static readonly TOP: number;
  113199. /**
  113200. * Mesh tile positioning : part tiles on bottom
  113201. */
  113202. static readonly BOTTOM: number;
  113203. /**
  113204. * Gets the default side orientation.
  113205. * @param orientation the orientation to value to attempt to get
  113206. * @returns the default orientation
  113207. * @hidden
  113208. */
  113209. static _GetDefaultSideOrientation(orientation?: number): number;
  113210. private _internalMeshDataInfo;
  113211. get computeBonesUsingShaders(): boolean;
  113212. set computeBonesUsingShaders(value: boolean);
  113213. /**
  113214. * An event triggered before rendering the mesh
  113215. */
  113216. get onBeforeRenderObservable(): Observable<Mesh>;
  113217. /**
  113218. * An event triggered before binding the mesh
  113219. */
  113220. get onBeforeBindObservable(): Observable<Mesh>;
  113221. /**
  113222. * An event triggered after rendering the mesh
  113223. */
  113224. get onAfterRenderObservable(): Observable<Mesh>;
  113225. /**
  113226. * An event triggered before drawing the mesh
  113227. */
  113228. get onBeforeDrawObservable(): Observable<Mesh>;
  113229. private _onBeforeDrawObserver;
  113230. /**
  113231. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113232. */
  113233. set onBeforeDraw(callback: () => void);
  113234. get hasInstances(): boolean;
  113235. get hasThinInstances(): boolean;
  113236. /**
  113237. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113238. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113239. */
  113240. delayLoadState: number;
  113241. /**
  113242. * Gets the list of instances created from this mesh
  113243. * it is not supposed to be modified manually.
  113244. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113245. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113246. */
  113247. instances: InstancedMesh[];
  113248. /**
  113249. * Gets the file containing delay loading data for this mesh
  113250. */
  113251. delayLoadingFile: string;
  113252. /** @hidden */
  113253. _binaryInfo: any;
  113254. /**
  113255. * User defined function used to change how LOD level selection is done
  113256. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113257. */
  113258. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113259. /**
  113260. * Gets or sets the morph target manager
  113261. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113262. */
  113263. get morphTargetManager(): Nullable<MorphTargetManager>;
  113264. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113265. /** @hidden */
  113266. _creationDataStorage: Nullable<_CreationDataStorage>;
  113267. /** @hidden */
  113268. _geometry: Nullable<Geometry>;
  113269. /** @hidden */
  113270. _delayInfo: Array<string>;
  113271. /** @hidden */
  113272. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  113273. /** @hidden */
  113274. _instanceDataStorage: _InstanceDataStorage;
  113275. /** @hidden */
  113276. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  113277. private _effectiveMaterial;
  113278. /** @hidden */
  113279. _shouldGenerateFlatShading: boolean;
  113280. /** @hidden */
  113281. _originalBuilderSideOrientation: number;
  113282. /**
  113283. * Use this property to change the original side orientation defined at construction time
  113284. */
  113285. overrideMaterialSideOrientation: Nullable<number>;
  113286. /**
  113287. * Gets the source mesh (the one used to clone this one from)
  113288. */
  113289. get source(): Nullable<Mesh>;
  113290. /**
  113291. * Gets the list of clones of this mesh
  113292. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  113293. * Note that useClonedMeshMap=true is the default setting
  113294. */
  113295. get cloneMeshMap(): Nullable<{
  113296. [id: string]: Mesh | undefined;
  113297. }>;
  113298. /**
  113299. * Gets or sets a boolean indicating that this mesh does not use index buffer
  113300. */
  113301. get isUnIndexed(): boolean;
  113302. set isUnIndexed(value: boolean);
  113303. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  113304. get worldMatrixInstancedBuffer(): Float32Array;
  113305. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  113306. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  113307. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  113308. /**
  113309. * @constructor
  113310. * @param name The value used by scene.getMeshByName() to do a lookup.
  113311. * @param scene The scene to add this mesh to.
  113312. * @param parent The parent of this mesh, if it has one
  113313. * @param source An optional Mesh from which geometry is shared, cloned.
  113314. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113315. * When false, achieved by calling a clone(), also passing False.
  113316. * This will make creation of children, recursive.
  113317. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  113318. */
  113319. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  113320. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  113321. doNotInstantiate: boolean;
  113322. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  113323. /**
  113324. * Gets the class name
  113325. * @returns the string "Mesh".
  113326. */
  113327. getClassName(): string;
  113328. /** @hidden */
  113329. get _isMesh(): boolean;
  113330. /**
  113331. * Returns a description of this mesh
  113332. * @param fullDetails define if full details about this mesh must be used
  113333. * @returns a descriptive string representing this mesh
  113334. */
  113335. toString(fullDetails?: boolean): string;
  113336. /** @hidden */
  113337. _unBindEffect(): void;
  113338. /**
  113339. * Gets a boolean indicating if this mesh has LOD
  113340. */
  113341. get hasLODLevels(): boolean;
  113342. /**
  113343. * Gets the list of MeshLODLevel associated with the current mesh
  113344. * @returns an array of MeshLODLevel
  113345. */
  113346. getLODLevels(): MeshLODLevel[];
  113347. private _sortLODLevels;
  113348. /**
  113349. * Add a mesh as LOD level triggered at the given distance.
  113350. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113351. * @param distance The distance from the center of the object to show this level
  113352. * @param mesh The mesh to be added as LOD level (can be null)
  113353. * @return This mesh (for chaining)
  113354. */
  113355. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  113356. /**
  113357. * Returns the LOD level mesh at the passed distance or null if not found.
  113358. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113359. * @param distance The distance from the center of the object to show this level
  113360. * @returns a Mesh or `null`
  113361. */
  113362. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  113363. /**
  113364. * Remove a mesh from the LOD array
  113365. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113366. * @param mesh defines the mesh to be removed
  113367. * @return This mesh (for chaining)
  113368. */
  113369. removeLODLevel(mesh: Mesh): Mesh;
  113370. /**
  113371. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  113372. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113373. * @param camera defines the camera to use to compute distance
  113374. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  113375. * @return This mesh (for chaining)
  113376. */
  113377. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  113378. /**
  113379. * Gets the mesh internal Geometry object
  113380. */
  113381. get geometry(): Nullable<Geometry>;
  113382. /**
  113383. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  113384. * @returns the total number of vertices
  113385. */
  113386. getTotalVertices(): number;
  113387. /**
  113388. * Returns the content of an associated vertex buffer
  113389. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113390. * - VertexBuffer.PositionKind
  113391. * - VertexBuffer.UVKind
  113392. * - VertexBuffer.UV2Kind
  113393. * - VertexBuffer.UV3Kind
  113394. * - VertexBuffer.UV4Kind
  113395. * - VertexBuffer.UV5Kind
  113396. * - VertexBuffer.UV6Kind
  113397. * - VertexBuffer.ColorKind
  113398. * - VertexBuffer.MatricesIndicesKind
  113399. * - VertexBuffer.MatricesIndicesExtraKind
  113400. * - VertexBuffer.MatricesWeightsKind
  113401. * - VertexBuffer.MatricesWeightsExtraKind
  113402. * @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
  113403. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  113404. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  113405. */
  113406. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  113407. /**
  113408. * Returns the mesh VertexBuffer object from the requested `kind`
  113409. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113410. * - VertexBuffer.PositionKind
  113411. * - VertexBuffer.NormalKind
  113412. * - VertexBuffer.UVKind
  113413. * - VertexBuffer.UV2Kind
  113414. * - VertexBuffer.UV3Kind
  113415. * - VertexBuffer.UV4Kind
  113416. * - VertexBuffer.UV5Kind
  113417. * - VertexBuffer.UV6Kind
  113418. * - VertexBuffer.ColorKind
  113419. * - VertexBuffer.MatricesIndicesKind
  113420. * - VertexBuffer.MatricesIndicesExtraKind
  113421. * - VertexBuffer.MatricesWeightsKind
  113422. * - VertexBuffer.MatricesWeightsExtraKind
  113423. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  113424. */
  113425. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  113426. /**
  113427. * Tests if a specific vertex buffer is associated with this mesh
  113428. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113429. * - VertexBuffer.PositionKind
  113430. * - VertexBuffer.NormalKind
  113431. * - VertexBuffer.UVKind
  113432. * - VertexBuffer.UV2Kind
  113433. * - VertexBuffer.UV3Kind
  113434. * - VertexBuffer.UV4Kind
  113435. * - VertexBuffer.UV5Kind
  113436. * - VertexBuffer.UV6Kind
  113437. * - VertexBuffer.ColorKind
  113438. * - VertexBuffer.MatricesIndicesKind
  113439. * - VertexBuffer.MatricesIndicesExtraKind
  113440. * - VertexBuffer.MatricesWeightsKind
  113441. * - VertexBuffer.MatricesWeightsExtraKind
  113442. * @returns a boolean
  113443. */
  113444. isVerticesDataPresent(kind: string): boolean;
  113445. /**
  113446. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  113447. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  113448. * - VertexBuffer.PositionKind
  113449. * - VertexBuffer.UVKind
  113450. * - VertexBuffer.UV2Kind
  113451. * - VertexBuffer.UV3Kind
  113452. * - VertexBuffer.UV4Kind
  113453. * - VertexBuffer.UV5Kind
  113454. * - VertexBuffer.UV6Kind
  113455. * - VertexBuffer.ColorKind
  113456. * - VertexBuffer.MatricesIndicesKind
  113457. * - VertexBuffer.MatricesIndicesExtraKind
  113458. * - VertexBuffer.MatricesWeightsKind
  113459. * - VertexBuffer.MatricesWeightsExtraKind
  113460. * @returns a boolean
  113461. */
  113462. isVertexBufferUpdatable(kind: string): boolean;
  113463. /**
  113464. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  113465. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  113466. * - VertexBuffer.PositionKind
  113467. * - VertexBuffer.NormalKind
  113468. * - VertexBuffer.UVKind
  113469. * - VertexBuffer.UV2Kind
  113470. * - VertexBuffer.UV3Kind
  113471. * - VertexBuffer.UV4Kind
  113472. * - VertexBuffer.UV5Kind
  113473. * - VertexBuffer.UV6Kind
  113474. * - VertexBuffer.ColorKind
  113475. * - VertexBuffer.MatricesIndicesKind
  113476. * - VertexBuffer.MatricesIndicesExtraKind
  113477. * - VertexBuffer.MatricesWeightsKind
  113478. * - VertexBuffer.MatricesWeightsExtraKind
  113479. * @returns an array of strings
  113480. */
  113481. getVerticesDataKinds(): string[];
  113482. /**
  113483. * Returns a positive integer : the total number of indices in this mesh geometry.
  113484. * @returns the numner of indices or zero if the mesh has no geometry.
  113485. */
  113486. getTotalIndices(): number;
  113487. /**
  113488. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  113489. * @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.
  113490. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  113491. * @returns the indices array or an empty array if the mesh has no geometry
  113492. */
  113493. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  113494. get isBlocked(): boolean;
  113495. /**
  113496. * Determine if the current mesh is ready to be rendered
  113497. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113498. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  113499. * @returns true if all associated assets are ready (material, textures, shaders)
  113500. */
  113501. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  113502. /**
  113503. * 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.
  113504. */
  113505. get areNormalsFrozen(): boolean;
  113506. /**
  113507. * 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.
  113508. * @returns the current mesh
  113509. */
  113510. freezeNormals(): Mesh;
  113511. /**
  113512. * 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
  113513. * @returns the current mesh
  113514. */
  113515. unfreezeNormals(): Mesh;
  113516. /**
  113517. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  113518. */
  113519. set overridenInstanceCount(count: number);
  113520. /** @hidden */
  113521. _preActivate(): Mesh;
  113522. /** @hidden */
  113523. _preActivateForIntermediateRendering(renderId: number): Mesh;
  113524. /** @hidden */
  113525. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  113526. protected _afterComputeWorldMatrix(): void;
  113527. /** @hidden */
  113528. _postActivate(): void;
  113529. /**
  113530. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113531. * This means the mesh underlying bounding box and sphere are recomputed.
  113532. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113533. * @returns the current mesh
  113534. */
  113535. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  113536. /** @hidden */
  113537. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  113538. /**
  113539. * This function will subdivide the mesh into multiple submeshes
  113540. * @param count defines the expected number of submeshes
  113541. */
  113542. subdivide(count: number): void;
  113543. /**
  113544. * Copy a FloatArray into a specific associated vertex buffer
  113545. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113546. * - VertexBuffer.PositionKind
  113547. * - VertexBuffer.UVKind
  113548. * - VertexBuffer.UV2Kind
  113549. * - VertexBuffer.UV3Kind
  113550. * - VertexBuffer.UV4Kind
  113551. * - VertexBuffer.UV5Kind
  113552. * - VertexBuffer.UV6Kind
  113553. * - VertexBuffer.ColorKind
  113554. * - VertexBuffer.MatricesIndicesKind
  113555. * - VertexBuffer.MatricesIndicesExtraKind
  113556. * - VertexBuffer.MatricesWeightsKind
  113557. * - VertexBuffer.MatricesWeightsExtraKind
  113558. * @param data defines the data source
  113559. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113560. * @param stride defines the data stride size (can be null)
  113561. * @returns the current mesh
  113562. */
  113563. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113564. /**
  113565. * Delete a vertex buffer associated with this mesh
  113566. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  113567. * - VertexBuffer.PositionKind
  113568. * - VertexBuffer.UVKind
  113569. * - VertexBuffer.UV2Kind
  113570. * - VertexBuffer.UV3Kind
  113571. * - VertexBuffer.UV4Kind
  113572. * - VertexBuffer.UV5Kind
  113573. * - VertexBuffer.UV6Kind
  113574. * - VertexBuffer.ColorKind
  113575. * - VertexBuffer.MatricesIndicesKind
  113576. * - VertexBuffer.MatricesIndicesExtraKind
  113577. * - VertexBuffer.MatricesWeightsKind
  113578. * - VertexBuffer.MatricesWeightsExtraKind
  113579. */
  113580. removeVerticesData(kind: string): void;
  113581. /**
  113582. * Flags an associated vertex buffer as updatable
  113583. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  113584. * - VertexBuffer.PositionKind
  113585. * - VertexBuffer.UVKind
  113586. * - VertexBuffer.UV2Kind
  113587. * - VertexBuffer.UV3Kind
  113588. * - VertexBuffer.UV4Kind
  113589. * - VertexBuffer.UV5Kind
  113590. * - VertexBuffer.UV6Kind
  113591. * - VertexBuffer.ColorKind
  113592. * - VertexBuffer.MatricesIndicesKind
  113593. * - VertexBuffer.MatricesIndicesExtraKind
  113594. * - VertexBuffer.MatricesWeightsKind
  113595. * - VertexBuffer.MatricesWeightsExtraKind
  113596. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  113597. */
  113598. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  113599. /**
  113600. * Sets the mesh global Vertex Buffer
  113601. * @param buffer defines the buffer to use
  113602. * @returns the current mesh
  113603. */
  113604. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  113605. /**
  113606. * Update a specific associated vertex buffer
  113607. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  113608. * - VertexBuffer.PositionKind
  113609. * - VertexBuffer.UVKind
  113610. * - VertexBuffer.UV2Kind
  113611. * - VertexBuffer.UV3Kind
  113612. * - VertexBuffer.UV4Kind
  113613. * - VertexBuffer.UV5Kind
  113614. * - VertexBuffer.UV6Kind
  113615. * - VertexBuffer.ColorKind
  113616. * - VertexBuffer.MatricesIndicesKind
  113617. * - VertexBuffer.MatricesIndicesExtraKind
  113618. * - VertexBuffer.MatricesWeightsKind
  113619. * - VertexBuffer.MatricesWeightsExtraKind
  113620. * @param data defines the data source
  113621. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  113622. * @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)
  113623. * @returns the current mesh
  113624. */
  113625. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  113626. /**
  113627. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  113628. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  113629. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  113630. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  113631. * @returns the current mesh
  113632. */
  113633. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  113634. /**
  113635. * Creates a un-shared specific occurence of the geometry for the mesh.
  113636. * @returns the current mesh
  113637. */
  113638. makeGeometryUnique(): Mesh;
  113639. /**
  113640. * Set the index buffer of this mesh
  113641. * @param indices defines the source data
  113642. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  113643. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  113644. * @returns the current mesh
  113645. */
  113646. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  113647. /**
  113648. * Update the current index buffer
  113649. * @param indices defines the source data
  113650. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113651. * @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)
  113652. * @returns the current mesh
  113653. */
  113654. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113655. /**
  113656. * Invert the geometry to move from a right handed system to a left handed one.
  113657. * @returns the current mesh
  113658. */
  113659. toLeftHanded(): Mesh;
  113660. /** @hidden */
  113661. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113662. /** @hidden */
  113663. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113664. /**
  113665. * Registers for this mesh a javascript function called just before the rendering process
  113666. * @param func defines the function to call before rendering this mesh
  113667. * @returns the current mesh
  113668. */
  113669. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113670. /**
  113671. * Disposes a previously registered javascript function called before the rendering
  113672. * @param func defines the function to remove
  113673. * @returns the current mesh
  113674. */
  113675. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  113676. /**
  113677. * Registers for this mesh a javascript function called just after the rendering is complete
  113678. * @param func defines the function to call after rendering this mesh
  113679. * @returns the current mesh
  113680. */
  113681. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113682. /**
  113683. * Disposes a previously registered javascript function called after the rendering.
  113684. * @param func defines the function to remove
  113685. * @returns the current mesh
  113686. */
  113687. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  113688. /** @hidden */
  113689. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  113690. /** @hidden */
  113691. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  113692. /** @hidden */
  113693. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  113694. /** @hidden */
  113695. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  113696. /** @hidden */
  113697. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  113698. /** @hidden */
  113699. _rebuild(): void;
  113700. /** @hidden */
  113701. _freeze(): void;
  113702. /** @hidden */
  113703. _unFreeze(): void;
  113704. /**
  113705. * 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
  113706. * @param subMesh defines the subMesh to render
  113707. * @param enableAlphaMode defines if alpha mode can be changed
  113708. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  113709. * @returns the current mesh
  113710. */
  113711. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  113712. private _onBeforeDraw;
  113713. /**
  113714. * Renormalize the mesh and patch it up if there are no weights
  113715. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  113716. * However in the case of zero weights then we set just a single influence to 1.
  113717. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  113718. */
  113719. cleanMatrixWeights(): void;
  113720. private normalizeSkinFourWeights;
  113721. private normalizeSkinWeightsAndExtra;
  113722. /**
  113723. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  113724. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  113725. * the user know there was an issue with importing the mesh
  113726. * @returns a validation object with skinned, valid and report string
  113727. */
  113728. validateSkinning(): {
  113729. skinned: boolean;
  113730. valid: boolean;
  113731. report: string;
  113732. };
  113733. /** @hidden */
  113734. _checkDelayState(): Mesh;
  113735. private _queueLoad;
  113736. /**
  113737. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  113738. * A mesh is in the frustum if its bounding box intersects the frustum
  113739. * @param frustumPlanes defines the frustum to test
  113740. * @returns true if the mesh is in the frustum planes
  113741. */
  113742. isInFrustum(frustumPlanes: Plane[]): boolean;
  113743. /**
  113744. * Sets the mesh material by the material or multiMaterial `id` property
  113745. * @param id is a string identifying the material or the multiMaterial
  113746. * @returns the current mesh
  113747. */
  113748. setMaterialByID(id: string): Mesh;
  113749. /**
  113750. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  113751. * @returns an array of IAnimatable
  113752. */
  113753. getAnimatables(): IAnimatable[];
  113754. /**
  113755. * Modifies the mesh geometry according to the passed transformation matrix.
  113756. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  113757. * The mesh normals are modified using the same transformation.
  113758. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113759. * @param transform defines the transform matrix to use
  113760. * @see https://doc.babylonjs.com/resources/baking_transformations
  113761. * @returns the current mesh
  113762. */
  113763. bakeTransformIntoVertices(transform: Matrix): Mesh;
  113764. /**
  113765. * Modifies the mesh geometry according to its own current World Matrix.
  113766. * The mesh World Matrix is then reset.
  113767. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  113768. * Note that, under the hood, this method sets a new VertexBuffer each call.
  113769. * @see https://doc.babylonjs.com/resources/baking_transformations
  113770. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  113771. * @returns the current mesh
  113772. */
  113773. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  113774. /** @hidden */
  113775. get _positions(): Nullable<Vector3[]>;
  113776. /** @hidden */
  113777. _resetPointsArrayCache(): Mesh;
  113778. /** @hidden */
  113779. _generatePointsArray(): boolean;
  113780. /**
  113781. * Returns a new Mesh object generated from the current mesh properties.
  113782. * This method must not get confused with createInstance()
  113783. * @param name is a string, the name given to the new mesh
  113784. * @param newParent can be any Node object (default `null`)
  113785. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  113786. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  113787. * @returns a new mesh
  113788. */
  113789. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  113790. /**
  113791. * Releases resources associated with this mesh.
  113792. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113793. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113794. */
  113795. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113796. /** @hidden */
  113797. _disposeInstanceSpecificData(): void;
  113798. /** @hidden */
  113799. _disposeThinInstanceSpecificData(): void;
  113800. /**
  113801. * Modifies the mesh geometry according to a displacement map.
  113802. * 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.
  113803. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113804. * @param url is a string, the URL from the image file is to be downloaded.
  113805. * @param minHeight is the lower limit of the displacement.
  113806. * @param maxHeight is the upper limit of the displacement.
  113807. * @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.
  113808. * @param uvOffset is an optional vector2 used to offset UV.
  113809. * @param uvScale is an optional vector2 used to scale UV.
  113810. * @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.
  113811. * @returns the Mesh.
  113812. */
  113813. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113814. /**
  113815. * Modifies the mesh geometry according to a displacementMap buffer.
  113816. * 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.
  113817. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  113818. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  113819. * @param heightMapWidth is the width of the buffer image.
  113820. * @param heightMapHeight is the height of the buffer image.
  113821. * @param minHeight is the lower limit of the displacement.
  113822. * @param maxHeight is the upper limit of the displacement.
  113823. * @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.
  113824. * @param uvOffset is an optional vector2 used to offset UV.
  113825. * @param uvScale is an optional vector2 used to scale UV.
  113826. * @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.
  113827. * @returns the Mesh.
  113828. */
  113829. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  113830. /**
  113831. * Modify the mesh to get a flat shading rendering.
  113832. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  113833. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  113834. * @returns current mesh
  113835. */
  113836. convertToFlatShadedMesh(): Mesh;
  113837. /**
  113838. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  113839. * In other words, more vertices, no more indices and a single bigger VBO.
  113840. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  113841. * @returns current mesh
  113842. */
  113843. convertToUnIndexedMesh(): Mesh;
  113844. /**
  113845. * Inverses facet orientations.
  113846. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113847. * @param flipNormals will also inverts the normals
  113848. * @returns current mesh
  113849. */
  113850. flipFaces(flipNormals?: boolean): Mesh;
  113851. /**
  113852. * Increase the number of facets and hence vertices in a mesh
  113853. * Vertex normals are interpolated from existing vertex normals
  113854. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113855. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  113856. */
  113857. increaseVertices(numberPerEdge: number): void;
  113858. /**
  113859. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  113860. * This will undo any application of covertToFlatShadedMesh
  113861. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  113862. */
  113863. forceSharedVertices(): void;
  113864. /** @hidden */
  113865. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  113866. /** @hidden */
  113867. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  113868. /**
  113869. * Creates a new InstancedMesh object from the mesh model.
  113870. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113871. * @param name defines the name of the new instance
  113872. * @returns a new InstancedMesh
  113873. */
  113874. createInstance(name: string): InstancedMesh;
  113875. /**
  113876. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  113877. * After this call, all the mesh instances have the same submeshes than the current mesh.
  113878. * @returns the current mesh
  113879. */
  113880. synchronizeInstances(): Mesh;
  113881. /**
  113882. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  113883. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  113884. * This should be used together with the simplification to avoid disappearing triangles.
  113885. * @param successCallback an optional success callback to be called after the optimization finished.
  113886. * @returns the current mesh
  113887. */
  113888. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  113889. /**
  113890. * Serialize current mesh
  113891. * @param serializationObject defines the object which will receive the serialization data
  113892. */
  113893. serialize(serializationObject: any): void;
  113894. /** @hidden */
  113895. _syncGeometryWithMorphTargetManager(): void;
  113896. /** @hidden */
  113897. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  113898. /**
  113899. * Returns a new Mesh object parsed from the source provided.
  113900. * @param parsedMesh is the source
  113901. * @param scene defines the hosting scene
  113902. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  113903. * @returns a new Mesh
  113904. */
  113905. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  113906. /**
  113907. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  113908. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113909. * @param name defines the name of the mesh to create
  113910. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  113911. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  113912. * @param closePath creates a seam between the first and the last points of each path of the path array
  113913. * @param offset is taken in account only if the `pathArray` is containing a single path
  113914. * @param scene defines the hosting scene
  113915. * @param updatable defines if the mesh must be flagged as updatable
  113916. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113917. * @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)
  113918. * @returns a new Mesh
  113919. */
  113920. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  113921. /**
  113922. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  113923. * @param name defines the name of the mesh to create
  113924. * @param radius sets the radius size (float) of the polygon (default 0.5)
  113925. * @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
  113926. * @param scene defines the hosting scene
  113927. * @param updatable defines if the mesh must be flagged as updatable
  113928. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113929. * @returns a new Mesh
  113930. */
  113931. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  113932. /**
  113933. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  113934. * @param name defines the name of the mesh to create
  113935. * @param size sets the size (float) of each box side (default 1)
  113936. * @param scene defines the hosting scene
  113937. * @param updatable defines if the mesh must be flagged as updatable
  113938. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113939. * @returns a new Mesh
  113940. */
  113941. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  113942. /**
  113943. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  113944. * @param name defines the name of the mesh to create
  113945. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  113946. * @param diameter sets the diameter size (float) of the sphere (default 1)
  113947. * @param scene defines the hosting scene
  113948. * @param updatable defines if the mesh must be flagged as updatable
  113949. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113950. * @returns a new Mesh
  113951. */
  113952. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113953. /**
  113954. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  113955. * @param name defines the name of the mesh to create
  113956. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  113957. * @param diameter sets the diameter size (float) of the sphere (default 1)
  113958. * @param scene defines the hosting scene
  113959. * @returns a new Mesh
  113960. */
  113961. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  113962. /**
  113963. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  113964. * @param name defines the name of the mesh to create
  113965. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  113966. * @param diameterTop set the top cap diameter (floats, default 1)
  113967. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  113968. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  113969. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  113970. * @param scene defines the hosting scene
  113971. * @param updatable defines if the mesh must be flagged as updatable
  113972. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113973. * @returns a new Mesh
  113974. */
  113975. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  113976. /**
  113977. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  113978. * @param name defines the name of the mesh to create
  113979. * @param diameter sets the diameter size (float) of the torus (default 1)
  113980. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  113981. * @param tessellation sets the number of torus sides (postive integer, default 16)
  113982. * @param scene defines the hosting scene
  113983. * @param updatable defines if the mesh must be flagged as updatable
  113984. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  113985. * @returns a new Mesh
  113986. */
  113987. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  113988. /**
  113989. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  113990. * @param name defines the name of the mesh to create
  113991. * @param radius sets the global radius size (float) of the torus knot (default 2)
  113992. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  113993. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  113994. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  113995. * @param p the number of windings on X axis (positive integers, default 2)
  113996. * @param q the number of windings on Y axis (positive integers, default 3)
  113997. * @param scene defines the hosting scene
  113998. * @param updatable defines if the mesh must be flagged as updatable
  113999. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114000. * @returns a new Mesh
  114001. */
  114002. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114003. /**
  114004. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114005. * @param name defines the name of the mesh to create
  114006. * @param points is an array successive Vector3
  114007. * @param scene defines the hosting scene
  114008. * @param updatable defines if the mesh must be flagged as updatable
  114009. * @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).
  114010. * @returns a new Mesh
  114011. */
  114012. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114013. /**
  114014. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114015. * @param name defines the name of the mesh to create
  114016. * @param points is an array successive Vector3
  114017. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114018. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114019. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114020. * @param scene defines the hosting scene
  114021. * @param updatable defines if the mesh must be flagged as updatable
  114022. * @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)
  114023. * @returns a new Mesh
  114024. */
  114025. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114026. /**
  114027. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114028. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114029. * 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.
  114030. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114031. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114032. * Remember you can only change the shape positions, not their number when updating a polygon.
  114033. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114034. * @param name defines the name of the mesh to create
  114035. * @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
  114036. * @param scene defines the hosting scene
  114037. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114038. * @param updatable defines if the mesh must be flagged as updatable
  114039. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114040. * @param earcutInjection can be used to inject your own earcut reference
  114041. * @returns a new Mesh
  114042. */
  114043. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114044. /**
  114045. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114047. * @param name defines the name of the mesh to create
  114048. * @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
  114049. * @param depth defines the height of extrusion
  114050. * @param scene defines the hosting scene
  114051. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114052. * @param updatable defines if the mesh must be flagged as updatable
  114053. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114054. * @param earcutInjection can be used to inject your own earcut reference
  114055. * @returns a new Mesh
  114056. */
  114057. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114058. /**
  114059. * Creates an extruded shape mesh.
  114060. * 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
  114061. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114062. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114063. * @param name defines the name of the mesh to create
  114064. * @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
  114065. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114066. * @param scale is the value to scale the shape
  114067. * @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
  114068. * @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
  114069. * @param scene defines the hosting scene
  114070. * @param updatable defines if the mesh must be flagged as updatable
  114071. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114072. * @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)
  114073. * @returns a new Mesh
  114074. */
  114075. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114076. /**
  114077. * Creates an custom extruded shape mesh.
  114078. * The custom extrusion is a parametric shape.
  114079. * It has no predefined shape. Its final shape will depend on the input parameters.
  114080. * Please consider using the same method from the MeshBuilder class instead
  114081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114082. * @param name defines the name of the mesh to create
  114083. * @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
  114084. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114085. * @param scaleFunction is a custom Javascript function called on each path point
  114086. * @param rotationFunction is a custom Javascript function called on each path point
  114087. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114088. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114089. * @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
  114090. * @param scene defines the hosting scene
  114091. * @param updatable defines if the mesh must be flagged as updatable
  114092. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114093. * @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)
  114094. * @returns a new Mesh
  114095. */
  114096. 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;
  114097. /**
  114098. * Creates lathe mesh.
  114099. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114100. * Please consider using the same method from the MeshBuilder class instead
  114101. * @param name defines the name of the mesh to create
  114102. * @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
  114103. * @param radius is the radius value of the lathe
  114104. * @param tessellation is the side number of the lathe.
  114105. * @param scene defines the hosting scene
  114106. * @param updatable defines if the mesh must be flagged as updatable
  114107. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114108. * @returns a new Mesh
  114109. */
  114110. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114111. /**
  114112. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114113. * @param name defines the name of the mesh to create
  114114. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114115. * @param scene defines the hosting scene
  114116. * @param updatable defines if the mesh must be flagged as updatable
  114117. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114118. * @returns a new Mesh
  114119. */
  114120. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114121. /**
  114122. * Creates a ground mesh.
  114123. * Please consider using the same method from the MeshBuilder class instead
  114124. * @param name defines the name of the mesh to create
  114125. * @param width set the width of the ground
  114126. * @param height set the height of the ground
  114127. * @param subdivisions sets the number of subdivisions per side
  114128. * @param scene defines the hosting scene
  114129. * @param updatable defines if the mesh must be flagged as updatable
  114130. * @returns a new Mesh
  114131. */
  114132. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114133. /**
  114134. * Creates a tiled ground mesh.
  114135. * Please consider using the same method from the MeshBuilder class instead
  114136. * @param name defines the name of the mesh to create
  114137. * @param xmin set the ground minimum X coordinate
  114138. * @param zmin set the ground minimum Y coordinate
  114139. * @param xmax set the ground maximum X coordinate
  114140. * @param zmax set the ground maximum Z coordinate
  114141. * @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
  114142. * @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
  114143. * @param scene defines the hosting scene
  114144. * @param updatable defines if the mesh must be flagged as updatable
  114145. * @returns a new Mesh
  114146. */
  114147. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114148. w: number;
  114149. h: number;
  114150. }, precision: {
  114151. w: number;
  114152. h: number;
  114153. }, scene: Scene, updatable?: boolean): Mesh;
  114154. /**
  114155. * Creates a ground mesh from a height map.
  114156. * Please consider using the same method from the MeshBuilder class instead
  114157. * @see https://doc.babylonjs.com/babylon101/height_map
  114158. * @param name defines the name of the mesh to create
  114159. * @param url sets the URL of the height map image resource
  114160. * @param width set the ground width size
  114161. * @param height set the ground height size
  114162. * @param subdivisions sets the number of subdivision per side
  114163. * @param minHeight is the minimum altitude on the ground
  114164. * @param maxHeight is the maximum altitude on the ground
  114165. * @param scene defines the hosting scene
  114166. * @param updatable defines if the mesh must be flagged as updatable
  114167. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114168. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114169. * @returns a new Mesh
  114170. */
  114171. 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;
  114172. /**
  114173. * Creates a tube mesh.
  114174. * The tube is a parametric shape.
  114175. * It has no predefined shape. Its final shape will depend on the input parameters.
  114176. * Please consider using the same method from the MeshBuilder class instead
  114177. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114178. * @param name defines the name of the mesh to create
  114179. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114180. * @param radius sets the tube radius size
  114181. * @param tessellation is the number of sides on the tubular surface
  114182. * @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
  114183. * @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
  114184. * @param scene defines the hosting scene
  114185. * @param updatable defines if the mesh must be flagged as updatable
  114186. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114187. * @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)
  114188. * @returns a new Mesh
  114189. */
  114190. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114191. (i: number, distance: number): number;
  114192. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114193. /**
  114194. * Creates a polyhedron mesh.
  114195. * Please consider using the same method from the MeshBuilder class instead.
  114196. * * 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
  114197. * * The parameter `size` (positive float, default 1) sets the polygon size
  114198. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114199. * * 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`
  114200. * * 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
  114201. * * 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)`)
  114202. * * 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
  114203. * * 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
  114204. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114205. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114207. * @param name defines the name of the mesh to create
  114208. * @param options defines the options used to create the mesh
  114209. * @param scene defines the hosting scene
  114210. * @returns a new Mesh
  114211. */
  114212. static CreatePolyhedron(name: string, options: {
  114213. type?: number;
  114214. size?: number;
  114215. sizeX?: number;
  114216. sizeY?: number;
  114217. sizeZ?: number;
  114218. custom?: any;
  114219. faceUV?: Vector4[];
  114220. faceColors?: Color4[];
  114221. updatable?: boolean;
  114222. sideOrientation?: number;
  114223. }, scene: Scene): Mesh;
  114224. /**
  114225. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114226. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114227. * * 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`)
  114228. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114229. * * 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
  114230. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114233. * @param name defines the name of the mesh
  114234. * @param options defines the options used to create the mesh
  114235. * @param scene defines the hosting scene
  114236. * @returns a new Mesh
  114237. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114238. */
  114239. static CreateIcoSphere(name: string, options: {
  114240. radius?: number;
  114241. flat?: boolean;
  114242. subdivisions?: number;
  114243. sideOrientation?: number;
  114244. updatable?: boolean;
  114245. }, scene: Scene): Mesh;
  114246. /**
  114247. * Creates a decal mesh.
  114248. * Please consider using the same method from the MeshBuilder class instead.
  114249. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114250. * @param name defines the name of the mesh
  114251. * @param sourceMesh defines the mesh receiving the decal
  114252. * @param position sets the position of the decal in world coordinates
  114253. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114254. * @param size sets the decal scaling
  114255. * @param angle sets the angle to rotate the decal
  114256. * @returns a new Mesh
  114257. */
  114258. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114259. /** Creates a Capsule Mesh
  114260. * @param name defines the name of the mesh.
  114261. * @param options the constructors options used to shape the mesh.
  114262. * @param scene defines the scene the mesh is scoped to.
  114263. * @returns the capsule mesh
  114264. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114265. */
  114266. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114267. /**
  114268. * Prepare internal position array for software CPU skinning
  114269. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114270. */
  114271. setPositionsForCPUSkinning(): Float32Array;
  114272. /**
  114273. * Prepare internal normal array for software CPU skinning
  114274. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  114275. */
  114276. setNormalsForCPUSkinning(): Float32Array;
  114277. /**
  114278. * Updates the vertex buffer by applying transformation from the bones
  114279. * @param skeleton defines the skeleton to apply to current mesh
  114280. * @returns the current mesh
  114281. */
  114282. applySkeleton(skeleton: Skeleton): Mesh;
  114283. /**
  114284. * 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
  114285. * @param meshes defines the list of meshes to scan
  114286. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  114287. */
  114288. static MinMax(meshes: AbstractMesh[]): {
  114289. min: Vector3;
  114290. max: Vector3;
  114291. };
  114292. /**
  114293. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  114294. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  114295. * @returns a vector3
  114296. */
  114297. static Center(meshesOrMinMaxVector: {
  114298. min: Vector3;
  114299. max: Vector3;
  114300. } | AbstractMesh[]): Vector3;
  114301. /**
  114302. * Merge the array of meshes into a single mesh for performance reasons.
  114303. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  114304. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  114305. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  114306. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  114307. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  114308. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  114309. * @returns a new mesh
  114310. */
  114311. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  114312. /** @hidden */
  114313. addInstance(instance: InstancedMesh): void;
  114314. /** @hidden */
  114315. removeInstance(instance: InstancedMesh): void;
  114316. }
  114317. }
  114318. declare module BABYLON {
  114319. /**
  114320. * This is the base class of all the camera used in the application.
  114321. * @see https://doc.babylonjs.com/features/cameras
  114322. */
  114323. export class Camera extends Node {
  114324. /** @hidden */
  114325. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  114326. /**
  114327. * This is the default projection mode used by the cameras.
  114328. * It helps recreating a feeling of perspective and better appreciate depth.
  114329. * This is the best way to simulate real life cameras.
  114330. */
  114331. static readonly PERSPECTIVE_CAMERA: number;
  114332. /**
  114333. * This helps creating camera with an orthographic mode.
  114334. * 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.
  114335. */
  114336. static readonly ORTHOGRAPHIC_CAMERA: number;
  114337. /**
  114338. * This is the default FOV mode for perspective cameras.
  114339. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  114340. */
  114341. static readonly FOVMODE_VERTICAL_FIXED: number;
  114342. /**
  114343. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  114344. */
  114345. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  114346. /**
  114347. * This specifies ther is no need for a camera rig.
  114348. * Basically only one eye is rendered corresponding to the camera.
  114349. */
  114350. static readonly RIG_MODE_NONE: number;
  114351. /**
  114352. * Simulates a camera Rig with one blue eye and one red eye.
  114353. * This can be use with 3d blue and red glasses.
  114354. */
  114355. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  114356. /**
  114357. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  114358. */
  114359. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  114360. /**
  114361. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  114362. */
  114363. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  114364. /**
  114365. * Defines that both eyes of the camera will be rendered over under each other.
  114366. */
  114367. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  114368. /**
  114369. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  114370. */
  114371. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  114372. /**
  114373. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  114374. */
  114375. static readonly RIG_MODE_VR: number;
  114376. /**
  114377. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  114378. */
  114379. static readonly RIG_MODE_WEBVR: number;
  114380. /**
  114381. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  114382. */
  114383. static readonly RIG_MODE_CUSTOM: number;
  114384. /**
  114385. * Defines if by default attaching controls should prevent the default javascript event to continue.
  114386. */
  114387. static ForceAttachControlToAlwaysPreventDefault: boolean;
  114388. /**
  114389. * Define the input manager associated with the camera.
  114390. */
  114391. inputs: CameraInputsManager<Camera>;
  114392. /** @hidden */
  114393. _position: Vector3;
  114394. /**
  114395. * Define the current local position of the camera in the scene
  114396. */
  114397. get position(): Vector3;
  114398. set position(newPosition: Vector3);
  114399. protected _upVector: Vector3;
  114400. /**
  114401. * The vector the camera should consider as up.
  114402. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  114403. */
  114404. set upVector(vec: Vector3);
  114405. get upVector(): Vector3;
  114406. /**
  114407. * Define the current limit on the left side for an orthographic camera
  114408. * In scene unit
  114409. */
  114410. orthoLeft: Nullable<number>;
  114411. /**
  114412. * Define the current limit on the right side for an orthographic camera
  114413. * In scene unit
  114414. */
  114415. orthoRight: Nullable<number>;
  114416. /**
  114417. * Define the current limit on the bottom side for an orthographic camera
  114418. * In scene unit
  114419. */
  114420. orthoBottom: Nullable<number>;
  114421. /**
  114422. * Define the current limit on the top side for an orthographic camera
  114423. * In scene unit
  114424. */
  114425. orthoTop: Nullable<number>;
  114426. /**
  114427. * Field Of View is set in Radians. (default is 0.8)
  114428. */
  114429. fov: number;
  114430. /**
  114431. * Define the minimum distance the camera can see from.
  114432. * This is important to note that the depth buffer are not infinite and the closer it starts
  114433. * the more your scene might encounter depth fighting issue.
  114434. */
  114435. minZ: number;
  114436. /**
  114437. * Define the maximum distance the camera can see to.
  114438. * This is important to note that the depth buffer are not infinite and the further it end
  114439. * the more your scene might encounter depth fighting issue.
  114440. */
  114441. maxZ: number;
  114442. /**
  114443. * Define the default inertia of the camera.
  114444. * This helps giving a smooth feeling to the camera movement.
  114445. */
  114446. inertia: number;
  114447. /**
  114448. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  114449. */
  114450. mode: number;
  114451. /**
  114452. * Define whether the camera is intermediate.
  114453. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  114454. */
  114455. isIntermediate: boolean;
  114456. /**
  114457. * Define the viewport of the camera.
  114458. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  114459. */
  114460. viewport: Viewport;
  114461. /**
  114462. * Restricts the camera to viewing objects with the same layerMask.
  114463. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  114464. */
  114465. layerMask: number;
  114466. /**
  114467. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  114468. */
  114469. fovMode: number;
  114470. /**
  114471. * Rig mode of the camera.
  114472. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  114473. * This is normally controlled byt the camera themselves as internal use.
  114474. */
  114475. cameraRigMode: number;
  114476. /**
  114477. * Defines the distance between both "eyes" in case of a RIG
  114478. */
  114479. interaxialDistance: number;
  114480. /**
  114481. * Defines if stereoscopic rendering is done side by side or over under.
  114482. */
  114483. isStereoscopicSideBySide: boolean;
  114484. /**
  114485. * 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
  114486. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  114487. * else in the scene. (Eg. security camera)
  114488. *
  114489. * 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)
  114490. */
  114491. customRenderTargets: RenderTargetTexture[];
  114492. /**
  114493. * When set, the camera will render to this render target instead of the default canvas
  114494. *
  114495. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  114496. */
  114497. outputRenderTarget: Nullable<RenderTargetTexture>;
  114498. /**
  114499. * Observable triggered when the camera view matrix has changed.
  114500. */
  114501. onViewMatrixChangedObservable: Observable<Camera>;
  114502. /**
  114503. * Observable triggered when the camera Projection matrix has changed.
  114504. */
  114505. onProjectionMatrixChangedObservable: Observable<Camera>;
  114506. /**
  114507. * Observable triggered when the inputs have been processed.
  114508. */
  114509. onAfterCheckInputsObservable: Observable<Camera>;
  114510. /**
  114511. * Observable triggered when reset has been called and applied to the camera.
  114512. */
  114513. onRestoreStateObservable: Observable<Camera>;
  114514. /**
  114515. * Is this camera a part of a rig system?
  114516. */
  114517. isRigCamera: boolean;
  114518. /**
  114519. * If isRigCamera set to true this will be set with the parent camera.
  114520. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  114521. */
  114522. rigParent?: Camera;
  114523. /** @hidden */
  114524. _cameraRigParams: any;
  114525. /** @hidden */
  114526. _rigCameras: Camera[];
  114527. /** @hidden */
  114528. _rigPostProcess: Nullable<PostProcess>;
  114529. protected _webvrViewMatrix: Matrix;
  114530. /** @hidden */
  114531. _skipRendering: boolean;
  114532. /** @hidden */
  114533. _projectionMatrix: Matrix;
  114534. /** @hidden */
  114535. _postProcesses: Nullable<PostProcess>[];
  114536. /** @hidden */
  114537. _activeMeshes: SmartArray<AbstractMesh>;
  114538. protected _globalPosition: Vector3;
  114539. /** @hidden */
  114540. _computedViewMatrix: Matrix;
  114541. private _doNotComputeProjectionMatrix;
  114542. private _transformMatrix;
  114543. private _frustumPlanes;
  114544. private _refreshFrustumPlanes;
  114545. private _storedFov;
  114546. private _stateStored;
  114547. /**
  114548. * Instantiates a new camera object.
  114549. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  114550. * @see https://doc.babylonjs.com/features/cameras
  114551. * @param name Defines the name of the camera in the scene
  114552. * @param position Defines the position of the camera
  114553. * @param scene Defines the scene the camera belongs too
  114554. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  114555. */
  114556. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114557. /**
  114558. * Store current camera state (fov, position, etc..)
  114559. * @returns the camera
  114560. */
  114561. storeState(): Camera;
  114562. /**
  114563. * Restores the camera state values if it has been stored. You must call storeState() first
  114564. */
  114565. protected _restoreStateValues(): boolean;
  114566. /**
  114567. * Restored camera state. You must call storeState() first.
  114568. * @returns true if restored and false otherwise
  114569. */
  114570. restoreState(): boolean;
  114571. /**
  114572. * Gets the class name of the camera.
  114573. * @returns the class name
  114574. */
  114575. getClassName(): string;
  114576. /** @hidden */
  114577. readonly _isCamera: boolean;
  114578. /**
  114579. * Gets a string representation of the camera useful for debug purpose.
  114580. * @param fullDetails Defines that a more verboe level of logging is required
  114581. * @returns the string representation
  114582. */
  114583. toString(fullDetails?: boolean): string;
  114584. /**
  114585. * Gets the current world space position of the camera.
  114586. */
  114587. get globalPosition(): Vector3;
  114588. /**
  114589. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  114590. * @returns the active meshe list
  114591. */
  114592. getActiveMeshes(): SmartArray<AbstractMesh>;
  114593. /**
  114594. * Check whether a mesh is part of the current active mesh list of the camera
  114595. * @param mesh Defines the mesh to check
  114596. * @returns true if active, false otherwise
  114597. */
  114598. isActiveMesh(mesh: Mesh): boolean;
  114599. /**
  114600. * Is this camera ready to be used/rendered
  114601. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  114602. * @return true if the camera is ready
  114603. */
  114604. isReady(completeCheck?: boolean): boolean;
  114605. /** @hidden */
  114606. _initCache(): void;
  114607. /** @hidden */
  114608. _updateCache(ignoreParentClass?: boolean): void;
  114609. /** @hidden */
  114610. _isSynchronized(): boolean;
  114611. /** @hidden */
  114612. _isSynchronizedViewMatrix(): boolean;
  114613. /** @hidden */
  114614. _isSynchronizedProjectionMatrix(): boolean;
  114615. /**
  114616. * Attach the input controls to a specific dom element to get the input from.
  114617. * @param element Defines the element the controls should be listened from
  114618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114619. */
  114620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114621. /**
  114622. * Detach the current controls from the specified dom element.
  114623. * @param element Defines the element to stop listening the inputs from
  114624. */
  114625. detachControl(element: HTMLElement): void;
  114626. /**
  114627. * Update the camera state according to the different inputs gathered during the frame.
  114628. */
  114629. update(): void;
  114630. /** @hidden */
  114631. _checkInputs(): void;
  114632. /** @hidden */
  114633. get rigCameras(): Camera[];
  114634. /**
  114635. * Gets the post process used by the rig cameras
  114636. */
  114637. get rigPostProcess(): Nullable<PostProcess>;
  114638. /**
  114639. * Internal, gets the first post proces.
  114640. * @returns the first post process to be run on this camera.
  114641. */
  114642. _getFirstPostProcess(): Nullable<PostProcess>;
  114643. private _cascadePostProcessesToRigCams;
  114644. /**
  114645. * Attach a post process to the camera.
  114646. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114647. * @param postProcess The post process to attach to the camera
  114648. * @param insertAt The position of the post process in case several of them are in use in the scene
  114649. * @returns the position the post process has been inserted at
  114650. */
  114651. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  114652. /**
  114653. * Detach a post process to the camera.
  114654. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  114655. * @param postProcess The post process to detach from the camera
  114656. */
  114657. detachPostProcess(postProcess: PostProcess): void;
  114658. /**
  114659. * Gets the current world matrix of the camera
  114660. */
  114661. getWorldMatrix(): Matrix;
  114662. /** @hidden */
  114663. _getViewMatrix(): Matrix;
  114664. /**
  114665. * Gets the current view matrix of the camera.
  114666. * @param force forces the camera to recompute the matrix without looking at the cached state
  114667. * @returns the view matrix
  114668. */
  114669. getViewMatrix(force?: boolean): Matrix;
  114670. /**
  114671. * Freeze the projection matrix.
  114672. * It will prevent the cache check of the camera projection compute and can speed up perf
  114673. * if no parameter of the camera are meant to change
  114674. * @param projection Defines manually a projection if necessary
  114675. */
  114676. freezeProjectionMatrix(projection?: Matrix): void;
  114677. /**
  114678. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  114679. */
  114680. unfreezeProjectionMatrix(): void;
  114681. /**
  114682. * Gets the current projection matrix of the camera.
  114683. * @param force forces the camera to recompute the matrix without looking at the cached state
  114684. * @returns the projection matrix
  114685. */
  114686. getProjectionMatrix(force?: boolean): Matrix;
  114687. /**
  114688. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  114689. * @returns a Matrix
  114690. */
  114691. getTransformationMatrix(): Matrix;
  114692. private _updateFrustumPlanes;
  114693. /**
  114694. * Checks if a cullable object (mesh...) is in the camera frustum
  114695. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  114696. * @param target The object to check
  114697. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  114698. * @returns true if the object is in frustum otherwise false
  114699. */
  114700. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  114701. /**
  114702. * Checks if a cullable object (mesh...) is in the camera frustum
  114703. * Unlike isInFrustum this cheks the full bounding box
  114704. * @param target The object to check
  114705. * @returns true if the object is in frustum otherwise false
  114706. */
  114707. isCompletelyInFrustum(target: ICullable): boolean;
  114708. /**
  114709. * Gets a ray in the forward direction from the camera.
  114710. * @param length Defines the length of the ray to create
  114711. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114712. * @param origin Defines the start point of the ray which defaults to the camera position
  114713. * @returns the forward ray
  114714. */
  114715. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114716. /**
  114717. * Gets a ray in the forward direction from the camera.
  114718. * @param refRay the ray to (re)use when setting the values
  114719. * @param length Defines the length of the ray to create
  114720. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  114721. * @param origin Defines the start point of the ray which defaults to the camera position
  114722. * @returns the forward ray
  114723. */
  114724. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  114725. /**
  114726. * Releases resources associated with this node.
  114727. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114728. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114729. */
  114730. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114731. /** @hidden */
  114732. _isLeftCamera: boolean;
  114733. /**
  114734. * Gets the left camera of a rig setup in case of Rigged Camera
  114735. */
  114736. get isLeftCamera(): boolean;
  114737. /** @hidden */
  114738. _isRightCamera: boolean;
  114739. /**
  114740. * Gets the right camera of a rig setup in case of Rigged Camera
  114741. */
  114742. get isRightCamera(): boolean;
  114743. /**
  114744. * Gets the left camera of a rig setup in case of Rigged Camera
  114745. */
  114746. get leftCamera(): Nullable<FreeCamera>;
  114747. /**
  114748. * Gets the right camera of a rig setup in case of Rigged Camera
  114749. */
  114750. get rightCamera(): Nullable<FreeCamera>;
  114751. /**
  114752. * Gets the left camera target of a rig setup in case of Rigged Camera
  114753. * @returns the target position
  114754. */
  114755. getLeftTarget(): Nullable<Vector3>;
  114756. /**
  114757. * Gets the right camera target of a rig setup in case of Rigged Camera
  114758. * @returns the target position
  114759. */
  114760. getRightTarget(): Nullable<Vector3>;
  114761. /**
  114762. * @hidden
  114763. */
  114764. setCameraRigMode(mode: number, rigParams: any): void;
  114765. /** @hidden */
  114766. static _setStereoscopicRigMode(camera: Camera): void;
  114767. /** @hidden */
  114768. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  114769. /** @hidden */
  114770. static _setVRRigMode(camera: Camera, rigParams: any): void;
  114771. /** @hidden */
  114772. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  114773. /** @hidden */
  114774. _getVRProjectionMatrix(): Matrix;
  114775. protected _updateCameraRotationMatrix(): void;
  114776. protected _updateWebVRCameraRotationMatrix(): void;
  114777. /**
  114778. * This function MUST be overwritten by the different WebVR cameras available.
  114779. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114780. * @hidden
  114781. */
  114782. _getWebVRProjectionMatrix(): Matrix;
  114783. /**
  114784. * This function MUST be overwritten by the different WebVR cameras available.
  114785. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  114786. * @hidden
  114787. */
  114788. _getWebVRViewMatrix(): Matrix;
  114789. /** @hidden */
  114790. setCameraRigParameter(name: string, value: any): void;
  114791. /**
  114792. * needs to be overridden by children so sub has required properties to be copied
  114793. * @hidden
  114794. */
  114795. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  114796. /**
  114797. * May need to be overridden by children
  114798. * @hidden
  114799. */
  114800. _updateRigCameras(): void;
  114801. /** @hidden */
  114802. _setupInputs(): void;
  114803. /**
  114804. * Serialiaze the camera setup to a json represention
  114805. * @returns the JSON representation
  114806. */
  114807. serialize(): any;
  114808. /**
  114809. * Clones the current camera.
  114810. * @param name The cloned camera name
  114811. * @returns the cloned camera
  114812. */
  114813. clone(name: string): Camera;
  114814. /**
  114815. * Gets the direction of the camera relative to a given local axis.
  114816. * @param localAxis Defines the reference axis to provide a relative direction.
  114817. * @return the direction
  114818. */
  114819. getDirection(localAxis: Vector3): Vector3;
  114820. /**
  114821. * Returns the current camera absolute rotation
  114822. */
  114823. get absoluteRotation(): Quaternion;
  114824. /**
  114825. * Gets the direction of the camera relative to a given local axis into a passed vector.
  114826. * @param localAxis Defines the reference axis to provide a relative direction.
  114827. * @param result Defines the vector to store the result in
  114828. */
  114829. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  114830. /**
  114831. * Gets a camera constructor for a given camera type
  114832. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  114833. * @param name The name of the camera the result will be able to instantiate
  114834. * @param scene The scene the result will construct the camera in
  114835. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  114836. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  114837. * @returns a factory method to construc the camera
  114838. */
  114839. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  114840. /**
  114841. * Compute the world matrix of the camera.
  114842. * @returns the camera world matrix
  114843. */
  114844. computeWorldMatrix(): Matrix;
  114845. /**
  114846. * Parse a JSON and creates the camera from the parsed information
  114847. * @param parsedCamera The JSON to parse
  114848. * @param scene The scene to instantiate the camera in
  114849. * @returns the newly constructed camera
  114850. */
  114851. static Parse(parsedCamera: any, scene: Scene): Camera;
  114852. }
  114853. }
  114854. declare module BABYLON {
  114855. /**
  114856. * Class containing static functions to help procedurally build meshes
  114857. */
  114858. export class DiscBuilder {
  114859. /**
  114860. * Creates a plane polygonal mesh. By default, this is a disc
  114861. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114862. * * 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
  114863. * * 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
  114864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114865. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114867. * @param name defines the name of the mesh
  114868. * @param options defines the options used to create the mesh
  114869. * @param scene defines the hosting scene
  114870. * @returns the plane polygonal mesh
  114871. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  114872. */
  114873. static CreateDisc(name: string, options: {
  114874. radius?: number;
  114875. tessellation?: number;
  114876. arc?: number;
  114877. updatable?: boolean;
  114878. sideOrientation?: number;
  114879. frontUVs?: Vector4;
  114880. backUVs?: Vector4;
  114881. }, scene?: Nullable<Scene>): Mesh;
  114882. }
  114883. }
  114884. declare module BABYLON {
  114885. /**
  114886. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  114887. *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.
  114888. * The SPS is also a particle system. It provides some methods to manage the particles.
  114889. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  114890. *
  114891. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  114892. */
  114893. export class SolidParticleSystem implements IDisposable {
  114894. /**
  114895. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  114896. * Example : var p = SPS.particles[i];
  114897. */
  114898. particles: SolidParticle[];
  114899. /**
  114900. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  114901. */
  114902. nbParticles: number;
  114903. /**
  114904. * If the particles must ever face the camera (default false). Useful for planar particles.
  114905. */
  114906. billboard: boolean;
  114907. /**
  114908. * Recompute normals when adding a shape
  114909. */
  114910. recomputeNormals: boolean;
  114911. /**
  114912. * This a counter ofr your own usage. It's not set by any SPS functions.
  114913. */
  114914. counter: number;
  114915. /**
  114916. * The SPS name. This name is also given to the underlying mesh.
  114917. */
  114918. name: string;
  114919. /**
  114920. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  114921. */
  114922. mesh: Mesh;
  114923. /**
  114924. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  114925. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  114926. */
  114927. vars: any;
  114928. /**
  114929. * This array is populated when the SPS is set as 'pickable'.
  114930. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  114931. * Each element of this array is an object `{idx: int, faceId: int}`.
  114932. * `idx` is the picked particle index in the `SPS.particles` array
  114933. * `faceId` is the picked face index counted within this particle.
  114934. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  114935. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  114936. * Use the method SPS.pickedParticle(pickingInfo) instead.
  114937. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  114938. */
  114939. pickedParticles: {
  114940. idx: number;
  114941. faceId: number;
  114942. }[];
  114943. /**
  114944. * This array is populated when the SPS is set as 'pickable'
  114945. * Each key of this array is a submesh index.
  114946. * Each element of this array is a second array defined like this :
  114947. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  114948. * Each element of this second array is an object `{idx: int, faceId: int}`.
  114949. * `idx` is the picked particle index in the `SPS.particles` array
  114950. * `faceId` is the picked face index counted within this particle.
  114951. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  114952. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  114953. */
  114954. pickedBySubMesh: {
  114955. idx: number;
  114956. faceId: number;
  114957. }[][];
  114958. /**
  114959. * This array is populated when `enableDepthSort` is set to true.
  114960. * Each element of this array is an instance of the class DepthSortedParticle.
  114961. */
  114962. depthSortedParticles: DepthSortedParticle[];
  114963. /**
  114964. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  114965. * @hidden
  114966. */
  114967. _bSphereOnly: boolean;
  114968. /**
  114969. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  114970. * @hidden
  114971. */
  114972. _bSphereRadiusFactor: number;
  114973. private _scene;
  114974. private _positions;
  114975. private _indices;
  114976. private _normals;
  114977. private _colors;
  114978. private _uvs;
  114979. private _indices32;
  114980. private _positions32;
  114981. private _normals32;
  114982. private _fixedNormal32;
  114983. private _colors32;
  114984. private _uvs32;
  114985. private _index;
  114986. private _updatable;
  114987. private _pickable;
  114988. private _isVisibilityBoxLocked;
  114989. private _alwaysVisible;
  114990. private _depthSort;
  114991. private _expandable;
  114992. private _shapeCounter;
  114993. private _copy;
  114994. private _color;
  114995. private _computeParticleColor;
  114996. private _computeParticleTexture;
  114997. private _computeParticleRotation;
  114998. private _computeParticleVertex;
  114999. private _computeBoundingBox;
  115000. private _depthSortParticles;
  115001. private _camera;
  115002. private _mustUnrotateFixedNormals;
  115003. private _particlesIntersect;
  115004. private _needs32Bits;
  115005. private _isNotBuilt;
  115006. private _lastParticleId;
  115007. private _idxOfId;
  115008. private _multimaterialEnabled;
  115009. private _useModelMaterial;
  115010. private _indicesByMaterial;
  115011. private _materialIndexes;
  115012. private _depthSortFunction;
  115013. private _materialSortFunction;
  115014. private _materials;
  115015. private _multimaterial;
  115016. private _materialIndexesById;
  115017. private _defaultMaterial;
  115018. private _autoUpdateSubMeshes;
  115019. private _tmpVertex;
  115020. /**
  115021. * Creates a SPS (Solid Particle System) object.
  115022. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115023. * @param scene (Scene) is the scene in which the SPS is added.
  115024. * @param options defines the options of the sps e.g.
  115025. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115026. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115027. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115028. * * 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.
  115029. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115030. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115031. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115032. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115033. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115034. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115035. */
  115036. constructor(name: string, scene: Scene, options?: {
  115037. updatable?: boolean;
  115038. isPickable?: boolean;
  115039. enableDepthSort?: boolean;
  115040. particleIntersection?: boolean;
  115041. boundingSphereOnly?: boolean;
  115042. bSphereRadiusFactor?: number;
  115043. expandable?: boolean;
  115044. useModelMaterial?: boolean;
  115045. enableMultiMaterial?: boolean;
  115046. });
  115047. /**
  115048. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115049. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115050. * @returns the created mesh
  115051. */
  115052. buildMesh(): Mesh;
  115053. /**
  115054. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115055. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115056. * Thus the particles generated from `digest()` have their property `position` set yet.
  115057. * @param mesh ( Mesh ) is the mesh to be digested
  115058. * @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
  115059. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115060. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115061. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115062. * @returns the current SPS
  115063. */
  115064. digest(mesh: Mesh, options?: {
  115065. facetNb?: number;
  115066. number?: number;
  115067. delta?: number;
  115068. storage?: [];
  115069. }): SolidParticleSystem;
  115070. /**
  115071. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115072. * @hidden
  115073. */
  115074. private _unrotateFixedNormals;
  115075. /**
  115076. * Resets the temporary working copy particle
  115077. * @hidden
  115078. */
  115079. private _resetCopy;
  115080. /**
  115081. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115082. * @param p the current index in the positions array to be updated
  115083. * @param ind the current index in the indices array
  115084. * @param shape a Vector3 array, the shape geometry
  115085. * @param positions the positions array to be updated
  115086. * @param meshInd the shape indices array
  115087. * @param indices the indices array to be updated
  115088. * @param meshUV the shape uv array
  115089. * @param uvs the uv array to be updated
  115090. * @param meshCol the shape color array
  115091. * @param colors the color array to be updated
  115092. * @param meshNor the shape normals array
  115093. * @param normals the normals array to be updated
  115094. * @param idx the particle index
  115095. * @param idxInShape the particle index in its shape
  115096. * @param options the addShape() method passed options
  115097. * @model the particle model
  115098. * @hidden
  115099. */
  115100. private _meshBuilder;
  115101. /**
  115102. * Returns a shape Vector3 array from positions float array
  115103. * @param positions float array
  115104. * @returns a vector3 array
  115105. * @hidden
  115106. */
  115107. private _posToShape;
  115108. /**
  115109. * Returns a shapeUV array from a float uvs (array deep copy)
  115110. * @param uvs as a float array
  115111. * @returns a shapeUV array
  115112. * @hidden
  115113. */
  115114. private _uvsToShapeUV;
  115115. /**
  115116. * Adds a new particle object in the particles array
  115117. * @param idx particle index in particles array
  115118. * @param id particle id
  115119. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115120. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115121. * @param model particle ModelShape object
  115122. * @param shapeId model shape identifier
  115123. * @param idxInShape index of the particle in the current model
  115124. * @param bInfo model bounding info object
  115125. * @param storage target storage array, if any
  115126. * @hidden
  115127. */
  115128. private _addParticle;
  115129. /**
  115130. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115131. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115132. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115133. * @param nb (positive integer) the number of particles to be created from this model
  115134. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115135. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115136. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115137. * @returns the number of shapes in the system
  115138. */
  115139. addShape(mesh: Mesh, nb: number, options?: {
  115140. positionFunction?: any;
  115141. vertexFunction?: any;
  115142. storage?: [];
  115143. }): number;
  115144. /**
  115145. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115146. * @hidden
  115147. */
  115148. private _rebuildParticle;
  115149. /**
  115150. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115151. * @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.
  115152. * @returns the SPS.
  115153. */
  115154. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115155. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115156. * Returns an array with the removed particles.
  115157. * 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.
  115158. * The SPS can't be empty so at least one particle needs to remain in place.
  115159. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115160. * @param start index of the first particle to remove
  115161. * @param end index of the last particle to remove (included)
  115162. * @returns an array populated with the removed particles
  115163. */
  115164. removeParticles(start: number, end: number): SolidParticle[];
  115165. /**
  115166. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115167. * @param solidParticleArray an array populated with Solid Particles objects
  115168. * @returns the SPS
  115169. */
  115170. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115171. /**
  115172. * Creates a new particle and modifies the SPS mesh geometry :
  115173. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115174. * - calls _addParticle() to populate the particle array
  115175. * factorized code from addShape() and insertParticlesFromArray()
  115176. * @param idx particle index in the particles array
  115177. * @param i particle index in its shape
  115178. * @param modelShape particle ModelShape object
  115179. * @param shape shape vertex array
  115180. * @param meshInd shape indices array
  115181. * @param meshUV shape uv array
  115182. * @param meshCol shape color array
  115183. * @param meshNor shape normals array
  115184. * @param bbInfo shape bounding info
  115185. * @param storage target particle storage
  115186. * @options addShape() passed options
  115187. * @hidden
  115188. */
  115189. private _insertNewParticle;
  115190. /**
  115191. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115192. * This method calls `updateParticle()` for each particle of the SPS.
  115193. * For an animated SPS, it is usually called within the render loop.
  115194. * 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.
  115195. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115196. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115197. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115198. * @returns the SPS.
  115199. */
  115200. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115201. /**
  115202. * Disposes the SPS.
  115203. */
  115204. dispose(): void;
  115205. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115206. * idx is the particle index in the SPS
  115207. * faceId is the picked face index counted within this particle.
  115208. * Returns null if the pickInfo can't identify a picked particle.
  115209. * @param pickingInfo (PickingInfo object)
  115210. * @returns {idx: number, faceId: number} or null
  115211. */
  115212. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115213. idx: number;
  115214. faceId: number;
  115215. }>;
  115216. /**
  115217. * Returns a SolidParticle object from its identifier : particle.id
  115218. * @param id (integer) the particle Id
  115219. * @returns the searched particle or null if not found in the SPS.
  115220. */
  115221. getParticleById(id: number): Nullable<SolidParticle>;
  115222. /**
  115223. * Returns a new array populated with the particles having the passed shapeId.
  115224. * @param shapeId (integer) the shape identifier
  115225. * @returns a new solid particle array
  115226. */
  115227. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115228. /**
  115229. * Populates the passed array "ref" with the particles having the passed shapeId.
  115230. * @param shapeId the shape identifier
  115231. * @returns the SPS
  115232. * @param ref
  115233. */
  115234. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115235. /**
  115236. * Computes the required SubMeshes according the materials assigned to the particles.
  115237. * @returns the solid particle system.
  115238. * Does nothing if called before the SPS mesh is built.
  115239. */
  115240. computeSubMeshes(): SolidParticleSystem;
  115241. /**
  115242. * Sorts the solid particles by material when MultiMaterial is enabled.
  115243. * Updates the indices32 array.
  115244. * Updates the indicesByMaterial array.
  115245. * Updates the mesh indices array.
  115246. * @returns the SPS
  115247. * @hidden
  115248. */
  115249. private _sortParticlesByMaterial;
  115250. /**
  115251. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115252. * @hidden
  115253. */
  115254. private _setMaterialIndexesById;
  115255. /**
  115256. * Returns an array with unique values of Materials from the passed array
  115257. * @param array the material array to be checked and filtered
  115258. * @hidden
  115259. */
  115260. private _filterUniqueMaterialId;
  115261. /**
  115262. * Sets a new Standard Material as _defaultMaterial if not already set.
  115263. * @hidden
  115264. */
  115265. private _setDefaultMaterial;
  115266. /**
  115267. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  115268. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115269. * @returns the SPS.
  115270. */
  115271. refreshVisibleSize(): SolidParticleSystem;
  115272. /**
  115273. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  115274. * @param size the size (float) of the visibility box
  115275. * note : this doesn't lock the SPS mesh bounding box.
  115276. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115277. */
  115278. setVisibilityBox(size: number): void;
  115279. /**
  115280. * Gets whether the SPS as always visible or not
  115281. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115282. */
  115283. get isAlwaysVisible(): boolean;
  115284. /**
  115285. * Sets the SPS as always visible or not
  115286. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115287. */
  115288. set isAlwaysVisible(val: boolean);
  115289. /**
  115290. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115291. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115292. */
  115293. set isVisibilityBoxLocked(val: boolean);
  115294. /**
  115295. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  115296. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  115297. */
  115298. get isVisibilityBoxLocked(): boolean;
  115299. /**
  115300. * Tells to `setParticles()` to compute the particle rotations or not.
  115301. * Default value : true. The SPS is faster when it's set to false.
  115302. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115303. */
  115304. set computeParticleRotation(val: boolean);
  115305. /**
  115306. * Tells to `setParticles()` to compute the particle colors or not.
  115307. * Default value : true. The SPS is faster when it's set to false.
  115308. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115309. */
  115310. set computeParticleColor(val: boolean);
  115311. set computeParticleTexture(val: boolean);
  115312. /**
  115313. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  115314. * Default value : false. The SPS is faster when it's set to false.
  115315. * Note : the particle custom vertex positions aren't stored values.
  115316. */
  115317. set computeParticleVertex(val: boolean);
  115318. /**
  115319. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  115320. */
  115321. set computeBoundingBox(val: boolean);
  115322. /**
  115323. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  115324. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115325. * Default : `true`
  115326. */
  115327. set depthSortParticles(val: boolean);
  115328. /**
  115329. * Gets if `setParticles()` computes the particle rotations or not.
  115330. * Default value : true. The SPS is faster when it's set to false.
  115331. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  115332. */
  115333. get computeParticleRotation(): boolean;
  115334. /**
  115335. * Gets if `setParticles()` computes the particle colors or not.
  115336. * Default value : true. The SPS is faster when it's set to false.
  115337. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  115338. */
  115339. get computeParticleColor(): boolean;
  115340. /**
  115341. * Gets if `setParticles()` computes the particle textures or not.
  115342. * Default value : true. The SPS is faster when it's set to false.
  115343. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  115344. */
  115345. get computeParticleTexture(): boolean;
  115346. /**
  115347. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  115348. * Default value : false. The SPS is faster when it's set to false.
  115349. * Note : the particle custom vertex positions aren't stored values.
  115350. */
  115351. get computeParticleVertex(): boolean;
  115352. /**
  115353. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  115354. */
  115355. get computeBoundingBox(): boolean;
  115356. /**
  115357. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  115358. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  115359. * Default : `true`
  115360. */
  115361. get depthSortParticles(): boolean;
  115362. /**
  115363. * Gets if the SPS is created as expandable at construction time.
  115364. * Default : `false`
  115365. */
  115366. get expandable(): boolean;
  115367. /**
  115368. * Gets if the SPS supports the Multi Materials
  115369. */
  115370. get multimaterialEnabled(): boolean;
  115371. /**
  115372. * Gets if the SPS uses the model materials for its own multimaterial.
  115373. */
  115374. get useModelMaterial(): boolean;
  115375. /**
  115376. * The SPS used material array.
  115377. */
  115378. get materials(): Material[];
  115379. /**
  115380. * Sets the SPS MultiMaterial from the passed materials.
  115381. * Note : the passed array is internally copied and not used then by reference.
  115382. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  115383. */
  115384. setMultiMaterial(materials: Material[]): void;
  115385. /**
  115386. * The SPS computed multimaterial object
  115387. */
  115388. get multimaterial(): MultiMaterial;
  115389. set multimaterial(mm: MultiMaterial);
  115390. /**
  115391. * If the subMeshes must be updated on the next call to setParticles()
  115392. */
  115393. get autoUpdateSubMeshes(): boolean;
  115394. set autoUpdateSubMeshes(val: boolean);
  115395. /**
  115396. * This function does nothing. It may be overwritten to set all the particle first values.
  115397. * The SPS doesn't call this function, you may have to call it by your own.
  115398. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115399. */
  115400. initParticles(): void;
  115401. /**
  115402. * This function does nothing. It may be overwritten to recycle a particle.
  115403. * The SPS doesn't call this function, you may have to call it by your own.
  115404. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115405. * @param particle The particle to recycle
  115406. * @returns the recycled particle
  115407. */
  115408. recycleParticle(particle: SolidParticle): SolidParticle;
  115409. /**
  115410. * Updates a particle : this function should be overwritten by the user.
  115411. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  115412. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  115413. * @example : just set a particle position or velocity and recycle conditions
  115414. * @param particle The particle to update
  115415. * @returns the updated particle
  115416. */
  115417. updateParticle(particle: SolidParticle): SolidParticle;
  115418. /**
  115419. * Updates a vertex of a particle : it can be overwritten by the user.
  115420. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  115421. * @param particle the current particle
  115422. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  115423. * @param pt the index of the current vertex in the particle shape
  115424. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  115425. * @example : just set a vertex particle position or color
  115426. * @returns the sps
  115427. */
  115428. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  115429. /**
  115430. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  115431. * This does nothing and may be overwritten by the user.
  115432. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115433. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115434. * @param update the boolean update value actually passed to setParticles()
  115435. */
  115436. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115437. /**
  115438. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  115439. * This will be passed three parameters.
  115440. * This does nothing and may be overwritten by the user.
  115441. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115442. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  115443. * @param update the boolean update value actually passed to setParticles()
  115444. */
  115445. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  115446. }
  115447. }
  115448. declare module BABYLON {
  115449. /**
  115450. * Represents one particle of a solid particle system.
  115451. */
  115452. export class SolidParticle {
  115453. /**
  115454. * particle global index
  115455. */
  115456. idx: number;
  115457. /**
  115458. * particle identifier
  115459. */
  115460. id: number;
  115461. /**
  115462. * The color of the particle
  115463. */
  115464. color: Nullable<Color4>;
  115465. /**
  115466. * The world space position of the particle.
  115467. */
  115468. position: Vector3;
  115469. /**
  115470. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  115471. */
  115472. rotation: Vector3;
  115473. /**
  115474. * The world space rotation quaternion of the particle.
  115475. */
  115476. rotationQuaternion: Nullable<Quaternion>;
  115477. /**
  115478. * The scaling of the particle.
  115479. */
  115480. scaling: Vector3;
  115481. /**
  115482. * The uvs of the particle.
  115483. */
  115484. uvs: Vector4;
  115485. /**
  115486. * The current speed of the particle.
  115487. */
  115488. velocity: Vector3;
  115489. /**
  115490. * The pivot point in the particle local space.
  115491. */
  115492. pivot: Vector3;
  115493. /**
  115494. * Must the particle be translated from its pivot point in its local space ?
  115495. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  115496. * Default : false
  115497. */
  115498. translateFromPivot: boolean;
  115499. /**
  115500. * Is the particle active or not ?
  115501. */
  115502. alive: boolean;
  115503. /**
  115504. * Is the particle visible or not ?
  115505. */
  115506. isVisible: boolean;
  115507. /**
  115508. * Index of this particle in the global "positions" array (Internal use)
  115509. * @hidden
  115510. */
  115511. _pos: number;
  115512. /**
  115513. * @hidden Index of this particle in the global "indices" array (Internal use)
  115514. */
  115515. _ind: number;
  115516. /**
  115517. * @hidden ModelShape of this particle (Internal use)
  115518. */
  115519. _model: ModelShape;
  115520. /**
  115521. * ModelShape id of this particle
  115522. */
  115523. shapeId: number;
  115524. /**
  115525. * Index of the particle in its shape id
  115526. */
  115527. idxInShape: number;
  115528. /**
  115529. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  115530. */
  115531. _modelBoundingInfo: BoundingInfo;
  115532. /**
  115533. * @hidden Particle BoundingInfo object (Internal use)
  115534. */
  115535. _boundingInfo: BoundingInfo;
  115536. /**
  115537. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  115538. */
  115539. _sps: SolidParticleSystem;
  115540. /**
  115541. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  115542. */
  115543. _stillInvisible: boolean;
  115544. /**
  115545. * @hidden Last computed particle rotation matrix
  115546. */
  115547. _rotationMatrix: number[];
  115548. /**
  115549. * Parent particle Id, if any.
  115550. * Default null.
  115551. */
  115552. parentId: Nullable<number>;
  115553. /**
  115554. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  115555. */
  115556. materialIndex: Nullable<number>;
  115557. /**
  115558. * Custom object or properties.
  115559. */
  115560. props: Nullable<any>;
  115561. /**
  115562. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  115563. * The possible values are :
  115564. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115565. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115566. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115567. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115568. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115569. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  115570. * */
  115571. cullingStrategy: number;
  115572. /**
  115573. * @hidden Internal global position in the SPS.
  115574. */
  115575. _globalPosition: Vector3;
  115576. /**
  115577. * Creates a Solid Particle object.
  115578. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  115579. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  115580. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  115581. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  115582. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  115583. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  115584. * @param shapeId (integer) is the model shape identifier in the SPS.
  115585. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  115586. * @param sps defines the sps it is associated to
  115587. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  115588. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  115589. */
  115590. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  115591. /**
  115592. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  115593. * @param target the particle target
  115594. * @returns the current particle
  115595. */
  115596. copyToRef(target: SolidParticle): SolidParticle;
  115597. /**
  115598. * Legacy support, changed scale to scaling
  115599. */
  115600. get scale(): Vector3;
  115601. /**
  115602. * Legacy support, changed scale to scaling
  115603. */
  115604. set scale(scale: Vector3);
  115605. /**
  115606. * Legacy support, changed quaternion to rotationQuaternion
  115607. */
  115608. get quaternion(): Nullable<Quaternion>;
  115609. /**
  115610. * Legacy support, changed quaternion to rotationQuaternion
  115611. */
  115612. set quaternion(q: Nullable<Quaternion>);
  115613. /**
  115614. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  115615. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  115616. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  115617. * @returns true if it intersects
  115618. */
  115619. intersectsMesh(target: Mesh | SolidParticle): boolean;
  115620. /**
  115621. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  115622. * A particle is in the frustum if its bounding box intersects the frustum
  115623. * @param frustumPlanes defines the frustum to test
  115624. * @returns true if the particle is in the frustum planes
  115625. */
  115626. isInFrustum(frustumPlanes: Plane[]): boolean;
  115627. /**
  115628. * get the rotation matrix of the particle
  115629. * @hidden
  115630. */
  115631. getRotationMatrix(m: Matrix): void;
  115632. }
  115633. /**
  115634. * Represents the shape of the model used by one particle of a solid particle system.
  115635. * SPS internal tool, don't use it manually.
  115636. */
  115637. export class ModelShape {
  115638. /**
  115639. * The shape id
  115640. * @hidden
  115641. */
  115642. shapeID: number;
  115643. /**
  115644. * flat array of model positions (internal use)
  115645. * @hidden
  115646. */
  115647. _shape: Vector3[];
  115648. /**
  115649. * flat array of model UVs (internal use)
  115650. * @hidden
  115651. */
  115652. _shapeUV: number[];
  115653. /**
  115654. * color array of the model
  115655. * @hidden
  115656. */
  115657. _shapeColors: number[];
  115658. /**
  115659. * indices array of the model
  115660. * @hidden
  115661. */
  115662. _indices: number[];
  115663. /**
  115664. * normals array of the model
  115665. * @hidden
  115666. */
  115667. _normals: number[];
  115668. /**
  115669. * length of the shape in the model indices array (internal use)
  115670. * @hidden
  115671. */
  115672. _indicesLength: number;
  115673. /**
  115674. * Custom position function (internal use)
  115675. * @hidden
  115676. */
  115677. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  115678. /**
  115679. * Custom vertex function (internal use)
  115680. * @hidden
  115681. */
  115682. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  115683. /**
  115684. * Model material (internal use)
  115685. * @hidden
  115686. */
  115687. _material: Nullable<Material>;
  115688. /**
  115689. * 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.
  115690. * SPS internal tool, don't use it manually.
  115691. * @hidden
  115692. */
  115693. 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>);
  115694. }
  115695. /**
  115696. * Represents a Depth Sorted Particle in the solid particle system.
  115697. * @hidden
  115698. */
  115699. export class DepthSortedParticle {
  115700. /**
  115701. * Particle index
  115702. */
  115703. idx: number;
  115704. /**
  115705. * Index of the particle in the "indices" array
  115706. */
  115707. ind: number;
  115708. /**
  115709. * Length of the particle shape in the "indices" array
  115710. */
  115711. indicesLength: number;
  115712. /**
  115713. * Squared distance from the particle to the camera
  115714. */
  115715. sqDistance: number;
  115716. /**
  115717. * Material index when used with MultiMaterials
  115718. */
  115719. materialIndex: number;
  115720. /**
  115721. * Creates a new sorted particle
  115722. * @param materialIndex
  115723. */
  115724. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  115725. }
  115726. /**
  115727. * Represents a solid particle vertex
  115728. */
  115729. export class SolidParticleVertex {
  115730. /**
  115731. * Vertex position
  115732. */
  115733. position: Vector3;
  115734. /**
  115735. * Vertex color
  115736. */
  115737. color: Color4;
  115738. /**
  115739. * Vertex UV
  115740. */
  115741. uv: Vector2;
  115742. /**
  115743. * Creates a new solid particle vertex
  115744. */
  115745. constructor();
  115746. /** Vertex x coordinate */
  115747. get x(): number;
  115748. set x(val: number);
  115749. /** Vertex y coordinate */
  115750. get y(): number;
  115751. set y(val: number);
  115752. /** Vertex z coordinate */
  115753. get z(): number;
  115754. set z(val: number);
  115755. }
  115756. }
  115757. declare module BABYLON {
  115758. /**
  115759. * @hidden
  115760. */
  115761. export class _MeshCollisionData {
  115762. _checkCollisions: boolean;
  115763. _collisionMask: number;
  115764. _collisionGroup: number;
  115765. _surroundingMeshes: Nullable<AbstractMesh[]>;
  115766. _collider: Nullable<Collider>;
  115767. _oldPositionForCollisions: Vector3;
  115768. _diffPositionForCollisions: Vector3;
  115769. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  115770. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  115771. _collisionResponse: boolean;
  115772. }
  115773. }
  115774. declare module BABYLON {
  115775. /** @hidden */
  115776. class _FacetDataStorage {
  115777. facetPositions: Vector3[];
  115778. facetNormals: Vector3[];
  115779. facetPartitioning: number[][];
  115780. facetNb: number;
  115781. partitioningSubdivisions: number;
  115782. partitioningBBoxRatio: number;
  115783. facetDataEnabled: boolean;
  115784. facetParameters: any;
  115785. bbSize: Vector3;
  115786. subDiv: {
  115787. max: number;
  115788. X: number;
  115789. Y: number;
  115790. Z: number;
  115791. };
  115792. facetDepthSort: boolean;
  115793. facetDepthSortEnabled: boolean;
  115794. depthSortedIndices: IndicesArray;
  115795. depthSortedFacets: {
  115796. ind: number;
  115797. sqDistance: number;
  115798. }[];
  115799. facetDepthSortFunction: (f1: {
  115800. ind: number;
  115801. sqDistance: number;
  115802. }, f2: {
  115803. ind: number;
  115804. sqDistance: number;
  115805. }) => number;
  115806. facetDepthSortFrom: Vector3;
  115807. facetDepthSortOrigin: Vector3;
  115808. invertedMatrix: Matrix;
  115809. }
  115810. /**
  115811. * @hidden
  115812. **/
  115813. class _InternalAbstractMeshDataInfo {
  115814. _hasVertexAlpha: boolean;
  115815. _useVertexColors: boolean;
  115816. _numBoneInfluencers: number;
  115817. _applyFog: boolean;
  115818. _receiveShadows: boolean;
  115819. _facetData: _FacetDataStorage;
  115820. _visibility: number;
  115821. _skeleton: Nullable<Skeleton>;
  115822. _layerMask: number;
  115823. _computeBonesUsingShaders: boolean;
  115824. _isActive: boolean;
  115825. _onlyForInstances: boolean;
  115826. _isActiveIntermediate: boolean;
  115827. _onlyForInstancesIntermediate: boolean;
  115828. _actAsRegularMesh: boolean;
  115829. }
  115830. /**
  115831. * Class used to store all common mesh properties
  115832. */
  115833. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  115834. /** No occlusion */
  115835. static OCCLUSION_TYPE_NONE: number;
  115836. /** Occlusion set to optimisitic */
  115837. static OCCLUSION_TYPE_OPTIMISTIC: number;
  115838. /** Occlusion set to strict */
  115839. static OCCLUSION_TYPE_STRICT: number;
  115840. /** Use an accurante occlusion algorithm */
  115841. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  115842. /** Use a conservative occlusion algorithm */
  115843. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  115844. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  115845. * Test order :
  115846. * Is the bounding sphere outside the frustum ?
  115847. * If not, are the bounding box vertices outside the frustum ?
  115848. * It not, then the cullable object is in the frustum.
  115849. */
  115850. static readonly CULLINGSTRATEGY_STANDARD: number;
  115851. /** Culling strategy : Bounding Sphere Only.
  115852. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  115853. * It's also less accurate than the standard because some not visible objects can still be selected.
  115854. * Test : is the bounding sphere outside the frustum ?
  115855. * If not, then the cullable object is in the frustum.
  115856. */
  115857. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  115858. /** Culling strategy : Optimistic Inclusion.
  115859. * This in an inclusion test first, then the standard exclusion test.
  115860. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  115861. * 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.
  115862. * Anyway, it's as accurate as the standard strategy.
  115863. * Test :
  115864. * Is the cullable object bounding sphere center in the frustum ?
  115865. * If not, apply the default culling strategy.
  115866. */
  115867. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  115868. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  115869. * This in an inclusion test first, then the bounding sphere only exclusion test.
  115870. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  115871. * 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.
  115872. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  115873. * Test :
  115874. * Is the cullable object bounding sphere center in the frustum ?
  115875. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  115876. */
  115877. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  115878. /**
  115879. * No billboard
  115880. */
  115881. static get BILLBOARDMODE_NONE(): number;
  115882. /** Billboard on X axis */
  115883. static get BILLBOARDMODE_X(): number;
  115884. /** Billboard on Y axis */
  115885. static get BILLBOARDMODE_Y(): number;
  115886. /** Billboard on Z axis */
  115887. static get BILLBOARDMODE_Z(): number;
  115888. /** Billboard on all axes */
  115889. static get BILLBOARDMODE_ALL(): number;
  115890. /** Billboard on using position instead of orientation */
  115891. static get BILLBOARDMODE_USE_POSITION(): number;
  115892. /** @hidden */
  115893. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  115894. /**
  115895. * The culling strategy to use to check whether the mesh must be rendered or not.
  115896. * This value can be changed at any time and will be used on the next render mesh selection.
  115897. * The possible values are :
  115898. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  115899. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  115900. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  115901. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  115902. * Please read each static variable documentation to get details about the culling process.
  115903. * */
  115904. cullingStrategy: number;
  115905. /**
  115906. * Gets the number of facets in the mesh
  115907. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  115908. */
  115909. get facetNb(): number;
  115910. /**
  115911. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  115912. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  115913. */
  115914. get partitioningSubdivisions(): number;
  115915. set partitioningSubdivisions(nb: number);
  115916. /**
  115917. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  115918. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  115919. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  115920. */
  115921. get partitioningBBoxRatio(): number;
  115922. set partitioningBBoxRatio(ratio: number);
  115923. /**
  115924. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  115925. * Works only for updatable meshes.
  115926. * Doesn't work with multi-materials
  115927. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  115928. */
  115929. get mustDepthSortFacets(): boolean;
  115930. set mustDepthSortFacets(sort: boolean);
  115931. /**
  115932. * The location (Vector3) where the facet depth sort must be computed from.
  115933. * By default, the active camera position.
  115934. * Used only when facet depth sort is enabled
  115935. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  115936. */
  115937. get facetDepthSortFrom(): Vector3;
  115938. set facetDepthSortFrom(location: Vector3);
  115939. /**
  115940. * gets a boolean indicating if facetData is enabled
  115941. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  115942. */
  115943. get isFacetDataEnabled(): boolean;
  115944. /** @hidden */
  115945. _updateNonUniformScalingState(value: boolean): boolean;
  115946. /**
  115947. * An event triggered when this mesh collides with another one
  115948. */
  115949. onCollideObservable: Observable<AbstractMesh>;
  115950. /** Set a function to call when this mesh collides with another one */
  115951. set onCollide(callback: () => void);
  115952. /**
  115953. * An event triggered when the collision's position changes
  115954. */
  115955. onCollisionPositionChangeObservable: Observable<Vector3>;
  115956. /** Set a function to call when the collision's position changes */
  115957. set onCollisionPositionChange(callback: () => void);
  115958. /**
  115959. * An event triggered when material is changed
  115960. */
  115961. onMaterialChangedObservable: Observable<AbstractMesh>;
  115962. /**
  115963. * Gets or sets the orientation for POV movement & rotation
  115964. */
  115965. definedFacingForward: boolean;
  115966. /** @hidden */
  115967. _occlusionQuery: Nullable<WebGLQuery>;
  115968. /** @hidden */
  115969. _renderingGroup: Nullable<RenderingGroup>;
  115970. /**
  115971. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  115972. */
  115973. get visibility(): number;
  115974. /**
  115975. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  115976. */
  115977. set visibility(value: number);
  115978. /** Gets or sets the alpha index used to sort transparent meshes
  115979. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  115980. */
  115981. alphaIndex: number;
  115982. /**
  115983. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  115984. */
  115985. isVisible: boolean;
  115986. /**
  115987. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  115988. */
  115989. isPickable: boolean;
  115990. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  115991. showSubMeshesBoundingBox: boolean;
  115992. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  115993. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115994. */
  115995. isBlocker: boolean;
  115996. /**
  115997. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  115998. */
  115999. enablePointerMoveEvents: boolean;
  116000. private _renderingGroupId;
  116001. /**
  116002. * Specifies the rendering group id for this mesh (0 by default)
  116003. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116004. */
  116005. get renderingGroupId(): number;
  116006. set renderingGroupId(value: number);
  116007. private _material;
  116008. /** Gets or sets current material */
  116009. get material(): Nullable<Material>;
  116010. set material(value: Nullable<Material>);
  116011. /**
  116012. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116013. * @see https://doc.babylonjs.com/babylon101/shadows
  116014. */
  116015. get receiveShadows(): boolean;
  116016. set receiveShadows(value: boolean);
  116017. /** Defines color to use when rendering outline */
  116018. outlineColor: Color3;
  116019. /** Define width to use when rendering outline */
  116020. outlineWidth: number;
  116021. /** Defines color to use when rendering overlay */
  116022. overlayColor: Color3;
  116023. /** Defines alpha to use when rendering overlay */
  116024. overlayAlpha: number;
  116025. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116026. get hasVertexAlpha(): boolean;
  116027. set hasVertexAlpha(value: boolean);
  116028. /** 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) */
  116029. get useVertexColors(): boolean;
  116030. set useVertexColors(value: boolean);
  116031. /**
  116032. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116033. */
  116034. get computeBonesUsingShaders(): boolean;
  116035. set computeBonesUsingShaders(value: boolean);
  116036. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116037. get numBoneInfluencers(): number;
  116038. set numBoneInfluencers(value: number);
  116039. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116040. get applyFog(): boolean;
  116041. set applyFog(value: boolean);
  116042. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116043. useOctreeForRenderingSelection: boolean;
  116044. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116045. useOctreeForPicking: boolean;
  116046. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116047. useOctreeForCollisions: boolean;
  116048. /**
  116049. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116050. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116051. */
  116052. get layerMask(): number;
  116053. set layerMask(value: number);
  116054. /**
  116055. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116056. */
  116057. alwaysSelectAsActiveMesh: boolean;
  116058. /**
  116059. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116060. */
  116061. doNotSyncBoundingInfo: boolean;
  116062. /**
  116063. * Gets or sets the current action manager
  116064. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116065. */
  116066. actionManager: Nullable<AbstractActionManager>;
  116067. private _meshCollisionData;
  116068. /**
  116069. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116070. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116071. */
  116072. ellipsoid: Vector3;
  116073. /**
  116074. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116075. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116076. */
  116077. ellipsoidOffset: Vector3;
  116078. /**
  116079. * Gets or sets a collision mask used to mask collisions (default is -1).
  116080. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116081. */
  116082. get collisionMask(): number;
  116083. set collisionMask(mask: number);
  116084. /**
  116085. * Gets or sets a collision response flag (default is true).
  116086. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116087. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116088. * to respond to the collision.
  116089. */
  116090. get collisionResponse(): boolean;
  116091. set collisionResponse(response: boolean);
  116092. /**
  116093. * Gets or sets the current collision group mask (-1 by default).
  116094. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116095. */
  116096. get collisionGroup(): number;
  116097. set collisionGroup(mask: number);
  116098. /**
  116099. * Gets or sets current surrounding meshes (null by default).
  116100. *
  116101. * By default collision detection is tested against every mesh in the scene.
  116102. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116103. * meshes will be tested for the collision.
  116104. *
  116105. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116106. */
  116107. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116108. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116109. /**
  116110. * Defines edge width used when edgesRenderer is enabled
  116111. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116112. */
  116113. edgesWidth: number;
  116114. /**
  116115. * Defines edge color used when edgesRenderer is enabled
  116116. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116117. */
  116118. edgesColor: Color4;
  116119. /** @hidden */
  116120. _edgesRenderer: Nullable<IEdgesRenderer>;
  116121. /** @hidden */
  116122. _masterMesh: Nullable<AbstractMesh>;
  116123. /** @hidden */
  116124. _boundingInfo: Nullable<BoundingInfo>;
  116125. /** @hidden */
  116126. _renderId: number;
  116127. /**
  116128. * Gets or sets the list of subMeshes
  116129. * @see https://doc.babylonjs.com/how_to/multi_materials
  116130. */
  116131. subMeshes: SubMesh[];
  116132. /** @hidden */
  116133. _intersectionsInProgress: AbstractMesh[];
  116134. /** @hidden */
  116135. _unIndexed: boolean;
  116136. /** @hidden */
  116137. _lightSources: Light[];
  116138. /** Gets the list of lights affecting that mesh */
  116139. get lightSources(): Light[];
  116140. /** @hidden */
  116141. get _positions(): Nullable<Vector3[]>;
  116142. /** @hidden */
  116143. _waitingData: {
  116144. lods: Nullable<any>;
  116145. actions: Nullable<any>;
  116146. freezeWorldMatrix: Nullable<boolean>;
  116147. };
  116148. /** @hidden */
  116149. _bonesTransformMatrices: Nullable<Float32Array>;
  116150. /** @hidden */
  116151. _transformMatrixTexture: Nullable<RawTexture>;
  116152. /**
  116153. * Gets or sets a skeleton to apply skining transformations
  116154. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116155. */
  116156. set skeleton(value: Nullable<Skeleton>);
  116157. get skeleton(): Nullable<Skeleton>;
  116158. /**
  116159. * An event triggered when the mesh is rebuilt.
  116160. */
  116161. onRebuildObservable: Observable<AbstractMesh>;
  116162. /**
  116163. * Creates a new AbstractMesh
  116164. * @param name defines the name of the mesh
  116165. * @param scene defines the hosting scene
  116166. */
  116167. constructor(name: string, scene?: Nullable<Scene>);
  116168. /**
  116169. * Returns the string "AbstractMesh"
  116170. * @returns "AbstractMesh"
  116171. */
  116172. getClassName(): string;
  116173. /**
  116174. * Gets a string representation of the current mesh
  116175. * @param fullDetails defines a boolean indicating if full details must be included
  116176. * @returns a string representation of the current mesh
  116177. */
  116178. toString(fullDetails?: boolean): string;
  116179. /**
  116180. * @hidden
  116181. */
  116182. protected _getEffectiveParent(): Nullable<Node>;
  116183. /** @hidden */
  116184. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116185. /** @hidden */
  116186. _rebuild(): void;
  116187. /** @hidden */
  116188. _resyncLightSources(): void;
  116189. /** @hidden */
  116190. _resyncLightSource(light: Light): void;
  116191. /** @hidden */
  116192. _unBindEffect(): void;
  116193. /** @hidden */
  116194. _removeLightSource(light: Light, dispose: boolean): void;
  116195. private _markSubMeshesAsDirty;
  116196. /** @hidden */
  116197. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116198. /** @hidden */
  116199. _markSubMeshesAsAttributesDirty(): void;
  116200. /** @hidden */
  116201. _markSubMeshesAsMiscDirty(): void;
  116202. /**
  116203. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116204. */
  116205. get scaling(): Vector3;
  116206. set scaling(newScaling: Vector3);
  116207. /**
  116208. * Returns true if the mesh is blocked. Implemented by child classes
  116209. */
  116210. get isBlocked(): boolean;
  116211. /**
  116212. * Returns the mesh itself by default. Implemented by child classes
  116213. * @param camera defines the camera to use to pick the right LOD level
  116214. * @returns the currentAbstractMesh
  116215. */
  116216. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116217. /**
  116218. * Returns 0 by default. Implemented by child classes
  116219. * @returns an integer
  116220. */
  116221. getTotalVertices(): number;
  116222. /**
  116223. * Returns a positive integer : the total number of indices in this mesh geometry.
  116224. * @returns the numner of indices or zero if the mesh has no geometry.
  116225. */
  116226. getTotalIndices(): number;
  116227. /**
  116228. * Returns null by default. Implemented by child classes
  116229. * @returns null
  116230. */
  116231. getIndices(): Nullable<IndicesArray>;
  116232. /**
  116233. * Returns the array of the requested vertex data kind. Implemented by child classes
  116234. * @param kind defines the vertex data kind to use
  116235. * @returns null
  116236. */
  116237. getVerticesData(kind: string): Nullable<FloatArray>;
  116238. /**
  116239. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116240. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116241. * Note that a new underlying VertexBuffer object is created each call.
  116242. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116243. * @param kind defines vertex data kind:
  116244. * * VertexBuffer.PositionKind
  116245. * * VertexBuffer.UVKind
  116246. * * VertexBuffer.UV2Kind
  116247. * * VertexBuffer.UV3Kind
  116248. * * VertexBuffer.UV4Kind
  116249. * * VertexBuffer.UV5Kind
  116250. * * VertexBuffer.UV6Kind
  116251. * * VertexBuffer.ColorKind
  116252. * * VertexBuffer.MatricesIndicesKind
  116253. * * VertexBuffer.MatricesIndicesExtraKind
  116254. * * VertexBuffer.MatricesWeightsKind
  116255. * * VertexBuffer.MatricesWeightsExtraKind
  116256. * @param data defines the data source
  116257. * @param updatable defines if the data must be flagged as updatable (or static)
  116258. * @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
  116259. * @returns the current mesh
  116260. */
  116261. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  116262. /**
  116263. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  116264. * If the mesh has no geometry, it is simply returned as it is.
  116265. * @param kind defines vertex data kind:
  116266. * * VertexBuffer.PositionKind
  116267. * * VertexBuffer.UVKind
  116268. * * VertexBuffer.UV2Kind
  116269. * * VertexBuffer.UV3Kind
  116270. * * VertexBuffer.UV4Kind
  116271. * * VertexBuffer.UV5Kind
  116272. * * VertexBuffer.UV6Kind
  116273. * * VertexBuffer.ColorKind
  116274. * * VertexBuffer.MatricesIndicesKind
  116275. * * VertexBuffer.MatricesIndicesExtraKind
  116276. * * VertexBuffer.MatricesWeightsKind
  116277. * * VertexBuffer.MatricesWeightsExtraKind
  116278. * @param data defines the data source
  116279. * @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
  116280. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  116281. * @returns the current mesh
  116282. */
  116283. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  116284. /**
  116285. * Sets the mesh indices,
  116286. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  116287. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  116288. * @param totalVertices Defines the total number of vertices
  116289. * @returns the current mesh
  116290. */
  116291. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  116292. /**
  116293. * Gets a boolean indicating if specific vertex data is present
  116294. * @param kind defines the vertex data kind to use
  116295. * @returns true is data kind is present
  116296. */
  116297. isVerticesDataPresent(kind: string): boolean;
  116298. /**
  116299. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  116300. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  116301. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  116302. * @returns a BoundingInfo
  116303. */
  116304. getBoundingInfo(): BoundingInfo;
  116305. /**
  116306. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  116307. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  116308. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  116309. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  116310. * @returns the current mesh
  116311. */
  116312. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  116313. /**
  116314. * Overwrite the current bounding info
  116315. * @param boundingInfo defines the new bounding info
  116316. * @returns the current mesh
  116317. */
  116318. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  116319. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  116320. get useBones(): boolean;
  116321. /** @hidden */
  116322. _preActivate(): void;
  116323. /** @hidden */
  116324. _preActivateForIntermediateRendering(renderId: number): void;
  116325. /** @hidden */
  116326. _activate(renderId: number, intermediateRendering: boolean): boolean;
  116327. /** @hidden */
  116328. _postActivate(): void;
  116329. /** @hidden */
  116330. _freeze(): void;
  116331. /** @hidden */
  116332. _unFreeze(): void;
  116333. /**
  116334. * Gets the current world matrix
  116335. * @returns a Matrix
  116336. */
  116337. getWorldMatrix(): Matrix;
  116338. /** @hidden */
  116339. _getWorldMatrixDeterminant(): number;
  116340. /**
  116341. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  116342. */
  116343. get isAnInstance(): boolean;
  116344. /**
  116345. * Gets a boolean indicating if this mesh has instances
  116346. */
  116347. get hasInstances(): boolean;
  116348. /**
  116349. * Gets a boolean indicating if this mesh has thin instances
  116350. */
  116351. get hasThinInstances(): boolean;
  116352. /**
  116353. * Perform relative position change from the point of view of behind the front of the mesh.
  116354. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116355. * Supports definition of mesh facing forward or backward
  116356. * @param amountRight defines the distance on the right axis
  116357. * @param amountUp defines the distance on the up axis
  116358. * @param amountForward defines the distance on the forward axis
  116359. * @returns the current mesh
  116360. */
  116361. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  116362. /**
  116363. * Calculate relative position change from the point of view of behind the front of the mesh.
  116364. * This is performed taking into account the meshes current rotation, so you do not have to care.
  116365. * Supports definition of mesh facing forward or backward
  116366. * @param amountRight defines the distance on the right axis
  116367. * @param amountUp defines the distance on the up axis
  116368. * @param amountForward defines the distance on the forward axis
  116369. * @returns the new displacement vector
  116370. */
  116371. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  116372. /**
  116373. * Perform relative rotation change from the point of view of behind the front of the mesh.
  116374. * Supports definition of mesh facing forward or backward
  116375. * @param flipBack defines the flip
  116376. * @param twirlClockwise defines the twirl
  116377. * @param tiltRight defines the tilt
  116378. * @returns the current mesh
  116379. */
  116380. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  116381. /**
  116382. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  116383. * Supports definition of mesh facing forward or backward.
  116384. * @param flipBack defines the flip
  116385. * @param twirlClockwise defines the twirl
  116386. * @param tiltRight defines the tilt
  116387. * @returns the new rotation vector
  116388. */
  116389. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  116390. /**
  116391. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  116392. * This means the mesh underlying bounding box and sphere are recomputed.
  116393. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  116394. * @returns the current mesh
  116395. */
  116396. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  116397. /** @hidden */
  116398. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  116399. /** @hidden */
  116400. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  116401. /** @hidden */
  116402. _updateBoundingInfo(): AbstractMesh;
  116403. /** @hidden */
  116404. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  116405. /** @hidden */
  116406. protected _afterComputeWorldMatrix(): void;
  116407. /** @hidden */
  116408. get _effectiveMesh(): AbstractMesh;
  116409. /**
  116410. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  116411. * A mesh is in the frustum if its bounding box intersects the frustum
  116412. * @param frustumPlanes defines the frustum to test
  116413. * @returns true if the mesh is in the frustum planes
  116414. */
  116415. isInFrustum(frustumPlanes: Plane[]): boolean;
  116416. /**
  116417. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  116418. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  116419. * @param frustumPlanes defines the frustum to test
  116420. * @returns true if the mesh is completely in the frustum planes
  116421. */
  116422. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  116423. /**
  116424. * True if the mesh intersects another mesh or a SolidParticle object
  116425. * @param mesh defines a target mesh or SolidParticle to test
  116426. * @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)
  116427. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  116428. * @returns true if there is an intersection
  116429. */
  116430. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  116431. /**
  116432. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  116433. * @param point defines the point to test
  116434. * @returns true if there is an intersection
  116435. */
  116436. intersectsPoint(point: Vector3): boolean;
  116437. /**
  116438. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  116439. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116440. */
  116441. get checkCollisions(): boolean;
  116442. set checkCollisions(collisionEnabled: boolean);
  116443. /**
  116444. * Gets Collider object used to compute collisions (not physics)
  116445. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116446. */
  116447. get collider(): Nullable<Collider>;
  116448. /**
  116449. * Move the mesh using collision engine
  116450. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116451. * @param displacement defines the requested displacement vector
  116452. * @returns the current mesh
  116453. */
  116454. moveWithCollisions(displacement: Vector3): AbstractMesh;
  116455. private _onCollisionPositionChange;
  116456. /** @hidden */
  116457. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  116458. /** @hidden */
  116459. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  116460. /** @hidden */
  116461. _checkCollision(collider: Collider): AbstractMesh;
  116462. /** @hidden */
  116463. _generatePointsArray(): boolean;
  116464. /**
  116465. * Checks if the passed Ray intersects with the mesh
  116466. * @param ray defines the ray to use
  116467. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  116468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  116469. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  116470. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  116471. * @returns the picking info
  116472. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  116473. */
  116474. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  116475. /**
  116476. * Clones the current mesh
  116477. * @param name defines the mesh name
  116478. * @param newParent defines the new mesh parent
  116479. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  116480. * @returns the new mesh
  116481. */
  116482. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  116483. /**
  116484. * Disposes all the submeshes of the current meshnp
  116485. * @returns the current mesh
  116486. */
  116487. releaseSubMeshes(): AbstractMesh;
  116488. /**
  116489. * Releases resources associated with this abstract mesh.
  116490. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116491. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116492. */
  116493. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116494. /**
  116495. * Adds the passed mesh as a child to the current mesh
  116496. * @param mesh defines the child mesh
  116497. * @returns the current mesh
  116498. */
  116499. addChild(mesh: AbstractMesh): AbstractMesh;
  116500. /**
  116501. * Removes the passed mesh from the current mesh children list
  116502. * @param mesh defines the child mesh
  116503. * @returns the current mesh
  116504. */
  116505. removeChild(mesh: AbstractMesh): AbstractMesh;
  116506. /** @hidden */
  116507. private _initFacetData;
  116508. /**
  116509. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  116510. * This method can be called within the render loop.
  116511. * 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
  116512. * @returns the current mesh
  116513. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116514. */
  116515. updateFacetData(): AbstractMesh;
  116516. /**
  116517. * Returns the facetLocalNormals array.
  116518. * The normals are expressed in the mesh local spac
  116519. * @returns an array of Vector3
  116520. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116521. */
  116522. getFacetLocalNormals(): Vector3[];
  116523. /**
  116524. * Returns the facetLocalPositions array.
  116525. * The facet positions are expressed in the mesh local space
  116526. * @returns an array of Vector3
  116527. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116528. */
  116529. getFacetLocalPositions(): Vector3[];
  116530. /**
  116531. * Returns the facetLocalPartioning array
  116532. * @returns an array of array of numbers
  116533. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116534. */
  116535. getFacetLocalPartitioning(): number[][];
  116536. /**
  116537. * Returns the i-th facet position in the world system.
  116538. * This method allocates a new Vector3 per call
  116539. * @param i defines the facet index
  116540. * @returns a new Vector3
  116541. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116542. */
  116543. getFacetPosition(i: number): Vector3;
  116544. /**
  116545. * Sets the reference Vector3 with the i-th facet position in the world system
  116546. * @param i defines the facet index
  116547. * @param ref defines the target vector
  116548. * @returns the current mesh
  116549. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116550. */
  116551. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  116552. /**
  116553. * Returns the i-th facet normal in the world system.
  116554. * This method allocates a new Vector3 per call
  116555. * @param i defines the facet index
  116556. * @returns a new Vector3
  116557. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116558. */
  116559. getFacetNormal(i: number): Vector3;
  116560. /**
  116561. * Sets the reference Vector3 with the i-th facet normal in the world system
  116562. * @param i defines the facet index
  116563. * @param ref defines the target vector
  116564. * @returns the current mesh
  116565. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116566. */
  116567. getFacetNormalToRef(i: number, ref: Vector3): this;
  116568. /**
  116569. * 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)
  116570. * @param x defines x coordinate
  116571. * @param y defines y coordinate
  116572. * @param z defines z coordinate
  116573. * @returns the array of facet indexes
  116574. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116575. */
  116576. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  116577. /**
  116578. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  116579. * @param projected sets as the (x,y,z) world projection on the facet
  116580. * @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
  116581. * @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
  116582. * @param x defines x coordinate
  116583. * @param y defines y coordinate
  116584. * @param z defines z coordinate
  116585. * @returns the face index if found (or null instead)
  116586. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116587. */
  116588. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116589. /**
  116590. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  116591. * @param projected sets as the (x,y,z) local projection on the facet
  116592. * @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
  116593. * @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
  116594. * @param x defines x coordinate
  116595. * @param y defines y coordinate
  116596. * @param z defines z coordinate
  116597. * @returns the face index if found (or null instead)
  116598. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116599. */
  116600. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  116601. /**
  116602. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  116603. * @returns the parameters
  116604. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116605. */
  116606. getFacetDataParameters(): any;
  116607. /**
  116608. * Disables the feature FacetData and frees the related memory
  116609. * @returns the current mesh
  116610. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  116611. */
  116612. disableFacetData(): AbstractMesh;
  116613. /**
  116614. * Updates the AbstractMesh indices array
  116615. * @param indices defines the data source
  116616. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  116617. * @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)
  116618. * @returns the current mesh
  116619. */
  116620. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  116621. /**
  116622. * Creates new normals data for the mesh
  116623. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  116624. * @returns the current mesh
  116625. */
  116626. createNormals(updatable: boolean): AbstractMesh;
  116627. /**
  116628. * Align the mesh with a normal
  116629. * @param normal defines the normal to use
  116630. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  116631. * @returns the current mesh
  116632. */
  116633. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  116634. /** @hidden */
  116635. _checkOcclusionQuery(): boolean;
  116636. /**
  116637. * Disables the mesh edge rendering mode
  116638. * @returns the currentAbstractMesh
  116639. */
  116640. disableEdgesRendering(): AbstractMesh;
  116641. /**
  116642. * Enables the edge rendering mode on the mesh.
  116643. * This mode makes the mesh edges visible
  116644. * @param epsilon defines the maximal distance between two angles to detect a face
  116645. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  116646. * @returns the currentAbstractMesh
  116647. * @see https://www.babylonjs-playground.com/#19O9TU#0
  116648. */
  116649. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  116650. /**
  116651. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  116652. * @returns an array of particle systems in the scene that use the mesh as an emitter
  116653. */
  116654. getConnectedParticleSystems(): IParticleSystem[];
  116655. }
  116656. }
  116657. declare module BABYLON {
  116658. /**
  116659. * Interface used to define ActionEvent
  116660. */
  116661. export interface IActionEvent {
  116662. /** The mesh or sprite that triggered the action */
  116663. source: any;
  116664. /** The X mouse cursor position at the time of the event */
  116665. pointerX: number;
  116666. /** The Y mouse cursor position at the time of the event */
  116667. pointerY: number;
  116668. /** The mesh that is currently pointed at (can be null) */
  116669. meshUnderPointer: Nullable<AbstractMesh>;
  116670. /** the original (browser) event that triggered the ActionEvent */
  116671. sourceEvent?: any;
  116672. /** additional data for the event */
  116673. additionalData?: any;
  116674. }
  116675. /**
  116676. * ActionEvent is the event being sent when an action is triggered.
  116677. */
  116678. export class ActionEvent implements IActionEvent {
  116679. /** The mesh or sprite that triggered the action */
  116680. source: any;
  116681. /** The X mouse cursor position at the time of the event */
  116682. pointerX: number;
  116683. /** The Y mouse cursor position at the time of the event */
  116684. pointerY: number;
  116685. /** The mesh that is currently pointed at (can be null) */
  116686. meshUnderPointer: Nullable<AbstractMesh>;
  116687. /** the original (browser) event that triggered the ActionEvent */
  116688. sourceEvent?: any;
  116689. /** additional data for the event */
  116690. additionalData?: any;
  116691. /**
  116692. * Creates a new ActionEvent
  116693. * @param source The mesh or sprite that triggered the action
  116694. * @param pointerX The X mouse cursor position at the time of the event
  116695. * @param pointerY The Y mouse cursor position at the time of the event
  116696. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  116697. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  116698. * @param additionalData additional data for the event
  116699. */
  116700. constructor(
  116701. /** The mesh or sprite that triggered the action */
  116702. source: any,
  116703. /** The X mouse cursor position at the time of the event */
  116704. pointerX: number,
  116705. /** The Y mouse cursor position at the time of the event */
  116706. pointerY: number,
  116707. /** The mesh that is currently pointed at (can be null) */
  116708. meshUnderPointer: Nullable<AbstractMesh>,
  116709. /** the original (browser) event that triggered the ActionEvent */
  116710. sourceEvent?: any,
  116711. /** additional data for the event */
  116712. additionalData?: any);
  116713. /**
  116714. * Helper function to auto-create an ActionEvent from a source mesh.
  116715. * @param source The source mesh that triggered the event
  116716. * @param evt The original (browser) event
  116717. * @param additionalData additional data for the event
  116718. * @returns the new ActionEvent
  116719. */
  116720. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  116721. /**
  116722. * Helper function to auto-create an ActionEvent from a source sprite
  116723. * @param source The source sprite that triggered the event
  116724. * @param scene Scene associated with the sprite
  116725. * @param evt The original (browser) event
  116726. * @param additionalData additional data for the event
  116727. * @returns the new ActionEvent
  116728. */
  116729. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  116730. /**
  116731. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  116732. * @param scene the scene where the event occurred
  116733. * @param evt The original (browser) event
  116734. * @returns the new ActionEvent
  116735. */
  116736. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  116737. /**
  116738. * Helper function to auto-create an ActionEvent from a primitive
  116739. * @param prim defines the target primitive
  116740. * @param pointerPos defines the pointer position
  116741. * @param evt The original (browser) event
  116742. * @param additionalData additional data for the event
  116743. * @returns the new ActionEvent
  116744. */
  116745. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  116746. }
  116747. }
  116748. declare module BABYLON {
  116749. /**
  116750. * Abstract class used to decouple action Manager from scene and meshes.
  116751. * Do not instantiate.
  116752. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116753. */
  116754. export abstract class AbstractActionManager implements IDisposable {
  116755. /** Gets the list of active triggers */
  116756. static Triggers: {
  116757. [key: string]: number;
  116758. };
  116759. /** Gets the cursor to use when hovering items */
  116760. hoverCursor: string;
  116761. /** Gets the list of actions */
  116762. actions: IAction[];
  116763. /**
  116764. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  116765. */
  116766. isRecursive: boolean;
  116767. /**
  116768. * Releases all associated resources
  116769. */
  116770. abstract dispose(): void;
  116771. /**
  116772. * Does this action manager has pointer triggers
  116773. */
  116774. abstract get hasPointerTriggers(): boolean;
  116775. /**
  116776. * Does this action manager has pick triggers
  116777. */
  116778. abstract get hasPickTriggers(): boolean;
  116779. /**
  116780. * Process a specific trigger
  116781. * @param trigger defines the trigger to process
  116782. * @param evt defines the event details to be processed
  116783. */
  116784. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  116785. /**
  116786. * Does this action manager handles actions of any of the given triggers
  116787. * @param triggers defines the triggers to be tested
  116788. * @return a boolean indicating whether one (or more) of the triggers is handled
  116789. */
  116790. abstract hasSpecificTriggers(triggers: number[]): boolean;
  116791. /**
  116792. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  116793. * speed.
  116794. * @param triggerA defines the trigger to be tested
  116795. * @param triggerB defines the trigger to be tested
  116796. * @return a boolean indicating whether one (or more) of the triggers is handled
  116797. */
  116798. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  116799. /**
  116800. * Does this action manager handles actions of a given trigger
  116801. * @param trigger defines the trigger to be tested
  116802. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  116803. * @return whether the trigger is handled
  116804. */
  116805. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  116806. /**
  116807. * Serialize this manager to a JSON object
  116808. * @param name defines the property name to store this manager
  116809. * @returns a JSON representation of this manager
  116810. */
  116811. abstract serialize(name: string): any;
  116812. /**
  116813. * Registers an action to this action manager
  116814. * @param action defines the action to be registered
  116815. * @return the action amended (prepared) after registration
  116816. */
  116817. abstract registerAction(action: IAction): Nullable<IAction>;
  116818. /**
  116819. * Unregisters an action to this action manager
  116820. * @param action defines the action to be unregistered
  116821. * @return a boolean indicating whether the action has been unregistered
  116822. */
  116823. abstract unregisterAction(action: IAction): Boolean;
  116824. /**
  116825. * Does exist one action manager with at least one trigger
  116826. **/
  116827. static get HasTriggers(): boolean;
  116828. /**
  116829. * Does exist one action manager with at least one pick trigger
  116830. **/
  116831. static get HasPickTriggers(): boolean;
  116832. /**
  116833. * Does exist one action manager that handles actions of a given trigger
  116834. * @param trigger defines the trigger to be tested
  116835. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  116836. **/
  116837. static HasSpecificTrigger(trigger: number): boolean;
  116838. }
  116839. }
  116840. declare module BABYLON {
  116841. /**
  116842. * Defines how a node can be built from a string name.
  116843. */
  116844. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  116845. /**
  116846. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  116847. */
  116848. export class Node implements IBehaviorAware<Node> {
  116849. /** @hidden */
  116850. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  116851. private static _NodeConstructors;
  116852. /**
  116853. * Add a new node constructor
  116854. * @param type defines the type name of the node to construct
  116855. * @param constructorFunc defines the constructor function
  116856. */
  116857. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  116858. /**
  116859. * Returns a node constructor based on type name
  116860. * @param type defines the type name
  116861. * @param name defines the new node name
  116862. * @param scene defines the hosting scene
  116863. * @param options defines optional options to transmit to constructors
  116864. * @returns the new constructor or null
  116865. */
  116866. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  116867. /**
  116868. * Gets or sets the name of the node
  116869. */
  116870. name: string;
  116871. /**
  116872. * Gets or sets the id of the node
  116873. */
  116874. id: string;
  116875. /**
  116876. * Gets or sets the unique id of the node
  116877. */
  116878. uniqueId: number;
  116879. /**
  116880. * Gets or sets a string used to store user defined state for the node
  116881. */
  116882. state: string;
  116883. /**
  116884. * Gets or sets an object used to store user defined information for the node
  116885. */
  116886. metadata: any;
  116887. /**
  116888. * For internal use only. Please do not use.
  116889. */
  116890. reservedDataStore: any;
  116891. /**
  116892. * List of inspectable custom properties (used by the Inspector)
  116893. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  116894. */
  116895. inspectableCustomProperties: IInspectable[];
  116896. private _doNotSerialize;
  116897. /**
  116898. * Gets or sets a boolean used to define if the node must be serialized
  116899. */
  116900. get doNotSerialize(): boolean;
  116901. set doNotSerialize(value: boolean);
  116902. /** @hidden */
  116903. _isDisposed: boolean;
  116904. /**
  116905. * Gets a list of Animations associated with the node
  116906. */
  116907. animations: Animation[];
  116908. protected _ranges: {
  116909. [name: string]: Nullable<AnimationRange>;
  116910. };
  116911. /**
  116912. * Callback raised when the node is ready to be used
  116913. */
  116914. onReady: Nullable<(node: Node) => void>;
  116915. private _isEnabled;
  116916. private _isParentEnabled;
  116917. private _isReady;
  116918. /** @hidden */
  116919. _currentRenderId: number;
  116920. private _parentUpdateId;
  116921. /** @hidden */
  116922. _childUpdateId: number;
  116923. /** @hidden */
  116924. _waitingParentId: Nullable<string>;
  116925. /** @hidden */
  116926. _scene: Scene;
  116927. /** @hidden */
  116928. _cache: any;
  116929. private _parentNode;
  116930. private _children;
  116931. /** @hidden */
  116932. _worldMatrix: Matrix;
  116933. /** @hidden */
  116934. _worldMatrixDeterminant: number;
  116935. /** @hidden */
  116936. _worldMatrixDeterminantIsDirty: boolean;
  116937. /** @hidden */
  116938. private _sceneRootNodesIndex;
  116939. /**
  116940. * Gets a boolean indicating if the node has been disposed
  116941. * @returns true if the node was disposed
  116942. */
  116943. isDisposed(): boolean;
  116944. /**
  116945. * Gets or sets the parent of the node (without keeping the current position in the scene)
  116946. * @see https://doc.babylonjs.com/how_to/parenting
  116947. */
  116948. set parent(parent: Nullable<Node>);
  116949. get parent(): Nullable<Node>;
  116950. /** @hidden */
  116951. _addToSceneRootNodes(): void;
  116952. /** @hidden */
  116953. _removeFromSceneRootNodes(): void;
  116954. private _animationPropertiesOverride;
  116955. /**
  116956. * Gets or sets the animation properties override
  116957. */
  116958. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116959. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116960. /**
  116961. * Gets a string identifying the name of the class
  116962. * @returns "Node" string
  116963. */
  116964. getClassName(): string;
  116965. /** @hidden */
  116966. readonly _isNode: boolean;
  116967. /**
  116968. * An event triggered when the mesh is disposed
  116969. */
  116970. onDisposeObservable: Observable<Node>;
  116971. private _onDisposeObserver;
  116972. /**
  116973. * Sets a callback that will be raised when the node will be disposed
  116974. */
  116975. set onDispose(callback: () => void);
  116976. /**
  116977. * Creates a new Node
  116978. * @param name the name and id to be given to this node
  116979. * @param scene the scene this node will be added to
  116980. */
  116981. constructor(name: string, scene?: Nullable<Scene>);
  116982. /**
  116983. * Gets the scene of the node
  116984. * @returns a scene
  116985. */
  116986. getScene(): Scene;
  116987. /**
  116988. * Gets the engine of the node
  116989. * @returns a Engine
  116990. */
  116991. getEngine(): Engine;
  116992. private _behaviors;
  116993. /**
  116994. * Attach a behavior to the node
  116995. * @see https://doc.babylonjs.com/features/behaviour
  116996. * @param behavior defines the behavior to attach
  116997. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  116998. * @returns the current Node
  116999. */
  117000. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117001. /**
  117002. * Remove an attached behavior
  117003. * @see https://doc.babylonjs.com/features/behaviour
  117004. * @param behavior defines the behavior to attach
  117005. * @returns the current Node
  117006. */
  117007. removeBehavior(behavior: Behavior<Node>): Node;
  117008. /**
  117009. * Gets the list of attached behaviors
  117010. * @see https://doc.babylonjs.com/features/behaviour
  117011. */
  117012. get behaviors(): Behavior<Node>[];
  117013. /**
  117014. * Gets an attached behavior by name
  117015. * @param name defines the name of the behavior to look for
  117016. * @see https://doc.babylonjs.com/features/behaviour
  117017. * @returns null if behavior was not found else the requested behavior
  117018. */
  117019. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117020. /**
  117021. * Returns the latest update of the World matrix
  117022. * @returns a Matrix
  117023. */
  117024. getWorldMatrix(): Matrix;
  117025. /** @hidden */
  117026. _getWorldMatrixDeterminant(): number;
  117027. /**
  117028. * Returns directly the latest state of the mesh World matrix.
  117029. * A Matrix is returned.
  117030. */
  117031. get worldMatrixFromCache(): Matrix;
  117032. /** @hidden */
  117033. _initCache(): void;
  117034. /** @hidden */
  117035. updateCache(force?: boolean): void;
  117036. /** @hidden */
  117037. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117038. /** @hidden */
  117039. _updateCache(ignoreParentClass?: boolean): void;
  117040. /** @hidden */
  117041. _isSynchronized(): boolean;
  117042. /** @hidden */
  117043. _markSyncedWithParent(): void;
  117044. /** @hidden */
  117045. isSynchronizedWithParent(): boolean;
  117046. /** @hidden */
  117047. isSynchronized(): boolean;
  117048. /**
  117049. * Is this node ready to be used/rendered
  117050. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117051. * @return true if the node is ready
  117052. */
  117053. isReady(completeCheck?: boolean): boolean;
  117054. /**
  117055. * Is this node enabled?
  117056. * 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
  117057. * @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
  117058. * @return whether this node (and its parent) is enabled
  117059. */
  117060. isEnabled(checkAncestors?: boolean): boolean;
  117061. /** @hidden */
  117062. protected _syncParentEnabledState(): void;
  117063. /**
  117064. * Set the enabled state of this node
  117065. * @param value defines the new enabled state
  117066. */
  117067. setEnabled(value: boolean): void;
  117068. /**
  117069. * Is this node a descendant of the given node?
  117070. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117071. * @param ancestor defines the parent node to inspect
  117072. * @returns a boolean indicating if this node is a descendant of the given node
  117073. */
  117074. isDescendantOf(ancestor: Node): boolean;
  117075. /** @hidden */
  117076. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117077. /**
  117078. * Will return all nodes that have this node as ascendant
  117079. * @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
  117080. * @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
  117081. * @return all children nodes of all types
  117082. */
  117083. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117084. /**
  117085. * Get all child-meshes of this node
  117086. * @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)
  117087. * @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
  117088. * @returns an array of AbstractMesh
  117089. */
  117090. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117091. /**
  117092. * Get all direct children of this node
  117093. * @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
  117094. * @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)
  117095. * @returns an array of Node
  117096. */
  117097. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117098. /** @hidden */
  117099. _setReady(state: boolean): void;
  117100. /**
  117101. * Get an animation by name
  117102. * @param name defines the name of the animation to look for
  117103. * @returns null if not found else the requested animation
  117104. */
  117105. getAnimationByName(name: string): Nullable<Animation>;
  117106. /**
  117107. * Creates an animation range for this node
  117108. * @param name defines the name of the range
  117109. * @param from defines the starting key
  117110. * @param to defines the end key
  117111. */
  117112. createAnimationRange(name: string, from: number, to: number): void;
  117113. /**
  117114. * Delete a specific animation range
  117115. * @param name defines the name of the range to delete
  117116. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117117. */
  117118. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117119. /**
  117120. * Get an animation range by name
  117121. * @param name defines the name of the animation range to look for
  117122. * @returns null if not found else the requested animation range
  117123. */
  117124. getAnimationRange(name: string): Nullable<AnimationRange>;
  117125. /**
  117126. * Gets the list of all animation ranges defined on this node
  117127. * @returns an array
  117128. */
  117129. getAnimationRanges(): Nullable<AnimationRange>[];
  117130. /**
  117131. * Will start the animation sequence
  117132. * @param name defines the range frames for animation sequence
  117133. * @param loop defines if the animation should loop (false by default)
  117134. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117135. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117136. * @returns the object created for this animation. If range does not exist, it will return null
  117137. */
  117138. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117139. /**
  117140. * Serialize animation ranges into a JSON compatible object
  117141. * @returns serialization object
  117142. */
  117143. serializeAnimationRanges(): any;
  117144. /**
  117145. * Computes the world matrix of the node
  117146. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117147. * @returns the world matrix
  117148. */
  117149. computeWorldMatrix(force?: boolean): Matrix;
  117150. /**
  117151. * Releases resources associated with this node.
  117152. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117153. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117154. */
  117155. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117156. /**
  117157. * Parse animation range data from a serialization object and store them into a given node
  117158. * @param node defines where to store the animation ranges
  117159. * @param parsedNode defines the serialization object to read data from
  117160. * @param scene defines the hosting scene
  117161. */
  117162. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117163. /**
  117164. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117165. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117166. * @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
  117167. * @returns the new bounding vectors
  117168. */
  117169. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117170. min: Vector3;
  117171. max: Vector3;
  117172. };
  117173. }
  117174. }
  117175. declare module BABYLON {
  117176. /**
  117177. * @hidden
  117178. */
  117179. export class _IAnimationState {
  117180. key: number;
  117181. repeatCount: number;
  117182. workValue?: any;
  117183. loopMode?: number;
  117184. offsetValue?: any;
  117185. highLimitValue?: any;
  117186. }
  117187. /**
  117188. * Class used to store any kind of animation
  117189. */
  117190. export class Animation {
  117191. /**Name of the animation */
  117192. name: string;
  117193. /**Property to animate */
  117194. targetProperty: string;
  117195. /**The frames per second of the animation */
  117196. framePerSecond: number;
  117197. /**The data type of the animation */
  117198. dataType: number;
  117199. /**The loop mode of the animation */
  117200. loopMode?: number | undefined;
  117201. /**Specifies if blending should be enabled */
  117202. enableBlending?: boolean | undefined;
  117203. /**
  117204. * Use matrix interpolation instead of using direct key value when animating matrices
  117205. */
  117206. static AllowMatricesInterpolation: boolean;
  117207. /**
  117208. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117209. */
  117210. static AllowMatrixDecomposeForInterpolation: boolean;
  117211. /** Define the Url to load snippets */
  117212. static SnippetUrl: string;
  117213. /** Snippet ID if the animation was created from the snippet server */
  117214. snippetId: string;
  117215. /**
  117216. * Stores the key frames of the animation
  117217. */
  117218. private _keys;
  117219. /**
  117220. * Stores the easing function of the animation
  117221. */
  117222. private _easingFunction;
  117223. /**
  117224. * @hidden Internal use only
  117225. */
  117226. _runtimeAnimations: RuntimeAnimation[];
  117227. /**
  117228. * The set of event that will be linked to this animation
  117229. */
  117230. private _events;
  117231. /**
  117232. * Stores an array of target property paths
  117233. */
  117234. targetPropertyPath: string[];
  117235. /**
  117236. * Stores the blending speed of the animation
  117237. */
  117238. blendingSpeed: number;
  117239. /**
  117240. * Stores the animation ranges for the animation
  117241. */
  117242. private _ranges;
  117243. /**
  117244. * @hidden Internal use
  117245. */
  117246. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117247. /**
  117248. * Sets up an animation
  117249. * @param property The property to animate
  117250. * @param animationType The animation type to apply
  117251. * @param framePerSecond The frames per second of the animation
  117252. * @param easingFunction The easing function used in the animation
  117253. * @returns The created animation
  117254. */
  117255. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117256. /**
  117257. * Create and start an animation on a node
  117258. * @param name defines the name of the global animation that will be run on all nodes
  117259. * @param node defines the root node where the animation will take place
  117260. * @param targetProperty defines property to animate
  117261. * @param framePerSecond defines the number of frame per second yo use
  117262. * @param totalFrame defines the number of frames in total
  117263. * @param from defines the initial value
  117264. * @param to defines the final value
  117265. * @param loopMode defines which loop mode you want to use (off by default)
  117266. * @param easingFunction defines the easing function to use (linear by default)
  117267. * @param onAnimationEnd defines the callback to call when animation end
  117268. * @returns the animatable created for this animation
  117269. */
  117270. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117271. /**
  117272. * Create and start an animation on a node and its descendants
  117273. * @param name defines the name of the global animation that will be run on all nodes
  117274. * @param node defines the root node where the animation will take place
  117275. * @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
  117276. * @param targetProperty defines property to animate
  117277. * @param framePerSecond defines the number of frame per second to use
  117278. * @param totalFrame defines the number of frames in total
  117279. * @param from defines the initial value
  117280. * @param to defines the final value
  117281. * @param loopMode defines which loop mode you want to use (off by default)
  117282. * @param easingFunction defines the easing function to use (linear by default)
  117283. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  117284. * @returns the list of animatables created for all nodes
  117285. * @example https://www.babylonjs-playground.com/#MH0VLI
  117286. */
  117287. 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[]>;
  117288. /**
  117289. * Creates a new animation, merges it with the existing animations and starts it
  117290. * @param name Name of the animation
  117291. * @param node Node which contains the scene that begins the animations
  117292. * @param targetProperty Specifies which property to animate
  117293. * @param framePerSecond The frames per second of the animation
  117294. * @param totalFrame The total number of frames
  117295. * @param from The frame at the beginning of the animation
  117296. * @param to The frame at the end of the animation
  117297. * @param loopMode Specifies the loop mode of the animation
  117298. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  117299. * @param onAnimationEnd Callback to run once the animation is complete
  117300. * @returns Nullable animation
  117301. */
  117302. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  117303. /**
  117304. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117305. * @param sourceAnimation defines the Animation containing keyframes to convert
  117306. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117307. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  117308. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  117309. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  117310. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  117311. */
  117312. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  117313. /**
  117314. * Transition property of an host to the target Value
  117315. * @param property The property to transition
  117316. * @param targetValue The target Value of the property
  117317. * @param host The object where the property to animate belongs
  117318. * @param scene Scene used to run the animation
  117319. * @param frameRate Framerate (in frame/s) to use
  117320. * @param transition The transition type we want to use
  117321. * @param duration The duration of the animation, in milliseconds
  117322. * @param onAnimationEnd Callback trigger at the end of the animation
  117323. * @returns Nullable animation
  117324. */
  117325. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  117326. /**
  117327. * Return the array of runtime animations currently using this animation
  117328. */
  117329. get runtimeAnimations(): RuntimeAnimation[];
  117330. /**
  117331. * Specifies if any of the runtime animations are currently running
  117332. */
  117333. get hasRunningRuntimeAnimations(): boolean;
  117334. /**
  117335. * Initializes the animation
  117336. * @param name Name of the animation
  117337. * @param targetProperty Property to animate
  117338. * @param framePerSecond The frames per second of the animation
  117339. * @param dataType The data type of the animation
  117340. * @param loopMode The loop mode of the animation
  117341. * @param enableBlending Specifies if blending should be enabled
  117342. */
  117343. constructor(
  117344. /**Name of the animation */
  117345. name: string,
  117346. /**Property to animate */
  117347. targetProperty: string,
  117348. /**The frames per second of the animation */
  117349. framePerSecond: number,
  117350. /**The data type of the animation */
  117351. dataType: number,
  117352. /**The loop mode of the animation */
  117353. loopMode?: number | undefined,
  117354. /**Specifies if blending should be enabled */
  117355. enableBlending?: boolean | undefined);
  117356. /**
  117357. * Converts the animation to a string
  117358. * @param fullDetails support for multiple levels of logging within scene loading
  117359. * @returns String form of the animation
  117360. */
  117361. toString(fullDetails?: boolean): string;
  117362. /**
  117363. * Add an event to this animation
  117364. * @param event Event to add
  117365. */
  117366. addEvent(event: AnimationEvent): void;
  117367. /**
  117368. * Remove all events found at the given frame
  117369. * @param frame The frame to remove events from
  117370. */
  117371. removeEvents(frame: number): void;
  117372. /**
  117373. * Retrieves all the events from the animation
  117374. * @returns Events from the animation
  117375. */
  117376. getEvents(): AnimationEvent[];
  117377. /**
  117378. * Creates an animation range
  117379. * @param name Name of the animation range
  117380. * @param from Starting frame of the animation range
  117381. * @param to Ending frame of the animation
  117382. */
  117383. createRange(name: string, from: number, to: number): void;
  117384. /**
  117385. * Deletes an animation range by name
  117386. * @param name Name of the animation range to delete
  117387. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  117388. */
  117389. deleteRange(name: string, deleteFrames?: boolean): void;
  117390. /**
  117391. * Gets the animation range by name, or null if not defined
  117392. * @param name Name of the animation range
  117393. * @returns Nullable animation range
  117394. */
  117395. getRange(name: string): Nullable<AnimationRange>;
  117396. /**
  117397. * Gets the key frames from the animation
  117398. * @returns The key frames of the animation
  117399. */
  117400. getKeys(): Array<IAnimationKey>;
  117401. /**
  117402. * Gets the highest frame rate of the animation
  117403. * @returns Highest frame rate of the animation
  117404. */
  117405. getHighestFrame(): number;
  117406. /**
  117407. * Gets the easing function of the animation
  117408. * @returns Easing function of the animation
  117409. */
  117410. getEasingFunction(): IEasingFunction;
  117411. /**
  117412. * Sets the easing function of the animation
  117413. * @param easingFunction A custom mathematical formula for animation
  117414. */
  117415. setEasingFunction(easingFunction: EasingFunction): void;
  117416. /**
  117417. * Interpolates a scalar linearly
  117418. * @param startValue Start value of the animation curve
  117419. * @param endValue End value of the animation curve
  117420. * @param gradient Scalar amount to interpolate
  117421. * @returns Interpolated scalar value
  117422. */
  117423. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  117424. /**
  117425. * Interpolates a scalar cubically
  117426. * @param startValue Start value of the animation curve
  117427. * @param outTangent End tangent of the animation
  117428. * @param endValue End value of the animation curve
  117429. * @param inTangent Start tangent of the animation curve
  117430. * @param gradient Scalar amount to interpolate
  117431. * @returns Interpolated scalar value
  117432. */
  117433. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  117434. /**
  117435. * Interpolates a quaternion using a spherical linear interpolation
  117436. * @param startValue Start value of the animation curve
  117437. * @param endValue End value of the animation curve
  117438. * @param gradient Scalar amount to interpolate
  117439. * @returns Interpolated quaternion value
  117440. */
  117441. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  117442. /**
  117443. * Interpolates a quaternion cubically
  117444. * @param startValue Start value of the animation curve
  117445. * @param outTangent End tangent of the animation curve
  117446. * @param endValue End value of the animation curve
  117447. * @param inTangent Start tangent of the animation curve
  117448. * @param gradient Scalar amount to interpolate
  117449. * @returns Interpolated quaternion value
  117450. */
  117451. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  117452. /**
  117453. * Interpolates a Vector3 linearl
  117454. * @param startValue Start value of the animation curve
  117455. * @param endValue End value of the animation curve
  117456. * @param gradient Scalar amount to interpolate
  117457. * @returns Interpolated scalar value
  117458. */
  117459. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  117460. /**
  117461. * Interpolates a Vector3 cubically
  117462. * @param startValue Start value of the animation curve
  117463. * @param outTangent End tangent of the animation
  117464. * @param endValue End value of the animation curve
  117465. * @param inTangent Start tangent of the animation curve
  117466. * @param gradient Scalar amount to interpolate
  117467. * @returns InterpolatedVector3 value
  117468. */
  117469. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  117470. /**
  117471. * Interpolates a Vector2 linearly
  117472. * @param startValue Start value of the animation curve
  117473. * @param endValue End value of the animation curve
  117474. * @param gradient Scalar amount to interpolate
  117475. * @returns Interpolated Vector2 value
  117476. */
  117477. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  117478. /**
  117479. * Interpolates a Vector2 cubically
  117480. * @param startValue Start value of the animation curve
  117481. * @param outTangent End tangent of the animation
  117482. * @param endValue End value of the animation curve
  117483. * @param inTangent Start tangent of the animation curve
  117484. * @param gradient Scalar amount to interpolate
  117485. * @returns Interpolated Vector2 value
  117486. */
  117487. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  117488. /**
  117489. * Interpolates a size linearly
  117490. * @param startValue Start value of the animation curve
  117491. * @param endValue End value of the animation curve
  117492. * @param gradient Scalar amount to interpolate
  117493. * @returns Interpolated Size value
  117494. */
  117495. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  117496. /**
  117497. * Interpolates a Color3 linearly
  117498. * @param startValue Start value of the animation curve
  117499. * @param endValue End value of the animation curve
  117500. * @param gradient Scalar amount to interpolate
  117501. * @returns Interpolated Color3 value
  117502. */
  117503. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  117504. /**
  117505. * Interpolates a Color4 linearly
  117506. * @param startValue Start value of the animation curve
  117507. * @param endValue End value of the animation curve
  117508. * @param gradient Scalar amount to interpolate
  117509. * @returns Interpolated Color3 value
  117510. */
  117511. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  117512. /**
  117513. * @hidden Internal use only
  117514. */
  117515. _getKeyValue(value: any): any;
  117516. /**
  117517. * @hidden Internal use only
  117518. */
  117519. _interpolate(currentFrame: number, state: _IAnimationState): any;
  117520. /**
  117521. * Defines the function to use to interpolate matrices
  117522. * @param startValue defines the start matrix
  117523. * @param endValue defines the end matrix
  117524. * @param gradient defines the gradient between both matrices
  117525. * @param result defines an optional target matrix where to store the interpolation
  117526. * @returns the interpolated matrix
  117527. */
  117528. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  117529. /**
  117530. * Makes a copy of the animation
  117531. * @returns Cloned animation
  117532. */
  117533. clone(): Animation;
  117534. /**
  117535. * Sets the key frames of the animation
  117536. * @param values The animation key frames to set
  117537. */
  117538. setKeys(values: Array<IAnimationKey>): void;
  117539. /**
  117540. * Serializes the animation to an object
  117541. * @returns Serialized object
  117542. */
  117543. serialize(): any;
  117544. /**
  117545. * Float animation type
  117546. */
  117547. static readonly ANIMATIONTYPE_FLOAT: number;
  117548. /**
  117549. * Vector3 animation type
  117550. */
  117551. static readonly ANIMATIONTYPE_VECTOR3: number;
  117552. /**
  117553. * Quaternion animation type
  117554. */
  117555. static readonly ANIMATIONTYPE_QUATERNION: number;
  117556. /**
  117557. * Matrix animation type
  117558. */
  117559. static readonly ANIMATIONTYPE_MATRIX: number;
  117560. /**
  117561. * Color3 animation type
  117562. */
  117563. static readonly ANIMATIONTYPE_COLOR3: number;
  117564. /**
  117565. * Color3 animation type
  117566. */
  117567. static readonly ANIMATIONTYPE_COLOR4: number;
  117568. /**
  117569. * Vector2 animation type
  117570. */
  117571. static readonly ANIMATIONTYPE_VECTOR2: number;
  117572. /**
  117573. * Size animation type
  117574. */
  117575. static readonly ANIMATIONTYPE_SIZE: number;
  117576. /**
  117577. * Relative Loop Mode
  117578. */
  117579. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  117580. /**
  117581. * Cycle Loop Mode
  117582. */
  117583. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  117584. /**
  117585. * Constant Loop Mode
  117586. */
  117587. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  117588. /** @hidden */
  117589. static _UniversalLerp(left: any, right: any, amount: number): any;
  117590. /**
  117591. * Parses an animation object and creates an animation
  117592. * @param parsedAnimation Parsed animation object
  117593. * @returns Animation object
  117594. */
  117595. static Parse(parsedAnimation: any): Animation;
  117596. /**
  117597. * Appends the serialized animations from the source animations
  117598. * @param source Source containing the animations
  117599. * @param destination Target to store the animations
  117600. */
  117601. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117602. /**
  117603. * Creates a new animation or an array of animations from a snippet saved in a remote file
  117604. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  117605. * @param url defines the url to load from
  117606. * @returns a promise that will resolve to the new animation or an array of animations
  117607. */
  117608. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  117609. /**
  117610. * Creates an animation or an array of animations from a snippet saved by the Inspector
  117611. * @param snippetId defines the snippet to load
  117612. * @returns a promise that will resolve to the new animation or a new array of animations
  117613. */
  117614. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  117615. }
  117616. }
  117617. declare module BABYLON {
  117618. /**
  117619. * Interface containing an array of animations
  117620. */
  117621. export interface IAnimatable {
  117622. /**
  117623. * Array of animations
  117624. */
  117625. animations: Nullable<Array<Animation>>;
  117626. }
  117627. }
  117628. declare module BABYLON {
  117629. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  117630. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117631. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117632. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117633. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117634. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117635. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117636. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117637. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117638. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117639. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117640. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117641. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117642. /**
  117643. * Decorator used to define property that can be serialized as reference to a camera
  117644. * @param sourceName defines the name of the property to decorate
  117645. */
  117646. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  117647. /**
  117648. * Class used to help serialization objects
  117649. */
  117650. export class SerializationHelper {
  117651. /** @hidden */
  117652. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  117653. /** @hidden */
  117654. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  117655. /** @hidden */
  117656. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  117657. /** @hidden */
  117658. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  117659. /**
  117660. * Appends the serialized animations from the source animations
  117661. * @param source Source containing the animations
  117662. * @param destination Target to store the animations
  117663. */
  117664. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  117665. /**
  117666. * Static function used to serialized a specific entity
  117667. * @param entity defines the entity to serialize
  117668. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  117669. * @returns a JSON compatible object representing the serialization of the entity
  117670. */
  117671. static Serialize<T>(entity: T, serializationObject?: any): any;
  117672. /**
  117673. * Creates a new entity from a serialization data object
  117674. * @param creationFunction defines a function used to instanciated the new entity
  117675. * @param source defines the source serialization data
  117676. * @param scene defines the hosting scene
  117677. * @param rootUrl defines the root url for resources
  117678. * @returns a new entity
  117679. */
  117680. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  117681. /**
  117682. * Clones an object
  117683. * @param creationFunction defines the function used to instanciate the new object
  117684. * @param source defines the source object
  117685. * @returns the cloned object
  117686. */
  117687. static Clone<T>(creationFunction: () => T, source: T): T;
  117688. /**
  117689. * Instanciates a new object based on a source one (some data will be shared between both object)
  117690. * @param creationFunction defines the function used to instanciate the new object
  117691. * @param source defines the source object
  117692. * @returns the new object
  117693. */
  117694. static Instanciate<T>(creationFunction: () => T, source: T): T;
  117695. }
  117696. }
  117697. declare module BABYLON {
  117698. /**
  117699. * Base class of all the textures in babylon.
  117700. * It groups all the common properties the materials, post process, lights... might need
  117701. * in order to make a correct use of the texture.
  117702. */
  117703. export class BaseTexture implements IAnimatable {
  117704. /**
  117705. * Default anisotropic filtering level for the application.
  117706. * It is set to 4 as a good tradeoff between perf and quality.
  117707. */
  117708. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  117709. /**
  117710. * Gets or sets the unique id of the texture
  117711. */
  117712. uniqueId: number;
  117713. /**
  117714. * Define the name of the texture.
  117715. */
  117716. name: string;
  117717. /**
  117718. * Gets or sets an object used to store user defined information.
  117719. */
  117720. metadata: any;
  117721. /**
  117722. * For internal use only. Please do not use.
  117723. */
  117724. reservedDataStore: any;
  117725. private _hasAlpha;
  117726. /**
  117727. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  117728. */
  117729. set hasAlpha(value: boolean);
  117730. get hasAlpha(): boolean;
  117731. /**
  117732. * Defines if the alpha value should be determined via the rgb values.
  117733. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  117734. */
  117735. getAlphaFromRGB: boolean;
  117736. /**
  117737. * Intensity or strength of the texture.
  117738. * It is commonly used by materials to fine tune the intensity of the texture
  117739. */
  117740. level: number;
  117741. /**
  117742. * Define the UV chanel to use starting from 0 and defaulting to 0.
  117743. * This is part of the texture as textures usually maps to one uv set.
  117744. */
  117745. coordinatesIndex: number;
  117746. protected _coordinatesMode: number;
  117747. /**
  117748. * How a texture is mapped.
  117749. *
  117750. * | Value | Type | Description |
  117751. * | ----- | ----------------------------------- | ----------- |
  117752. * | 0 | EXPLICIT_MODE | |
  117753. * | 1 | SPHERICAL_MODE | |
  117754. * | 2 | PLANAR_MODE | |
  117755. * | 3 | CUBIC_MODE | |
  117756. * | 4 | PROJECTION_MODE | |
  117757. * | 5 | SKYBOX_MODE | |
  117758. * | 6 | INVCUBIC_MODE | |
  117759. * | 7 | EQUIRECTANGULAR_MODE | |
  117760. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  117761. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  117762. */
  117763. set coordinatesMode(value: number);
  117764. get coordinatesMode(): number;
  117765. private _wrapU;
  117766. /**
  117767. * | Value | Type | Description |
  117768. * | ----- | ------------------ | ----------- |
  117769. * | 0 | CLAMP_ADDRESSMODE | |
  117770. * | 1 | WRAP_ADDRESSMODE | |
  117771. * | 2 | MIRROR_ADDRESSMODE | |
  117772. */
  117773. get wrapU(): number;
  117774. set wrapU(value: number);
  117775. private _wrapV;
  117776. /**
  117777. * | Value | Type | Description |
  117778. * | ----- | ------------------ | ----------- |
  117779. * | 0 | CLAMP_ADDRESSMODE | |
  117780. * | 1 | WRAP_ADDRESSMODE | |
  117781. * | 2 | MIRROR_ADDRESSMODE | |
  117782. */
  117783. get wrapV(): number;
  117784. set wrapV(value: number);
  117785. /**
  117786. * | Value | Type | Description |
  117787. * | ----- | ------------------ | ----------- |
  117788. * | 0 | CLAMP_ADDRESSMODE | |
  117789. * | 1 | WRAP_ADDRESSMODE | |
  117790. * | 2 | MIRROR_ADDRESSMODE | |
  117791. */
  117792. wrapR: number;
  117793. /**
  117794. * With compliant hardware and browser (supporting anisotropic filtering)
  117795. * this defines the level of anisotropic filtering in the texture.
  117796. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  117797. */
  117798. anisotropicFilteringLevel: number;
  117799. /**
  117800. * Define if the texture is a cube texture or if false a 2d texture.
  117801. */
  117802. get isCube(): boolean;
  117803. set isCube(value: boolean);
  117804. /**
  117805. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  117806. */
  117807. get is3D(): boolean;
  117808. set is3D(value: boolean);
  117809. /**
  117810. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  117811. */
  117812. get is2DArray(): boolean;
  117813. set is2DArray(value: boolean);
  117814. private _gammaSpace;
  117815. /**
  117816. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  117817. * HDR texture are usually stored in linear space.
  117818. * This only impacts the PBR and Background materials
  117819. */
  117820. get gammaSpace(): boolean;
  117821. set gammaSpace(gamma: boolean);
  117822. /**
  117823. * Gets or sets whether or not the texture contains RGBD data.
  117824. */
  117825. get isRGBD(): boolean;
  117826. set isRGBD(value: boolean);
  117827. /**
  117828. * Is Z inverted in the texture (useful in a cube texture).
  117829. */
  117830. invertZ: boolean;
  117831. /**
  117832. * Are mip maps generated for this texture or not.
  117833. */
  117834. get noMipmap(): boolean;
  117835. /**
  117836. * @hidden
  117837. */
  117838. lodLevelInAlpha: boolean;
  117839. /**
  117840. * With prefiltered texture, defined the offset used during the prefiltering steps.
  117841. */
  117842. get lodGenerationOffset(): number;
  117843. set lodGenerationOffset(value: number);
  117844. /**
  117845. * With prefiltered texture, defined the scale used during the prefiltering steps.
  117846. */
  117847. get lodGenerationScale(): number;
  117848. set lodGenerationScale(value: number);
  117849. /**
  117850. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  117851. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  117852. * average roughness values.
  117853. */
  117854. get linearSpecularLOD(): boolean;
  117855. set linearSpecularLOD(value: boolean);
  117856. /**
  117857. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  117858. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  117859. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  117860. */
  117861. get irradianceTexture(): Nullable<BaseTexture>;
  117862. set irradianceTexture(value: Nullable<BaseTexture>);
  117863. /**
  117864. * Define if the texture is a render target.
  117865. */
  117866. isRenderTarget: boolean;
  117867. /**
  117868. * Define the unique id of the texture in the scene.
  117869. */
  117870. get uid(): string;
  117871. /** @hidden */
  117872. _prefiltered: boolean;
  117873. /**
  117874. * Return a string representation of the texture.
  117875. * @returns the texture as a string
  117876. */
  117877. toString(): string;
  117878. /**
  117879. * Get the class name of the texture.
  117880. * @returns "BaseTexture"
  117881. */
  117882. getClassName(): string;
  117883. /**
  117884. * Define the list of animation attached to the texture.
  117885. */
  117886. animations: Animation[];
  117887. /**
  117888. * An event triggered when the texture is disposed.
  117889. */
  117890. onDisposeObservable: Observable<BaseTexture>;
  117891. private _onDisposeObserver;
  117892. /**
  117893. * Callback triggered when the texture has been disposed.
  117894. * Kept for back compatibility, you can use the onDisposeObservable instead.
  117895. */
  117896. set onDispose(callback: () => void);
  117897. /**
  117898. * Define the current state of the loading sequence when in delayed load mode.
  117899. */
  117900. delayLoadState: number;
  117901. protected _scene: Nullable<Scene>;
  117902. protected _engine: Nullable<ThinEngine>;
  117903. /** @hidden */
  117904. _texture: Nullable<InternalTexture>;
  117905. private _uid;
  117906. /**
  117907. * Define if the texture is preventinga material to render or not.
  117908. * If not and the texture is not ready, the engine will use a default black texture instead.
  117909. */
  117910. get isBlocking(): boolean;
  117911. /**
  117912. * Instantiates a new BaseTexture.
  117913. * Base class of all the textures in babylon.
  117914. * It groups all the common properties the materials, post process, lights... might need
  117915. * in order to make a correct use of the texture.
  117916. * @param sceneOrEngine Define the scene or engine the texture blongs to
  117917. */
  117918. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  117919. /**
  117920. * Get the scene the texture belongs to.
  117921. * @returns the scene or null if undefined
  117922. */
  117923. getScene(): Nullable<Scene>;
  117924. /** @hidden */
  117925. protected _getEngine(): Nullable<ThinEngine>;
  117926. /**
  117927. * Checks if the texture has the same transform matrix than another texture
  117928. * @param texture texture to check against
  117929. * @returns true if the transforms are the same, else false
  117930. */
  117931. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  117932. /**
  117933. * Get the texture transform matrix used to offset tile the texture for istance.
  117934. * @returns the transformation matrix
  117935. */
  117936. getTextureMatrix(): Matrix;
  117937. /**
  117938. * Get the texture reflection matrix used to rotate/transform the reflection.
  117939. * @returns the reflection matrix
  117940. */
  117941. getReflectionTextureMatrix(): Matrix;
  117942. /**
  117943. * Get the underlying lower level texture from Babylon.
  117944. * @returns the insternal texture
  117945. */
  117946. getInternalTexture(): Nullable<InternalTexture>;
  117947. /**
  117948. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  117949. * @returns true if ready or not blocking
  117950. */
  117951. isReadyOrNotBlocking(): boolean;
  117952. /**
  117953. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  117954. * @returns true if fully ready
  117955. */
  117956. isReady(): boolean;
  117957. private _cachedSize;
  117958. /**
  117959. * Get the size of the texture.
  117960. * @returns the texture size.
  117961. */
  117962. getSize(): ISize;
  117963. /**
  117964. * Get the base size of the texture.
  117965. * It can be different from the size if the texture has been resized for POT for instance
  117966. * @returns the base size
  117967. */
  117968. getBaseSize(): ISize;
  117969. /**
  117970. * Update the sampling mode of the texture.
  117971. * Default is Trilinear mode.
  117972. *
  117973. * | Value | Type | Description |
  117974. * | ----- | ------------------ | ----------- |
  117975. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  117976. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  117977. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  117978. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  117979. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  117980. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  117981. * | 7 | NEAREST_LINEAR | |
  117982. * | 8 | NEAREST_NEAREST | |
  117983. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  117984. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  117985. * | 11 | LINEAR_LINEAR | |
  117986. * | 12 | LINEAR_NEAREST | |
  117987. *
  117988. * > _mag_: magnification filter (close to the viewer)
  117989. * > _min_: minification filter (far from the viewer)
  117990. * > _mip_: filter used between mip map levels
  117991. *@param samplingMode Define the new sampling mode of the texture
  117992. */
  117993. updateSamplingMode(samplingMode: number): void;
  117994. /**
  117995. * Scales the texture if is `canRescale()`
  117996. * @param ratio the resize factor we want to use to rescale
  117997. */
  117998. scale(ratio: number): void;
  117999. /**
  118000. * Get if the texture can rescale.
  118001. */
  118002. get canRescale(): boolean;
  118003. /** @hidden */
  118004. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  118005. /** @hidden */
  118006. _rebuild(): void;
  118007. /**
  118008. * Triggers the load sequence in delayed load mode.
  118009. */
  118010. delayLoad(): void;
  118011. /**
  118012. * Clones the texture.
  118013. * @returns the cloned texture
  118014. */
  118015. clone(): Nullable<BaseTexture>;
  118016. /**
  118017. * Get the texture underlying type (INT, FLOAT...)
  118018. */
  118019. get textureType(): number;
  118020. /**
  118021. * Get the texture underlying format (RGB, RGBA...)
  118022. */
  118023. get textureFormat(): number;
  118024. /**
  118025. * Indicates that textures need to be re-calculated for all materials
  118026. */
  118027. protected _markAllSubMeshesAsTexturesDirty(): void;
  118028. /**
  118029. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  118030. * This will returns an RGBA array buffer containing either in values (0-255) or
  118031. * float values (0-1) depending of the underlying buffer type.
  118032. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  118033. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  118034. * @param buffer defines a user defined buffer to fill with data (can be null)
  118035. * @returns The Array buffer containing the pixels data.
  118036. */
  118037. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  118038. /**
  118039. * Release and destroy the underlying lower level texture aka internalTexture.
  118040. */
  118041. releaseInternalTexture(): void;
  118042. /** @hidden */
  118043. get _lodTextureHigh(): Nullable<BaseTexture>;
  118044. /** @hidden */
  118045. get _lodTextureMid(): Nullable<BaseTexture>;
  118046. /** @hidden */
  118047. get _lodTextureLow(): Nullable<BaseTexture>;
  118048. /**
  118049. * Dispose the texture and release its associated resources.
  118050. */
  118051. dispose(): void;
  118052. /**
  118053. * Serialize the texture into a JSON representation that can be parsed later on.
  118054. * @returns the JSON representation of the texture
  118055. */
  118056. serialize(): any;
  118057. /**
  118058. * Helper function to be called back once a list of texture contains only ready textures.
  118059. * @param textures Define the list of textures to wait for
  118060. * @param callback Define the callback triggered once the entire list will be ready
  118061. */
  118062. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  118063. private static _isScene;
  118064. }
  118065. }
  118066. declare module BABYLON {
  118067. /**
  118068. * Options to be used when creating an effect.
  118069. */
  118070. export interface IEffectCreationOptions {
  118071. /**
  118072. * Atrributes that will be used in the shader.
  118073. */
  118074. attributes: string[];
  118075. /**
  118076. * Uniform varible names that will be set in the shader.
  118077. */
  118078. uniformsNames: string[];
  118079. /**
  118080. * Uniform buffer variable names that will be set in the shader.
  118081. */
  118082. uniformBuffersNames: string[];
  118083. /**
  118084. * Sampler texture variable names that will be set in the shader.
  118085. */
  118086. samplers: string[];
  118087. /**
  118088. * Define statements that will be set in the shader.
  118089. */
  118090. defines: any;
  118091. /**
  118092. * Possible fallbacks for this effect to improve performance when needed.
  118093. */
  118094. fallbacks: Nullable<IEffectFallbacks>;
  118095. /**
  118096. * Callback that will be called when the shader is compiled.
  118097. */
  118098. onCompiled: Nullable<(effect: Effect) => void>;
  118099. /**
  118100. * Callback that will be called if an error occurs during shader compilation.
  118101. */
  118102. onError: Nullable<(effect: Effect, errors: string) => void>;
  118103. /**
  118104. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118105. */
  118106. indexParameters?: any;
  118107. /**
  118108. * Max number of lights that can be used in the shader.
  118109. */
  118110. maxSimultaneousLights?: number;
  118111. /**
  118112. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  118113. */
  118114. transformFeedbackVaryings?: Nullable<string[]>;
  118115. /**
  118116. * 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
  118117. */
  118118. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  118119. /**
  118120. * Is this effect rendering to several color attachments ?
  118121. */
  118122. multiTarget?: boolean;
  118123. }
  118124. /**
  118125. * Effect containing vertex and fragment shader that can be executed on an object.
  118126. */
  118127. export class Effect implements IDisposable {
  118128. /**
  118129. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  118130. */
  118131. static ShadersRepository: string;
  118132. /**
  118133. * Enable logging of the shader code when a compilation error occurs
  118134. */
  118135. static LogShaderCodeOnCompilationError: boolean;
  118136. /**
  118137. * Name of the effect.
  118138. */
  118139. name: any;
  118140. /**
  118141. * String container all the define statements that should be set on the shader.
  118142. */
  118143. defines: string;
  118144. /**
  118145. * Callback that will be called when the shader is compiled.
  118146. */
  118147. onCompiled: Nullable<(effect: Effect) => void>;
  118148. /**
  118149. * Callback that will be called if an error occurs during shader compilation.
  118150. */
  118151. onError: Nullable<(effect: Effect, errors: string) => void>;
  118152. /**
  118153. * Callback that will be called when effect is bound.
  118154. */
  118155. onBind: Nullable<(effect: Effect) => void>;
  118156. /**
  118157. * Unique ID of the effect.
  118158. */
  118159. uniqueId: number;
  118160. /**
  118161. * Observable that will be called when the shader is compiled.
  118162. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118163. */
  118164. onCompileObservable: Observable<Effect>;
  118165. /**
  118166. * Observable that will be called if an error occurs during shader compilation.
  118167. */
  118168. onErrorObservable: Observable<Effect>;
  118169. /** @hidden */
  118170. _onBindObservable: Nullable<Observable<Effect>>;
  118171. /**
  118172. * @hidden
  118173. * Specifies if the effect was previously ready
  118174. */
  118175. _wasPreviouslyReady: boolean;
  118176. /**
  118177. * Observable that will be called when effect is bound.
  118178. */
  118179. get onBindObservable(): Observable<Effect>;
  118180. /** @hidden */
  118181. _bonesComputationForcedToCPU: boolean;
  118182. /** @hidden */
  118183. _multiTarget: boolean;
  118184. private static _uniqueIdSeed;
  118185. private _engine;
  118186. private _uniformBuffersNames;
  118187. private _uniformBuffersNamesList;
  118188. private _uniformsNames;
  118189. private _samplerList;
  118190. private _samplers;
  118191. private _isReady;
  118192. private _compilationError;
  118193. private _allFallbacksProcessed;
  118194. private _attributesNames;
  118195. private _attributes;
  118196. private _attributeLocationByName;
  118197. private _uniforms;
  118198. /**
  118199. * Key for the effect.
  118200. * @hidden
  118201. */
  118202. _key: string;
  118203. private _indexParameters;
  118204. private _fallbacks;
  118205. private _vertexSourceCode;
  118206. private _fragmentSourceCode;
  118207. private _vertexSourceCodeOverride;
  118208. private _fragmentSourceCodeOverride;
  118209. private _transformFeedbackVaryings;
  118210. /**
  118211. * Compiled shader to webGL program.
  118212. * @hidden
  118213. */
  118214. _pipelineContext: Nullable<IPipelineContext>;
  118215. private _valueCache;
  118216. private static _baseCache;
  118217. /**
  118218. * Instantiates an effect.
  118219. * An effect can be used to create/manage/execute vertex and fragment shaders.
  118220. * @param baseName Name of the effect.
  118221. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  118222. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  118223. * @param samplers List of sampler variables that will be passed to the shader.
  118224. * @param engine Engine to be used to render the effect
  118225. * @param defines Define statements to be added to the shader.
  118226. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  118227. * @param onCompiled Callback that will be called when the shader is compiled.
  118228. * @param onError Callback that will be called if an error occurs during shader compilation.
  118229. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118230. */
  118231. 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);
  118232. private _useFinalCode;
  118233. /**
  118234. * Unique key for this effect
  118235. */
  118236. get key(): string;
  118237. /**
  118238. * If the effect has been compiled and prepared.
  118239. * @returns if the effect is compiled and prepared.
  118240. */
  118241. isReady(): boolean;
  118242. private _isReadyInternal;
  118243. /**
  118244. * The engine the effect was initialized with.
  118245. * @returns the engine.
  118246. */
  118247. getEngine(): Engine;
  118248. /**
  118249. * The pipeline context for this effect
  118250. * @returns the associated pipeline context
  118251. */
  118252. getPipelineContext(): Nullable<IPipelineContext>;
  118253. /**
  118254. * The set of names of attribute variables for the shader.
  118255. * @returns An array of attribute names.
  118256. */
  118257. getAttributesNames(): string[];
  118258. /**
  118259. * Returns the attribute at the given index.
  118260. * @param index The index of the attribute.
  118261. * @returns The location of the attribute.
  118262. */
  118263. getAttributeLocation(index: number): number;
  118264. /**
  118265. * Returns the attribute based on the name of the variable.
  118266. * @param name of the attribute to look up.
  118267. * @returns the attribute location.
  118268. */
  118269. getAttributeLocationByName(name: string): number;
  118270. /**
  118271. * The number of attributes.
  118272. * @returns the numnber of attributes.
  118273. */
  118274. getAttributesCount(): number;
  118275. /**
  118276. * Gets the index of a uniform variable.
  118277. * @param uniformName of the uniform to look up.
  118278. * @returns the index.
  118279. */
  118280. getUniformIndex(uniformName: string): number;
  118281. /**
  118282. * Returns the attribute based on the name of the variable.
  118283. * @param uniformName of the uniform to look up.
  118284. * @returns the location of the uniform.
  118285. */
  118286. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  118287. /**
  118288. * Returns an array of sampler variable names
  118289. * @returns The array of sampler variable names.
  118290. */
  118291. getSamplers(): string[];
  118292. /**
  118293. * Returns an array of uniform variable names
  118294. * @returns The array of uniform variable names.
  118295. */
  118296. getUniformNames(): string[];
  118297. /**
  118298. * Returns an array of uniform buffer variable names
  118299. * @returns The array of uniform buffer variable names.
  118300. */
  118301. getUniformBuffersNames(): string[];
  118302. /**
  118303. * Returns the index parameters used to create the effect
  118304. * @returns The index parameters object
  118305. */
  118306. getIndexParameters(): any;
  118307. /**
  118308. * The error from the last compilation.
  118309. * @returns the error string.
  118310. */
  118311. getCompilationError(): string;
  118312. /**
  118313. * Gets a boolean indicating that all fallbacks were used during compilation
  118314. * @returns true if all fallbacks were used
  118315. */
  118316. allFallbacksProcessed(): boolean;
  118317. /**
  118318. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  118319. * @param func The callback to be used.
  118320. */
  118321. executeWhenCompiled(func: (effect: Effect) => void): void;
  118322. private _checkIsReady;
  118323. private _loadShader;
  118324. /**
  118325. * Gets the vertex shader source code of this effect
  118326. */
  118327. get vertexSourceCode(): string;
  118328. /**
  118329. * Gets the fragment shader source code of this effect
  118330. */
  118331. get fragmentSourceCode(): string;
  118332. /**
  118333. * Recompiles the webGL program
  118334. * @param vertexSourceCode The source code for the vertex shader.
  118335. * @param fragmentSourceCode The source code for the fragment shader.
  118336. * @param onCompiled Callback called when completed.
  118337. * @param onError Callback called on error.
  118338. * @hidden
  118339. */
  118340. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  118341. /**
  118342. * Prepares the effect
  118343. * @hidden
  118344. */
  118345. _prepareEffect(): void;
  118346. private _getShaderCodeAndErrorLine;
  118347. private _processCompilationErrors;
  118348. /**
  118349. * Checks if the effect is supported. (Must be called after compilation)
  118350. */
  118351. get isSupported(): boolean;
  118352. /**
  118353. * Binds a texture to the engine to be used as output of the shader.
  118354. * @param channel Name of the output variable.
  118355. * @param texture Texture to bind.
  118356. * @hidden
  118357. */
  118358. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  118359. /**
  118360. * Sets a texture on the engine to be used in the shader.
  118361. * @param channel Name of the sampler variable.
  118362. * @param texture Texture to set.
  118363. */
  118364. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  118365. /**
  118366. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  118367. * @param channel Name of the sampler variable.
  118368. * @param texture Texture to set.
  118369. */
  118370. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  118371. /**
  118372. * Sets an array of textures on the engine to be used in the shader.
  118373. * @param channel Name of the variable.
  118374. * @param textures Textures to set.
  118375. */
  118376. setTextureArray(channel: string, textures: BaseTexture[]): void;
  118377. /**
  118378. * 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)
  118379. * @param channel Name of the sampler variable.
  118380. * @param postProcess Post process to get the input texture from.
  118381. */
  118382. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  118383. /**
  118384. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  118385. * 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)
  118386. * @param channel Name of the sampler variable.
  118387. * @param postProcess Post process to get the output texture from.
  118388. */
  118389. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  118390. /** @hidden */
  118391. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  118392. /** @hidden */
  118393. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  118394. /** @hidden */
  118395. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  118396. /** @hidden */
  118397. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  118398. /**
  118399. * Binds a buffer to a uniform.
  118400. * @param buffer Buffer to bind.
  118401. * @param name Name of the uniform variable to bind to.
  118402. */
  118403. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  118404. /**
  118405. * Binds block to a uniform.
  118406. * @param blockName Name of the block to bind.
  118407. * @param index Index to bind.
  118408. */
  118409. bindUniformBlock(blockName: string, index: number): void;
  118410. /**
  118411. * Sets an interger value on a uniform variable.
  118412. * @param uniformName Name of the variable.
  118413. * @param value Value to be set.
  118414. * @returns this effect.
  118415. */
  118416. setInt(uniformName: string, value: number): Effect;
  118417. /**
  118418. * Sets an int array on a uniform variable.
  118419. * @param uniformName Name of the variable.
  118420. * @param array array to be set.
  118421. * @returns this effect.
  118422. */
  118423. setIntArray(uniformName: string, array: Int32Array): Effect;
  118424. /**
  118425. * 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)
  118426. * @param uniformName Name of the variable.
  118427. * @param array array to be set.
  118428. * @returns this effect.
  118429. */
  118430. setIntArray2(uniformName: string, array: Int32Array): Effect;
  118431. /**
  118432. * 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)
  118433. * @param uniformName Name of the variable.
  118434. * @param array array to be set.
  118435. * @returns this effect.
  118436. */
  118437. setIntArray3(uniformName: string, array: Int32Array): Effect;
  118438. /**
  118439. * 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)
  118440. * @param uniformName Name of the variable.
  118441. * @param array array to be set.
  118442. * @returns this effect.
  118443. */
  118444. setIntArray4(uniformName: string, array: Int32Array): Effect;
  118445. /**
  118446. * Sets an float array on a uniform variable.
  118447. * @param uniformName Name of the variable.
  118448. * @param array array to be set.
  118449. * @returns this effect.
  118450. */
  118451. setFloatArray(uniformName: string, array: Float32Array): Effect;
  118452. /**
  118453. * 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)
  118454. * @param uniformName Name of the variable.
  118455. * @param array array to be set.
  118456. * @returns this effect.
  118457. */
  118458. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  118459. /**
  118460. * 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)
  118461. * @param uniformName Name of the variable.
  118462. * @param array array to be set.
  118463. * @returns this effect.
  118464. */
  118465. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  118466. /**
  118467. * 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)
  118468. * @param uniformName Name of the variable.
  118469. * @param array array to be set.
  118470. * @returns this effect.
  118471. */
  118472. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  118473. /**
  118474. * Sets an array on a uniform variable.
  118475. * @param uniformName Name of the variable.
  118476. * @param array array to be set.
  118477. * @returns this effect.
  118478. */
  118479. setArray(uniformName: string, array: number[]): Effect;
  118480. /**
  118481. * 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)
  118482. * @param uniformName Name of the variable.
  118483. * @param array array to be set.
  118484. * @returns this effect.
  118485. */
  118486. setArray2(uniformName: string, array: number[]): Effect;
  118487. /**
  118488. * 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)
  118489. * @param uniformName Name of the variable.
  118490. * @param array array to be set.
  118491. * @returns this effect.
  118492. */
  118493. setArray3(uniformName: string, array: number[]): Effect;
  118494. /**
  118495. * 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)
  118496. * @param uniformName Name of the variable.
  118497. * @param array array to be set.
  118498. * @returns this effect.
  118499. */
  118500. setArray4(uniformName: string, array: number[]): Effect;
  118501. /**
  118502. * Sets matrices on a uniform variable.
  118503. * @param uniformName Name of the variable.
  118504. * @param matrices matrices to be set.
  118505. * @returns this effect.
  118506. */
  118507. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  118508. /**
  118509. * Sets matrix on a uniform variable.
  118510. * @param uniformName Name of the variable.
  118511. * @param matrix matrix to be set.
  118512. * @returns this effect.
  118513. */
  118514. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  118515. /**
  118516. * 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)
  118517. * @param uniformName Name of the variable.
  118518. * @param matrix matrix to be set.
  118519. * @returns this effect.
  118520. */
  118521. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118522. /**
  118523. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  118524. * @param uniformName Name of the variable.
  118525. * @param matrix matrix to be set.
  118526. * @returns this effect.
  118527. */
  118528. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  118529. /**
  118530. * Sets a float on a uniform variable.
  118531. * @param uniformName Name of the variable.
  118532. * @param value value to be set.
  118533. * @returns this effect.
  118534. */
  118535. setFloat(uniformName: string, value: number): Effect;
  118536. /**
  118537. * Sets a boolean on a uniform variable.
  118538. * @param uniformName Name of the variable.
  118539. * @param bool value to be set.
  118540. * @returns this effect.
  118541. */
  118542. setBool(uniformName: string, bool: boolean): Effect;
  118543. /**
  118544. * Sets a Vector2 on a uniform variable.
  118545. * @param uniformName Name of the variable.
  118546. * @param vector2 vector2 to be set.
  118547. * @returns this effect.
  118548. */
  118549. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  118550. /**
  118551. * Sets a float2 on a uniform variable.
  118552. * @param uniformName Name of the variable.
  118553. * @param x First float in float2.
  118554. * @param y Second float in float2.
  118555. * @returns this effect.
  118556. */
  118557. setFloat2(uniformName: string, x: number, y: number): Effect;
  118558. /**
  118559. * Sets a Vector3 on a uniform variable.
  118560. * @param uniformName Name of the variable.
  118561. * @param vector3 Value to be set.
  118562. * @returns this effect.
  118563. */
  118564. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  118565. /**
  118566. * Sets a float3 on a uniform variable.
  118567. * @param uniformName Name of the variable.
  118568. * @param x First float in float3.
  118569. * @param y Second float in float3.
  118570. * @param z Third float in float3.
  118571. * @returns this effect.
  118572. */
  118573. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  118574. /**
  118575. * Sets a Vector4 on a uniform variable.
  118576. * @param uniformName Name of the variable.
  118577. * @param vector4 Value to be set.
  118578. * @returns this effect.
  118579. */
  118580. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  118581. /**
  118582. * Sets a float4 on a uniform variable.
  118583. * @param uniformName Name of the variable.
  118584. * @param x First float in float4.
  118585. * @param y Second float in float4.
  118586. * @param z Third float in float4.
  118587. * @param w Fourth float in float4.
  118588. * @returns this effect.
  118589. */
  118590. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  118591. /**
  118592. * Sets a Color3 on a uniform variable.
  118593. * @param uniformName Name of the variable.
  118594. * @param color3 Value to be set.
  118595. * @returns this effect.
  118596. */
  118597. setColor3(uniformName: string, color3: IColor3Like): Effect;
  118598. /**
  118599. * Sets a Color4 on a uniform variable.
  118600. * @param uniformName Name of the variable.
  118601. * @param color3 Value to be set.
  118602. * @param alpha Alpha value to be set.
  118603. * @returns this effect.
  118604. */
  118605. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  118606. /**
  118607. * Sets a Color4 on a uniform variable
  118608. * @param uniformName defines the name of the variable
  118609. * @param color4 defines the value to be set
  118610. * @returns this effect.
  118611. */
  118612. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  118613. /** Release all associated resources */
  118614. dispose(): void;
  118615. /**
  118616. * This function will add a new shader to the shader store
  118617. * @param name the name of the shader
  118618. * @param pixelShader optional pixel shader content
  118619. * @param vertexShader optional vertex shader content
  118620. */
  118621. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  118622. /**
  118623. * Store of each shader (The can be looked up using effect.key)
  118624. */
  118625. static ShadersStore: {
  118626. [key: string]: string;
  118627. };
  118628. /**
  118629. * Store of each included file for a shader (The can be looked up using effect.key)
  118630. */
  118631. static IncludesShadersStore: {
  118632. [key: string]: string;
  118633. };
  118634. /**
  118635. * Resets the cache of effects.
  118636. */
  118637. static ResetCache(): void;
  118638. }
  118639. }
  118640. declare module BABYLON {
  118641. /**
  118642. * Interface used to describe the capabilities of the engine relatively to the current browser
  118643. */
  118644. export interface EngineCapabilities {
  118645. /** Maximum textures units per fragment shader */
  118646. maxTexturesImageUnits: number;
  118647. /** Maximum texture units per vertex shader */
  118648. maxVertexTextureImageUnits: number;
  118649. /** Maximum textures units in the entire pipeline */
  118650. maxCombinedTexturesImageUnits: number;
  118651. /** Maximum texture size */
  118652. maxTextureSize: number;
  118653. /** Maximum texture samples */
  118654. maxSamples?: number;
  118655. /** Maximum cube texture size */
  118656. maxCubemapTextureSize: number;
  118657. /** Maximum render texture size */
  118658. maxRenderTextureSize: number;
  118659. /** Maximum number of vertex attributes */
  118660. maxVertexAttribs: number;
  118661. /** Maximum number of varyings */
  118662. maxVaryingVectors: number;
  118663. /** Maximum number of uniforms per vertex shader */
  118664. maxVertexUniformVectors: number;
  118665. /** Maximum number of uniforms per fragment shader */
  118666. maxFragmentUniformVectors: number;
  118667. /** Defines if standard derivates (dx/dy) are supported */
  118668. standardDerivatives: boolean;
  118669. /** Defines if s3tc texture compression is supported */
  118670. s3tc?: WEBGL_compressed_texture_s3tc;
  118671. /** Defines if pvrtc texture compression is supported */
  118672. pvrtc: any;
  118673. /** Defines if etc1 texture compression is supported */
  118674. etc1: any;
  118675. /** Defines if etc2 texture compression is supported */
  118676. etc2: any;
  118677. /** Defines if astc texture compression is supported */
  118678. astc: any;
  118679. /** Defines if bptc texture compression is supported */
  118680. bptc: any;
  118681. /** Defines if float textures are supported */
  118682. textureFloat: boolean;
  118683. /** Defines if vertex array objects are supported */
  118684. vertexArrayObject: boolean;
  118685. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  118686. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  118687. /** Gets the maximum level of anisotropy supported */
  118688. maxAnisotropy: number;
  118689. /** Defines if instancing is supported */
  118690. instancedArrays: boolean;
  118691. /** Defines if 32 bits indices are supported */
  118692. uintIndices: boolean;
  118693. /** Defines if high precision shaders are supported */
  118694. highPrecisionShaderSupported: boolean;
  118695. /** Defines if depth reading in the fragment shader is supported */
  118696. fragmentDepthSupported: boolean;
  118697. /** Defines if float texture linear filtering is supported*/
  118698. textureFloatLinearFiltering: boolean;
  118699. /** Defines if rendering to float textures is supported */
  118700. textureFloatRender: boolean;
  118701. /** Defines if half float textures are supported*/
  118702. textureHalfFloat: boolean;
  118703. /** Defines if half float texture linear filtering is supported*/
  118704. textureHalfFloatLinearFiltering: boolean;
  118705. /** Defines if rendering to half float textures is supported */
  118706. textureHalfFloatRender: boolean;
  118707. /** Defines if textureLOD shader command is supported */
  118708. textureLOD: boolean;
  118709. /** Defines if draw buffers extension is supported */
  118710. drawBuffersExtension: boolean;
  118711. /** Defines if depth textures are supported */
  118712. depthTextureExtension: boolean;
  118713. /** Defines if float color buffer are supported */
  118714. colorBufferFloat: boolean;
  118715. /** Gets disjoint timer query extension (null if not supported) */
  118716. timerQuery?: EXT_disjoint_timer_query;
  118717. /** Defines if timestamp can be used with timer query */
  118718. canUseTimestampForTimerQuery: boolean;
  118719. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  118720. multiview?: any;
  118721. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  118722. oculusMultiview?: any;
  118723. /** Function used to let the system compiles shaders in background */
  118724. parallelShaderCompile?: {
  118725. COMPLETION_STATUS_KHR: number;
  118726. };
  118727. /** Max number of texture samples for MSAA */
  118728. maxMSAASamples: number;
  118729. /** Defines if the blend min max extension is supported */
  118730. blendMinMax: boolean;
  118731. }
  118732. }
  118733. declare module BABYLON {
  118734. /**
  118735. * @hidden
  118736. **/
  118737. export class DepthCullingState {
  118738. private _isDepthTestDirty;
  118739. private _isDepthMaskDirty;
  118740. private _isDepthFuncDirty;
  118741. private _isCullFaceDirty;
  118742. private _isCullDirty;
  118743. private _isZOffsetDirty;
  118744. private _isFrontFaceDirty;
  118745. private _depthTest;
  118746. private _depthMask;
  118747. private _depthFunc;
  118748. private _cull;
  118749. private _cullFace;
  118750. private _zOffset;
  118751. private _frontFace;
  118752. /**
  118753. * Initializes the state.
  118754. */
  118755. constructor();
  118756. get isDirty(): boolean;
  118757. get zOffset(): number;
  118758. set zOffset(value: number);
  118759. get cullFace(): Nullable<number>;
  118760. set cullFace(value: Nullable<number>);
  118761. get cull(): Nullable<boolean>;
  118762. set cull(value: Nullable<boolean>);
  118763. get depthFunc(): Nullable<number>;
  118764. set depthFunc(value: Nullable<number>);
  118765. get depthMask(): boolean;
  118766. set depthMask(value: boolean);
  118767. get depthTest(): boolean;
  118768. set depthTest(value: boolean);
  118769. get frontFace(): Nullable<number>;
  118770. set frontFace(value: Nullable<number>);
  118771. reset(): void;
  118772. apply(gl: WebGLRenderingContext): void;
  118773. }
  118774. }
  118775. declare module BABYLON {
  118776. /**
  118777. * @hidden
  118778. **/
  118779. export class StencilState {
  118780. /** 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 */
  118781. static readonly ALWAYS: number;
  118782. /** Passed to stencilOperation to specify that stencil value must be kept */
  118783. static readonly KEEP: number;
  118784. /** Passed to stencilOperation to specify that stencil value must be replaced */
  118785. static readonly REPLACE: number;
  118786. private _isStencilTestDirty;
  118787. private _isStencilMaskDirty;
  118788. private _isStencilFuncDirty;
  118789. private _isStencilOpDirty;
  118790. private _stencilTest;
  118791. private _stencilMask;
  118792. private _stencilFunc;
  118793. private _stencilFuncRef;
  118794. private _stencilFuncMask;
  118795. private _stencilOpStencilFail;
  118796. private _stencilOpDepthFail;
  118797. private _stencilOpStencilDepthPass;
  118798. get isDirty(): boolean;
  118799. get stencilFunc(): number;
  118800. set stencilFunc(value: number);
  118801. get stencilFuncRef(): number;
  118802. set stencilFuncRef(value: number);
  118803. get stencilFuncMask(): number;
  118804. set stencilFuncMask(value: number);
  118805. get stencilOpStencilFail(): number;
  118806. set stencilOpStencilFail(value: number);
  118807. get stencilOpDepthFail(): number;
  118808. set stencilOpDepthFail(value: number);
  118809. get stencilOpStencilDepthPass(): number;
  118810. set stencilOpStencilDepthPass(value: number);
  118811. get stencilMask(): number;
  118812. set stencilMask(value: number);
  118813. get stencilTest(): boolean;
  118814. set stencilTest(value: boolean);
  118815. constructor();
  118816. reset(): void;
  118817. apply(gl: WebGLRenderingContext): void;
  118818. }
  118819. }
  118820. declare module BABYLON {
  118821. /**
  118822. * @hidden
  118823. **/
  118824. export class AlphaState {
  118825. private _isAlphaBlendDirty;
  118826. private _isBlendFunctionParametersDirty;
  118827. private _isBlendEquationParametersDirty;
  118828. private _isBlendConstantsDirty;
  118829. private _alphaBlend;
  118830. private _blendFunctionParameters;
  118831. private _blendEquationParameters;
  118832. private _blendConstants;
  118833. /**
  118834. * Initializes the state.
  118835. */
  118836. constructor();
  118837. get isDirty(): boolean;
  118838. get alphaBlend(): boolean;
  118839. set alphaBlend(value: boolean);
  118840. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  118841. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  118842. setAlphaEquationParameters(rgb: number, alpha: number): void;
  118843. reset(): void;
  118844. apply(gl: WebGLRenderingContext): void;
  118845. }
  118846. }
  118847. declare module BABYLON {
  118848. /** @hidden */
  118849. export class WebGL2ShaderProcessor implements IShaderProcessor {
  118850. attributeProcessor(attribute: string): string;
  118851. varyingProcessor(varying: string, isFragment: boolean): string;
  118852. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  118853. }
  118854. }
  118855. declare module BABYLON {
  118856. /**
  118857. * Interface for attribute information associated with buffer instanciation
  118858. */
  118859. export interface InstancingAttributeInfo {
  118860. /**
  118861. * Name of the GLSL attribute
  118862. * if attribute index is not specified, this is used to retrieve the index from the effect
  118863. */
  118864. attributeName: string;
  118865. /**
  118866. * Index/offset of the attribute in the vertex shader
  118867. * if not specified, this will be computes from the name.
  118868. */
  118869. index?: number;
  118870. /**
  118871. * size of the attribute, 1, 2, 3 or 4
  118872. */
  118873. attributeSize: number;
  118874. /**
  118875. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  118876. */
  118877. offset: number;
  118878. /**
  118879. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  118880. * default to 1
  118881. */
  118882. divisor?: number;
  118883. /**
  118884. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  118885. * default is FLOAT
  118886. */
  118887. attributeType?: number;
  118888. /**
  118889. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  118890. */
  118891. normalized?: boolean;
  118892. }
  118893. }
  118894. declare module BABYLON {
  118895. interface ThinEngine {
  118896. /**
  118897. * Update a video texture
  118898. * @param texture defines the texture to update
  118899. * @param video defines the video element to use
  118900. * @param invertY defines if data must be stored with Y axis inverted
  118901. */
  118902. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  118903. }
  118904. }
  118905. declare module BABYLON {
  118906. interface ThinEngine {
  118907. /**
  118908. * Creates a dynamic texture
  118909. * @param width defines the width of the texture
  118910. * @param height defines the height of the texture
  118911. * @param generateMipMaps defines if the engine should generate the mip levels
  118912. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  118913. * @returns the dynamic texture inside an InternalTexture
  118914. */
  118915. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  118916. /**
  118917. * Update the content of a dynamic texture
  118918. * @param texture defines the texture to update
  118919. * @param canvas defines the canvas containing the source
  118920. * @param invertY defines if data must be stored with Y axis inverted
  118921. * @param premulAlpha defines if alpha is stored as premultiplied
  118922. * @param format defines the format of the data
  118923. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  118924. */
  118925. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  118926. }
  118927. }
  118928. declare module BABYLON {
  118929. /**
  118930. * Settings for finer control over video usage
  118931. */
  118932. export interface VideoTextureSettings {
  118933. /**
  118934. * Applies `autoplay` to video, if specified
  118935. */
  118936. autoPlay?: boolean;
  118937. /**
  118938. * Applies `muted` to video, if specified
  118939. */
  118940. muted?: boolean;
  118941. /**
  118942. * Applies `loop` to video, if specified
  118943. */
  118944. loop?: boolean;
  118945. /**
  118946. * Automatically updates internal texture from video at every frame in the render loop
  118947. */
  118948. autoUpdateTexture: boolean;
  118949. /**
  118950. * Image src displayed during the video loading or until the user interacts with the video.
  118951. */
  118952. poster?: string;
  118953. }
  118954. /**
  118955. * If you want to display a video in your scene, this is the special texture for that.
  118956. * This special texture works similar to other textures, with the exception of a few parameters.
  118957. * @see https://doc.babylonjs.com/how_to/video_texture
  118958. */
  118959. export class VideoTexture extends Texture {
  118960. /**
  118961. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  118962. */
  118963. readonly autoUpdateTexture: boolean;
  118964. /**
  118965. * The video instance used by the texture internally
  118966. */
  118967. readonly video: HTMLVideoElement;
  118968. private _onUserActionRequestedObservable;
  118969. /**
  118970. * Event triggerd when a dom action is required by the user to play the video.
  118971. * This happens due to recent changes in browser policies preventing video to auto start.
  118972. */
  118973. get onUserActionRequestedObservable(): Observable<Texture>;
  118974. private _generateMipMaps;
  118975. private _stillImageCaptured;
  118976. private _displayingPosterTexture;
  118977. private _settings;
  118978. private _createInternalTextureOnEvent;
  118979. private _frameId;
  118980. private _currentSrc;
  118981. /**
  118982. * Creates a video texture.
  118983. * If you want to display a video in your scene, this is the special texture for that.
  118984. * This special texture works similar to other textures, with the exception of a few parameters.
  118985. * @see https://doc.babylonjs.com/how_to/video_texture
  118986. * @param name optional name, will detect from video source, if not defined
  118987. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  118988. * @param scene is obviously the current scene.
  118989. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  118990. * @param invertY is false by default but can be used to invert video on Y axis
  118991. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  118992. * @param settings allows finer control over video usage
  118993. */
  118994. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  118995. private _getName;
  118996. private _getVideo;
  118997. private _createInternalTexture;
  118998. private reset;
  118999. /**
  119000. * @hidden Internal method to initiate `update`.
  119001. */
  119002. _rebuild(): void;
  119003. /**
  119004. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  119005. */
  119006. update(): void;
  119007. /**
  119008. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  119009. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  119010. */
  119011. updateTexture(isVisible: boolean): void;
  119012. protected _updateInternalTexture: () => void;
  119013. /**
  119014. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  119015. * @param url New url.
  119016. */
  119017. updateURL(url: string): void;
  119018. /**
  119019. * Clones the texture.
  119020. * @returns the cloned texture
  119021. */
  119022. clone(): VideoTexture;
  119023. /**
  119024. * Dispose the texture and release its associated resources.
  119025. */
  119026. dispose(): void;
  119027. /**
  119028. * Creates a video texture straight from a stream.
  119029. * @param scene Define the scene the texture should be created in
  119030. * @param stream Define the stream the texture should be created from
  119031. * @returns The created video texture as a promise
  119032. */
  119033. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  119034. /**
  119035. * Creates a video texture straight from your WebCam video feed.
  119036. * @param scene Define the scene the texture should be created in
  119037. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119038. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119039. * @returns The created video texture as a promise
  119040. */
  119041. static CreateFromWebCamAsync(scene: Scene, constraints: {
  119042. minWidth: number;
  119043. maxWidth: number;
  119044. minHeight: number;
  119045. maxHeight: number;
  119046. deviceId: string;
  119047. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  119048. /**
  119049. * Creates a video texture straight from your WebCam video feed.
  119050. * @param scene Define the scene the texture should be created in
  119051. * @param onReady Define a callback to triggered once the texture will be ready
  119052. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119053. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119054. */
  119055. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  119056. minWidth: number;
  119057. maxWidth: number;
  119058. minHeight: number;
  119059. maxHeight: number;
  119060. deviceId: string;
  119061. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  119062. }
  119063. }
  119064. declare module BABYLON {
  119065. /**
  119066. * Defines the interface used by objects working like Scene
  119067. * @hidden
  119068. */
  119069. export interface ISceneLike {
  119070. _addPendingData(data: any): void;
  119071. _removePendingData(data: any): void;
  119072. offlineProvider: IOfflineProvider;
  119073. }
  119074. /**
  119075. * Information about the current host
  119076. */
  119077. export interface HostInformation {
  119078. /**
  119079. * Defines if the current host is a mobile
  119080. */
  119081. isMobile: boolean;
  119082. }
  119083. /** Interface defining initialization parameters for Engine class */
  119084. export interface EngineOptions extends WebGLContextAttributes {
  119085. /**
  119086. * Defines if the engine should no exceed a specified device ratio
  119087. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  119088. */
  119089. limitDeviceRatio?: number;
  119090. /**
  119091. * Defines if webvr should be enabled automatically
  119092. * @see https://doc.babylonjs.com/how_to/webvr_camera
  119093. */
  119094. autoEnableWebVR?: boolean;
  119095. /**
  119096. * Defines if webgl2 should be turned off even if supported
  119097. * @see https://doc.babylonjs.com/features/webgl2
  119098. */
  119099. disableWebGL2Support?: boolean;
  119100. /**
  119101. * Defines if webaudio should be initialized as well
  119102. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119103. */
  119104. audioEngine?: boolean;
  119105. /**
  119106. * Defines if animations should run using a deterministic lock step
  119107. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119108. */
  119109. deterministicLockstep?: boolean;
  119110. /** Defines the maximum steps to use with deterministic lock step mode */
  119111. lockstepMaxSteps?: number;
  119112. /** Defines the seconds between each deterministic lock step */
  119113. timeStep?: number;
  119114. /**
  119115. * Defines that engine should ignore context lost events
  119116. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  119117. */
  119118. doNotHandleContextLost?: boolean;
  119119. /**
  119120. * Defines that engine should ignore modifying touch action attribute and style
  119121. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  119122. */
  119123. doNotHandleTouchAction?: boolean;
  119124. /**
  119125. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  119126. */
  119127. useHighPrecisionFloats?: boolean;
  119128. /**
  119129. * Make the canvas XR Compatible for XR sessions
  119130. */
  119131. xrCompatible?: boolean;
  119132. /**
  119133. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  119134. */
  119135. useHighPrecisionMatrix?: boolean;
  119136. /**
  119137. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  119138. */
  119139. failIfMajorPerformanceCaveat?: boolean;
  119140. }
  119141. /**
  119142. * The base engine class (root of all engines)
  119143. */
  119144. export class ThinEngine {
  119145. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  119146. static ExceptionList: ({
  119147. key: string;
  119148. capture: string;
  119149. captureConstraint: number;
  119150. targets: string[];
  119151. } | {
  119152. key: string;
  119153. capture: null;
  119154. captureConstraint: null;
  119155. targets: string[];
  119156. })[];
  119157. /** @hidden */
  119158. static _TextureLoaders: IInternalTextureLoader[];
  119159. /**
  119160. * Returns the current npm package of the sdk
  119161. */
  119162. static get NpmPackage(): string;
  119163. /**
  119164. * Returns the current version of the framework
  119165. */
  119166. static get Version(): string;
  119167. /**
  119168. * Returns a string describing the current engine
  119169. */
  119170. get description(): string;
  119171. /**
  119172. * Gets or sets the epsilon value used by collision engine
  119173. */
  119174. static CollisionsEpsilon: number;
  119175. /**
  119176. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119177. */
  119178. static get ShadersRepository(): string;
  119179. static set ShadersRepository(value: string);
  119180. /** @hidden */
  119181. _shaderProcessor: IShaderProcessor;
  119182. /**
  119183. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  119184. */
  119185. forcePOTTextures: boolean;
  119186. /**
  119187. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  119188. */
  119189. isFullscreen: boolean;
  119190. /**
  119191. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  119192. */
  119193. cullBackFaces: boolean;
  119194. /**
  119195. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  119196. */
  119197. renderEvenInBackground: boolean;
  119198. /**
  119199. * Gets or sets a boolean indicating that cache can be kept between frames
  119200. */
  119201. preventCacheWipeBetweenFrames: boolean;
  119202. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  119203. validateShaderPrograms: boolean;
  119204. /**
  119205. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  119206. * This can provide greater z depth for distant objects.
  119207. */
  119208. useReverseDepthBuffer: boolean;
  119209. /**
  119210. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  119211. */
  119212. disableUniformBuffers: boolean;
  119213. /** @hidden */
  119214. _uniformBuffers: UniformBuffer[];
  119215. /**
  119216. * Gets a boolean indicating that the engine supports uniform buffers
  119217. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  119218. */
  119219. get supportsUniformBuffers(): boolean;
  119220. /** @hidden */
  119221. _gl: WebGLRenderingContext;
  119222. /** @hidden */
  119223. _webGLVersion: number;
  119224. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  119225. protected _windowIsBackground: boolean;
  119226. protected _creationOptions: EngineOptions;
  119227. protected _highPrecisionShadersAllowed: boolean;
  119228. /** @hidden */
  119229. get _shouldUseHighPrecisionShader(): boolean;
  119230. /**
  119231. * Gets a boolean indicating that only power of 2 textures are supported
  119232. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  119233. */
  119234. get needPOTTextures(): boolean;
  119235. /** @hidden */
  119236. _badOS: boolean;
  119237. /** @hidden */
  119238. _badDesktopOS: boolean;
  119239. private _hardwareScalingLevel;
  119240. /** @hidden */
  119241. _caps: EngineCapabilities;
  119242. private _isStencilEnable;
  119243. private _glVersion;
  119244. private _glRenderer;
  119245. private _glVendor;
  119246. /** @hidden */
  119247. _videoTextureSupported: boolean;
  119248. protected _renderingQueueLaunched: boolean;
  119249. protected _activeRenderLoops: (() => void)[];
  119250. /**
  119251. * Observable signaled when a context lost event is raised
  119252. */
  119253. onContextLostObservable: Observable<ThinEngine>;
  119254. /**
  119255. * Observable signaled when a context restored event is raised
  119256. */
  119257. onContextRestoredObservable: Observable<ThinEngine>;
  119258. private _onContextLost;
  119259. private _onContextRestored;
  119260. protected _contextWasLost: boolean;
  119261. /** @hidden */
  119262. _doNotHandleContextLost: boolean;
  119263. /**
  119264. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  119265. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  119266. */
  119267. get doNotHandleContextLost(): boolean;
  119268. set doNotHandleContextLost(value: boolean);
  119269. /**
  119270. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  119271. */
  119272. disableVertexArrayObjects: boolean;
  119273. /** @hidden */
  119274. protected _colorWrite: boolean;
  119275. /** @hidden */
  119276. protected _colorWriteChanged: boolean;
  119277. /** @hidden */
  119278. protected _depthCullingState: DepthCullingState;
  119279. /** @hidden */
  119280. protected _stencilState: StencilState;
  119281. /** @hidden */
  119282. _alphaState: AlphaState;
  119283. /** @hidden */
  119284. _alphaMode: number;
  119285. /** @hidden */
  119286. _alphaEquation: number;
  119287. /** @hidden */
  119288. _internalTexturesCache: InternalTexture[];
  119289. /** @hidden */
  119290. protected _activeChannel: number;
  119291. private _currentTextureChannel;
  119292. /** @hidden */
  119293. protected _boundTexturesCache: {
  119294. [key: string]: Nullable<InternalTexture>;
  119295. };
  119296. /** @hidden */
  119297. protected _currentEffect: Nullable<Effect>;
  119298. /** @hidden */
  119299. protected _currentProgram: Nullable<WebGLProgram>;
  119300. private _compiledEffects;
  119301. private _vertexAttribArraysEnabled;
  119302. /** @hidden */
  119303. protected _cachedViewport: Nullable<IViewportLike>;
  119304. private _cachedVertexArrayObject;
  119305. /** @hidden */
  119306. protected _cachedVertexBuffers: any;
  119307. /** @hidden */
  119308. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  119309. /** @hidden */
  119310. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  119311. /** @hidden */
  119312. _currentRenderTarget: Nullable<InternalTexture>;
  119313. private _uintIndicesCurrentlySet;
  119314. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  119315. /** @hidden */
  119316. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  119317. /** @hidden */
  119318. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  119319. private _currentBufferPointers;
  119320. private _currentInstanceLocations;
  119321. private _currentInstanceBuffers;
  119322. private _textureUnits;
  119323. /** @hidden */
  119324. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  119325. /** @hidden */
  119326. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  119327. /** @hidden */
  119328. _boundRenderFunction: any;
  119329. private _vaoRecordInProgress;
  119330. private _mustWipeVertexAttributes;
  119331. private _emptyTexture;
  119332. private _emptyCubeTexture;
  119333. private _emptyTexture3D;
  119334. private _emptyTexture2DArray;
  119335. /** @hidden */
  119336. _frameHandler: number;
  119337. private _nextFreeTextureSlots;
  119338. private _maxSimultaneousTextures;
  119339. private _activeRequests;
  119340. /** @hidden */
  119341. _transformTextureUrl: Nullable<(url: string) => string>;
  119342. /**
  119343. * Gets information about the current host
  119344. */
  119345. hostInformation: HostInformation;
  119346. protected get _supportsHardwareTextureRescaling(): boolean;
  119347. private _framebufferDimensionsObject;
  119348. /**
  119349. * sets the object from which width and height will be taken from when getting render width and height
  119350. * Will fallback to the gl object
  119351. * @param dimensions the framebuffer width and height that will be used.
  119352. */
  119353. set framebufferDimensionsObject(dimensions: Nullable<{
  119354. framebufferWidth: number;
  119355. framebufferHeight: number;
  119356. }>);
  119357. /**
  119358. * Gets the current viewport
  119359. */
  119360. get currentViewport(): Nullable<IViewportLike>;
  119361. /**
  119362. * Gets the default empty texture
  119363. */
  119364. get emptyTexture(): InternalTexture;
  119365. /**
  119366. * Gets the default empty 3D texture
  119367. */
  119368. get emptyTexture3D(): InternalTexture;
  119369. /**
  119370. * Gets the default empty 2D array texture
  119371. */
  119372. get emptyTexture2DArray(): InternalTexture;
  119373. /**
  119374. * Gets the default empty cube texture
  119375. */
  119376. get emptyCubeTexture(): InternalTexture;
  119377. /**
  119378. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  119379. */
  119380. readonly premultipliedAlpha: boolean;
  119381. /**
  119382. * Observable event triggered before each texture is initialized
  119383. */
  119384. onBeforeTextureInitObservable: Observable<Texture>;
  119385. /**
  119386. * Creates a new engine
  119387. * @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
  119388. * @param antialias defines enable antialiasing (default: false)
  119389. * @param options defines further options to be sent to the getContext() function
  119390. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  119391. */
  119392. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  119393. private _rebuildInternalTextures;
  119394. private _rebuildEffects;
  119395. /**
  119396. * Gets a boolean indicating if all created effects are ready
  119397. * @returns true if all effects are ready
  119398. */
  119399. areAllEffectsReady(): boolean;
  119400. protected _rebuildBuffers(): void;
  119401. protected _initGLContext(): void;
  119402. /**
  119403. * Gets version of the current webGL context
  119404. */
  119405. get webGLVersion(): number;
  119406. /**
  119407. * Gets a string identifying the name of the class
  119408. * @returns "Engine" string
  119409. */
  119410. getClassName(): string;
  119411. /**
  119412. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  119413. */
  119414. get isStencilEnable(): boolean;
  119415. /** @hidden */
  119416. _prepareWorkingCanvas(): void;
  119417. /**
  119418. * Reset the texture cache to empty state
  119419. */
  119420. resetTextureCache(): void;
  119421. /**
  119422. * Gets an object containing information about the current webGL context
  119423. * @returns an object containing the vender, the renderer and the version of the current webGL context
  119424. */
  119425. getGlInfo(): {
  119426. vendor: string;
  119427. renderer: string;
  119428. version: string;
  119429. };
  119430. /**
  119431. * Defines the hardware scaling level.
  119432. * By default the hardware scaling level is computed from the window device ratio.
  119433. * 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.
  119434. * @param level defines the level to use
  119435. */
  119436. setHardwareScalingLevel(level: number): void;
  119437. /**
  119438. * Gets the current hardware scaling level.
  119439. * By default the hardware scaling level is computed from the window device ratio.
  119440. * 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.
  119441. * @returns a number indicating the current hardware scaling level
  119442. */
  119443. getHardwareScalingLevel(): number;
  119444. /**
  119445. * Gets the list of loaded textures
  119446. * @returns an array containing all loaded textures
  119447. */
  119448. getLoadedTexturesCache(): InternalTexture[];
  119449. /**
  119450. * Gets the object containing all engine capabilities
  119451. * @returns the EngineCapabilities object
  119452. */
  119453. getCaps(): EngineCapabilities;
  119454. /**
  119455. * stop executing a render loop function and remove it from the execution array
  119456. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  119457. */
  119458. stopRenderLoop(renderFunction?: () => void): void;
  119459. /** @hidden */
  119460. _renderLoop(): void;
  119461. /**
  119462. * Gets the HTML canvas attached with the current webGL context
  119463. * @returns a HTML canvas
  119464. */
  119465. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  119466. /**
  119467. * Gets host window
  119468. * @returns the host window object
  119469. */
  119470. getHostWindow(): Nullable<Window>;
  119471. /**
  119472. * Gets the current render width
  119473. * @param useScreen defines if screen size must be used (or the current render target if any)
  119474. * @returns a number defining the current render width
  119475. */
  119476. getRenderWidth(useScreen?: boolean): number;
  119477. /**
  119478. * Gets the current render height
  119479. * @param useScreen defines if screen size must be used (or the current render target if any)
  119480. * @returns a number defining the current render height
  119481. */
  119482. getRenderHeight(useScreen?: boolean): number;
  119483. /**
  119484. * Can be used to override the current requestAnimationFrame requester.
  119485. * @hidden
  119486. */
  119487. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  119488. /**
  119489. * Register and execute a render loop. The engine can have more than one render function
  119490. * @param renderFunction defines the function to continuously execute
  119491. */
  119492. runRenderLoop(renderFunction: () => void): void;
  119493. /**
  119494. * Clear the current render buffer or the current render target (if any is set up)
  119495. * @param color defines the color to use
  119496. * @param backBuffer defines if the back buffer must be cleared
  119497. * @param depth defines if the depth buffer must be cleared
  119498. * @param stencil defines if the stencil buffer must be cleared
  119499. */
  119500. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119501. private _viewportCached;
  119502. /** @hidden */
  119503. _viewport(x: number, y: number, width: number, height: number): void;
  119504. /**
  119505. * Set the WebGL's viewport
  119506. * @param viewport defines the viewport element to be used
  119507. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119508. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119509. */
  119510. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119511. /**
  119512. * Begin a new frame
  119513. */
  119514. beginFrame(): void;
  119515. /**
  119516. * Enf the current frame
  119517. */
  119518. endFrame(): void;
  119519. /**
  119520. * Resize the view according to the canvas' size
  119521. */
  119522. resize(): void;
  119523. /**
  119524. * Force a specific size of the canvas
  119525. * @param width defines the new canvas' width
  119526. * @param height defines the new canvas' height
  119527. * @returns true if the size was changed
  119528. */
  119529. setSize(width: number, height: number): boolean;
  119530. /**
  119531. * Binds the frame buffer to the specified texture.
  119532. * @param texture The texture to render to or null for the default canvas
  119533. * @param faceIndex The face of the texture to render to in case of cube texture
  119534. * @param requiredWidth The width of the target to render to
  119535. * @param requiredHeight The height of the target to render to
  119536. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119537. * @param lodLevel defines the lod level to bind to the frame buffer
  119538. * @param layer defines the 2d array index to bind to frame buffer to
  119539. */
  119540. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  119541. /** @hidden */
  119542. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  119543. /**
  119544. * Unbind the current render target texture from the webGL context
  119545. * @param texture defines the render target texture to unbind
  119546. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119547. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119548. */
  119549. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119550. /**
  119551. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  119552. */
  119553. flushFramebuffer(): void;
  119554. /**
  119555. * Unbind the current render target and bind the default framebuffer
  119556. */
  119557. restoreDefaultFramebuffer(): void;
  119558. /** @hidden */
  119559. protected _resetVertexBufferBinding(): void;
  119560. /**
  119561. * Creates a vertex buffer
  119562. * @param data the data for the vertex buffer
  119563. * @returns the new WebGL static buffer
  119564. */
  119565. createVertexBuffer(data: DataArray): DataBuffer;
  119566. private _createVertexBuffer;
  119567. /**
  119568. * Creates a dynamic vertex buffer
  119569. * @param data the data for the dynamic vertex buffer
  119570. * @returns the new WebGL dynamic buffer
  119571. */
  119572. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  119573. protected _resetIndexBufferBinding(): void;
  119574. /**
  119575. * Creates a new index buffer
  119576. * @param indices defines the content of the index buffer
  119577. * @param updatable defines if the index buffer must be updatable
  119578. * @returns a new webGL buffer
  119579. */
  119580. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  119581. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  119582. /**
  119583. * Bind a webGL buffer to the webGL context
  119584. * @param buffer defines the buffer to bind
  119585. */
  119586. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  119587. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  119588. private bindBuffer;
  119589. /**
  119590. * update the bound buffer with the given data
  119591. * @param data defines the data to update
  119592. */
  119593. updateArrayBuffer(data: Float32Array): void;
  119594. private _vertexAttribPointer;
  119595. /** @hidden */
  119596. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  119597. private _bindVertexBuffersAttributes;
  119598. /**
  119599. * Records a vertex array object
  119600. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119601. * @param vertexBuffers defines the list of vertex buffers to store
  119602. * @param indexBuffer defines the index buffer to store
  119603. * @param effect defines the effect to store
  119604. * @returns the new vertex array object
  119605. */
  119606. recordVertexArrayObject(vertexBuffers: {
  119607. [key: string]: VertexBuffer;
  119608. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  119609. /**
  119610. * Bind a specific vertex array object
  119611. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  119612. * @param vertexArrayObject defines the vertex array object to bind
  119613. * @param indexBuffer defines the index buffer to bind
  119614. */
  119615. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  119616. /**
  119617. * Bind webGl buffers directly to the webGL context
  119618. * @param vertexBuffer defines the vertex buffer to bind
  119619. * @param indexBuffer defines the index buffer to bind
  119620. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119621. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119622. * @param effect defines the effect associated with the vertex buffer
  119623. */
  119624. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  119625. private _unbindVertexArrayObject;
  119626. /**
  119627. * Bind a list of vertex buffers to the webGL context
  119628. * @param vertexBuffers defines the list of vertex buffers to bind
  119629. * @param indexBuffer defines the index buffer to bind
  119630. * @param effect defines the effect associated with the vertex buffers
  119631. */
  119632. bindBuffers(vertexBuffers: {
  119633. [key: string]: Nullable<VertexBuffer>;
  119634. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  119635. /**
  119636. * Unbind all instance attributes
  119637. */
  119638. unbindInstanceAttributes(): void;
  119639. /**
  119640. * Release and free the memory of a vertex array object
  119641. * @param vao defines the vertex array object to delete
  119642. */
  119643. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  119644. /** @hidden */
  119645. _releaseBuffer(buffer: DataBuffer): boolean;
  119646. protected _deleteBuffer(buffer: DataBuffer): void;
  119647. /**
  119648. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  119649. * @param instancesBuffer defines the webGL buffer to update and bind
  119650. * @param data defines the data to store in the buffer
  119651. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  119652. */
  119653. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  119654. /**
  119655. * Bind the content of a webGL buffer used with instantiation
  119656. * @param instancesBuffer defines the webGL buffer to bind
  119657. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  119658. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  119659. */
  119660. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  119661. /**
  119662. * Disable the instance attribute corresponding to the name in parameter
  119663. * @param name defines the name of the attribute to disable
  119664. */
  119665. disableInstanceAttributeByName(name: string): void;
  119666. /**
  119667. * Disable the instance attribute corresponding to the location in parameter
  119668. * @param attributeLocation defines the attribute location of the attribute to disable
  119669. */
  119670. disableInstanceAttribute(attributeLocation: number): void;
  119671. /**
  119672. * Disable the attribute corresponding to the location in parameter
  119673. * @param attributeLocation defines the attribute location of the attribute to disable
  119674. */
  119675. disableAttributeByIndex(attributeLocation: number): void;
  119676. /**
  119677. * Send a draw order
  119678. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119679. * @param indexStart defines the starting index
  119680. * @param indexCount defines the number of index to draw
  119681. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119682. */
  119683. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119684. /**
  119685. * Draw a list of points
  119686. * @param verticesStart defines the index of first vertex to draw
  119687. * @param verticesCount defines the count of vertices to draw
  119688. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119689. */
  119690. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119691. /**
  119692. * Draw a list of unindexed primitives
  119693. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119694. * @param verticesStart defines the index of first vertex to draw
  119695. * @param verticesCount defines the count of vertices to draw
  119696. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119697. */
  119698. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119699. /**
  119700. * Draw a list of indexed primitives
  119701. * @param fillMode defines the primitive to use
  119702. * @param indexStart defines the starting index
  119703. * @param indexCount defines the number of index to draw
  119704. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119705. */
  119706. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119707. /**
  119708. * Draw a list of unindexed primitives
  119709. * @param fillMode defines the primitive to use
  119710. * @param verticesStart defines the index of first vertex to draw
  119711. * @param verticesCount defines the count of vertices to draw
  119712. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119713. */
  119714. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119715. private _drawMode;
  119716. /** @hidden */
  119717. protected _reportDrawCall(): void;
  119718. /** @hidden */
  119719. _releaseEffect(effect: Effect): void;
  119720. /** @hidden */
  119721. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  119722. /**
  119723. * Create a new effect (used to store vertex/fragment shaders)
  119724. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  119725. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  119726. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  119727. * @param samplers defines an array of string used to represent textures
  119728. * @param defines defines the string containing the defines to use to compile the shaders
  119729. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119730. * @param onCompiled defines a function to call when the effect creation is successful
  119731. * @param onError defines a function to call when the effect creation has failed
  119732. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  119733. * @returns the new Effect
  119734. */
  119735. 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;
  119736. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  119737. private _compileShader;
  119738. private _compileRawShader;
  119739. /** @hidden */
  119740. _getShaderSource(shader: WebGLShader): Nullable<string>;
  119741. /**
  119742. * Directly creates a webGL program
  119743. * @param pipelineContext defines the pipeline context to attach to
  119744. * @param vertexCode defines the vertex shader code to use
  119745. * @param fragmentCode defines the fragment shader code to use
  119746. * @param context defines the webGL context to use (if not set, the current one will be used)
  119747. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119748. * @returns the new webGL program
  119749. */
  119750. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119751. /**
  119752. * Creates a webGL program
  119753. * @param pipelineContext defines the pipeline context to attach to
  119754. * @param vertexCode defines the vertex shader code to use
  119755. * @param fragmentCode defines the fragment shader code to use
  119756. * @param defines defines the string containing the defines to use to compile the shaders
  119757. * @param context defines the webGL context to use (if not set, the current one will be used)
  119758. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  119759. * @returns the new webGL program
  119760. */
  119761. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119762. /**
  119763. * Creates a new pipeline context
  119764. * @returns the new pipeline
  119765. */
  119766. createPipelineContext(): IPipelineContext;
  119767. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  119768. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  119769. /** @hidden */
  119770. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  119771. /** @hidden */
  119772. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  119773. /** @hidden */
  119774. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  119775. /**
  119776. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119777. * @param pipelineContext defines the pipeline context to use
  119778. * @param uniformsNames defines the list of uniform names
  119779. * @returns an array of webGL uniform locations
  119780. */
  119781. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119782. /**
  119783. * Gets the lsit of active attributes for a given webGL program
  119784. * @param pipelineContext defines the pipeline context to use
  119785. * @param attributesNames defines the list of attribute names to get
  119786. * @returns an array of indices indicating the offset of each attribute
  119787. */
  119788. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119789. /**
  119790. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119791. * @param effect defines the effect to activate
  119792. */
  119793. enableEffect(effect: Nullable<Effect>): void;
  119794. /**
  119795. * Set the value of an uniform to a number (int)
  119796. * @param uniform defines the webGL uniform location where to store the value
  119797. * @param value defines the int number to store
  119798. * @returns true if the value was set
  119799. */
  119800. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119801. /**
  119802. * Set the value of an uniform to an array of int32
  119803. * @param uniform defines the webGL uniform location where to store the value
  119804. * @param array defines the array of int32 to store
  119805. * @returns true if the value was set
  119806. */
  119807. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119808. /**
  119809. * Set the value of an uniform to an array of int32 (stored as vec2)
  119810. * @param uniform defines the webGL uniform location where to store the value
  119811. * @param array defines the array of int32 to store
  119812. * @returns true if the value was set
  119813. */
  119814. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119815. /**
  119816. * Set the value of an uniform to an array of int32 (stored as vec3)
  119817. * @param uniform defines the webGL uniform location where to store the value
  119818. * @param array defines the array of int32 to store
  119819. * @returns true if the value was set
  119820. */
  119821. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119822. /**
  119823. * Set the value of an uniform to an array of int32 (stored as vec4)
  119824. * @param uniform defines the webGL uniform location where to store the value
  119825. * @param array defines the array of int32 to store
  119826. * @returns true if the value was set
  119827. */
  119828. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  119829. /**
  119830. * Set the value of an uniform to an array of number
  119831. * @param uniform defines the webGL uniform location where to store the value
  119832. * @param array defines the array of number to store
  119833. * @returns true if the value was set
  119834. */
  119835. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119836. /**
  119837. * Set the value of an uniform to an array of number (stored as vec2)
  119838. * @param uniform defines the webGL uniform location where to store the value
  119839. * @param array defines the array of number to store
  119840. * @returns true if the value was set
  119841. */
  119842. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119843. /**
  119844. * Set the value of an uniform to an array of number (stored as vec3)
  119845. * @param uniform defines the webGL uniform location where to store the value
  119846. * @param array defines the array of number to store
  119847. * @returns true if the value was set
  119848. */
  119849. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119850. /**
  119851. * Set the value of an uniform to an array of number (stored as vec4)
  119852. * @param uniform defines the webGL uniform location where to store the value
  119853. * @param array defines the array of number to store
  119854. * @returns true if the value was set
  119855. */
  119856. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  119857. /**
  119858. * Set the value of an uniform to an array of float32 (stored as matrices)
  119859. * @param uniform defines the webGL uniform location where to store the value
  119860. * @param matrices defines the array of float32 to store
  119861. * @returns true if the value was set
  119862. */
  119863. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  119864. /**
  119865. * Set the value of an uniform to a matrix (3x3)
  119866. * @param uniform defines the webGL uniform location where to store the value
  119867. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119868. * @returns true if the value was set
  119869. */
  119870. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119871. /**
  119872. * Set the value of an uniform to a matrix (2x2)
  119873. * @param uniform defines the webGL uniform location where to store the value
  119874. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119875. * @returns true if the value was set
  119876. */
  119877. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  119878. /**
  119879. * Set the value of an uniform to a number (float)
  119880. * @param uniform defines the webGL uniform location where to store the value
  119881. * @param value defines the float number to store
  119882. * @returns true if the value was transfered
  119883. */
  119884. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  119885. /**
  119886. * Set the value of an uniform to a vec2
  119887. * @param uniform defines the webGL uniform location where to store the value
  119888. * @param x defines the 1st component of the value
  119889. * @param y defines the 2nd component of the value
  119890. * @returns true if the value was set
  119891. */
  119892. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  119893. /**
  119894. * Set the value of an uniform to a vec3
  119895. * @param uniform defines the webGL uniform location where to store the value
  119896. * @param x defines the 1st component of the value
  119897. * @param y defines the 2nd component of the value
  119898. * @param z defines the 3rd component of the value
  119899. * @returns true if the value was set
  119900. */
  119901. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  119902. /**
  119903. * Set the value of an uniform to a vec4
  119904. * @param uniform defines the webGL uniform location where to store the value
  119905. * @param x defines the 1st component of the value
  119906. * @param y defines the 2nd component of the value
  119907. * @param z defines the 3rd component of the value
  119908. * @param w defines the 4th component of the value
  119909. * @returns true if the value was set
  119910. */
  119911. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  119912. /**
  119913. * Apply all cached states (depth, culling, stencil and alpha)
  119914. */
  119915. applyStates(): void;
  119916. /**
  119917. * Enable or disable color writing
  119918. * @param enable defines the state to set
  119919. */
  119920. setColorWrite(enable: boolean): void;
  119921. /**
  119922. * Gets a boolean indicating if color writing is enabled
  119923. * @returns the current color writing state
  119924. */
  119925. getColorWrite(): boolean;
  119926. /**
  119927. * Gets the depth culling state manager
  119928. */
  119929. get depthCullingState(): DepthCullingState;
  119930. /**
  119931. * Gets the alpha state manager
  119932. */
  119933. get alphaState(): AlphaState;
  119934. /**
  119935. * Gets the stencil state manager
  119936. */
  119937. get stencilState(): StencilState;
  119938. /**
  119939. * Clears the list of texture accessible through engine.
  119940. * This can help preventing texture load conflict due to name collision.
  119941. */
  119942. clearInternalTexturesCache(): void;
  119943. /**
  119944. * Force the entire cache to be cleared
  119945. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119946. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119947. */
  119948. wipeCaches(bruteForce?: boolean): void;
  119949. /** @hidden */
  119950. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  119951. min: number;
  119952. mag: number;
  119953. };
  119954. /** @hidden */
  119955. _createTexture(): WebGLTexture;
  119956. /**
  119957. * Usually called from Texture.ts.
  119958. * Passed information to create a WebGLTexture
  119959. * @param url defines a value which contains one of the following:
  119960. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119961. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119962. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119963. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119964. * @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)
  119965. * @param scene needed for loading to the correct scene
  119966. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119967. * @param onLoad optional callback to be called upon successful completion
  119968. * @param onError optional callback to be called upon failure
  119969. * @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
  119970. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119971. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119972. * @param forcedExtension defines the extension to use to pick the right loader
  119973. * @param mimeType defines an optional mime type
  119974. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119975. */
  119976. 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;
  119977. /**
  119978. * Loads an image as an HTMLImageElement.
  119979. * @param input url string, ArrayBuffer, or Blob to load
  119980. * @param onLoad callback called when the image successfully loads
  119981. * @param onError callback called when the image fails to load
  119982. * @param offlineProvider offline provider for caching
  119983. * @param mimeType optional mime type
  119984. * @returns the HTMLImageElement of the loaded image
  119985. * @hidden
  119986. */
  119987. 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>;
  119988. /**
  119989. * @hidden
  119990. */
  119991. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  119992. private _unpackFlipYCached;
  119993. /**
  119994. * In case you are sharing the context with other applications, it might
  119995. * be interested to not cache the unpack flip y state to ensure a consistent
  119996. * value would be set.
  119997. */
  119998. enableUnpackFlipYCached: boolean;
  119999. /** @hidden */
  120000. _unpackFlipY(value: boolean): void;
  120001. /** @hidden */
  120002. _getUnpackAlignement(): number;
  120003. private _getTextureTarget;
  120004. /**
  120005. * Update the sampling mode of a given texture
  120006. * @param samplingMode defines the required sampling mode
  120007. * @param texture defines the texture to update
  120008. * @param generateMipMaps defines whether to generate mipmaps for the texture
  120009. */
  120010. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  120011. /**
  120012. * Update the sampling mode of a given texture
  120013. * @param texture defines the texture to update
  120014. * @param wrapU defines the texture wrap mode of the u coordinates
  120015. * @param wrapV defines the texture wrap mode of the v coordinates
  120016. * @param wrapR defines the texture wrap mode of the r coordinates
  120017. */
  120018. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  120019. /** @hidden */
  120020. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  120021. width: number;
  120022. height: number;
  120023. layers?: number;
  120024. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  120025. /** @hidden */
  120026. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120027. /** @hidden */
  120028. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  120029. /**
  120030. * Update a portion of an internal texture
  120031. * @param texture defines the texture to update
  120032. * @param imageData defines the data to store into the texture
  120033. * @param xOffset defines the x coordinates of the update rectangle
  120034. * @param yOffset defines the y coordinates of the update rectangle
  120035. * @param width defines the width of the update rectangle
  120036. * @param height defines the height of the update rectangle
  120037. * @param faceIndex defines the face index if texture is a cube (0 by default)
  120038. * @param lod defines the lod level to update (0 by default)
  120039. */
  120040. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  120041. /** @hidden */
  120042. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120043. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  120044. private _prepareWebGLTexture;
  120045. /** @hidden */
  120046. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  120047. private _getDepthStencilBuffer;
  120048. /** @hidden */
  120049. _releaseFramebufferObjects(texture: InternalTexture): void;
  120050. /** @hidden */
  120051. _releaseTexture(texture: InternalTexture): void;
  120052. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120053. protected _setProgram(program: WebGLProgram): void;
  120054. protected _boundUniforms: {
  120055. [key: number]: WebGLUniformLocation;
  120056. };
  120057. /**
  120058. * Binds an effect to the webGL context
  120059. * @param effect defines the effect to bind
  120060. */
  120061. bindSamplers(effect: Effect): void;
  120062. private _activateCurrentTexture;
  120063. /** @hidden */
  120064. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  120065. /** @hidden */
  120066. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  120067. /**
  120068. * Unbind all textures from the webGL context
  120069. */
  120070. unbindAllTextures(): void;
  120071. /**
  120072. * Sets a texture to the according uniform.
  120073. * @param channel The texture channel
  120074. * @param uniform The uniform to set
  120075. * @param texture The texture to apply
  120076. */
  120077. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  120078. private _bindSamplerUniformToChannel;
  120079. private _getTextureWrapMode;
  120080. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120081. /**
  120082. * Sets an array of texture to the webGL context
  120083. * @param channel defines the channel where the texture array must be set
  120084. * @param uniform defines the associated uniform location
  120085. * @param textures defines the array of textures to bind
  120086. */
  120087. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  120088. /** @hidden */
  120089. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  120090. private _setTextureParameterFloat;
  120091. private _setTextureParameterInteger;
  120092. /**
  120093. * Unbind all vertex attributes from the webGL context
  120094. */
  120095. unbindAllAttributes(): void;
  120096. /**
  120097. * 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
  120098. */
  120099. releaseEffects(): void;
  120100. /**
  120101. * Dispose and release all associated resources
  120102. */
  120103. dispose(): void;
  120104. /**
  120105. * Attach a new callback raised when context lost event is fired
  120106. * @param callback defines the callback to call
  120107. */
  120108. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120109. /**
  120110. * Attach a new callback raised when context restored event is fired
  120111. * @param callback defines the callback to call
  120112. */
  120113. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120114. /**
  120115. * Get the current error code of the webGL context
  120116. * @returns the error code
  120117. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120118. */
  120119. getError(): number;
  120120. private _canRenderToFloatFramebuffer;
  120121. private _canRenderToHalfFloatFramebuffer;
  120122. private _canRenderToFramebuffer;
  120123. /** @hidden */
  120124. _getWebGLTextureType(type: number): number;
  120125. /** @hidden */
  120126. _getInternalFormat(format: number): number;
  120127. /** @hidden */
  120128. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  120129. /** @hidden */
  120130. _getRGBAMultiSampleBufferFormat(type: number): number;
  120131. /** @hidden */
  120132. _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;
  120133. /**
  120134. * Loads a file from a url
  120135. * @param url url to load
  120136. * @param onSuccess callback called when the file successfully loads
  120137. * @param onProgress callback called while file is loading (if the server supports this mode)
  120138. * @param offlineProvider defines the offline provider for caching
  120139. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  120140. * @param onError callback called when the file fails to load
  120141. * @returns a file request object
  120142. * @hidden
  120143. */
  120144. 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;
  120145. /**
  120146. * Reads pixels from the current frame buffer. Please note that this function can be slow
  120147. * @param x defines the x coordinate of the rectangle where pixels must be read
  120148. * @param y defines the y coordinate of the rectangle where pixels must be read
  120149. * @param width defines the width of the rectangle where pixels must be read
  120150. * @param height defines the height of the rectangle where pixels must be read
  120151. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  120152. * @returns a Uint8Array containing RGBA colors
  120153. */
  120154. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  120155. private static _IsSupported;
  120156. private static _HasMajorPerformanceCaveat;
  120157. /**
  120158. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120159. */
  120160. static get IsSupported(): boolean;
  120161. /**
  120162. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120163. * @returns true if the engine can be created
  120164. * @ignorenaming
  120165. */
  120166. static isSupported(): boolean;
  120167. /**
  120168. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  120169. */
  120170. static get HasMajorPerformanceCaveat(): boolean;
  120171. /**
  120172. * Find the next highest power of two.
  120173. * @param x Number to start search from.
  120174. * @return Next highest power of two.
  120175. */
  120176. static CeilingPOT(x: number): number;
  120177. /**
  120178. * Find the next lowest power of two.
  120179. * @param x Number to start search from.
  120180. * @return Next lowest power of two.
  120181. */
  120182. static FloorPOT(x: number): number;
  120183. /**
  120184. * Find the nearest power of two.
  120185. * @param x Number to start search from.
  120186. * @return Next nearest power of two.
  120187. */
  120188. static NearestPOT(x: number): number;
  120189. /**
  120190. * Get the closest exponent of two
  120191. * @param value defines the value to approximate
  120192. * @param max defines the maximum value to return
  120193. * @param mode defines how to define the closest value
  120194. * @returns closest exponent of two of the given value
  120195. */
  120196. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  120197. /**
  120198. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  120199. * @param func - the function to be called
  120200. * @param requester - the object that will request the next frame. Falls back to window.
  120201. * @returns frame number
  120202. */
  120203. static QueueNewFrame(func: () => void, requester?: any): number;
  120204. /**
  120205. * Gets host document
  120206. * @returns the host document object
  120207. */
  120208. getHostDocument(): Nullable<Document>;
  120209. }
  120210. }
  120211. declare module BABYLON {
  120212. /**
  120213. * Defines the source of the internal texture
  120214. */
  120215. export enum InternalTextureSource {
  120216. /**
  120217. * The source of the texture data is unknown
  120218. */
  120219. Unknown = 0,
  120220. /**
  120221. * Texture data comes from an URL
  120222. */
  120223. Url = 1,
  120224. /**
  120225. * Texture data is only used for temporary storage
  120226. */
  120227. Temp = 2,
  120228. /**
  120229. * Texture data comes from raw data (ArrayBuffer)
  120230. */
  120231. Raw = 3,
  120232. /**
  120233. * Texture content is dynamic (video or dynamic texture)
  120234. */
  120235. Dynamic = 4,
  120236. /**
  120237. * Texture content is generated by rendering to it
  120238. */
  120239. RenderTarget = 5,
  120240. /**
  120241. * Texture content is part of a multi render target process
  120242. */
  120243. MultiRenderTarget = 6,
  120244. /**
  120245. * Texture data comes from a cube data file
  120246. */
  120247. Cube = 7,
  120248. /**
  120249. * Texture data comes from a raw cube data
  120250. */
  120251. CubeRaw = 8,
  120252. /**
  120253. * Texture data come from a prefiltered cube data file
  120254. */
  120255. CubePrefiltered = 9,
  120256. /**
  120257. * Texture content is raw 3D data
  120258. */
  120259. Raw3D = 10,
  120260. /**
  120261. * Texture content is raw 2D array data
  120262. */
  120263. Raw2DArray = 11,
  120264. /**
  120265. * Texture content is a depth texture
  120266. */
  120267. Depth = 12,
  120268. /**
  120269. * Texture data comes from a raw cube data encoded with RGBD
  120270. */
  120271. CubeRawRGBD = 13
  120272. }
  120273. /**
  120274. * Class used to store data associated with WebGL texture data for the engine
  120275. * This class should not be used directly
  120276. */
  120277. export class InternalTexture {
  120278. /** @hidden */
  120279. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  120280. /**
  120281. * Defines if the texture is ready
  120282. */
  120283. isReady: boolean;
  120284. /**
  120285. * Defines if the texture is a cube texture
  120286. */
  120287. isCube: boolean;
  120288. /**
  120289. * Defines if the texture contains 3D data
  120290. */
  120291. is3D: boolean;
  120292. /**
  120293. * Defines if the texture contains 2D array data
  120294. */
  120295. is2DArray: boolean;
  120296. /**
  120297. * Defines if the texture contains multiview data
  120298. */
  120299. isMultiview: boolean;
  120300. /**
  120301. * Gets the URL used to load this texture
  120302. */
  120303. url: string;
  120304. /**
  120305. * Gets the sampling mode of the texture
  120306. */
  120307. samplingMode: number;
  120308. /**
  120309. * Gets a boolean indicating if the texture needs mipmaps generation
  120310. */
  120311. generateMipMaps: boolean;
  120312. /**
  120313. * Gets the number of samples used by the texture (WebGL2+ only)
  120314. */
  120315. samples: number;
  120316. /**
  120317. * Gets the type of the texture (int, float...)
  120318. */
  120319. type: number;
  120320. /**
  120321. * Gets the format of the texture (RGB, RGBA...)
  120322. */
  120323. format: number;
  120324. /**
  120325. * Observable called when the texture is loaded
  120326. */
  120327. onLoadedObservable: Observable<InternalTexture>;
  120328. /**
  120329. * Gets the width of the texture
  120330. */
  120331. width: number;
  120332. /**
  120333. * Gets the height of the texture
  120334. */
  120335. height: number;
  120336. /**
  120337. * Gets the depth of the texture
  120338. */
  120339. depth: number;
  120340. /**
  120341. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  120342. */
  120343. baseWidth: number;
  120344. /**
  120345. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  120346. */
  120347. baseHeight: number;
  120348. /**
  120349. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  120350. */
  120351. baseDepth: number;
  120352. /**
  120353. * Gets a boolean indicating if the texture is inverted on Y axis
  120354. */
  120355. invertY: boolean;
  120356. /** @hidden */
  120357. _invertVScale: boolean;
  120358. /** @hidden */
  120359. _associatedChannel: number;
  120360. /** @hidden */
  120361. _source: InternalTextureSource;
  120362. /** @hidden */
  120363. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  120364. /** @hidden */
  120365. _bufferView: Nullable<ArrayBufferView>;
  120366. /** @hidden */
  120367. _bufferViewArray: Nullable<ArrayBufferView[]>;
  120368. /** @hidden */
  120369. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  120370. /** @hidden */
  120371. _size: number;
  120372. /** @hidden */
  120373. _extension: string;
  120374. /** @hidden */
  120375. _files: Nullable<string[]>;
  120376. /** @hidden */
  120377. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120378. /** @hidden */
  120379. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120380. /** @hidden */
  120381. _framebuffer: Nullable<WebGLFramebuffer>;
  120382. /** @hidden */
  120383. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  120384. /** @hidden */
  120385. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  120386. /** @hidden */
  120387. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  120388. /** @hidden */
  120389. _attachments: Nullable<number[]>;
  120390. /** @hidden */
  120391. _textureArray: Nullable<InternalTexture[]>;
  120392. /** @hidden */
  120393. _cachedCoordinatesMode: Nullable<number>;
  120394. /** @hidden */
  120395. _cachedWrapU: Nullable<number>;
  120396. /** @hidden */
  120397. _cachedWrapV: Nullable<number>;
  120398. /** @hidden */
  120399. _cachedWrapR: Nullable<number>;
  120400. /** @hidden */
  120401. _cachedAnisotropicFilteringLevel: Nullable<number>;
  120402. /** @hidden */
  120403. _isDisabled: boolean;
  120404. /** @hidden */
  120405. _compression: Nullable<string>;
  120406. /** @hidden */
  120407. _generateStencilBuffer: boolean;
  120408. /** @hidden */
  120409. _generateDepthBuffer: boolean;
  120410. /** @hidden */
  120411. _comparisonFunction: number;
  120412. /** @hidden */
  120413. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  120414. /** @hidden */
  120415. _lodGenerationScale: number;
  120416. /** @hidden */
  120417. _lodGenerationOffset: number;
  120418. /** @hidden */
  120419. _depthStencilTexture: Nullable<InternalTexture>;
  120420. /** @hidden */
  120421. _colorTextureArray: Nullable<WebGLTexture>;
  120422. /** @hidden */
  120423. _depthStencilTextureArray: Nullable<WebGLTexture>;
  120424. /** @hidden */
  120425. _lodTextureHigh: Nullable<BaseTexture>;
  120426. /** @hidden */
  120427. _lodTextureMid: Nullable<BaseTexture>;
  120428. /** @hidden */
  120429. _lodTextureLow: Nullable<BaseTexture>;
  120430. /** @hidden */
  120431. _isRGBD: boolean;
  120432. /** @hidden */
  120433. _linearSpecularLOD: boolean;
  120434. /** @hidden */
  120435. _irradianceTexture: Nullable<BaseTexture>;
  120436. /** @hidden */
  120437. _webGLTexture: Nullable<WebGLTexture>;
  120438. /** @hidden */
  120439. _references: number;
  120440. /** @hidden */
  120441. _gammaSpace: Nullable<boolean>;
  120442. private _engine;
  120443. /**
  120444. * Gets the Engine the texture belongs to.
  120445. * @returns The babylon engine
  120446. */
  120447. getEngine(): ThinEngine;
  120448. /**
  120449. * Gets the data source type of the texture
  120450. */
  120451. get source(): InternalTextureSource;
  120452. /**
  120453. * Creates a new InternalTexture
  120454. * @param engine defines the engine to use
  120455. * @param source defines the type of data that will be used
  120456. * @param delayAllocation if the texture allocation should be delayed (default: false)
  120457. */
  120458. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  120459. /**
  120460. * Increments the number of references (ie. the number of Texture that point to it)
  120461. */
  120462. incrementReferences(): void;
  120463. /**
  120464. * Change the size of the texture (not the size of the content)
  120465. * @param width defines the new width
  120466. * @param height defines the new height
  120467. * @param depth defines the new depth (1 by default)
  120468. */
  120469. updateSize(width: int, height: int, depth?: int): void;
  120470. /** @hidden */
  120471. _rebuild(): void;
  120472. /** @hidden */
  120473. _swapAndDie(target: InternalTexture): void;
  120474. /**
  120475. * Dispose the current allocated resources
  120476. */
  120477. dispose(): void;
  120478. }
  120479. }
  120480. declare module BABYLON {
  120481. /**
  120482. * Class used to work with sound analyzer using fast fourier transform (FFT)
  120483. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120484. */
  120485. export class Analyser {
  120486. /**
  120487. * Gets or sets the smoothing
  120488. * @ignorenaming
  120489. */
  120490. SMOOTHING: number;
  120491. /**
  120492. * Gets or sets the FFT table size
  120493. * @ignorenaming
  120494. */
  120495. FFT_SIZE: number;
  120496. /**
  120497. * Gets or sets the bar graph amplitude
  120498. * @ignorenaming
  120499. */
  120500. BARGRAPHAMPLITUDE: number;
  120501. /**
  120502. * Gets or sets the position of the debug canvas
  120503. * @ignorenaming
  120504. */
  120505. DEBUGCANVASPOS: {
  120506. x: number;
  120507. y: number;
  120508. };
  120509. /**
  120510. * Gets or sets the debug canvas size
  120511. * @ignorenaming
  120512. */
  120513. DEBUGCANVASSIZE: {
  120514. width: number;
  120515. height: number;
  120516. };
  120517. private _byteFreqs;
  120518. private _byteTime;
  120519. private _floatFreqs;
  120520. private _webAudioAnalyser;
  120521. private _debugCanvas;
  120522. private _debugCanvasContext;
  120523. private _scene;
  120524. private _registerFunc;
  120525. private _audioEngine;
  120526. /**
  120527. * Creates a new analyser
  120528. * @param scene defines hosting scene
  120529. */
  120530. constructor(scene: Scene);
  120531. /**
  120532. * Get the number of data values you will have to play with for the visualization
  120533. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  120534. * @returns a number
  120535. */
  120536. getFrequencyBinCount(): number;
  120537. /**
  120538. * Gets the current frequency data as a byte array
  120539. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120540. * @returns a Uint8Array
  120541. */
  120542. getByteFrequencyData(): Uint8Array;
  120543. /**
  120544. * Gets the current waveform as a byte array
  120545. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  120546. * @returns a Uint8Array
  120547. */
  120548. getByteTimeDomainData(): Uint8Array;
  120549. /**
  120550. * Gets the current frequency data as a float array
  120551. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  120552. * @returns a Float32Array
  120553. */
  120554. getFloatFrequencyData(): Float32Array;
  120555. /**
  120556. * Renders the debug canvas
  120557. */
  120558. drawDebugCanvas(): void;
  120559. /**
  120560. * Stops rendering the debug canvas and removes it
  120561. */
  120562. stopDebugCanvas(): void;
  120563. /**
  120564. * Connects two audio nodes
  120565. * @param inputAudioNode defines first node to connect
  120566. * @param outputAudioNode defines second node to connect
  120567. */
  120568. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  120569. /**
  120570. * Releases all associated resources
  120571. */
  120572. dispose(): void;
  120573. }
  120574. }
  120575. declare module BABYLON {
  120576. /**
  120577. * This represents an audio engine and it is responsible
  120578. * to play, synchronize and analyse sounds throughout the application.
  120579. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120580. */
  120581. export interface IAudioEngine extends IDisposable {
  120582. /**
  120583. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120584. */
  120585. readonly canUseWebAudio: boolean;
  120586. /**
  120587. * Gets the current AudioContext if available.
  120588. */
  120589. readonly audioContext: Nullable<AudioContext>;
  120590. /**
  120591. * The master gain node defines the global audio volume of your audio engine.
  120592. */
  120593. readonly masterGain: GainNode;
  120594. /**
  120595. * Gets whether or not mp3 are supported by your browser.
  120596. */
  120597. readonly isMP3supported: boolean;
  120598. /**
  120599. * Gets whether or not ogg are supported by your browser.
  120600. */
  120601. readonly isOGGsupported: boolean;
  120602. /**
  120603. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120604. * @ignoreNaming
  120605. */
  120606. WarnedWebAudioUnsupported: boolean;
  120607. /**
  120608. * Defines if the audio engine relies on a custom unlocked button.
  120609. * In this case, the embedded button will not be displayed.
  120610. */
  120611. useCustomUnlockedButton: boolean;
  120612. /**
  120613. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  120614. */
  120615. readonly unlocked: boolean;
  120616. /**
  120617. * Event raised when audio has been unlocked on the browser.
  120618. */
  120619. onAudioUnlockedObservable: Observable<AudioEngine>;
  120620. /**
  120621. * Event raised when audio has been locked on the browser.
  120622. */
  120623. onAudioLockedObservable: Observable<AudioEngine>;
  120624. /**
  120625. * Flags the audio engine in Locked state.
  120626. * This happens due to new browser policies preventing audio to autoplay.
  120627. */
  120628. lock(): void;
  120629. /**
  120630. * Unlocks the audio engine once a user action has been done on the dom.
  120631. * This is helpful to resume play once browser policies have been satisfied.
  120632. */
  120633. unlock(): void;
  120634. /**
  120635. * Gets the global volume sets on the master gain.
  120636. * @returns the global volume if set or -1 otherwise
  120637. */
  120638. getGlobalVolume(): number;
  120639. /**
  120640. * Sets the global volume of your experience (sets on the master gain).
  120641. * @param newVolume Defines the new global volume of the application
  120642. */
  120643. setGlobalVolume(newVolume: number): void;
  120644. /**
  120645. * Connect the audio engine to an audio analyser allowing some amazing
  120646. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120648. * @param analyser The analyser to connect to the engine
  120649. */
  120650. connectToAnalyser(analyser: Analyser): void;
  120651. }
  120652. /**
  120653. * This represents the default audio engine used in babylon.
  120654. * It is responsible to play, synchronize and analyse sounds throughout the application.
  120655. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120656. */
  120657. export class AudioEngine implements IAudioEngine {
  120658. private _audioContext;
  120659. private _audioContextInitialized;
  120660. private _muteButton;
  120661. private _hostElement;
  120662. /**
  120663. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  120664. */
  120665. canUseWebAudio: boolean;
  120666. /**
  120667. * The master gain node defines the global audio volume of your audio engine.
  120668. */
  120669. masterGain: GainNode;
  120670. /**
  120671. * Defines if Babylon should emit a warning if WebAudio is not supported.
  120672. * @ignoreNaming
  120673. */
  120674. WarnedWebAudioUnsupported: boolean;
  120675. /**
  120676. * Gets whether or not mp3 are supported by your browser.
  120677. */
  120678. isMP3supported: boolean;
  120679. /**
  120680. * Gets whether or not ogg are supported by your browser.
  120681. */
  120682. isOGGsupported: boolean;
  120683. /**
  120684. * Gets whether audio has been unlocked on the device.
  120685. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  120686. * a user interaction has happened.
  120687. */
  120688. unlocked: boolean;
  120689. /**
  120690. * Defines if the audio engine relies on a custom unlocked button.
  120691. * In this case, the embedded button will not be displayed.
  120692. */
  120693. useCustomUnlockedButton: boolean;
  120694. /**
  120695. * Event raised when audio has been unlocked on the browser.
  120696. */
  120697. onAudioUnlockedObservable: Observable<AudioEngine>;
  120698. /**
  120699. * Event raised when audio has been locked on the browser.
  120700. */
  120701. onAudioLockedObservable: Observable<AudioEngine>;
  120702. /**
  120703. * Gets the current AudioContext if available.
  120704. */
  120705. get audioContext(): Nullable<AudioContext>;
  120706. private _connectedAnalyser;
  120707. /**
  120708. * Instantiates a new audio engine.
  120709. *
  120710. * There should be only one per page as some browsers restrict the number
  120711. * of audio contexts you can create.
  120712. * @param hostElement defines the host element where to display the mute icon if necessary
  120713. */
  120714. constructor(hostElement?: Nullable<HTMLElement>);
  120715. /**
  120716. * Flags the audio engine in Locked state.
  120717. * This happens due to new browser policies preventing audio to autoplay.
  120718. */
  120719. lock(): void;
  120720. /**
  120721. * Unlocks the audio engine once a user action has been done on the dom.
  120722. * This is helpful to resume play once browser policies have been satisfied.
  120723. */
  120724. unlock(): void;
  120725. private _resumeAudioContext;
  120726. private _initializeAudioContext;
  120727. private _tryToRun;
  120728. private _triggerRunningState;
  120729. private _triggerSuspendedState;
  120730. private _displayMuteButton;
  120731. private _moveButtonToTopLeft;
  120732. private _onResize;
  120733. private _hideMuteButton;
  120734. /**
  120735. * Destroy and release the resources associated with the audio ccontext.
  120736. */
  120737. dispose(): void;
  120738. /**
  120739. * Gets the global volume sets on the master gain.
  120740. * @returns the global volume if set or -1 otherwise
  120741. */
  120742. getGlobalVolume(): number;
  120743. /**
  120744. * Sets the global volume of your experience (sets on the master gain).
  120745. * @param newVolume Defines the new global volume of the application
  120746. */
  120747. setGlobalVolume(newVolume: number): void;
  120748. /**
  120749. * Connect the audio engine to an audio analyser allowing some amazing
  120750. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120751. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120752. * @param analyser The analyser to connect to the engine
  120753. */
  120754. connectToAnalyser(analyser: Analyser): void;
  120755. }
  120756. }
  120757. declare module BABYLON {
  120758. /**
  120759. * Interface used to present a loading screen while loading a scene
  120760. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120761. */
  120762. export interface ILoadingScreen {
  120763. /**
  120764. * Function called to display the loading screen
  120765. */
  120766. displayLoadingUI: () => void;
  120767. /**
  120768. * Function called to hide the loading screen
  120769. */
  120770. hideLoadingUI: () => void;
  120771. /**
  120772. * Gets or sets the color to use for the background
  120773. */
  120774. loadingUIBackgroundColor: string;
  120775. /**
  120776. * Gets or sets the text to display while loading
  120777. */
  120778. loadingUIText: string;
  120779. }
  120780. /**
  120781. * Class used for the default loading screen
  120782. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120783. */
  120784. export class DefaultLoadingScreen implements ILoadingScreen {
  120785. private _renderingCanvas;
  120786. private _loadingText;
  120787. private _loadingDivBackgroundColor;
  120788. private _loadingDiv;
  120789. private _loadingTextDiv;
  120790. /** Gets or sets the logo url to use for the default loading screen */
  120791. static DefaultLogoUrl: string;
  120792. /** Gets or sets the spinner url to use for the default loading screen */
  120793. static DefaultSpinnerUrl: string;
  120794. /**
  120795. * Creates a new default loading screen
  120796. * @param _renderingCanvas defines the canvas used to render the scene
  120797. * @param _loadingText defines the default text to display
  120798. * @param _loadingDivBackgroundColor defines the default background color
  120799. */
  120800. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  120801. /**
  120802. * Function called to display the loading screen
  120803. */
  120804. displayLoadingUI(): void;
  120805. /**
  120806. * Function called to hide the loading screen
  120807. */
  120808. hideLoadingUI(): void;
  120809. /**
  120810. * Gets or sets the text to display while loading
  120811. */
  120812. set loadingUIText(text: string);
  120813. get loadingUIText(): string;
  120814. /**
  120815. * Gets or sets the color to use for the background
  120816. */
  120817. get loadingUIBackgroundColor(): string;
  120818. set loadingUIBackgroundColor(color: string);
  120819. private _resizeLoadingUI;
  120820. }
  120821. }
  120822. declare module BABYLON {
  120823. /**
  120824. * Interface for any object that can request an animation frame
  120825. */
  120826. export interface ICustomAnimationFrameRequester {
  120827. /**
  120828. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  120829. */
  120830. renderFunction?: Function;
  120831. /**
  120832. * Called to request the next frame to render to
  120833. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  120834. */
  120835. requestAnimationFrame: Function;
  120836. /**
  120837. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  120838. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  120839. */
  120840. requestID?: number;
  120841. }
  120842. }
  120843. declare module BABYLON {
  120844. /**
  120845. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  120846. */
  120847. export class PerformanceMonitor {
  120848. private _enabled;
  120849. private _rollingFrameTime;
  120850. private _lastFrameTimeMs;
  120851. /**
  120852. * constructor
  120853. * @param frameSampleSize The number of samples required to saturate the sliding window
  120854. */
  120855. constructor(frameSampleSize?: number);
  120856. /**
  120857. * Samples current frame
  120858. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  120859. */
  120860. sampleFrame(timeMs?: number): void;
  120861. /**
  120862. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120863. */
  120864. get averageFrameTime(): number;
  120865. /**
  120866. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  120867. */
  120868. get averageFrameTimeVariance(): number;
  120869. /**
  120870. * Returns the frame time of the most recent frame
  120871. */
  120872. get instantaneousFrameTime(): number;
  120873. /**
  120874. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  120875. */
  120876. get averageFPS(): number;
  120877. /**
  120878. * Returns the average framerate in frames per second using the most recent frame time
  120879. */
  120880. get instantaneousFPS(): number;
  120881. /**
  120882. * Returns true if enough samples have been taken to completely fill the sliding window
  120883. */
  120884. get isSaturated(): boolean;
  120885. /**
  120886. * Enables contributions to the sliding window sample set
  120887. */
  120888. enable(): void;
  120889. /**
  120890. * Disables contributions to the sliding window sample set
  120891. * Samples will not be interpolated over the disabled period
  120892. */
  120893. disable(): void;
  120894. /**
  120895. * Returns true if sampling is enabled
  120896. */
  120897. get isEnabled(): boolean;
  120898. /**
  120899. * Resets performance monitor
  120900. */
  120901. reset(): void;
  120902. }
  120903. /**
  120904. * RollingAverage
  120905. *
  120906. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  120907. */
  120908. export class RollingAverage {
  120909. /**
  120910. * Current average
  120911. */
  120912. average: number;
  120913. /**
  120914. * Current variance
  120915. */
  120916. variance: number;
  120917. protected _samples: Array<number>;
  120918. protected _sampleCount: number;
  120919. protected _pos: number;
  120920. protected _m2: number;
  120921. /**
  120922. * constructor
  120923. * @param length The number of samples required to saturate the sliding window
  120924. */
  120925. constructor(length: number);
  120926. /**
  120927. * Adds a sample to the sample set
  120928. * @param v The sample value
  120929. */
  120930. add(v: number): void;
  120931. /**
  120932. * Returns previously added values or null if outside of history or outside the sliding window domain
  120933. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  120934. * @return Value previously recorded with add() or null if outside of range
  120935. */
  120936. history(i: number): number;
  120937. /**
  120938. * Returns true if enough samples have been taken to completely fill the sliding window
  120939. * @return true if sample-set saturated
  120940. */
  120941. isSaturated(): boolean;
  120942. /**
  120943. * Resets the rolling average (equivalent to 0 samples taken so far)
  120944. */
  120945. reset(): void;
  120946. /**
  120947. * Wraps a value around the sample range boundaries
  120948. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  120949. * @return Wrapped position in sample range
  120950. */
  120951. protected _wrapPosition(i: number): number;
  120952. }
  120953. }
  120954. declare module BABYLON {
  120955. /**
  120956. * This class is used to track a performance counter which is number based.
  120957. * The user has access to many properties which give statistics of different nature.
  120958. *
  120959. * The implementer can track two kinds of Performance Counter: time and count.
  120960. * 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.
  120961. * 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.
  120962. */
  120963. export class PerfCounter {
  120964. /**
  120965. * Gets or sets a global boolean to turn on and off all the counters
  120966. */
  120967. static Enabled: boolean;
  120968. /**
  120969. * Returns the smallest value ever
  120970. */
  120971. get min(): number;
  120972. /**
  120973. * Returns the biggest value ever
  120974. */
  120975. get max(): number;
  120976. /**
  120977. * Returns the average value since the performance counter is running
  120978. */
  120979. get average(): number;
  120980. /**
  120981. * Returns the average value of the last second the counter was monitored
  120982. */
  120983. get lastSecAverage(): number;
  120984. /**
  120985. * Returns the current value
  120986. */
  120987. get current(): number;
  120988. /**
  120989. * Gets the accumulated total
  120990. */
  120991. get total(): number;
  120992. /**
  120993. * Gets the total value count
  120994. */
  120995. get count(): number;
  120996. /**
  120997. * Creates a new counter
  120998. */
  120999. constructor();
  121000. /**
  121001. * Call this method to start monitoring a new frame.
  121002. * 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.
  121003. */
  121004. fetchNewFrame(): void;
  121005. /**
  121006. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  121007. * @param newCount the count value to add to the monitored count
  121008. * @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.
  121009. */
  121010. addCount(newCount: number, fetchResult: boolean): void;
  121011. /**
  121012. * Start monitoring this performance counter
  121013. */
  121014. beginMonitoring(): void;
  121015. /**
  121016. * Compute the time lapsed since the previous beginMonitoring() call.
  121017. * @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
  121018. */
  121019. endMonitoring(newFrame?: boolean): void;
  121020. private _fetchResult;
  121021. private _startMonitoringTime;
  121022. private _min;
  121023. private _max;
  121024. private _average;
  121025. private _current;
  121026. private _totalValueCount;
  121027. private _totalAccumulated;
  121028. private _lastSecAverage;
  121029. private _lastSecAccumulated;
  121030. private _lastSecTime;
  121031. private _lastSecValueCount;
  121032. }
  121033. }
  121034. declare module BABYLON {
  121035. interface ThinEngine {
  121036. /** @hidden */
  121037. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  121038. }
  121039. }
  121040. declare module BABYLON {
  121041. /**
  121042. * Defines the interface used by display changed events
  121043. */
  121044. export interface IDisplayChangedEventArgs {
  121045. /** Gets the vrDisplay object (if any) */
  121046. vrDisplay: Nullable<any>;
  121047. /** Gets a boolean indicating if webVR is supported */
  121048. vrSupported: boolean;
  121049. }
  121050. /**
  121051. * Defines the interface used by objects containing a viewport (like a camera)
  121052. */
  121053. interface IViewportOwnerLike {
  121054. /**
  121055. * Gets or sets the viewport
  121056. */
  121057. viewport: IViewportLike;
  121058. }
  121059. /**
  121060. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  121061. */
  121062. export class Engine extends ThinEngine {
  121063. /** Defines that alpha blending is disabled */
  121064. static readonly ALPHA_DISABLE: number;
  121065. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  121066. static readonly ALPHA_ADD: number;
  121067. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  121068. static readonly ALPHA_COMBINE: number;
  121069. /** Defines that alpha blending to DEST - SRC * DEST */
  121070. static readonly ALPHA_SUBTRACT: number;
  121071. /** Defines that alpha blending to SRC * DEST */
  121072. static readonly ALPHA_MULTIPLY: number;
  121073. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  121074. static readonly ALPHA_MAXIMIZED: number;
  121075. /** Defines that alpha blending to SRC + DEST */
  121076. static readonly ALPHA_ONEONE: number;
  121077. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  121078. static readonly ALPHA_PREMULTIPLIED: number;
  121079. /**
  121080. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  121081. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  121082. */
  121083. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  121084. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  121085. static readonly ALPHA_INTERPOLATE: number;
  121086. /**
  121087. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  121088. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  121089. */
  121090. static readonly ALPHA_SCREENMODE: number;
  121091. /** Defines that the ressource is not delayed*/
  121092. static readonly DELAYLOADSTATE_NONE: number;
  121093. /** Defines that the ressource was successfully delay loaded */
  121094. static readonly DELAYLOADSTATE_LOADED: number;
  121095. /** Defines that the ressource is currently delay loading */
  121096. static readonly DELAYLOADSTATE_LOADING: number;
  121097. /** Defines that the ressource is delayed and has not started loading */
  121098. static readonly DELAYLOADSTATE_NOTLOADED: number;
  121099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  121100. static readonly NEVER: number;
  121101. /** 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 */
  121102. static readonly ALWAYS: number;
  121103. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  121104. static readonly LESS: number;
  121105. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  121106. static readonly EQUAL: number;
  121107. /** 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 */
  121108. static readonly LEQUAL: number;
  121109. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  121110. static readonly GREATER: number;
  121111. /** 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 */
  121112. static readonly GEQUAL: number;
  121113. /** 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 */
  121114. static readonly NOTEQUAL: number;
  121115. /** Passed to stencilOperation to specify that stencil value must be kept */
  121116. static readonly KEEP: number;
  121117. /** Passed to stencilOperation to specify that stencil value must be replaced */
  121118. static readonly REPLACE: number;
  121119. /** Passed to stencilOperation to specify that stencil value must be incremented */
  121120. static readonly INCR: number;
  121121. /** Passed to stencilOperation to specify that stencil value must be decremented */
  121122. static readonly DECR: number;
  121123. /** Passed to stencilOperation to specify that stencil value must be inverted */
  121124. static readonly INVERT: number;
  121125. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  121126. static readonly INCR_WRAP: number;
  121127. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  121128. static readonly DECR_WRAP: number;
  121129. /** Texture is not repeating outside of 0..1 UVs */
  121130. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  121131. /** Texture is repeating outside of 0..1 UVs */
  121132. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  121133. /** Texture is repeating and mirrored */
  121134. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  121135. /** ALPHA */
  121136. static readonly TEXTUREFORMAT_ALPHA: number;
  121137. /** LUMINANCE */
  121138. static readonly TEXTUREFORMAT_LUMINANCE: number;
  121139. /** LUMINANCE_ALPHA */
  121140. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  121141. /** RGB */
  121142. static readonly TEXTUREFORMAT_RGB: number;
  121143. /** RGBA */
  121144. static readonly TEXTUREFORMAT_RGBA: number;
  121145. /** RED */
  121146. static readonly TEXTUREFORMAT_RED: number;
  121147. /** RED (2nd reference) */
  121148. static readonly TEXTUREFORMAT_R: number;
  121149. /** RG */
  121150. static readonly TEXTUREFORMAT_RG: number;
  121151. /** RED_INTEGER */
  121152. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121153. /** RED_INTEGER (2nd reference) */
  121154. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121155. /** RG_INTEGER */
  121156. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121157. /** RGB_INTEGER */
  121158. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121159. /** RGBA_INTEGER */
  121160. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121161. /** UNSIGNED_BYTE */
  121162. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121163. /** UNSIGNED_BYTE (2nd reference) */
  121164. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121165. /** FLOAT */
  121166. static readonly TEXTURETYPE_FLOAT: number;
  121167. /** HALF_FLOAT */
  121168. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121169. /** BYTE */
  121170. static readonly TEXTURETYPE_BYTE: number;
  121171. /** SHORT */
  121172. static readonly TEXTURETYPE_SHORT: number;
  121173. /** UNSIGNED_SHORT */
  121174. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121175. /** INT */
  121176. static readonly TEXTURETYPE_INT: number;
  121177. /** UNSIGNED_INT */
  121178. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121179. /** UNSIGNED_SHORT_4_4_4_4 */
  121180. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121181. /** UNSIGNED_SHORT_5_5_5_1 */
  121182. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121183. /** UNSIGNED_SHORT_5_6_5 */
  121184. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121185. /** UNSIGNED_INT_2_10_10_10_REV */
  121186. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121187. /** UNSIGNED_INT_24_8 */
  121188. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121189. /** UNSIGNED_INT_10F_11F_11F_REV */
  121190. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121191. /** UNSIGNED_INT_5_9_9_9_REV */
  121192. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121193. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121194. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121195. /** nearest is mag = nearest and min = nearest and mip = linear */
  121196. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121197. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121198. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121199. /** Trilinear is mag = linear and min = linear and mip = linear */
  121200. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121201. /** nearest is mag = nearest and min = nearest and mip = linear */
  121202. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121203. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121204. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121205. /** Trilinear is mag = linear and min = linear and mip = linear */
  121206. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121207. /** mag = nearest and min = nearest and mip = nearest */
  121208. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121209. /** mag = nearest and min = linear and mip = nearest */
  121210. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121211. /** mag = nearest and min = linear and mip = linear */
  121212. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121213. /** mag = nearest and min = linear and mip = none */
  121214. static readonly TEXTURE_NEAREST_LINEAR: number;
  121215. /** mag = nearest and min = nearest and mip = none */
  121216. static readonly TEXTURE_NEAREST_NEAREST: number;
  121217. /** mag = linear and min = nearest and mip = nearest */
  121218. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121219. /** mag = linear and min = nearest and mip = linear */
  121220. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121221. /** mag = linear and min = linear and mip = none */
  121222. static readonly TEXTURE_LINEAR_LINEAR: number;
  121223. /** mag = linear and min = nearest and mip = none */
  121224. static readonly TEXTURE_LINEAR_NEAREST: number;
  121225. /** Explicit coordinates mode */
  121226. static readonly TEXTURE_EXPLICIT_MODE: number;
  121227. /** Spherical coordinates mode */
  121228. static readonly TEXTURE_SPHERICAL_MODE: number;
  121229. /** Planar coordinates mode */
  121230. static readonly TEXTURE_PLANAR_MODE: number;
  121231. /** Cubic coordinates mode */
  121232. static readonly TEXTURE_CUBIC_MODE: number;
  121233. /** Projection coordinates mode */
  121234. static readonly TEXTURE_PROJECTION_MODE: number;
  121235. /** Skybox coordinates mode */
  121236. static readonly TEXTURE_SKYBOX_MODE: number;
  121237. /** Inverse Cubic coordinates mode */
  121238. static readonly TEXTURE_INVCUBIC_MODE: number;
  121239. /** Equirectangular coordinates mode */
  121240. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121241. /** Equirectangular Fixed coordinates mode */
  121242. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121243. /** Equirectangular Fixed Mirrored coordinates mode */
  121244. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121245. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121246. static readonly SCALEMODE_FLOOR: number;
  121247. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121248. static readonly SCALEMODE_NEAREST: number;
  121249. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121250. static readonly SCALEMODE_CEILING: number;
  121251. /**
  121252. * Returns the current npm package of the sdk
  121253. */
  121254. static get NpmPackage(): string;
  121255. /**
  121256. * Returns the current version of the framework
  121257. */
  121258. static get Version(): string;
  121259. /** Gets the list of created engines */
  121260. static get Instances(): Engine[];
  121261. /**
  121262. * Gets the latest created engine
  121263. */
  121264. static get LastCreatedEngine(): Nullable<Engine>;
  121265. /**
  121266. * Gets the latest created scene
  121267. */
  121268. static get LastCreatedScene(): Nullable<Scene>;
  121269. /**
  121270. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  121271. * @param flag defines which part of the materials must be marked as dirty
  121272. * @param predicate defines a predicate used to filter which materials should be affected
  121273. */
  121274. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121275. /**
  121276. * Method called to create the default loading screen.
  121277. * This can be overriden in your own app.
  121278. * @param canvas The rendering canvas element
  121279. * @returns The loading screen
  121280. */
  121281. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  121282. /**
  121283. * Method called to create the default rescale post process on each engine.
  121284. */
  121285. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  121286. /**
  121287. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  121288. **/
  121289. enableOfflineSupport: boolean;
  121290. /**
  121291. * 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)
  121292. **/
  121293. disableManifestCheck: boolean;
  121294. /**
  121295. * Gets the list of created scenes
  121296. */
  121297. scenes: Scene[];
  121298. /**
  121299. * Event raised when a new scene is created
  121300. */
  121301. onNewSceneAddedObservable: Observable<Scene>;
  121302. /**
  121303. * Gets the list of created postprocesses
  121304. */
  121305. postProcesses: PostProcess[];
  121306. /**
  121307. * Gets a boolean indicating if the pointer is currently locked
  121308. */
  121309. isPointerLock: boolean;
  121310. /**
  121311. * Observable event triggered each time the rendering canvas is resized
  121312. */
  121313. onResizeObservable: Observable<Engine>;
  121314. /**
  121315. * Observable event triggered each time the canvas loses focus
  121316. */
  121317. onCanvasBlurObservable: Observable<Engine>;
  121318. /**
  121319. * Observable event triggered each time the canvas gains focus
  121320. */
  121321. onCanvasFocusObservable: Observable<Engine>;
  121322. /**
  121323. * Observable event triggered each time the canvas receives pointerout event
  121324. */
  121325. onCanvasPointerOutObservable: Observable<PointerEvent>;
  121326. /**
  121327. * Observable raised when the engine begins a new frame
  121328. */
  121329. onBeginFrameObservable: Observable<Engine>;
  121330. /**
  121331. * If set, will be used to request the next animation frame for the render loop
  121332. */
  121333. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  121334. /**
  121335. * Observable raised when the engine ends the current frame
  121336. */
  121337. onEndFrameObservable: Observable<Engine>;
  121338. /**
  121339. * Observable raised when the engine is about to compile a shader
  121340. */
  121341. onBeforeShaderCompilationObservable: Observable<Engine>;
  121342. /**
  121343. * Observable raised when the engine has jsut compiled a shader
  121344. */
  121345. onAfterShaderCompilationObservable: Observable<Engine>;
  121346. /**
  121347. * Gets the audio engine
  121348. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121349. * @ignorenaming
  121350. */
  121351. static audioEngine: IAudioEngine;
  121352. /**
  121353. * Default AudioEngine factory responsible of creating the Audio Engine.
  121354. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  121355. */
  121356. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  121357. /**
  121358. * Default offline support factory responsible of creating a tool used to store data locally.
  121359. * By default, this will create a Database object if the workload has been embedded.
  121360. */
  121361. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  121362. private _loadingScreen;
  121363. private _pointerLockRequested;
  121364. private _rescalePostProcess;
  121365. private _deterministicLockstep;
  121366. private _lockstepMaxSteps;
  121367. private _timeStep;
  121368. protected get _supportsHardwareTextureRescaling(): boolean;
  121369. private _fps;
  121370. private _deltaTime;
  121371. /** @hidden */
  121372. _drawCalls: PerfCounter;
  121373. /** 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 */
  121374. canvasTabIndex: number;
  121375. /**
  121376. * Turn this value on if you want to pause FPS computation when in background
  121377. */
  121378. disablePerformanceMonitorInBackground: boolean;
  121379. private _performanceMonitor;
  121380. /**
  121381. * Gets the performance monitor attached to this engine
  121382. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  121383. */
  121384. get performanceMonitor(): PerformanceMonitor;
  121385. private _onFocus;
  121386. private _onBlur;
  121387. private _onCanvasPointerOut;
  121388. private _onCanvasBlur;
  121389. private _onCanvasFocus;
  121390. private _onFullscreenChange;
  121391. private _onPointerLockChange;
  121392. /**
  121393. * Gets the HTML element used to attach event listeners
  121394. * @returns a HTML element
  121395. */
  121396. getInputElement(): Nullable<HTMLElement>;
  121397. /**
  121398. * Creates a new engine
  121399. * @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
  121400. * @param antialias defines enable antialiasing (default: false)
  121401. * @param options defines further options to be sent to the getContext() function
  121402. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  121403. */
  121404. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  121405. /**
  121406. * Gets current aspect ratio
  121407. * @param viewportOwner defines the camera to use to get the aspect ratio
  121408. * @param useScreen defines if screen size must be used (or the current render target if any)
  121409. * @returns a number defining the aspect ratio
  121410. */
  121411. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  121412. /**
  121413. * Gets current screen aspect ratio
  121414. * @returns a number defining the aspect ratio
  121415. */
  121416. getScreenAspectRatio(): number;
  121417. /**
  121418. * Gets the client rect of the HTML canvas attached with the current webGL context
  121419. * @returns a client rectanglee
  121420. */
  121421. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  121422. /**
  121423. * Gets the client rect of the HTML element used for events
  121424. * @returns a client rectanglee
  121425. */
  121426. getInputElementClientRect(): Nullable<ClientRect>;
  121427. /**
  121428. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121429. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121430. * @returns true if engine is in deterministic lock step mode
  121431. */
  121432. isDeterministicLockStep(): boolean;
  121433. /**
  121434. * Gets the max steps when engine is running in deterministic lock step
  121435. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121436. * @returns the max steps
  121437. */
  121438. getLockstepMaxSteps(): number;
  121439. /**
  121440. * Returns the time in ms between steps when using deterministic lock step.
  121441. * @returns time step in (ms)
  121442. */
  121443. getTimeStep(): number;
  121444. /**
  121445. * Force the mipmap generation for the given render target texture
  121446. * @param texture defines the render target texture to use
  121447. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  121448. */
  121449. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  121450. /** States */
  121451. /**
  121452. * Set various states to the webGL context
  121453. * @param culling defines backface culling state
  121454. * @param zOffset defines the value to apply to zOffset (0 by default)
  121455. * @param force defines if states must be applied even if cache is up to date
  121456. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121457. */
  121458. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121459. /**
  121460. * Set the z offset to apply to current rendering
  121461. * @param value defines the offset to apply
  121462. */
  121463. setZOffset(value: number): void;
  121464. /**
  121465. * Gets the current value of the zOffset
  121466. * @returns the current zOffset state
  121467. */
  121468. getZOffset(): number;
  121469. /**
  121470. * Enable or disable depth buffering
  121471. * @param enable defines the state to set
  121472. */
  121473. setDepthBuffer(enable: boolean): void;
  121474. /**
  121475. * Gets a boolean indicating if depth writing is enabled
  121476. * @returns the current depth writing state
  121477. */
  121478. getDepthWrite(): boolean;
  121479. /**
  121480. * Enable or disable depth writing
  121481. * @param enable defines the state to set
  121482. */
  121483. setDepthWrite(enable: boolean): void;
  121484. /**
  121485. * Gets a boolean indicating if stencil buffer is enabled
  121486. * @returns the current stencil buffer state
  121487. */
  121488. getStencilBuffer(): boolean;
  121489. /**
  121490. * Enable or disable the stencil buffer
  121491. * @param enable defines if the stencil buffer must be enabled or disabled
  121492. */
  121493. setStencilBuffer(enable: boolean): void;
  121494. /**
  121495. * Gets the current stencil mask
  121496. * @returns a number defining the new stencil mask to use
  121497. */
  121498. getStencilMask(): number;
  121499. /**
  121500. * Sets the current stencil mask
  121501. * @param mask defines the new stencil mask to use
  121502. */
  121503. setStencilMask(mask: number): void;
  121504. /**
  121505. * Gets the current stencil function
  121506. * @returns a number defining the stencil function to use
  121507. */
  121508. getStencilFunction(): number;
  121509. /**
  121510. * Gets the current stencil reference value
  121511. * @returns a number defining the stencil reference value to use
  121512. */
  121513. getStencilFunctionReference(): number;
  121514. /**
  121515. * Gets the current stencil mask
  121516. * @returns a number defining the stencil mask to use
  121517. */
  121518. getStencilFunctionMask(): number;
  121519. /**
  121520. * Sets the current stencil function
  121521. * @param stencilFunc defines the new stencil function to use
  121522. */
  121523. setStencilFunction(stencilFunc: number): void;
  121524. /**
  121525. * Sets the current stencil reference
  121526. * @param reference defines the new stencil reference to use
  121527. */
  121528. setStencilFunctionReference(reference: number): void;
  121529. /**
  121530. * Sets the current stencil mask
  121531. * @param mask defines the new stencil mask to use
  121532. */
  121533. setStencilFunctionMask(mask: number): void;
  121534. /**
  121535. * Gets the current stencil operation when stencil fails
  121536. * @returns a number defining stencil operation to use when stencil fails
  121537. */
  121538. getStencilOperationFail(): number;
  121539. /**
  121540. * Gets the current stencil operation when depth fails
  121541. * @returns a number defining stencil operation to use when depth fails
  121542. */
  121543. getStencilOperationDepthFail(): number;
  121544. /**
  121545. * Gets the current stencil operation when stencil passes
  121546. * @returns a number defining stencil operation to use when stencil passes
  121547. */
  121548. getStencilOperationPass(): number;
  121549. /**
  121550. * Sets the stencil operation to use when stencil fails
  121551. * @param operation defines the stencil operation to use when stencil fails
  121552. */
  121553. setStencilOperationFail(operation: number): void;
  121554. /**
  121555. * Sets the stencil operation to use when depth fails
  121556. * @param operation defines the stencil operation to use when depth fails
  121557. */
  121558. setStencilOperationDepthFail(operation: number): void;
  121559. /**
  121560. * Sets the stencil operation to use when stencil passes
  121561. * @param operation defines the stencil operation to use when stencil passes
  121562. */
  121563. setStencilOperationPass(operation: number): void;
  121564. /**
  121565. * Sets a boolean indicating if the dithering state is enabled or disabled
  121566. * @param value defines the dithering state
  121567. */
  121568. setDitheringState(value: boolean): void;
  121569. /**
  121570. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  121571. * @param value defines the rasterizer state
  121572. */
  121573. setRasterizerState(value: boolean): void;
  121574. /**
  121575. * Gets the current depth function
  121576. * @returns a number defining the depth function
  121577. */
  121578. getDepthFunction(): Nullable<number>;
  121579. /**
  121580. * Sets the current depth function
  121581. * @param depthFunc defines the function to use
  121582. */
  121583. setDepthFunction(depthFunc: number): void;
  121584. /**
  121585. * Sets the current depth function to GREATER
  121586. */
  121587. setDepthFunctionToGreater(): void;
  121588. /**
  121589. * Sets the current depth function to GEQUAL
  121590. */
  121591. setDepthFunctionToGreaterOrEqual(): void;
  121592. /**
  121593. * Sets the current depth function to LESS
  121594. */
  121595. setDepthFunctionToLess(): void;
  121596. /**
  121597. * Sets the current depth function to LEQUAL
  121598. */
  121599. setDepthFunctionToLessOrEqual(): void;
  121600. private _cachedStencilBuffer;
  121601. private _cachedStencilFunction;
  121602. private _cachedStencilMask;
  121603. private _cachedStencilOperationPass;
  121604. private _cachedStencilOperationFail;
  121605. private _cachedStencilOperationDepthFail;
  121606. private _cachedStencilReference;
  121607. /**
  121608. * Caches the the state of the stencil buffer
  121609. */
  121610. cacheStencilState(): void;
  121611. /**
  121612. * Restores the state of the stencil buffer
  121613. */
  121614. restoreStencilState(): void;
  121615. /**
  121616. * Directly set the WebGL Viewport
  121617. * @param x defines the x coordinate of the viewport (in screen space)
  121618. * @param y defines the y coordinate of the viewport (in screen space)
  121619. * @param width defines the width of the viewport (in screen space)
  121620. * @param height defines the height of the viewport (in screen space)
  121621. * @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
  121622. */
  121623. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  121624. /**
  121625. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  121626. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121627. * @param y defines the y-coordinate of the corner of the clear rectangle
  121628. * @param width defines the width of the clear rectangle
  121629. * @param height defines the height of the clear rectangle
  121630. * @param clearColor defines the clear color
  121631. */
  121632. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  121633. /**
  121634. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  121635. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  121636. * @param y defines the y-coordinate of the corner of the clear rectangle
  121637. * @param width defines the width of the clear rectangle
  121638. * @param height defines the height of the clear rectangle
  121639. */
  121640. enableScissor(x: number, y: number, width: number, height: number): void;
  121641. /**
  121642. * Disable previously set scissor test rectangle
  121643. */
  121644. disableScissor(): void;
  121645. protected _reportDrawCall(): void;
  121646. /**
  121647. * Initializes a webVR display and starts listening to display change events
  121648. * The onVRDisplayChangedObservable will be notified upon these changes
  121649. * @returns The onVRDisplayChangedObservable
  121650. */
  121651. initWebVR(): Observable<IDisplayChangedEventArgs>;
  121652. /** @hidden */
  121653. _prepareVRComponent(): void;
  121654. /** @hidden */
  121655. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  121656. /** @hidden */
  121657. _submitVRFrame(): void;
  121658. /**
  121659. * Call this function to leave webVR mode
  121660. * Will do nothing if webVR is not supported or if there is no webVR device
  121661. * @see https://doc.babylonjs.com/how_to/webvr_camera
  121662. */
  121663. disableVR(): void;
  121664. /**
  121665. * Gets a boolean indicating that the system is in VR mode and is presenting
  121666. * @returns true if VR mode is engaged
  121667. */
  121668. isVRPresenting(): boolean;
  121669. /** @hidden */
  121670. _requestVRFrame(): void;
  121671. /** @hidden */
  121672. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121673. /**
  121674. * Gets the source code of the vertex shader associated with a specific webGL program
  121675. * @param program defines the program to use
  121676. * @returns a string containing the source code of the vertex shader associated with the program
  121677. */
  121678. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  121679. /**
  121680. * Gets the source code of the fragment shader associated with a specific webGL program
  121681. * @param program defines the program to use
  121682. * @returns a string containing the source code of the fragment shader associated with the program
  121683. */
  121684. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  121685. /**
  121686. * Sets a depth stencil texture from a render target to the according uniform.
  121687. * @param channel The texture channel
  121688. * @param uniform The uniform to set
  121689. * @param texture The render target texture containing the depth stencil texture to apply
  121690. */
  121691. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  121692. /**
  121693. * Sets a texture to the webGL context from a postprocess
  121694. * @param channel defines the channel to use
  121695. * @param postProcess defines the source postprocess
  121696. */
  121697. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  121698. /**
  121699. * Binds the output of the passed in post process to the texture channel specified
  121700. * @param channel The channel the texture should be bound to
  121701. * @param postProcess The post process which's output should be bound
  121702. */
  121703. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  121704. protected _rebuildBuffers(): void;
  121705. /** @hidden */
  121706. _renderFrame(): void;
  121707. _renderLoop(): void;
  121708. /** @hidden */
  121709. _renderViews(): boolean;
  121710. /**
  121711. * Toggle full screen mode
  121712. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121713. */
  121714. switchFullscreen(requestPointerLock: boolean): void;
  121715. /**
  121716. * Enters full screen mode
  121717. * @param requestPointerLock defines if a pointer lock should be requested from the user
  121718. */
  121719. enterFullscreen(requestPointerLock: boolean): void;
  121720. /**
  121721. * Exits full screen mode
  121722. */
  121723. exitFullscreen(): void;
  121724. /**
  121725. * Enters Pointerlock mode
  121726. */
  121727. enterPointerlock(): void;
  121728. /**
  121729. * Exits Pointerlock mode
  121730. */
  121731. exitPointerlock(): void;
  121732. /**
  121733. * Begin a new frame
  121734. */
  121735. beginFrame(): void;
  121736. /**
  121737. * Enf the current frame
  121738. */
  121739. endFrame(): void;
  121740. resize(): void;
  121741. /**
  121742. * Force a specific size of the canvas
  121743. * @param width defines the new canvas' width
  121744. * @param height defines the new canvas' height
  121745. * @returns true if the size was changed
  121746. */
  121747. setSize(width: number, height: number): boolean;
  121748. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121749. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121750. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121751. _releaseTexture(texture: InternalTexture): void;
  121752. /**
  121753. * @hidden
  121754. * Rescales a texture
  121755. * @param source input texutre
  121756. * @param destination destination texture
  121757. * @param scene scene to use to render the resize
  121758. * @param internalFormat format to use when resizing
  121759. * @param onComplete callback to be called when resize has completed
  121760. */
  121761. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121762. /**
  121763. * Gets the current framerate
  121764. * @returns a number representing the framerate
  121765. */
  121766. getFps(): number;
  121767. /**
  121768. * Gets the time spent between current and previous frame
  121769. * @returns a number representing the delta time in ms
  121770. */
  121771. getDeltaTime(): number;
  121772. private _measureFps;
  121773. /** @hidden */
  121774. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  121775. /**
  121776. * Updates the sample count of a render target texture
  121777. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121778. * @param texture defines the texture to update
  121779. * @param samples defines the sample count to set
  121780. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121781. */
  121782. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  121783. /**
  121784. * Updates a depth texture Comparison Mode and Function.
  121785. * If the comparison Function is equal to 0, the mode will be set to none.
  121786. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  121787. * @param texture The texture to set the comparison function for
  121788. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  121789. */
  121790. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  121791. /**
  121792. * Creates a webGL buffer to use with instanciation
  121793. * @param capacity defines the size of the buffer
  121794. * @returns the webGL buffer
  121795. */
  121796. createInstancesBuffer(capacity: number): DataBuffer;
  121797. /**
  121798. * Delete a webGL buffer used with instanciation
  121799. * @param buffer defines the webGL buffer to delete
  121800. */
  121801. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  121802. private _clientWaitAsync;
  121803. /** @hidden */
  121804. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  121805. dispose(): void;
  121806. private _disableTouchAction;
  121807. /**
  121808. * Display the loading screen
  121809. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121810. */
  121811. displayLoadingUI(): void;
  121812. /**
  121813. * Hide the loading screen
  121814. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121815. */
  121816. hideLoadingUI(): void;
  121817. /**
  121818. * Gets the current loading screen object
  121819. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121820. */
  121821. get loadingScreen(): ILoadingScreen;
  121822. /**
  121823. * Sets the current loading screen object
  121824. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121825. */
  121826. set loadingScreen(loadingScreen: ILoadingScreen);
  121827. /**
  121828. * Sets the current loading screen text
  121829. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121830. */
  121831. set loadingUIText(text: string);
  121832. /**
  121833. * Sets the current loading screen background color
  121834. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121835. */
  121836. set loadingUIBackgroundColor(color: string);
  121837. /** Pointerlock and fullscreen */
  121838. /**
  121839. * Ask the browser to promote the current element to pointerlock mode
  121840. * @param element defines the DOM element to promote
  121841. */
  121842. static _RequestPointerlock(element: HTMLElement): void;
  121843. /**
  121844. * Asks the browser to exit pointerlock mode
  121845. */
  121846. static _ExitPointerlock(): void;
  121847. /**
  121848. * Ask the browser to promote the current element to fullscreen rendering mode
  121849. * @param element defines the DOM element to promote
  121850. */
  121851. static _RequestFullscreen(element: HTMLElement): void;
  121852. /**
  121853. * Asks the browser to exit fullscreen mode
  121854. */
  121855. static _ExitFullscreen(): void;
  121856. }
  121857. }
  121858. declare module BABYLON {
  121859. /**
  121860. * The engine store class is responsible to hold all the instances of Engine and Scene created
  121861. * during the life time of the application.
  121862. */
  121863. export class EngineStore {
  121864. /** Gets the list of created engines */
  121865. static Instances: Engine[];
  121866. /** @hidden */
  121867. static _LastCreatedScene: Nullable<Scene>;
  121868. /**
  121869. * Gets the latest created engine
  121870. */
  121871. static get LastCreatedEngine(): Nullable<Engine>;
  121872. /**
  121873. * Gets the latest created scene
  121874. */
  121875. static get LastCreatedScene(): Nullable<Scene>;
  121876. /**
  121877. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  121878. * @ignorenaming
  121879. */
  121880. static UseFallbackTexture: boolean;
  121881. /**
  121882. * Texture content used if a texture cannot loaded
  121883. * @ignorenaming
  121884. */
  121885. static FallbackTexture: string;
  121886. }
  121887. }
  121888. declare module BABYLON {
  121889. /**
  121890. * Helper class that provides a small promise polyfill
  121891. */
  121892. export class PromisePolyfill {
  121893. /**
  121894. * Static function used to check if the polyfill is required
  121895. * If this is the case then the function will inject the polyfill to window.Promise
  121896. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  121897. */
  121898. static Apply(force?: boolean): void;
  121899. }
  121900. }
  121901. declare module BABYLON {
  121902. /**
  121903. * Interface for screenshot methods with describe argument called `size` as object with options
  121904. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  121905. */
  121906. export interface IScreenshotSize {
  121907. /**
  121908. * number in pixels for canvas height
  121909. */
  121910. height?: number;
  121911. /**
  121912. * multiplier allowing render at a higher or lower resolution
  121913. * If value is defined then height and width will be ignored and taken from camera
  121914. */
  121915. precision?: number;
  121916. /**
  121917. * number in pixels for canvas width
  121918. */
  121919. width?: number;
  121920. }
  121921. }
  121922. declare module BABYLON {
  121923. interface IColor4Like {
  121924. r: float;
  121925. g: float;
  121926. b: float;
  121927. a: float;
  121928. }
  121929. /**
  121930. * Class containing a set of static utilities functions
  121931. */
  121932. export class Tools {
  121933. /**
  121934. * Gets or sets the base URL to use to load assets
  121935. */
  121936. static get BaseUrl(): string;
  121937. static set BaseUrl(value: string);
  121938. /**
  121939. * Enable/Disable Custom HTTP Request Headers globally.
  121940. * default = false
  121941. * @see CustomRequestHeaders
  121942. */
  121943. static UseCustomRequestHeaders: boolean;
  121944. /**
  121945. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  121946. * i.e. when loading files, where the server/service expects an Authorization header
  121947. */
  121948. static CustomRequestHeaders: {
  121949. [key: string]: string;
  121950. };
  121951. /**
  121952. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  121953. */
  121954. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  121955. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  121956. /**
  121957. * Default behaviour for cors in the application.
  121958. * It can be a string if the expected behavior is identical in the entire app.
  121959. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  121960. */
  121961. static get CorsBehavior(): string | ((url: string | string[]) => string);
  121962. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  121963. /**
  121964. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  121965. * @ignorenaming
  121966. */
  121967. static get UseFallbackTexture(): boolean;
  121968. static set UseFallbackTexture(value: boolean);
  121969. /**
  121970. * Use this object to register external classes like custom textures or material
  121971. * to allow the laoders to instantiate them
  121972. */
  121973. static get RegisteredExternalClasses(): {
  121974. [key: string]: Object;
  121975. };
  121976. static set RegisteredExternalClasses(classes: {
  121977. [key: string]: Object;
  121978. });
  121979. /**
  121980. * Texture content used if a texture cannot loaded
  121981. * @ignorenaming
  121982. */
  121983. static get fallbackTexture(): string;
  121984. static set fallbackTexture(value: string);
  121985. /**
  121986. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  121987. * @param u defines the coordinate on X axis
  121988. * @param v defines the coordinate on Y axis
  121989. * @param width defines the width of the source data
  121990. * @param height defines the height of the source data
  121991. * @param pixels defines the source byte array
  121992. * @param color defines the output color
  121993. */
  121994. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  121995. /**
  121996. * Interpolates between a and b via alpha
  121997. * @param a The lower value (returned when alpha = 0)
  121998. * @param b The upper value (returned when alpha = 1)
  121999. * @param alpha The interpolation-factor
  122000. * @return The mixed value
  122001. */
  122002. static Mix(a: number, b: number, alpha: number): number;
  122003. /**
  122004. * Tries to instantiate a new object from a given class name
  122005. * @param className defines the class name to instantiate
  122006. * @returns the new object or null if the system was not able to do the instantiation
  122007. */
  122008. static Instantiate(className: string): any;
  122009. /**
  122010. * Provides a slice function that will work even on IE
  122011. * @param data defines the array to slice
  122012. * @param start defines the start of the data (optional)
  122013. * @param end defines the end of the data (optional)
  122014. * @returns the new sliced array
  122015. */
  122016. static Slice<T>(data: T, start?: number, end?: number): T;
  122017. /**
  122018. * Polyfill for setImmediate
  122019. * @param action defines the action to execute after the current execution block
  122020. */
  122021. static SetImmediate(action: () => void): void;
  122022. /**
  122023. * Function indicating if a number is an exponent of 2
  122024. * @param value defines the value to test
  122025. * @returns true if the value is an exponent of 2
  122026. */
  122027. static IsExponentOfTwo(value: number): boolean;
  122028. private static _tmpFloatArray;
  122029. /**
  122030. * Returns the nearest 32-bit single precision float representation of a Number
  122031. * @param value A Number. If the parameter is of a different type, it will get converted
  122032. * to a number or to NaN if it cannot be converted
  122033. * @returns number
  122034. */
  122035. static FloatRound(value: number): number;
  122036. /**
  122037. * Extracts the filename from a path
  122038. * @param path defines the path to use
  122039. * @returns the filename
  122040. */
  122041. static GetFilename(path: string): string;
  122042. /**
  122043. * Extracts the "folder" part of a path (everything before the filename).
  122044. * @param uri The URI to extract the info from
  122045. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  122046. * @returns The "folder" part of the path
  122047. */
  122048. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  122049. /**
  122050. * Extracts text content from a DOM element hierarchy
  122051. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  122052. */
  122053. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  122054. /**
  122055. * Convert an angle in radians to degrees
  122056. * @param angle defines the angle to convert
  122057. * @returns the angle in degrees
  122058. */
  122059. static ToDegrees(angle: number): number;
  122060. /**
  122061. * Convert an angle in degrees to radians
  122062. * @param angle defines the angle to convert
  122063. * @returns the angle in radians
  122064. */
  122065. static ToRadians(angle: number): number;
  122066. /**
  122067. * Returns an array if obj is not an array
  122068. * @param obj defines the object to evaluate as an array
  122069. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  122070. * @returns either obj directly if obj is an array or a new array containing obj
  122071. */
  122072. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  122073. /**
  122074. * Gets the pointer prefix to use
  122075. * @param engine defines the engine we are finding the prefix for
  122076. * @returns "pointer" if touch is enabled. Else returns "mouse"
  122077. */
  122078. static GetPointerPrefix(engine: Engine): string;
  122079. /**
  122080. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  122081. * @param url define the url we are trying
  122082. * @param element define the dom element where to configure the cors policy
  122083. */
  122084. static SetCorsBehavior(url: string | string[], element: {
  122085. crossOrigin: string | null;
  122086. }): void;
  122087. /**
  122088. * Removes unwanted characters from an url
  122089. * @param url defines the url to clean
  122090. * @returns the cleaned url
  122091. */
  122092. static CleanUrl(url: string): string;
  122093. /**
  122094. * Gets or sets a function used to pre-process url before using them to load assets
  122095. */
  122096. static get PreprocessUrl(): (url: string) => string;
  122097. static set PreprocessUrl(processor: (url: string) => string);
  122098. /**
  122099. * Loads an image as an HTMLImageElement.
  122100. * @param input url string, ArrayBuffer, or Blob to load
  122101. * @param onLoad callback called when the image successfully loads
  122102. * @param onError callback called when the image fails to load
  122103. * @param offlineProvider offline provider for caching
  122104. * @param mimeType optional mime type
  122105. * @returns the HTMLImageElement of the loaded image
  122106. */
  122107. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  122108. /**
  122109. * Loads a file from a url
  122110. * @param url url string, ArrayBuffer, or Blob to load
  122111. * @param onSuccess callback called when the file successfully loads
  122112. * @param onProgress callback called while file is loading (if the server supports this mode)
  122113. * @param offlineProvider defines the offline provider for caching
  122114. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122115. * @param onError callback called when the file fails to load
  122116. * @returns a file request object
  122117. */
  122118. 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;
  122119. /**
  122120. * Loads a file from a url
  122121. * @param url the file url to load
  122122. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122123. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  122124. */
  122125. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  122126. /**
  122127. * Load a script (identified by an url). When the url returns, the
  122128. * content of this file is added into a new script element, attached to the DOM (body element)
  122129. * @param scriptUrl defines the url of the script to laod
  122130. * @param onSuccess defines the callback called when the script is loaded
  122131. * @param onError defines the callback to call if an error occurs
  122132. * @param scriptId defines the id of the script element
  122133. */
  122134. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  122135. /**
  122136. * Load an asynchronous script (identified by an url). When the url returns, the
  122137. * content of this file is added into a new script element, attached to the DOM (body element)
  122138. * @param scriptUrl defines the url of the script to laod
  122139. * @param scriptId defines the id of the script element
  122140. * @returns a promise request object
  122141. */
  122142. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  122143. /**
  122144. * Loads a file from a blob
  122145. * @param fileToLoad defines the blob to use
  122146. * @param callback defines the callback to call when data is loaded
  122147. * @param progressCallback defines the callback to call during loading process
  122148. * @returns a file request object
  122149. */
  122150. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122151. /**
  122152. * Reads a file from a File object
  122153. * @param file defines the file to load
  122154. * @param onSuccess defines the callback to call when data is loaded
  122155. * @param onProgress defines the callback to call during loading process
  122156. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122157. * @param onError defines the callback to call when an error occurs
  122158. * @returns a file request object
  122159. */
  122160. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122161. /**
  122162. * Creates a data url from a given string content
  122163. * @param content defines the content to convert
  122164. * @returns the new data url link
  122165. */
  122166. static FileAsURL(content: string): string;
  122167. /**
  122168. * Format the given number to a specific decimal format
  122169. * @param value defines the number to format
  122170. * @param decimals defines the number of decimals to use
  122171. * @returns the formatted string
  122172. */
  122173. static Format(value: number, decimals?: number): string;
  122174. /**
  122175. * Tries to copy an object by duplicating every property
  122176. * @param source defines the source object
  122177. * @param destination defines the target object
  122178. * @param doNotCopyList defines a list of properties to avoid
  122179. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122180. */
  122181. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122182. /**
  122183. * Gets a boolean indicating if the given object has no own property
  122184. * @param obj defines the object to test
  122185. * @returns true if object has no own property
  122186. */
  122187. static IsEmpty(obj: any): boolean;
  122188. /**
  122189. * Function used to register events at window level
  122190. * @param windowElement defines the Window object to use
  122191. * @param events defines the events to register
  122192. */
  122193. static RegisterTopRootEvents(windowElement: Window, events: {
  122194. name: string;
  122195. handler: Nullable<(e: FocusEvent) => any>;
  122196. }[]): void;
  122197. /**
  122198. * Function used to unregister events from window level
  122199. * @param windowElement defines the Window object to use
  122200. * @param events defines the events to unregister
  122201. */
  122202. static UnregisterTopRootEvents(windowElement: Window, events: {
  122203. name: string;
  122204. handler: Nullable<(e: FocusEvent) => any>;
  122205. }[]): void;
  122206. /**
  122207. * @ignore
  122208. */
  122209. static _ScreenshotCanvas: HTMLCanvasElement;
  122210. /**
  122211. * Dumps the current bound framebuffer
  122212. * @param width defines the rendering width
  122213. * @param height defines the rendering height
  122214. * @param engine defines the hosting engine
  122215. * @param successCallback defines the callback triggered once the data are available
  122216. * @param mimeType defines the mime type of the result
  122217. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122218. */
  122219. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122220. /**
  122221. * Converts the canvas data to blob.
  122222. * This acts as a polyfill for browsers not supporting the to blob function.
  122223. * @param canvas Defines the canvas to extract the data from
  122224. * @param successCallback Defines the callback triggered once the data are available
  122225. * @param mimeType Defines the mime type of the result
  122226. */
  122227. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122228. /**
  122229. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122230. * @param successCallback defines the callback triggered once the data are available
  122231. * @param mimeType defines the mime type of the result
  122232. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122233. */
  122234. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122235. /**
  122236. * Downloads a blob in the browser
  122237. * @param blob defines the blob to download
  122238. * @param fileName defines the name of the downloaded file
  122239. */
  122240. static Download(blob: Blob, fileName: string): void;
  122241. /**
  122242. * Captures a screenshot of the current rendering
  122243. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122244. * @param engine defines the rendering engine
  122245. * @param camera defines the source camera
  122246. * @param size This parameter can be set to a single number or to an object with the
  122247. * following (optional) properties: precision, width, height. If a single number is passed,
  122248. * it will be used for both width and height. If an object is passed, the screenshot size
  122249. * will be derived from the parameters. The precision property is a multiplier allowing
  122250. * rendering at a higher or lower resolution
  122251. * @param successCallback defines the callback receives a single parameter which contains the
  122252. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122253. * src parameter of an <img> to display it
  122254. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122255. * Check your browser for supported MIME types
  122256. */
  122257. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  122258. /**
  122259. * Captures a screenshot of the current rendering
  122260. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122261. * @param engine defines the rendering engine
  122262. * @param camera defines the source camera
  122263. * @param size This parameter can be set to a single number or to an object with the
  122264. * following (optional) properties: precision, width, height. If a single number is passed,
  122265. * it will be used for both width and height. If an object is passed, the screenshot size
  122266. * will be derived from the parameters. The precision property is a multiplier allowing
  122267. * rendering at a higher or lower resolution
  122268. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122269. * Check your browser for supported MIME types
  122270. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122271. * to the src parameter of an <img> to display it
  122272. */
  122273. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  122274. /**
  122275. * Generates an image screenshot from the specified camera.
  122276. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122277. * @param engine The engine to use for rendering
  122278. * @param camera The camera to use for rendering
  122279. * @param size This parameter can be set to a single number or to an object with the
  122280. * following (optional) properties: precision, width, height. If a single number is passed,
  122281. * it will be used for both width and height. If an object is passed, the screenshot size
  122282. * will be derived from the parameters. The precision property is a multiplier allowing
  122283. * rendering at a higher or lower resolution
  122284. * @param successCallback The callback receives a single parameter which contains the
  122285. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122286. * src parameter of an <img> to display it
  122287. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122288. * Check your browser for supported MIME types
  122289. * @param samples Texture samples (default: 1)
  122290. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122291. * @param fileName A name for for the downloaded file.
  122292. */
  122293. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122294. /**
  122295. * Generates an image screenshot from the specified camera.
  122296. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122297. * @param engine The engine to use for rendering
  122298. * @param camera The camera to use for rendering
  122299. * @param size This parameter can be set to a single number or to an object with the
  122300. * following (optional) properties: precision, width, height. If a single number is passed,
  122301. * it will be used for both width and height. If an object is passed, the screenshot size
  122302. * will be derived from the parameters. The precision property is a multiplier allowing
  122303. * rendering at a higher or lower resolution
  122304. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122305. * Check your browser for supported MIME types
  122306. * @param samples Texture samples (default: 1)
  122307. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122308. * @param fileName A name for for the downloaded file.
  122309. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  122310. * to the src parameter of an <img> to display it
  122311. */
  122312. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  122313. /**
  122314. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  122315. * Be aware Math.random() could cause collisions, but:
  122316. * "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"
  122317. * @returns a pseudo random id
  122318. */
  122319. static RandomId(): string;
  122320. /**
  122321. * Test if the given uri is a base64 string
  122322. * @param uri The uri to test
  122323. * @return True if the uri is a base64 string or false otherwise
  122324. */
  122325. static IsBase64(uri: string): boolean;
  122326. /**
  122327. * Decode the given base64 uri.
  122328. * @param uri The uri to decode
  122329. * @return The decoded base64 data.
  122330. */
  122331. static DecodeBase64(uri: string): ArrayBuffer;
  122332. /**
  122333. * Gets the absolute url.
  122334. * @param url the input url
  122335. * @return the absolute url
  122336. */
  122337. static GetAbsoluteUrl(url: string): string;
  122338. /**
  122339. * No log
  122340. */
  122341. static readonly NoneLogLevel: number;
  122342. /**
  122343. * Only message logs
  122344. */
  122345. static readonly MessageLogLevel: number;
  122346. /**
  122347. * Only warning logs
  122348. */
  122349. static readonly WarningLogLevel: number;
  122350. /**
  122351. * Only error logs
  122352. */
  122353. static readonly ErrorLogLevel: number;
  122354. /**
  122355. * All logs
  122356. */
  122357. static readonly AllLogLevel: number;
  122358. /**
  122359. * Gets a value indicating the number of loading errors
  122360. * @ignorenaming
  122361. */
  122362. static get errorsCount(): number;
  122363. /**
  122364. * Callback called when a new log is added
  122365. */
  122366. static OnNewCacheEntry: (entry: string) => void;
  122367. /**
  122368. * Log a message to the console
  122369. * @param message defines the message to log
  122370. */
  122371. static Log(message: string): void;
  122372. /**
  122373. * Write a warning message to the console
  122374. * @param message defines the message to log
  122375. */
  122376. static Warn(message: string): void;
  122377. /**
  122378. * Write an error message to the console
  122379. * @param message defines the message to log
  122380. */
  122381. static Error(message: string): void;
  122382. /**
  122383. * Gets current log cache (list of logs)
  122384. */
  122385. static get LogCache(): string;
  122386. /**
  122387. * Clears the log cache
  122388. */
  122389. static ClearLogCache(): void;
  122390. /**
  122391. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  122392. */
  122393. static set LogLevels(level: number);
  122394. /**
  122395. * Checks if the window object exists
  122396. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  122397. */
  122398. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  122399. /**
  122400. * No performance log
  122401. */
  122402. static readonly PerformanceNoneLogLevel: number;
  122403. /**
  122404. * Use user marks to log performance
  122405. */
  122406. static readonly PerformanceUserMarkLogLevel: number;
  122407. /**
  122408. * Log performance to the console
  122409. */
  122410. static readonly PerformanceConsoleLogLevel: number;
  122411. private static _performance;
  122412. /**
  122413. * Sets the current performance log level
  122414. */
  122415. static set PerformanceLogLevel(level: number);
  122416. private static _StartPerformanceCounterDisabled;
  122417. private static _EndPerformanceCounterDisabled;
  122418. private static _StartUserMark;
  122419. private static _EndUserMark;
  122420. private static _StartPerformanceConsole;
  122421. private static _EndPerformanceConsole;
  122422. /**
  122423. * Starts a performance counter
  122424. */
  122425. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122426. /**
  122427. * Ends a specific performance coutner
  122428. */
  122429. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  122430. /**
  122431. * Gets either window.performance.now() if supported or Date.now() else
  122432. */
  122433. static get Now(): number;
  122434. /**
  122435. * This method will return the name of the class used to create the instance of the given object.
  122436. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  122437. * @param object the object to get the class name from
  122438. * @param isType defines if the object is actually a type
  122439. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  122440. */
  122441. static GetClassName(object: any, isType?: boolean): string;
  122442. /**
  122443. * Gets the first element of an array satisfying a given predicate
  122444. * @param array defines the array to browse
  122445. * @param predicate defines the predicate to use
  122446. * @returns null if not found or the element
  122447. */
  122448. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  122449. /**
  122450. * This method will return the name of the full name of the class, including its owning module (if any).
  122451. * 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).
  122452. * @param object the object to get the class name from
  122453. * @param isType defines if the object is actually a type
  122454. * @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.
  122455. * @ignorenaming
  122456. */
  122457. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  122458. /**
  122459. * Returns a promise that resolves after the given amount of time.
  122460. * @param delay Number of milliseconds to delay
  122461. * @returns Promise that resolves after the given amount of time
  122462. */
  122463. static DelayAsync(delay: number): Promise<void>;
  122464. /**
  122465. * Utility function to detect if the current user agent is Safari
  122466. * @returns whether or not the current user agent is safari
  122467. */
  122468. static IsSafari(): boolean;
  122469. }
  122470. /**
  122471. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  122472. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  122473. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  122474. * @param name The name of the class, case should be preserved
  122475. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  122476. */
  122477. export function className(name: string, module?: string): (target: Object) => void;
  122478. /**
  122479. * An implementation of a loop for asynchronous functions.
  122480. */
  122481. export class AsyncLoop {
  122482. /**
  122483. * Defines the number of iterations for the loop
  122484. */
  122485. iterations: number;
  122486. /**
  122487. * Defines the current index of the loop.
  122488. */
  122489. index: number;
  122490. private _done;
  122491. private _fn;
  122492. private _successCallback;
  122493. /**
  122494. * Constructor.
  122495. * @param iterations the number of iterations.
  122496. * @param func the function to run each iteration
  122497. * @param successCallback the callback that will be called upon succesful execution
  122498. * @param offset starting offset.
  122499. */
  122500. constructor(
  122501. /**
  122502. * Defines the number of iterations for the loop
  122503. */
  122504. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  122505. /**
  122506. * Execute the next iteration. Must be called after the last iteration was finished.
  122507. */
  122508. executeNext(): void;
  122509. /**
  122510. * Break the loop and run the success callback.
  122511. */
  122512. breakLoop(): void;
  122513. /**
  122514. * Create and run an async loop.
  122515. * @param iterations the number of iterations.
  122516. * @param fn the function to run each iteration
  122517. * @param successCallback the callback that will be called upon succesful execution
  122518. * @param offset starting offset.
  122519. * @returns the created async loop object
  122520. */
  122521. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  122522. /**
  122523. * A for-loop that will run a given number of iterations synchronous and the rest async.
  122524. * @param iterations total number of iterations
  122525. * @param syncedIterations number of synchronous iterations in each async iteration.
  122526. * @param fn the function to call each iteration.
  122527. * @param callback a success call back that will be called when iterating stops.
  122528. * @param breakFunction a break condition (optional)
  122529. * @param timeout timeout settings for the setTimeout function. default - 0.
  122530. * @returns the created async loop object
  122531. */
  122532. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  122533. }
  122534. }
  122535. declare module BABYLON {
  122536. /**
  122537. * This class implement a typical dictionary using a string as key and the generic type T as value.
  122538. * The underlying implementation relies on an associative array to ensure the best performances.
  122539. * The value can be anything including 'null' but except 'undefined'
  122540. */
  122541. export class StringDictionary<T> {
  122542. /**
  122543. * This will clear this dictionary and copy the content from the 'source' one.
  122544. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  122545. * @param source the dictionary to take the content from and copy to this dictionary
  122546. */
  122547. copyFrom(source: StringDictionary<T>): void;
  122548. /**
  122549. * Get a value based from its key
  122550. * @param key the given key to get the matching value from
  122551. * @return the value if found, otherwise undefined is returned
  122552. */
  122553. get(key: string): T | undefined;
  122554. /**
  122555. * Get a value from its key or add it if it doesn't exist.
  122556. * This method will ensure you that a given key/data will be present in the dictionary.
  122557. * @param key the given key to get the matching value from
  122558. * @param factory the factory that will create the value if the key is not present in the dictionary.
  122559. * The factory will only be invoked if there's no data for the given key.
  122560. * @return the value corresponding to the key.
  122561. */
  122562. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  122563. /**
  122564. * Get a value from its key if present in the dictionary otherwise add it
  122565. * @param key the key to get the value from
  122566. * @param val if there's no such key/value pair in the dictionary add it with this value
  122567. * @return the value corresponding to the key
  122568. */
  122569. getOrAdd(key: string, val: T): T;
  122570. /**
  122571. * Check if there's a given key in the dictionary
  122572. * @param key the key to check for
  122573. * @return true if the key is present, false otherwise
  122574. */
  122575. contains(key: string): boolean;
  122576. /**
  122577. * Add a new key and its corresponding value
  122578. * @param key the key to add
  122579. * @param value the value corresponding to the key
  122580. * @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
  122581. */
  122582. add(key: string, value: T): boolean;
  122583. /**
  122584. * Update a specific value associated to a key
  122585. * @param key defines the key to use
  122586. * @param value defines the value to store
  122587. * @returns true if the value was updated (or false if the key was not found)
  122588. */
  122589. set(key: string, value: T): boolean;
  122590. /**
  122591. * Get the element of the given key and remove it from the dictionary
  122592. * @param key defines the key to search
  122593. * @returns the value associated with the key or null if not found
  122594. */
  122595. getAndRemove(key: string): Nullable<T>;
  122596. /**
  122597. * Remove a key/value from the dictionary.
  122598. * @param key the key to remove
  122599. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  122600. */
  122601. remove(key: string): boolean;
  122602. /**
  122603. * Clear the whole content of the dictionary
  122604. */
  122605. clear(): void;
  122606. /**
  122607. * Gets the current count
  122608. */
  122609. get count(): number;
  122610. /**
  122611. * Execute a callback on each key/val of the dictionary.
  122612. * Note that you can remove any element in this dictionary in the callback implementation
  122613. * @param callback the callback to execute on a given key/value pair
  122614. */
  122615. forEach(callback: (key: string, val: T) => void): void;
  122616. /**
  122617. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  122618. * If the callback returns null or undefined the method will iterate to the next key/value pair
  122619. * Note that you can remove any element in this dictionary in the callback implementation
  122620. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  122621. * @returns the first item
  122622. */
  122623. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  122624. private _count;
  122625. private _data;
  122626. }
  122627. }
  122628. declare module BABYLON {
  122629. /** @hidden */
  122630. export interface ICollisionCoordinator {
  122631. createCollider(): Collider;
  122632. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122633. init(scene: Scene): void;
  122634. }
  122635. /** @hidden */
  122636. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  122637. private _scene;
  122638. private _scaledPosition;
  122639. private _scaledVelocity;
  122640. private _finalPosition;
  122641. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  122642. createCollider(): Collider;
  122643. init(scene: Scene): void;
  122644. private _collideWithWorld;
  122645. }
  122646. }
  122647. declare module BABYLON {
  122648. /**
  122649. * Class used to manage all inputs for the scene.
  122650. */
  122651. export class InputManager {
  122652. /** The distance in pixel that you have to move to prevent some events */
  122653. static DragMovementThreshold: number;
  122654. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  122655. static LongPressDelay: number;
  122656. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  122657. static DoubleClickDelay: number;
  122658. /** If you need to check double click without raising a single click at first click, enable this flag */
  122659. static ExclusiveDoubleClickMode: boolean;
  122660. /** 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. */
  122661. private _alreadyAttached;
  122662. private _wheelEventName;
  122663. private _onPointerMove;
  122664. private _onPointerDown;
  122665. private _onPointerUp;
  122666. private _initClickEvent;
  122667. private _initActionManager;
  122668. private _delayedSimpleClick;
  122669. private _delayedSimpleClickTimeout;
  122670. private _previousDelayedSimpleClickTimeout;
  122671. private _meshPickProceed;
  122672. private _previousButtonPressed;
  122673. private _currentPickResult;
  122674. private _previousPickResult;
  122675. private _totalPointersPressed;
  122676. private _doubleClickOccured;
  122677. private _pointerOverMesh;
  122678. private _pickedDownMesh;
  122679. private _pickedUpMesh;
  122680. private _pointerX;
  122681. private _pointerY;
  122682. private _unTranslatedPointerX;
  122683. private _unTranslatedPointerY;
  122684. private _startingPointerPosition;
  122685. private _previousStartingPointerPosition;
  122686. private _startingPointerTime;
  122687. private _previousStartingPointerTime;
  122688. private _pointerCaptures;
  122689. private _meshUnderPointerId;
  122690. private _onKeyDown;
  122691. private _onKeyUp;
  122692. private _onCanvasFocusObserver;
  122693. private _onCanvasBlurObserver;
  122694. private _scene;
  122695. /**
  122696. * Creates a new InputManager
  122697. * @param scene defines the hosting scene
  122698. */
  122699. constructor(scene: Scene);
  122700. /**
  122701. * Gets the mesh that is currently under the pointer
  122702. */
  122703. get meshUnderPointer(): Nullable<AbstractMesh>;
  122704. /**
  122705. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  122706. * @param pointerId the pointer id to use
  122707. * @returns The mesh under this pointer id or null if not found
  122708. */
  122709. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  122710. /**
  122711. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  122712. */
  122713. get unTranslatedPointer(): Vector2;
  122714. /**
  122715. * Gets or sets the current on-screen X position of the pointer
  122716. */
  122717. get pointerX(): number;
  122718. set pointerX(value: number);
  122719. /**
  122720. * Gets or sets the current on-screen Y position of the pointer
  122721. */
  122722. get pointerY(): number;
  122723. set pointerY(value: number);
  122724. private _updatePointerPosition;
  122725. private _processPointerMove;
  122726. private _setRayOnPointerInfo;
  122727. private _checkPrePointerObservable;
  122728. /**
  122729. * Use this method to simulate a pointer move on a mesh
  122730. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122731. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122732. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122733. */
  122734. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122735. /**
  122736. * Use this method to simulate a pointer down on a mesh
  122737. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122738. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122739. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122740. */
  122741. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  122742. private _processPointerDown;
  122743. /** @hidden */
  122744. _isPointerSwiping(): boolean;
  122745. /**
  122746. * Use this method to simulate a pointer up on a mesh
  122747. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  122748. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  122749. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  122750. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  122751. */
  122752. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  122753. private _processPointerUp;
  122754. /**
  122755. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  122756. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  122757. * @returns true if the pointer was captured
  122758. */
  122759. isPointerCaptured(pointerId?: number): boolean;
  122760. /**
  122761. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  122762. * @param attachUp defines if you want to attach events to pointerup
  122763. * @param attachDown defines if you want to attach events to pointerdown
  122764. * @param attachMove defines if you want to attach events to pointermove
  122765. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  122766. */
  122767. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  122768. /**
  122769. * Detaches all event handlers
  122770. */
  122771. detachControl(): void;
  122772. /**
  122773. * Force the value of meshUnderPointer
  122774. * @param mesh defines the mesh to use
  122775. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  122776. */
  122777. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  122778. /**
  122779. * Gets the mesh under the pointer
  122780. * @returns a Mesh or null if no mesh is under the pointer
  122781. */
  122782. getPointerOverMesh(): Nullable<AbstractMesh>;
  122783. }
  122784. }
  122785. declare module BABYLON {
  122786. /**
  122787. * This class defines the direct association between an animation and a target
  122788. */
  122789. export class TargetedAnimation {
  122790. /**
  122791. * Animation to perform
  122792. */
  122793. animation: Animation;
  122794. /**
  122795. * Target to animate
  122796. */
  122797. target: any;
  122798. /**
  122799. * Returns the string "TargetedAnimation"
  122800. * @returns "TargetedAnimation"
  122801. */
  122802. getClassName(): string;
  122803. /**
  122804. * Serialize the object
  122805. * @returns the JSON object representing the current entity
  122806. */
  122807. serialize(): any;
  122808. }
  122809. /**
  122810. * Use this class to create coordinated animations on multiple targets
  122811. */
  122812. export class AnimationGroup implements IDisposable {
  122813. /** The name of the animation group */
  122814. name: string;
  122815. private _scene;
  122816. private _targetedAnimations;
  122817. private _animatables;
  122818. private _from;
  122819. private _to;
  122820. private _isStarted;
  122821. private _isPaused;
  122822. private _speedRatio;
  122823. private _loopAnimation;
  122824. private _isAdditive;
  122825. /**
  122826. * Gets or sets the unique id of the node
  122827. */
  122828. uniqueId: number;
  122829. /**
  122830. * This observable will notify when one animation have ended
  122831. */
  122832. onAnimationEndObservable: Observable<TargetedAnimation>;
  122833. /**
  122834. * Observer raised when one animation loops
  122835. */
  122836. onAnimationLoopObservable: Observable<TargetedAnimation>;
  122837. /**
  122838. * Observer raised when all animations have looped
  122839. */
  122840. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  122841. /**
  122842. * This observable will notify when all animations have ended.
  122843. */
  122844. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  122845. /**
  122846. * This observable will notify when all animations have paused.
  122847. */
  122848. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  122849. /**
  122850. * This observable will notify when all animations are playing.
  122851. */
  122852. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  122853. /**
  122854. * Gets the first frame
  122855. */
  122856. get from(): number;
  122857. /**
  122858. * Gets the last frame
  122859. */
  122860. get to(): number;
  122861. /**
  122862. * Define if the animations are started
  122863. */
  122864. get isStarted(): boolean;
  122865. /**
  122866. * Gets a value indicating that the current group is playing
  122867. */
  122868. get isPlaying(): boolean;
  122869. /**
  122870. * Gets or sets the speed ratio to use for all animations
  122871. */
  122872. get speedRatio(): number;
  122873. /**
  122874. * Gets or sets the speed ratio to use for all animations
  122875. */
  122876. set speedRatio(value: number);
  122877. /**
  122878. * Gets or sets if all animations should loop or not
  122879. */
  122880. get loopAnimation(): boolean;
  122881. set loopAnimation(value: boolean);
  122882. /**
  122883. * Gets or sets if all animations should be evaluated additively
  122884. */
  122885. get isAdditive(): boolean;
  122886. set isAdditive(value: boolean);
  122887. /**
  122888. * Gets the targeted animations for this animation group
  122889. */
  122890. get targetedAnimations(): Array<TargetedAnimation>;
  122891. /**
  122892. * returning the list of animatables controlled by this animation group.
  122893. */
  122894. get animatables(): Array<Animatable>;
  122895. /**
  122896. * Gets the list of target animations
  122897. */
  122898. get children(): TargetedAnimation[];
  122899. /**
  122900. * Instantiates a new Animation Group.
  122901. * This helps managing several animations at once.
  122902. * @see https://doc.babylonjs.com/how_to/group
  122903. * @param name Defines the name of the group
  122904. * @param scene Defines the scene the group belongs to
  122905. */
  122906. constructor(
  122907. /** The name of the animation group */
  122908. name: string, scene?: Nullable<Scene>);
  122909. /**
  122910. * Add an animation (with its target) in the group
  122911. * @param animation defines the animation we want to add
  122912. * @param target defines the target of the animation
  122913. * @returns the TargetedAnimation object
  122914. */
  122915. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  122916. /**
  122917. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  122918. * It can add constant keys at begin or end
  122919. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  122920. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  122921. * @returns the animation group
  122922. */
  122923. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  122924. private _animationLoopCount;
  122925. private _animationLoopFlags;
  122926. private _processLoop;
  122927. /**
  122928. * Start all animations on given targets
  122929. * @param loop defines if animations must loop
  122930. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  122931. * @param from defines the from key (optional)
  122932. * @param to defines the to key (optional)
  122933. * @param isAdditive defines the additive state for the resulting animatables (optional)
  122934. * @returns the current animation group
  122935. */
  122936. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  122937. /**
  122938. * Pause all animations
  122939. * @returns the animation group
  122940. */
  122941. pause(): AnimationGroup;
  122942. /**
  122943. * Play all animations to initial state
  122944. * This function will start() the animations if they were not started or will restart() them if they were paused
  122945. * @param loop defines if animations must loop
  122946. * @returns the animation group
  122947. */
  122948. play(loop?: boolean): AnimationGroup;
  122949. /**
  122950. * Reset all animations to initial state
  122951. * @returns the animation group
  122952. */
  122953. reset(): AnimationGroup;
  122954. /**
  122955. * Restart animations from key 0
  122956. * @returns the animation group
  122957. */
  122958. restart(): AnimationGroup;
  122959. /**
  122960. * Stop all animations
  122961. * @returns the animation group
  122962. */
  122963. stop(): AnimationGroup;
  122964. /**
  122965. * Set animation weight for all animatables
  122966. * @param weight defines the weight to use
  122967. * @return the animationGroup
  122968. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  122969. */
  122970. setWeightForAllAnimatables(weight: number): AnimationGroup;
  122971. /**
  122972. * Synchronize and normalize all animatables with a source animatable
  122973. * @param root defines the root animatable to synchronize with
  122974. * @return the animationGroup
  122975. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  122976. */
  122977. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  122978. /**
  122979. * Goes to a specific frame in this animation group
  122980. * @param frame the frame number to go to
  122981. * @return the animationGroup
  122982. */
  122983. goToFrame(frame: number): AnimationGroup;
  122984. /**
  122985. * Dispose all associated resources
  122986. */
  122987. dispose(): void;
  122988. private _checkAnimationGroupEnded;
  122989. /**
  122990. * Clone the current animation group and returns a copy
  122991. * @param newName defines the name of the new group
  122992. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  122993. * @returns the new aniamtion group
  122994. */
  122995. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  122996. /**
  122997. * Serializes the animationGroup to an object
  122998. * @returns Serialized object
  122999. */
  123000. serialize(): any;
  123001. /**
  123002. * Returns a new AnimationGroup object parsed from the source provided.
  123003. * @param parsedAnimationGroup defines the source
  123004. * @param scene defines the scene that will receive the animationGroup
  123005. * @returns a new AnimationGroup
  123006. */
  123007. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  123008. /**
  123009. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  123010. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  123011. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  123012. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  123013. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  123014. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  123015. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  123016. */
  123017. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  123018. /**
  123019. * Returns the string "AnimationGroup"
  123020. * @returns "AnimationGroup"
  123021. */
  123022. getClassName(): string;
  123023. /**
  123024. * Creates a detailled string about the object
  123025. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  123026. * @returns a string representing the object
  123027. */
  123028. toString(fullDetails?: boolean): string;
  123029. }
  123030. }
  123031. declare module BABYLON {
  123032. /**
  123033. * Define an interface for all classes that will hold resources
  123034. */
  123035. export interface IDisposable {
  123036. /**
  123037. * Releases all held resources
  123038. */
  123039. dispose(): void;
  123040. }
  123041. /** Interface defining initialization parameters for Scene class */
  123042. export interface SceneOptions {
  123043. /**
  123044. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  123045. * It will improve performance when the number of geometries becomes important.
  123046. */
  123047. useGeometryUniqueIdsMap?: boolean;
  123048. /**
  123049. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  123050. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123051. */
  123052. useMaterialMeshMap?: boolean;
  123053. /**
  123054. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  123055. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123056. */
  123057. useClonedMeshMap?: boolean;
  123058. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  123059. virtual?: boolean;
  123060. }
  123061. /**
  123062. * Represents a scene to be rendered by the engine.
  123063. * @see https://doc.babylonjs.com/features/scene
  123064. */
  123065. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  123066. /** The fog is deactivated */
  123067. static readonly FOGMODE_NONE: number;
  123068. /** The fog density is following an exponential function */
  123069. static readonly FOGMODE_EXP: number;
  123070. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  123071. static readonly FOGMODE_EXP2: number;
  123072. /** The fog density is following a linear function. */
  123073. static readonly FOGMODE_LINEAR: number;
  123074. /**
  123075. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  123076. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123077. */
  123078. static MinDeltaTime: number;
  123079. /**
  123080. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  123081. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123082. */
  123083. static MaxDeltaTime: number;
  123084. /**
  123085. * Factory used to create the default material.
  123086. * @param name The name of the material to create
  123087. * @param scene The scene to create the material for
  123088. * @returns The default material
  123089. */
  123090. static DefaultMaterialFactory(scene: Scene): Material;
  123091. /**
  123092. * Factory used to create the a collision coordinator.
  123093. * @returns The collision coordinator
  123094. */
  123095. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  123096. /** @hidden */
  123097. _inputManager: InputManager;
  123098. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  123099. cameraToUseForPointers: Nullable<Camera>;
  123100. /** @hidden */
  123101. readonly _isScene: boolean;
  123102. /** @hidden */
  123103. _blockEntityCollection: boolean;
  123104. /**
  123105. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  123106. */
  123107. autoClear: boolean;
  123108. /**
  123109. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  123110. */
  123111. autoClearDepthAndStencil: boolean;
  123112. /**
  123113. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  123114. */
  123115. clearColor: Color4;
  123116. /**
  123117. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  123118. */
  123119. ambientColor: Color3;
  123120. /**
  123121. * This is use to store the default BRDF lookup for PBR materials in your scene.
  123122. * It should only be one of the following (if not the default embedded one):
  123123. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  123124. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  123125. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  123126. * The material properties need to be setup according to the type of texture in use.
  123127. */
  123128. environmentBRDFTexture: BaseTexture;
  123129. /**
  123130. * Texture used in all pbr material as the reflection texture.
  123131. * As in the majority of the scene they are the same (exception for multi room and so on),
  123132. * this is easier to reference from here than from all the materials.
  123133. */
  123134. get environmentTexture(): Nullable<BaseTexture>;
  123135. /**
  123136. * Texture used in all pbr material as the reflection texture.
  123137. * As in the majority of the scene they are the same (exception for multi room and so on),
  123138. * this is easier to set here than in all the materials.
  123139. */
  123140. set environmentTexture(value: Nullable<BaseTexture>);
  123141. /** @hidden */
  123142. protected _environmentIntensity: number;
  123143. /**
  123144. * Intensity of the environment in all pbr material.
  123145. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123146. * As in the majority of the scene they are the same (exception for multi room and so on),
  123147. * this is easier to reference from here than from all the materials.
  123148. */
  123149. get environmentIntensity(): number;
  123150. /**
  123151. * Intensity of the environment in all pbr material.
  123152. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123153. * As in the majority of the scene they are the same (exception for multi room and so on),
  123154. * this is easier to set here than in all the materials.
  123155. */
  123156. set environmentIntensity(value: number);
  123157. /** @hidden */
  123158. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123159. /**
  123160. * Default image processing configuration used either in the rendering
  123161. * Forward main pass or through the imageProcessingPostProcess if present.
  123162. * As in the majority of the scene they are the same (exception for multi camera),
  123163. * this is easier to reference from here than from all the materials and post process.
  123164. *
  123165. * No setter as we it is a shared configuration, you can set the values instead.
  123166. */
  123167. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123168. private _forceWireframe;
  123169. /**
  123170. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123171. */
  123172. set forceWireframe(value: boolean);
  123173. get forceWireframe(): boolean;
  123174. private _skipFrustumClipping;
  123175. /**
  123176. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123177. */
  123178. set skipFrustumClipping(value: boolean);
  123179. get skipFrustumClipping(): boolean;
  123180. private _forcePointsCloud;
  123181. /**
  123182. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123183. */
  123184. set forcePointsCloud(value: boolean);
  123185. get forcePointsCloud(): boolean;
  123186. /**
  123187. * Gets or sets the active clipplane 1
  123188. */
  123189. clipPlane: Nullable<Plane>;
  123190. /**
  123191. * Gets or sets the active clipplane 2
  123192. */
  123193. clipPlane2: Nullable<Plane>;
  123194. /**
  123195. * Gets or sets the active clipplane 3
  123196. */
  123197. clipPlane3: Nullable<Plane>;
  123198. /**
  123199. * Gets or sets the active clipplane 4
  123200. */
  123201. clipPlane4: Nullable<Plane>;
  123202. /**
  123203. * Gets or sets the active clipplane 5
  123204. */
  123205. clipPlane5: Nullable<Plane>;
  123206. /**
  123207. * Gets or sets the active clipplane 6
  123208. */
  123209. clipPlane6: Nullable<Plane>;
  123210. /**
  123211. * Gets or sets a boolean indicating if animations are enabled
  123212. */
  123213. animationsEnabled: boolean;
  123214. private _animationPropertiesOverride;
  123215. /**
  123216. * Gets or sets the animation properties override
  123217. */
  123218. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123219. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123220. /**
  123221. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123222. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123223. */
  123224. useConstantAnimationDeltaTime: boolean;
  123225. /**
  123226. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123227. * Please note that it requires to run a ray cast through the scene on every frame
  123228. */
  123229. constantlyUpdateMeshUnderPointer: boolean;
  123230. /**
  123231. * Defines the HTML cursor to use when hovering over interactive elements
  123232. */
  123233. hoverCursor: string;
  123234. /**
  123235. * Defines the HTML default cursor to use (empty by default)
  123236. */
  123237. defaultCursor: string;
  123238. /**
  123239. * Defines whether cursors are handled by the scene.
  123240. */
  123241. doNotHandleCursors: boolean;
  123242. /**
  123243. * This is used to call preventDefault() on pointer down
  123244. * in order to block unwanted artifacts like system double clicks
  123245. */
  123246. preventDefaultOnPointerDown: boolean;
  123247. /**
  123248. * This is used to call preventDefault() on pointer up
  123249. * in order to block unwanted artifacts like system double clicks
  123250. */
  123251. preventDefaultOnPointerUp: boolean;
  123252. /**
  123253. * Gets or sets user defined metadata
  123254. */
  123255. metadata: any;
  123256. /**
  123257. * For internal use only. Please do not use.
  123258. */
  123259. reservedDataStore: any;
  123260. /**
  123261. * Gets the name of the plugin used to load this scene (null by default)
  123262. */
  123263. loadingPluginName: string;
  123264. /**
  123265. * Use this array to add regular expressions used to disable offline support for specific urls
  123266. */
  123267. disableOfflineSupportExceptionRules: RegExp[];
  123268. /**
  123269. * An event triggered when the scene is disposed.
  123270. */
  123271. onDisposeObservable: Observable<Scene>;
  123272. private _onDisposeObserver;
  123273. /** Sets a function to be executed when this scene is disposed. */
  123274. set onDispose(callback: () => void);
  123275. /**
  123276. * An event triggered before rendering the scene (right after animations and physics)
  123277. */
  123278. onBeforeRenderObservable: Observable<Scene>;
  123279. private _onBeforeRenderObserver;
  123280. /** Sets a function to be executed before rendering this scene */
  123281. set beforeRender(callback: Nullable<() => void>);
  123282. /**
  123283. * An event triggered after rendering the scene
  123284. */
  123285. onAfterRenderObservable: Observable<Scene>;
  123286. /**
  123287. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  123288. */
  123289. onAfterRenderCameraObservable: Observable<Camera>;
  123290. private _onAfterRenderObserver;
  123291. /** Sets a function to be executed after rendering this scene */
  123292. set afterRender(callback: Nullable<() => void>);
  123293. /**
  123294. * An event triggered before animating the scene
  123295. */
  123296. onBeforeAnimationsObservable: Observable<Scene>;
  123297. /**
  123298. * An event triggered after animations processing
  123299. */
  123300. onAfterAnimationsObservable: Observable<Scene>;
  123301. /**
  123302. * An event triggered before draw calls are ready to be sent
  123303. */
  123304. onBeforeDrawPhaseObservable: Observable<Scene>;
  123305. /**
  123306. * An event triggered after draw calls have been sent
  123307. */
  123308. onAfterDrawPhaseObservable: Observable<Scene>;
  123309. /**
  123310. * An event triggered when the scene is ready
  123311. */
  123312. onReadyObservable: Observable<Scene>;
  123313. /**
  123314. * An event triggered before rendering a camera
  123315. */
  123316. onBeforeCameraRenderObservable: Observable<Camera>;
  123317. private _onBeforeCameraRenderObserver;
  123318. /** Sets a function to be executed before rendering a camera*/
  123319. set beforeCameraRender(callback: () => void);
  123320. /**
  123321. * An event triggered after rendering a camera
  123322. */
  123323. onAfterCameraRenderObservable: Observable<Camera>;
  123324. private _onAfterCameraRenderObserver;
  123325. /** Sets a function to be executed after rendering a camera*/
  123326. set afterCameraRender(callback: () => void);
  123327. /**
  123328. * An event triggered when active meshes evaluation is about to start
  123329. */
  123330. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  123331. /**
  123332. * An event triggered when active meshes evaluation is done
  123333. */
  123334. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  123335. /**
  123336. * An event triggered when particles rendering is about to start
  123337. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123338. */
  123339. onBeforeParticlesRenderingObservable: Observable<Scene>;
  123340. /**
  123341. * An event triggered when particles rendering is done
  123342. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  123343. */
  123344. onAfterParticlesRenderingObservable: Observable<Scene>;
  123345. /**
  123346. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  123347. */
  123348. onDataLoadedObservable: Observable<Scene>;
  123349. /**
  123350. * An event triggered when a camera is created
  123351. */
  123352. onNewCameraAddedObservable: Observable<Camera>;
  123353. /**
  123354. * An event triggered when a camera is removed
  123355. */
  123356. onCameraRemovedObservable: Observable<Camera>;
  123357. /**
  123358. * An event triggered when a light is created
  123359. */
  123360. onNewLightAddedObservable: Observable<Light>;
  123361. /**
  123362. * An event triggered when a light is removed
  123363. */
  123364. onLightRemovedObservable: Observable<Light>;
  123365. /**
  123366. * An event triggered when a geometry is created
  123367. */
  123368. onNewGeometryAddedObservable: Observable<Geometry>;
  123369. /**
  123370. * An event triggered when a geometry is removed
  123371. */
  123372. onGeometryRemovedObservable: Observable<Geometry>;
  123373. /**
  123374. * An event triggered when a transform node is created
  123375. */
  123376. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  123377. /**
  123378. * An event triggered when a transform node is removed
  123379. */
  123380. onTransformNodeRemovedObservable: Observable<TransformNode>;
  123381. /**
  123382. * An event triggered when a mesh is created
  123383. */
  123384. onNewMeshAddedObservable: Observable<AbstractMesh>;
  123385. /**
  123386. * An event triggered when a mesh is removed
  123387. */
  123388. onMeshRemovedObservable: Observable<AbstractMesh>;
  123389. /**
  123390. * An event triggered when a skeleton is created
  123391. */
  123392. onNewSkeletonAddedObservable: Observable<Skeleton>;
  123393. /**
  123394. * An event triggered when a skeleton is removed
  123395. */
  123396. onSkeletonRemovedObservable: Observable<Skeleton>;
  123397. /**
  123398. * An event triggered when a material is created
  123399. */
  123400. onNewMaterialAddedObservable: Observable<Material>;
  123401. /**
  123402. * An event triggered when a material is removed
  123403. */
  123404. onMaterialRemovedObservable: Observable<Material>;
  123405. /**
  123406. * An event triggered when a texture is created
  123407. */
  123408. onNewTextureAddedObservable: Observable<BaseTexture>;
  123409. /**
  123410. * An event triggered when a texture is removed
  123411. */
  123412. onTextureRemovedObservable: Observable<BaseTexture>;
  123413. /**
  123414. * An event triggered when render targets are about to be rendered
  123415. * Can happen multiple times per frame.
  123416. */
  123417. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  123418. /**
  123419. * An event triggered when render targets were rendered.
  123420. * Can happen multiple times per frame.
  123421. */
  123422. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  123423. /**
  123424. * An event triggered before calculating deterministic simulation step
  123425. */
  123426. onBeforeStepObservable: Observable<Scene>;
  123427. /**
  123428. * An event triggered after calculating deterministic simulation step
  123429. */
  123430. onAfterStepObservable: Observable<Scene>;
  123431. /**
  123432. * An event triggered when the activeCamera property is updated
  123433. */
  123434. onActiveCameraChanged: Observable<Scene>;
  123435. /**
  123436. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  123437. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123438. * 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)
  123439. */
  123440. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123441. /**
  123442. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  123443. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  123444. * 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)
  123445. */
  123446. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  123447. /**
  123448. * This Observable will when a mesh has been imported into the scene.
  123449. */
  123450. onMeshImportedObservable: Observable<AbstractMesh>;
  123451. /**
  123452. * This Observable will when an animation file has been imported into the scene.
  123453. */
  123454. onAnimationFileImportedObservable: Observable<Scene>;
  123455. /**
  123456. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  123457. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  123458. */
  123459. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  123460. /** @hidden */
  123461. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  123462. /**
  123463. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  123464. */
  123465. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  123466. /**
  123467. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  123468. */
  123469. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  123470. /**
  123471. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  123472. */
  123473. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  123474. /** Callback called when a pointer move is detected */
  123475. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123476. /** Callback called when a pointer down is detected */
  123477. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  123478. /** Callback called when a pointer up is detected */
  123479. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  123480. /** Callback called when a pointer pick is detected */
  123481. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  123482. /**
  123483. * 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).
  123484. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  123485. */
  123486. onPrePointerObservable: Observable<PointerInfoPre>;
  123487. /**
  123488. * Observable event triggered each time an input event is received from the rendering canvas
  123489. */
  123490. onPointerObservable: Observable<PointerInfo>;
  123491. /**
  123492. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  123493. */
  123494. get unTranslatedPointer(): Vector2;
  123495. /**
  123496. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  123497. */
  123498. static get DragMovementThreshold(): number;
  123499. static set DragMovementThreshold(value: number);
  123500. /**
  123501. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  123502. */
  123503. static get LongPressDelay(): number;
  123504. static set LongPressDelay(value: number);
  123505. /**
  123506. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  123507. */
  123508. static get DoubleClickDelay(): number;
  123509. static set DoubleClickDelay(value: number);
  123510. /** If you need to check double click without raising a single click at first click, enable this flag */
  123511. static get ExclusiveDoubleClickMode(): boolean;
  123512. static set ExclusiveDoubleClickMode(value: boolean);
  123513. /** @hidden */
  123514. _mirroredCameraPosition: Nullable<Vector3>;
  123515. /**
  123516. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  123517. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  123518. */
  123519. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  123520. /**
  123521. * Observable event triggered each time an keyboard event is received from the hosting window
  123522. */
  123523. onKeyboardObservable: Observable<KeyboardInfo>;
  123524. private _useRightHandedSystem;
  123525. /**
  123526. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  123527. */
  123528. set useRightHandedSystem(value: boolean);
  123529. get useRightHandedSystem(): boolean;
  123530. private _timeAccumulator;
  123531. private _currentStepId;
  123532. private _currentInternalStep;
  123533. /**
  123534. * Sets the step Id used by deterministic lock step
  123535. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123536. * @param newStepId defines the step Id
  123537. */
  123538. setStepId(newStepId: number): void;
  123539. /**
  123540. * Gets the step Id used by deterministic lock step
  123541. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123542. * @returns the step Id
  123543. */
  123544. getStepId(): number;
  123545. /**
  123546. * Gets the internal step used by deterministic lock step
  123547. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123548. * @returns the internal step
  123549. */
  123550. getInternalStep(): number;
  123551. private _fogEnabled;
  123552. /**
  123553. * Gets or sets a boolean indicating if fog is enabled on this scene
  123554. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123555. * (Default is true)
  123556. */
  123557. set fogEnabled(value: boolean);
  123558. get fogEnabled(): boolean;
  123559. private _fogMode;
  123560. /**
  123561. * Gets or sets the fog mode to use
  123562. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123563. * | mode | value |
  123564. * | --- | --- |
  123565. * | FOGMODE_NONE | 0 |
  123566. * | FOGMODE_EXP | 1 |
  123567. * | FOGMODE_EXP2 | 2 |
  123568. * | FOGMODE_LINEAR | 3 |
  123569. */
  123570. set fogMode(value: number);
  123571. get fogMode(): number;
  123572. /**
  123573. * Gets or sets the fog color to use
  123574. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123575. * (Default is Color3(0.2, 0.2, 0.3))
  123576. */
  123577. fogColor: Color3;
  123578. /**
  123579. * Gets or sets the fog density to use
  123580. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123581. * (Default is 0.1)
  123582. */
  123583. fogDensity: number;
  123584. /**
  123585. * Gets or sets the fog start distance to use
  123586. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123587. * (Default is 0)
  123588. */
  123589. fogStart: number;
  123590. /**
  123591. * Gets or sets the fog end distance to use
  123592. * @see https://doc.babylonjs.com/babylon101/environment#fog
  123593. * (Default is 1000)
  123594. */
  123595. fogEnd: number;
  123596. /**
  123597. * Flag indicating that the frame buffer binding is handled by another component
  123598. */
  123599. prePass: boolean;
  123600. private _shadowsEnabled;
  123601. /**
  123602. * Gets or sets a boolean indicating if shadows are enabled on this scene
  123603. */
  123604. set shadowsEnabled(value: boolean);
  123605. get shadowsEnabled(): boolean;
  123606. private _lightsEnabled;
  123607. /**
  123608. * Gets or sets a boolean indicating if lights are enabled on this scene
  123609. */
  123610. set lightsEnabled(value: boolean);
  123611. get lightsEnabled(): boolean;
  123612. /** All of the active cameras added to this scene. */
  123613. activeCameras: Camera[];
  123614. /** @hidden */
  123615. _activeCamera: Nullable<Camera>;
  123616. /** Gets or sets the current active camera */
  123617. get activeCamera(): Nullable<Camera>;
  123618. set activeCamera(value: Nullable<Camera>);
  123619. private _defaultMaterial;
  123620. /** The default material used on meshes when no material is affected */
  123621. get defaultMaterial(): Material;
  123622. /** The default material used on meshes when no material is affected */
  123623. set defaultMaterial(value: Material);
  123624. private _texturesEnabled;
  123625. /**
  123626. * Gets or sets a boolean indicating if textures are enabled on this scene
  123627. */
  123628. set texturesEnabled(value: boolean);
  123629. get texturesEnabled(): boolean;
  123630. /**
  123631. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  123632. */
  123633. physicsEnabled: boolean;
  123634. /**
  123635. * Gets or sets a boolean indicating if particles are enabled on this scene
  123636. */
  123637. particlesEnabled: boolean;
  123638. /**
  123639. * Gets or sets a boolean indicating if sprites are enabled on this scene
  123640. */
  123641. spritesEnabled: boolean;
  123642. private _skeletonsEnabled;
  123643. /**
  123644. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  123645. */
  123646. set skeletonsEnabled(value: boolean);
  123647. get skeletonsEnabled(): boolean;
  123648. /**
  123649. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  123650. */
  123651. lensFlaresEnabled: boolean;
  123652. /**
  123653. * Gets or sets a boolean indicating if collisions are enabled on this scene
  123654. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123655. */
  123656. collisionsEnabled: boolean;
  123657. private _collisionCoordinator;
  123658. /** @hidden */
  123659. get collisionCoordinator(): ICollisionCoordinator;
  123660. /**
  123661. * Defines the gravity applied to this scene (used only for collisions)
  123662. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  123663. */
  123664. gravity: Vector3;
  123665. /**
  123666. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  123667. */
  123668. postProcessesEnabled: boolean;
  123669. /**
  123670. * Gets the current postprocess manager
  123671. */
  123672. postProcessManager: PostProcessManager;
  123673. /**
  123674. * Gets or sets a boolean indicating if render targets are enabled on this scene
  123675. */
  123676. renderTargetsEnabled: boolean;
  123677. /**
  123678. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  123679. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  123680. */
  123681. dumpNextRenderTargets: boolean;
  123682. /**
  123683. * The list of user defined render targets added to the scene
  123684. */
  123685. customRenderTargets: RenderTargetTexture[];
  123686. /**
  123687. * Defines if texture loading must be delayed
  123688. * If true, textures will only be loaded when they need to be rendered
  123689. */
  123690. useDelayedTextureLoading: boolean;
  123691. /**
  123692. * Gets the list of meshes imported to the scene through SceneLoader
  123693. */
  123694. importedMeshesFiles: String[];
  123695. /**
  123696. * Gets or sets a boolean indicating if probes are enabled on this scene
  123697. */
  123698. probesEnabled: boolean;
  123699. /**
  123700. * Gets or sets the current offline provider to use to store scene data
  123701. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  123702. */
  123703. offlineProvider: IOfflineProvider;
  123704. /**
  123705. * Gets or sets the action manager associated with the scene
  123706. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  123707. */
  123708. actionManager: AbstractActionManager;
  123709. private _meshesForIntersections;
  123710. /**
  123711. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  123712. */
  123713. proceduralTexturesEnabled: boolean;
  123714. private _engine;
  123715. private _totalVertices;
  123716. /** @hidden */
  123717. _activeIndices: PerfCounter;
  123718. /** @hidden */
  123719. _activeParticles: PerfCounter;
  123720. /** @hidden */
  123721. _activeBones: PerfCounter;
  123722. private _animationRatio;
  123723. /** @hidden */
  123724. _animationTimeLast: number;
  123725. /** @hidden */
  123726. _animationTime: number;
  123727. /**
  123728. * Gets or sets a general scale for animation speed
  123729. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  123730. */
  123731. animationTimeScale: number;
  123732. /** @hidden */
  123733. _cachedMaterial: Nullable<Material>;
  123734. /** @hidden */
  123735. _cachedEffect: Nullable<Effect>;
  123736. /** @hidden */
  123737. _cachedVisibility: Nullable<number>;
  123738. private _renderId;
  123739. private _frameId;
  123740. private _executeWhenReadyTimeoutId;
  123741. private _intermediateRendering;
  123742. private _viewUpdateFlag;
  123743. private _projectionUpdateFlag;
  123744. /** @hidden */
  123745. _toBeDisposed: Nullable<IDisposable>[];
  123746. private _activeRequests;
  123747. /** @hidden */
  123748. _pendingData: any[];
  123749. private _isDisposed;
  123750. /**
  123751. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  123752. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  123753. */
  123754. dispatchAllSubMeshesOfActiveMeshes: boolean;
  123755. private _activeMeshes;
  123756. private _processedMaterials;
  123757. private _renderTargets;
  123758. /** @hidden */
  123759. _activeParticleSystems: SmartArray<IParticleSystem>;
  123760. private _activeSkeletons;
  123761. private _softwareSkinnedMeshes;
  123762. private _renderingManager;
  123763. /** @hidden */
  123764. _activeAnimatables: Animatable[];
  123765. private _transformMatrix;
  123766. private _sceneUbo;
  123767. /** @hidden */
  123768. _viewMatrix: Matrix;
  123769. private _projectionMatrix;
  123770. /** @hidden */
  123771. _forcedViewPosition: Nullable<Vector3>;
  123772. /** @hidden */
  123773. _frustumPlanes: Plane[];
  123774. /**
  123775. * Gets the list of frustum planes (built from the active camera)
  123776. */
  123777. get frustumPlanes(): Plane[];
  123778. /**
  123779. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  123780. * This is useful if there are more lights that the maximum simulteanous authorized
  123781. */
  123782. requireLightSorting: boolean;
  123783. /** @hidden */
  123784. readonly useMaterialMeshMap: boolean;
  123785. /** @hidden */
  123786. readonly useClonedMeshMap: boolean;
  123787. private _externalData;
  123788. private _uid;
  123789. /**
  123790. * @hidden
  123791. * Backing store of defined scene components.
  123792. */
  123793. _components: ISceneComponent[];
  123794. /**
  123795. * @hidden
  123796. * Backing store of defined scene components.
  123797. */
  123798. _serializableComponents: ISceneSerializableComponent[];
  123799. /**
  123800. * List of components to register on the next registration step.
  123801. */
  123802. private _transientComponents;
  123803. /**
  123804. * Registers the transient components if needed.
  123805. */
  123806. private _registerTransientComponents;
  123807. /**
  123808. * @hidden
  123809. * Add a component to the scene.
  123810. * Note that the ccomponent could be registered on th next frame if this is called after
  123811. * the register component stage.
  123812. * @param component Defines the component to add to the scene
  123813. */
  123814. _addComponent(component: ISceneComponent): void;
  123815. /**
  123816. * @hidden
  123817. * Gets a component from the scene.
  123818. * @param name defines the name of the component to retrieve
  123819. * @returns the component or null if not present
  123820. */
  123821. _getComponent(name: string): Nullable<ISceneComponent>;
  123822. /**
  123823. * @hidden
  123824. * Defines the actions happening before camera updates.
  123825. */
  123826. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  123827. /**
  123828. * @hidden
  123829. * Defines the actions happening before clear the canvas.
  123830. */
  123831. _beforeClearStage: Stage<SimpleStageAction>;
  123832. /**
  123833. * @hidden
  123834. * Defines the actions when collecting render targets for the frame.
  123835. */
  123836. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123837. /**
  123838. * @hidden
  123839. * Defines the actions happening for one camera in the frame.
  123840. */
  123841. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  123842. /**
  123843. * @hidden
  123844. * Defines the actions happening during the per mesh ready checks.
  123845. */
  123846. _isReadyForMeshStage: Stage<MeshStageAction>;
  123847. /**
  123848. * @hidden
  123849. * Defines the actions happening before evaluate active mesh checks.
  123850. */
  123851. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  123852. /**
  123853. * @hidden
  123854. * Defines the actions happening during the evaluate sub mesh checks.
  123855. */
  123856. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  123857. /**
  123858. * @hidden
  123859. * Defines the actions happening during the active mesh stage.
  123860. */
  123861. _activeMeshStage: Stage<ActiveMeshStageAction>;
  123862. /**
  123863. * @hidden
  123864. * Defines the actions happening during the per camera render target step.
  123865. */
  123866. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  123867. /**
  123868. * @hidden
  123869. * Defines the actions happening just before the active camera is drawing.
  123870. */
  123871. _beforeCameraDrawStage: Stage<CameraStageAction>;
  123872. /**
  123873. * @hidden
  123874. * Defines the actions happening just before a render target is drawing.
  123875. */
  123876. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123877. /**
  123878. * @hidden
  123879. * Defines the actions happening just before a rendering group is drawing.
  123880. */
  123881. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123882. /**
  123883. * @hidden
  123884. * Defines the actions happening just before a mesh is drawing.
  123885. */
  123886. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  123887. /**
  123888. * @hidden
  123889. * Defines the actions happening just after a mesh has been drawn.
  123890. */
  123891. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  123892. /**
  123893. * @hidden
  123894. * Defines the actions happening just after a rendering group has been drawn.
  123895. */
  123896. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  123897. /**
  123898. * @hidden
  123899. * Defines the actions happening just after the active camera has been drawn.
  123900. */
  123901. _afterCameraDrawStage: Stage<CameraStageAction>;
  123902. /**
  123903. * @hidden
  123904. * Defines the actions happening just after a render target has been drawn.
  123905. */
  123906. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  123907. /**
  123908. * @hidden
  123909. * Defines the actions happening just after rendering all cameras and computing intersections.
  123910. */
  123911. _afterRenderStage: Stage<SimpleStageAction>;
  123912. /**
  123913. * @hidden
  123914. * Defines the actions happening when a pointer move event happens.
  123915. */
  123916. _pointerMoveStage: Stage<PointerMoveStageAction>;
  123917. /**
  123918. * @hidden
  123919. * Defines the actions happening when a pointer down event happens.
  123920. */
  123921. _pointerDownStage: Stage<PointerUpDownStageAction>;
  123922. /**
  123923. * @hidden
  123924. * Defines the actions happening when a pointer up event happens.
  123925. */
  123926. _pointerUpStage: Stage<PointerUpDownStageAction>;
  123927. /**
  123928. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  123929. */
  123930. private geometriesByUniqueId;
  123931. /**
  123932. * Creates a new Scene
  123933. * @param engine defines the engine to use to render this scene
  123934. * @param options defines the scene options
  123935. */
  123936. constructor(engine: Engine, options?: SceneOptions);
  123937. /**
  123938. * Gets a string identifying the name of the class
  123939. * @returns "Scene" string
  123940. */
  123941. getClassName(): string;
  123942. private _defaultMeshCandidates;
  123943. /**
  123944. * @hidden
  123945. */
  123946. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  123947. private _defaultSubMeshCandidates;
  123948. /**
  123949. * @hidden
  123950. */
  123951. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  123952. /**
  123953. * Sets the default candidate providers for the scene.
  123954. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  123955. * and getCollidingSubMeshCandidates to their default function
  123956. */
  123957. setDefaultCandidateProviders(): void;
  123958. /**
  123959. * Gets the mesh that is currently under the pointer
  123960. */
  123961. get meshUnderPointer(): Nullable<AbstractMesh>;
  123962. /**
  123963. * Gets or sets the current on-screen X position of the pointer
  123964. */
  123965. get pointerX(): number;
  123966. set pointerX(value: number);
  123967. /**
  123968. * Gets or sets the current on-screen Y position of the pointer
  123969. */
  123970. get pointerY(): number;
  123971. set pointerY(value: number);
  123972. /**
  123973. * Gets the cached material (ie. the latest rendered one)
  123974. * @returns the cached material
  123975. */
  123976. getCachedMaterial(): Nullable<Material>;
  123977. /**
  123978. * Gets the cached effect (ie. the latest rendered one)
  123979. * @returns the cached effect
  123980. */
  123981. getCachedEffect(): Nullable<Effect>;
  123982. /**
  123983. * Gets the cached visibility state (ie. the latest rendered one)
  123984. * @returns the cached visibility state
  123985. */
  123986. getCachedVisibility(): Nullable<number>;
  123987. /**
  123988. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  123989. * @param material defines the current material
  123990. * @param effect defines the current effect
  123991. * @param visibility defines the current visibility state
  123992. * @returns true if one parameter is not cached
  123993. */
  123994. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  123995. /**
  123996. * Gets the engine associated with the scene
  123997. * @returns an Engine
  123998. */
  123999. getEngine(): Engine;
  124000. /**
  124001. * Gets the total number of vertices rendered per frame
  124002. * @returns the total number of vertices rendered per frame
  124003. */
  124004. getTotalVertices(): number;
  124005. /**
  124006. * Gets the performance counter for total vertices
  124007. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124008. */
  124009. get totalVerticesPerfCounter(): PerfCounter;
  124010. /**
  124011. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  124012. * @returns the total number of active indices rendered per frame
  124013. */
  124014. getActiveIndices(): number;
  124015. /**
  124016. * Gets the performance counter for active indices
  124017. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124018. */
  124019. get totalActiveIndicesPerfCounter(): PerfCounter;
  124020. /**
  124021. * Gets the total number of active particles rendered per frame
  124022. * @returns the total number of active particles rendered per frame
  124023. */
  124024. getActiveParticles(): number;
  124025. /**
  124026. * Gets the performance counter for active particles
  124027. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124028. */
  124029. get activeParticlesPerfCounter(): PerfCounter;
  124030. /**
  124031. * Gets the total number of active bones rendered per frame
  124032. * @returns the total number of active bones rendered per frame
  124033. */
  124034. getActiveBones(): number;
  124035. /**
  124036. * Gets the performance counter for active bones
  124037. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124038. */
  124039. get activeBonesPerfCounter(): PerfCounter;
  124040. /**
  124041. * Gets the array of active meshes
  124042. * @returns an array of AbstractMesh
  124043. */
  124044. getActiveMeshes(): SmartArray<AbstractMesh>;
  124045. /**
  124046. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  124047. * @returns a number
  124048. */
  124049. getAnimationRatio(): number;
  124050. /**
  124051. * Gets an unique Id for the current render phase
  124052. * @returns a number
  124053. */
  124054. getRenderId(): number;
  124055. /**
  124056. * Gets an unique Id for the current frame
  124057. * @returns a number
  124058. */
  124059. getFrameId(): number;
  124060. /** Call this function if you want to manually increment the render Id*/
  124061. incrementRenderId(): void;
  124062. private _createUbo;
  124063. /**
  124064. * Use this method to simulate a pointer move on a mesh
  124065. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124066. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124067. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124068. * @returns the current scene
  124069. */
  124070. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124071. /**
  124072. * Use this method to simulate a pointer down on a mesh
  124073. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124074. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124075. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124076. * @returns the current scene
  124077. */
  124078. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124079. /**
  124080. * Use this method to simulate a pointer up on a mesh
  124081. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124082. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124083. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124084. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124085. * @returns the current scene
  124086. */
  124087. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  124088. /**
  124089. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124090. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124091. * @returns true if the pointer was captured
  124092. */
  124093. isPointerCaptured(pointerId?: number): boolean;
  124094. /**
  124095. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124096. * @param attachUp defines if you want to attach events to pointerup
  124097. * @param attachDown defines if you want to attach events to pointerdown
  124098. * @param attachMove defines if you want to attach events to pointermove
  124099. */
  124100. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  124101. /** Detaches all event handlers*/
  124102. detachControl(): void;
  124103. /**
  124104. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  124105. * Delay loaded resources are not taking in account
  124106. * @return true if all required resources are ready
  124107. */
  124108. isReady(): boolean;
  124109. /** Resets all cached information relative to material (including effect and visibility) */
  124110. resetCachedMaterial(): void;
  124111. /**
  124112. * Registers a function to be called before every frame render
  124113. * @param func defines the function to register
  124114. */
  124115. registerBeforeRender(func: () => void): void;
  124116. /**
  124117. * Unregisters a function called before every frame render
  124118. * @param func defines the function to unregister
  124119. */
  124120. unregisterBeforeRender(func: () => void): void;
  124121. /**
  124122. * Registers a function to be called after every frame render
  124123. * @param func defines the function to register
  124124. */
  124125. registerAfterRender(func: () => void): void;
  124126. /**
  124127. * Unregisters a function called after every frame render
  124128. * @param func defines the function to unregister
  124129. */
  124130. unregisterAfterRender(func: () => void): void;
  124131. private _executeOnceBeforeRender;
  124132. /**
  124133. * The provided function will run before render once and will be disposed afterwards.
  124134. * A timeout delay can be provided so that the function will be executed in N ms.
  124135. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  124136. * @param func The function to be executed.
  124137. * @param timeout optional delay in ms
  124138. */
  124139. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  124140. /** @hidden */
  124141. _addPendingData(data: any): void;
  124142. /** @hidden */
  124143. _removePendingData(data: any): void;
  124144. /**
  124145. * Returns the number of items waiting to be loaded
  124146. * @returns the number of items waiting to be loaded
  124147. */
  124148. getWaitingItemsCount(): number;
  124149. /**
  124150. * Returns a boolean indicating if the scene is still loading data
  124151. */
  124152. get isLoading(): boolean;
  124153. /**
  124154. * Registers a function to be executed when the scene is ready
  124155. * @param {Function} func - the function to be executed
  124156. */
  124157. executeWhenReady(func: () => void): void;
  124158. /**
  124159. * Returns a promise that resolves when the scene is ready
  124160. * @returns A promise that resolves when the scene is ready
  124161. */
  124162. whenReadyAsync(): Promise<void>;
  124163. /** @hidden */
  124164. _checkIsReady(): void;
  124165. /**
  124166. * Gets all animatable attached to the scene
  124167. */
  124168. get animatables(): Animatable[];
  124169. /**
  124170. * Resets the last animation time frame.
  124171. * Useful to override when animations start running when loading a scene for the first time.
  124172. */
  124173. resetLastAnimationTimeFrame(): void;
  124174. /**
  124175. * Gets the current view matrix
  124176. * @returns a Matrix
  124177. */
  124178. getViewMatrix(): Matrix;
  124179. /**
  124180. * Gets the current projection matrix
  124181. * @returns a Matrix
  124182. */
  124183. getProjectionMatrix(): Matrix;
  124184. /**
  124185. * Gets the current transform matrix
  124186. * @returns a Matrix made of View * Projection
  124187. */
  124188. getTransformMatrix(): Matrix;
  124189. /**
  124190. * Sets the current transform matrix
  124191. * @param viewL defines the View matrix to use
  124192. * @param projectionL defines the Projection matrix to use
  124193. * @param viewR defines the right View matrix to use (if provided)
  124194. * @param projectionR defines the right Projection matrix to use (if provided)
  124195. */
  124196. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124197. /**
  124198. * Gets the uniform buffer used to store scene data
  124199. * @returns a UniformBuffer
  124200. */
  124201. getSceneUniformBuffer(): UniformBuffer;
  124202. /**
  124203. * Gets an unique (relatively to the current scene) Id
  124204. * @returns an unique number for the scene
  124205. */
  124206. getUniqueId(): number;
  124207. /**
  124208. * Add a mesh to the list of scene's meshes
  124209. * @param newMesh defines the mesh to add
  124210. * @param recursive if all child meshes should also be added to the scene
  124211. */
  124212. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124213. /**
  124214. * Remove a mesh for the list of scene's meshes
  124215. * @param toRemove defines the mesh to remove
  124216. * @param recursive if all child meshes should also be removed from the scene
  124217. * @returns the index where the mesh was in the mesh list
  124218. */
  124219. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124220. /**
  124221. * Add a transform node to the list of scene's transform nodes
  124222. * @param newTransformNode defines the transform node to add
  124223. */
  124224. addTransformNode(newTransformNode: TransformNode): void;
  124225. /**
  124226. * Remove a transform node for the list of scene's transform nodes
  124227. * @param toRemove defines the transform node to remove
  124228. * @returns the index where the transform node was in the transform node list
  124229. */
  124230. removeTransformNode(toRemove: TransformNode): number;
  124231. /**
  124232. * Remove a skeleton for the list of scene's skeletons
  124233. * @param toRemove defines the skeleton to remove
  124234. * @returns the index where the skeleton was in the skeleton list
  124235. */
  124236. removeSkeleton(toRemove: Skeleton): number;
  124237. /**
  124238. * Remove a morph target for the list of scene's morph targets
  124239. * @param toRemove defines the morph target to remove
  124240. * @returns the index where the morph target was in the morph target list
  124241. */
  124242. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  124243. /**
  124244. * Remove a light for the list of scene's lights
  124245. * @param toRemove defines the light to remove
  124246. * @returns the index where the light was in the light list
  124247. */
  124248. removeLight(toRemove: Light): number;
  124249. /**
  124250. * Remove a camera for the list of scene's cameras
  124251. * @param toRemove defines the camera to remove
  124252. * @returns the index where the camera was in the camera list
  124253. */
  124254. removeCamera(toRemove: Camera): number;
  124255. /**
  124256. * Remove a particle system for the list of scene's particle systems
  124257. * @param toRemove defines the particle system to remove
  124258. * @returns the index where the particle system was in the particle system list
  124259. */
  124260. removeParticleSystem(toRemove: IParticleSystem): number;
  124261. /**
  124262. * Remove a animation for the list of scene's animations
  124263. * @param toRemove defines the animation to remove
  124264. * @returns the index where the animation was in the animation list
  124265. */
  124266. removeAnimation(toRemove: Animation): number;
  124267. /**
  124268. * Will stop the animation of the given target
  124269. * @param target - the target
  124270. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  124271. * @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)
  124272. */
  124273. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  124274. /**
  124275. * Removes the given animation group from this scene.
  124276. * @param toRemove The animation group to remove
  124277. * @returns The index of the removed animation group
  124278. */
  124279. removeAnimationGroup(toRemove: AnimationGroup): number;
  124280. /**
  124281. * Removes the given multi-material from this scene.
  124282. * @param toRemove The multi-material to remove
  124283. * @returns The index of the removed multi-material
  124284. */
  124285. removeMultiMaterial(toRemove: MultiMaterial): number;
  124286. /**
  124287. * Removes the given material from this scene.
  124288. * @param toRemove The material to remove
  124289. * @returns The index of the removed material
  124290. */
  124291. removeMaterial(toRemove: Material): number;
  124292. /**
  124293. * Removes the given action manager from this scene.
  124294. * @param toRemove The action manager to remove
  124295. * @returns The index of the removed action manager
  124296. */
  124297. removeActionManager(toRemove: AbstractActionManager): number;
  124298. /**
  124299. * Removes the given texture from this scene.
  124300. * @param toRemove The texture to remove
  124301. * @returns The index of the removed texture
  124302. */
  124303. removeTexture(toRemove: BaseTexture): number;
  124304. /**
  124305. * Adds the given light to this scene
  124306. * @param newLight The light to add
  124307. */
  124308. addLight(newLight: Light): void;
  124309. /**
  124310. * Sorts the list list based on light priorities
  124311. */
  124312. sortLightsByPriority(): void;
  124313. /**
  124314. * Adds the given camera to this scene
  124315. * @param newCamera The camera to add
  124316. */
  124317. addCamera(newCamera: Camera): void;
  124318. /**
  124319. * Adds the given skeleton to this scene
  124320. * @param newSkeleton The skeleton to add
  124321. */
  124322. addSkeleton(newSkeleton: Skeleton): void;
  124323. /**
  124324. * Adds the given particle system to this scene
  124325. * @param newParticleSystem The particle system to add
  124326. */
  124327. addParticleSystem(newParticleSystem: IParticleSystem): void;
  124328. /**
  124329. * Adds the given animation to this scene
  124330. * @param newAnimation The animation to add
  124331. */
  124332. addAnimation(newAnimation: Animation): void;
  124333. /**
  124334. * Adds the given animation group to this scene.
  124335. * @param newAnimationGroup The animation group to add
  124336. */
  124337. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  124338. /**
  124339. * Adds the given multi-material to this scene
  124340. * @param newMultiMaterial The multi-material to add
  124341. */
  124342. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  124343. /**
  124344. * Adds the given material to this scene
  124345. * @param newMaterial The material to add
  124346. */
  124347. addMaterial(newMaterial: Material): void;
  124348. /**
  124349. * Adds the given morph target to this scene
  124350. * @param newMorphTargetManager The morph target to add
  124351. */
  124352. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  124353. /**
  124354. * Adds the given geometry to this scene
  124355. * @param newGeometry The geometry to add
  124356. */
  124357. addGeometry(newGeometry: Geometry): void;
  124358. /**
  124359. * Adds the given action manager to this scene
  124360. * @param newActionManager The action manager to add
  124361. */
  124362. addActionManager(newActionManager: AbstractActionManager): void;
  124363. /**
  124364. * Adds the given texture to this scene.
  124365. * @param newTexture The texture to add
  124366. */
  124367. addTexture(newTexture: BaseTexture): void;
  124368. /**
  124369. * Switch active camera
  124370. * @param newCamera defines the new active camera
  124371. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  124372. */
  124373. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  124374. /**
  124375. * sets the active camera of the scene using its ID
  124376. * @param id defines the camera's ID
  124377. * @return the new active camera or null if none found.
  124378. */
  124379. setActiveCameraByID(id: string): Nullable<Camera>;
  124380. /**
  124381. * sets the active camera of the scene using its name
  124382. * @param name defines the camera's name
  124383. * @returns the new active camera or null if none found.
  124384. */
  124385. setActiveCameraByName(name: string): Nullable<Camera>;
  124386. /**
  124387. * get an animation group using its name
  124388. * @param name defines the material's name
  124389. * @return the animation group or null if none found.
  124390. */
  124391. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  124392. /**
  124393. * Get a material using its unique id
  124394. * @param uniqueId defines the material's unique id
  124395. * @return the material or null if none found.
  124396. */
  124397. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  124398. /**
  124399. * get a material using its id
  124400. * @param id defines the material's ID
  124401. * @return the material or null if none found.
  124402. */
  124403. getMaterialByID(id: string): Nullable<Material>;
  124404. /**
  124405. * Gets a the last added material using a given id
  124406. * @param id defines the material's ID
  124407. * @return the last material with the given id or null if none found.
  124408. */
  124409. getLastMaterialByID(id: string): Nullable<Material>;
  124410. /**
  124411. * Gets a material using its name
  124412. * @param name defines the material's name
  124413. * @return the material or null if none found.
  124414. */
  124415. getMaterialByName(name: string): Nullable<Material>;
  124416. /**
  124417. * Get a texture using its unique id
  124418. * @param uniqueId defines the texture's unique id
  124419. * @return the texture or null if none found.
  124420. */
  124421. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  124422. /**
  124423. * Gets a camera using its id
  124424. * @param id defines the id to look for
  124425. * @returns the camera or null if not found
  124426. */
  124427. getCameraByID(id: string): Nullable<Camera>;
  124428. /**
  124429. * Gets a camera using its unique id
  124430. * @param uniqueId defines the unique id to look for
  124431. * @returns the camera or null if not found
  124432. */
  124433. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  124434. /**
  124435. * Gets a camera using its name
  124436. * @param name defines the camera's name
  124437. * @return the camera or null if none found.
  124438. */
  124439. getCameraByName(name: string): Nullable<Camera>;
  124440. /**
  124441. * Gets a bone using its id
  124442. * @param id defines the bone's id
  124443. * @return the bone or null if not found
  124444. */
  124445. getBoneByID(id: string): Nullable<Bone>;
  124446. /**
  124447. * Gets a bone using its id
  124448. * @param name defines the bone's name
  124449. * @return the bone or null if not found
  124450. */
  124451. getBoneByName(name: string): Nullable<Bone>;
  124452. /**
  124453. * Gets a light node using its name
  124454. * @param name defines the the light's name
  124455. * @return the light or null if none found.
  124456. */
  124457. getLightByName(name: string): Nullable<Light>;
  124458. /**
  124459. * Gets a light node using its id
  124460. * @param id defines the light's id
  124461. * @return the light or null if none found.
  124462. */
  124463. getLightByID(id: string): Nullable<Light>;
  124464. /**
  124465. * Gets a light node using its scene-generated unique ID
  124466. * @param uniqueId defines the light's unique id
  124467. * @return the light or null if none found.
  124468. */
  124469. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  124470. /**
  124471. * Gets a particle system by id
  124472. * @param id defines the particle system id
  124473. * @return the corresponding system or null if none found
  124474. */
  124475. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  124476. /**
  124477. * Gets a geometry using its ID
  124478. * @param id defines the geometry's id
  124479. * @return the geometry or null if none found.
  124480. */
  124481. getGeometryByID(id: string): Nullable<Geometry>;
  124482. private _getGeometryByUniqueID;
  124483. /**
  124484. * Add a new geometry to this scene
  124485. * @param geometry defines the geometry to be added to the scene.
  124486. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  124487. * @return a boolean defining if the geometry was added or not
  124488. */
  124489. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  124490. /**
  124491. * Removes an existing geometry
  124492. * @param geometry defines the geometry to be removed from the scene
  124493. * @return a boolean defining if the geometry was removed or not
  124494. */
  124495. removeGeometry(geometry: Geometry): boolean;
  124496. /**
  124497. * Gets the list of geometries attached to the scene
  124498. * @returns an array of Geometry
  124499. */
  124500. getGeometries(): Geometry[];
  124501. /**
  124502. * Gets the first added mesh found of a given ID
  124503. * @param id defines the id to search for
  124504. * @return the mesh found or null if not found at all
  124505. */
  124506. getMeshByID(id: string): Nullable<AbstractMesh>;
  124507. /**
  124508. * Gets a list of meshes using their id
  124509. * @param id defines the id to search for
  124510. * @returns a list of meshes
  124511. */
  124512. getMeshesByID(id: string): Array<AbstractMesh>;
  124513. /**
  124514. * Gets the first added transform node found of a given ID
  124515. * @param id defines the id to search for
  124516. * @return the found transform node or null if not found at all.
  124517. */
  124518. getTransformNodeByID(id: string): Nullable<TransformNode>;
  124519. /**
  124520. * Gets a transform node with its auto-generated unique id
  124521. * @param uniqueId efines the unique id to search for
  124522. * @return the found transform node or null if not found at all.
  124523. */
  124524. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  124525. /**
  124526. * Gets a list of transform nodes using their id
  124527. * @param id defines the id to search for
  124528. * @returns a list of transform nodes
  124529. */
  124530. getTransformNodesByID(id: string): Array<TransformNode>;
  124531. /**
  124532. * Gets a mesh with its auto-generated unique id
  124533. * @param uniqueId defines the unique id to search for
  124534. * @return the found mesh or null if not found at all.
  124535. */
  124536. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  124537. /**
  124538. * Gets a the last added mesh using a given id
  124539. * @param id defines the id to search for
  124540. * @return the found mesh or null if not found at all.
  124541. */
  124542. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  124543. /**
  124544. * Gets a the last added node (Mesh, Camera, Light) using a given id
  124545. * @param id defines the id to search for
  124546. * @return the found node or null if not found at all
  124547. */
  124548. getLastEntryByID(id: string): Nullable<Node>;
  124549. /**
  124550. * Gets a node (Mesh, Camera, Light) using a given id
  124551. * @param id defines the id to search for
  124552. * @return the found node or null if not found at all
  124553. */
  124554. getNodeByID(id: string): Nullable<Node>;
  124555. /**
  124556. * Gets a node (Mesh, Camera, Light) using a given name
  124557. * @param name defines the name to search for
  124558. * @return the found node or null if not found at all.
  124559. */
  124560. getNodeByName(name: string): Nullable<Node>;
  124561. /**
  124562. * Gets a mesh using a given name
  124563. * @param name defines the name to search for
  124564. * @return the found mesh or null if not found at all.
  124565. */
  124566. getMeshByName(name: string): Nullable<AbstractMesh>;
  124567. /**
  124568. * Gets a transform node using a given name
  124569. * @param name defines the name to search for
  124570. * @return the found transform node or null if not found at all.
  124571. */
  124572. getTransformNodeByName(name: string): Nullable<TransformNode>;
  124573. /**
  124574. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  124575. * @param id defines the id to search for
  124576. * @return the found skeleton or null if not found at all.
  124577. */
  124578. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  124579. /**
  124580. * Gets a skeleton using a given auto generated unique id
  124581. * @param uniqueId defines the unique id to search for
  124582. * @return the found skeleton or null if not found at all.
  124583. */
  124584. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  124585. /**
  124586. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  124587. * @param id defines the id to search for
  124588. * @return the found skeleton or null if not found at all.
  124589. */
  124590. getSkeletonById(id: string): Nullable<Skeleton>;
  124591. /**
  124592. * Gets a skeleton using a given name
  124593. * @param name defines the name to search for
  124594. * @return the found skeleton or null if not found at all.
  124595. */
  124596. getSkeletonByName(name: string): Nullable<Skeleton>;
  124597. /**
  124598. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  124599. * @param id defines the id to search for
  124600. * @return the found morph target manager or null if not found at all.
  124601. */
  124602. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  124603. /**
  124604. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  124605. * @param id defines the id to search for
  124606. * @return the found morph target or null if not found at all.
  124607. */
  124608. getMorphTargetById(id: string): Nullable<MorphTarget>;
  124609. /**
  124610. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  124611. * @param name defines the name to search for
  124612. * @return the found morph target or null if not found at all.
  124613. */
  124614. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  124615. /**
  124616. * Gets a post process using a given name (if many are found, this function will pick the first one)
  124617. * @param name defines the name to search for
  124618. * @return the found post process or null if not found at all.
  124619. */
  124620. getPostProcessByName(name: string): Nullable<PostProcess>;
  124621. /**
  124622. * Gets a boolean indicating if the given mesh is active
  124623. * @param mesh defines the mesh to look for
  124624. * @returns true if the mesh is in the active list
  124625. */
  124626. isActiveMesh(mesh: AbstractMesh): boolean;
  124627. /**
  124628. * Return a unique id as a string which can serve as an identifier for the scene
  124629. */
  124630. get uid(): string;
  124631. /**
  124632. * Add an externaly attached data from its key.
  124633. * This method call will fail and return false, if such key already exists.
  124634. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  124635. * @param key the unique key that identifies the data
  124636. * @param data the data object to associate to the key for this Engine instance
  124637. * @return true if no such key were already present and the data was added successfully, false otherwise
  124638. */
  124639. addExternalData<T>(key: string, data: T): boolean;
  124640. /**
  124641. * Get an externaly attached data from its key
  124642. * @param key the unique key that identifies the data
  124643. * @return the associated data, if present (can be null), or undefined if not present
  124644. */
  124645. getExternalData<T>(key: string): Nullable<T>;
  124646. /**
  124647. * Get an externaly attached data from its key, create it using a factory if it's not already present
  124648. * @param key the unique key that identifies the data
  124649. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  124650. * @return the associated data, can be null if the factory returned null.
  124651. */
  124652. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  124653. /**
  124654. * Remove an externaly attached data from the Engine instance
  124655. * @param key the unique key that identifies the data
  124656. * @return true if the data was successfully removed, false if it doesn't exist
  124657. */
  124658. removeExternalData(key: string): boolean;
  124659. private _evaluateSubMesh;
  124660. /**
  124661. * Clear the processed materials smart array preventing retention point in material dispose.
  124662. */
  124663. freeProcessedMaterials(): void;
  124664. private _preventFreeActiveMeshesAndRenderingGroups;
  124665. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  124666. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  124667. * when disposing several meshes in a row or a hierarchy of meshes.
  124668. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  124669. */
  124670. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  124671. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  124672. /**
  124673. * Clear the active meshes smart array preventing retention point in mesh dispose.
  124674. */
  124675. freeActiveMeshes(): void;
  124676. /**
  124677. * Clear the info related to rendering groups preventing retention points during dispose.
  124678. */
  124679. freeRenderingGroups(): void;
  124680. /** @hidden */
  124681. _isInIntermediateRendering(): boolean;
  124682. /**
  124683. * Lambda returning the list of potentially active meshes.
  124684. */
  124685. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  124686. /**
  124687. * Lambda returning the list of potentially active sub meshes.
  124688. */
  124689. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  124690. /**
  124691. * Lambda returning the list of potentially intersecting sub meshes.
  124692. */
  124693. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  124694. /**
  124695. * Lambda returning the list of potentially colliding sub meshes.
  124696. */
  124697. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  124698. private _activeMeshesFrozen;
  124699. private _skipEvaluateActiveMeshesCompletely;
  124700. /**
  124701. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  124702. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  124703. * @param onSuccess optional success callback
  124704. * @param onError optional error callback
  124705. * @returns the current scene
  124706. */
  124707. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  124708. /**
  124709. * Use this function to restart evaluating active meshes on every frame
  124710. * @returns the current scene
  124711. */
  124712. unfreezeActiveMeshes(): Scene;
  124713. private _evaluateActiveMeshes;
  124714. private _activeMesh;
  124715. /**
  124716. * Update the transform matrix to update from the current active camera
  124717. * @param force defines a boolean used to force the update even if cache is up to date
  124718. */
  124719. updateTransformMatrix(force?: boolean): void;
  124720. private _bindFrameBuffer;
  124721. /** @hidden */
  124722. _allowPostProcessClearColor: boolean;
  124723. /** @hidden */
  124724. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  124725. private _processSubCameras;
  124726. private _checkIntersections;
  124727. /** @hidden */
  124728. _advancePhysicsEngineStep(step: number): void;
  124729. /**
  124730. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  124731. */
  124732. getDeterministicFrameTime: () => number;
  124733. /** @hidden */
  124734. _animate(): void;
  124735. /** Execute all animations (for a frame) */
  124736. animate(): void;
  124737. /**
  124738. * Render the scene
  124739. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  124740. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  124741. */
  124742. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  124743. /**
  124744. * Freeze all materials
  124745. * A frozen material will not be updatable but should be faster to render
  124746. */
  124747. freezeMaterials(): void;
  124748. /**
  124749. * Unfreeze all materials
  124750. * A frozen material will not be updatable but should be faster to render
  124751. */
  124752. unfreezeMaterials(): void;
  124753. /**
  124754. * Releases all held ressources
  124755. */
  124756. dispose(): void;
  124757. /**
  124758. * Gets if the scene is already disposed
  124759. */
  124760. get isDisposed(): boolean;
  124761. /**
  124762. * Call this function to reduce memory footprint of the scene.
  124763. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  124764. */
  124765. clearCachedVertexData(): void;
  124766. /**
  124767. * This function will remove the local cached buffer data from texture.
  124768. * It will save memory but will prevent the texture from being rebuilt
  124769. */
  124770. cleanCachedTextureBuffer(): void;
  124771. /**
  124772. * Get the world extend vectors with an optional filter
  124773. *
  124774. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  124775. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  124776. */
  124777. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  124778. min: Vector3;
  124779. max: Vector3;
  124780. };
  124781. /**
  124782. * Creates a ray that can be used to pick in the scene
  124783. * @param x defines the x coordinate of the origin (on-screen)
  124784. * @param y defines the y coordinate of the origin (on-screen)
  124785. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124786. * @param camera defines the camera to use for the picking
  124787. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124788. * @returns a Ray
  124789. */
  124790. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  124791. /**
  124792. * Creates a ray that can be used to pick in the scene
  124793. * @param x defines the x coordinate of the origin (on-screen)
  124794. * @param y defines the y coordinate of the origin (on-screen)
  124795. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  124796. * @param result defines the ray where to store the picking ray
  124797. * @param camera defines the camera to use for the picking
  124798. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  124799. * @returns the current scene
  124800. */
  124801. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  124802. /**
  124803. * Creates a ray that can be used to pick in the scene
  124804. * @param x defines the x coordinate of the origin (on-screen)
  124805. * @param y defines the y coordinate of the origin (on-screen)
  124806. * @param camera defines the camera to use for the picking
  124807. * @returns a Ray
  124808. */
  124809. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  124810. /**
  124811. * Creates a ray that can be used to pick in the scene
  124812. * @param x defines the x coordinate of the origin (on-screen)
  124813. * @param y defines the y coordinate of the origin (on-screen)
  124814. * @param result defines the ray where to store the picking ray
  124815. * @param camera defines the camera to use for the picking
  124816. * @returns the current scene
  124817. */
  124818. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  124819. /** Launch a ray to try to pick a mesh in the scene
  124820. * @param x position on screen
  124821. * @param y position on screen
  124822. * @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
  124823. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124824. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124825. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124826. * @returns a PickingInfo
  124827. */
  124828. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124829. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  124830. * @param x position on screen
  124831. * @param y position on screen
  124832. * @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
  124833. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124834. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124835. * @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)
  124836. */
  124837. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  124838. /** Use the given ray to pick a mesh in the scene
  124839. * @param ray The ray to use to pick meshes
  124840. * @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
  124841. * @param fastCheck defines if the first intersection will be used (and not the closest)
  124842. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124843. * @returns a PickingInfo
  124844. */
  124845. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  124846. /**
  124847. * Launch a ray to try to pick a mesh in the scene
  124848. * @param x X position on screen
  124849. * @param y Y position on screen
  124850. * @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
  124851. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  124852. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124853. * @returns an array of PickingInfo
  124854. */
  124855. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124856. /**
  124857. * Launch a ray to try to pick a mesh in the scene
  124858. * @param ray Ray to use
  124859. * @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
  124860. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  124861. * @returns an array of PickingInfo
  124862. */
  124863. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  124864. /**
  124865. * Force the value of meshUnderPointer
  124866. * @param mesh defines the mesh to use
  124867. * @param pointerId optional pointer id when using more than one pointer
  124868. */
  124869. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  124870. /**
  124871. * Gets the mesh under the pointer
  124872. * @returns a Mesh or null if no mesh is under the pointer
  124873. */
  124874. getPointerOverMesh(): Nullable<AbstractMesh>;
  124875. /** @hidden */
  124876. _rebuildGeometries(): void;
  124877. /** @hidden */
  124878. _rebuildTextures(): void;
  124879. private _getByTags;
  124880. /**
  124881. * Get a list of meshes by tags
  124882. * @param tagsQuery defines the tags query to use
  124883. * @param forEach defines a predicate used to filter results
  124884. * @returns an array of Mesh
  124885. */
  124886. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  124887. /**
  124888. * Get a list of cameras by tags
  124889. * @param tagsQuery defines the tags query to use
  124890. * @param forEach defines a predicate used to filter results
  124891. * @returns an array of Camera
  124892. */
  124893. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  124894. /**
  124895. * Get a list of lights by tags
  124896. * @param tagsQuery defines the tags query to use
  124897. * @param forEach defines a predicate used to filter results
  124898. * @returns an array of Light
  124899. */
  124900. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  124901. /**
  124902. * Get a list of materials by tags
  124903. * @param tagsQuery defines the tags query to use
  124904. * @param forEach defines a predicate used to filter results
  124905. * @returns an array of Material
  124906. */
  124907. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  124908. /**
  124909. * Get a list of transform nodes by tags
  124910. * @param tagsQuery defines the tags query to use
  124911. * @param forEach defines a predicate used to filter results
  124912. * @returns an array of TransformNode
  124913. */
  124914. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  124915. /**
  124916. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  124917. * This allowed control for front to back rendering or reversly depending of the special needs.
  124918. *
  124919. * @param renderingGroupId The rendering group id corresponding to its index
  124920. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  124921. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  124922. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  124923. */
  124924. 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;
  124925. /**
  124926. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  124927. *
  124928. * @param renderingGroupId The rendering group id corresponding to its index
  124929. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124930. * @param depth Automatically clears depth between groups if true and autoClear is true.
  124931. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  124932. */
  124933. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  124934. /**
  124935. * Gets the current auto clear configuration for one rendering group of the rendering
  124936. * manager.
  124937. * @param index the rendering group index to get the information for
  124938. * @returns The auto clear setup for the requested rendering group
  124939. */
  124940. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  124941. private _blockMaterialDirtyMechanism;
  124942. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  124943. get blockMaterialDirtyMechanism(): boolean;
  124944. set blockMaterialDirtyMechanism(value: boolean);
  124945. /**
  124946. * Will flag all materials as dirty to trigger new shader compilation
  124947. * @param flag defines the flag used to specify which material part must be marked as dirty
  124948. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  124949. */
  124950. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  124951. /** @hidden */
  124952. _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;
  124953. /** @hidden */
  124954. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  124955. /** @hidden */
  124956. _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;
  124957. /** @hidden */
  124958. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  124959. /** @hidden */
  124960. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  124961. /** @hidden */
  124962. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  124963. }
  124964. }
  124965. declare module BABYLON {
  124966. /**
  124967. * Set of assets to keep when moving a scene into an asset container.
  124968. */
  124969. export class KeepAssets extends AbstractScene {
  124970. }
  124971. /**
  124972. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  124973. */
  124974. export class InstantiatedEntries {
  124975. /**
  124976. * List of new root nodes (eg. nodes with no parent)
  124977. */
  124978. rootNodes: TransformNode[];
  124979. /**
  124980. * List of new skeletons
  124981. */
  124982. skeletons: Skeleton[];
  124983. /**
  124984. * List of new animation groups
  124985. */
  124986. animationGroups: AnimationGroup[];
  124987. }
  124988. /**
  124989. * Container with a set of assets that can be added or removed from a scene.
  124990. */
  124991. export class AssetContainer extends AbstractScene {
  124992. private _wasAddedToScene;
  124993. /**
  124994. * The scene the AssetContainer belongs to.
  124995. */
  124996. scene: Scene;
  124997. /**
  124998. * Instantiates an AssetContainer.
  124999. * @param scene The scene the AssetContainer belongs to.
  125000. */
  125001. constructor(scene: Scene);
  125002. /**
  125003. * Instantiate or clone all meshes and add the new ones to the scene.
  125004. * Skeletons and animation groups will all be cloned
  125005. * @param nameFunction defines an optional function used to get new names for clones
  125006. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  125007. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  125008. */
  125009. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  125010. /**
  125011. * Adds all the assets from the container to the scene.
  125012. */
  125013. addAllToScene(): void;
  125014. /**
  125015. * Removes all the assets in the container from the scene
  125016. */
  125017. removeAllFromScene(): void;
  125018. /**
  125019. * Disposes all the assets in the container
  125020. */
  125021. dispose(): void;
  125022. private _moveAssets;
  125023. /**
  125024. * Removes all the assets contained in the scene and adds them to the container.
  125025. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125026. */
  125027. moveAllFromScene(keepAssets?: KeepAssets): void;
  125028. /**
  125029. * 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.
  125030. * @returns the root mesh
  125031. */
  125032. createRootMesh(): Mesh;
  125033. /**
  125034. * Merge animations (direct and animation groups) from this asset container into a scene
  125035. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125036. * @param animatables set of animatables to retarget to a node from the scene
  125037. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  125038. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  125039. */
  125040. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  125041. }
  125042. }
  125043. declare module BABYLON {
  125044. /**
  125045. * Defines how the parser contract is defined.
  125046. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  125047. */
  125048. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  125049. /**
  125050. * Defines how the individual parser contract is defined.
  125051. * These parser can parse an individual asset
  125052. */
  125053. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  125054. /**
  125055. * Base class of the scene acting as a container for the different elements composing a scene.
  125056. * This class is dynamically extended by the different components of the scene increasing
  125057. * flexibility and reducing coupling
  125058. */
  125059. export abstract class AbstractScene {
  125060. /**
  125061. * Stores the list of available parsers in the application.
  125062. */
  125063. private static _BabylonFileParsers;
  125064. /**
  125065. * Stores the list of available individual parsers in the application.
  125066. */
  125067. private static _IndividualBabylonFileParsers;
  125068. /**
  125069. * Adds a parser in the list of available ones
  125070. * @param name Defines the name of the parser
  125071. * @param parser Defines the parser to add
  125072. */
  125073. static AddParser(name: string, parser: BabylonFileParser): void;
  125074. /**
  125075. * Gets a general parser from the list of avaialble ones
  125076. * @param name Defines the name of the parser
  125077. * @returns the requested parser or null
  125078. */
  125079. static GetParser(name: string): Nullable<BabylonFileParser>;
  125080. /**
  125081. * Adds n individual parser in the list of available ones
  125082. * @param name Defines the name of the parser
  125083. * @param parser Defines the parser to add
  125084. */
  125085. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  125086. /**
  125087. * Gets an individual parser from the list of avaialble ones
  125088. * @param name Defines the name of the parser
  125089. * @returns the requested parser or null
  125090. */
  125091. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  125092. /**
  125093. * Parser json data and populate both a scene and its associated container object
  125094. * @param jsonData Defines the data to parse
  125095. * @param scene Defines the scene to parse the data for
  125096. * @param container Defines the container attached to the parsing sequence
  125097. * @param rootUrl Defines the root url of the data
  125098. */
  125099. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  125100. /**
  125101. * Gets the list of root nodes (ie. nodes with no parent)
  125102. */
  125103. rootNodes: Node[];
  125104. /** All of the cameras added to this scene
  125105. * @see https://doc.babylonjs.com/babylon101/cameras
  125106. */
  125107. cameras: Camera[];
  125108. /**
  125109. * All of the lights added to this scene
  125110. * @see https://doc.babylonjs.com/babylon101/lights
  125111. */
  125112. lights: Light[];
  125113. /**
  125114. * All of the (abstract) meshes added to this scene
  125115. */
  125116. meshes: AbstractMesh[];
  125117. /**
  125118. * The list of skeletons added to the scene
  125119. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125120. */
  125121. skeletons: Skeleton[];
  125122. /**
  125123. * All of the particle systems added to this scene
  125124. * @see https://doc.babylonjs.com/babylon101/particles
  125125. */
  125126. particleSystems: IParticleSystem[];
  125127. /**
  125128. * Gets a list of Animations associated with the scene
  125129. */
  125130. animations: Animation[];
  125131. /**
  125132. * All of the animation groups added to this scene
  125133. * @see https://doc.babylonjs.com/how_to/group
  125134. */
  125135. animationGroups: AnimationGroup[];
  125136. /**
  125137. * All of the multi-materials added to this scene
  125138. * @see https://doc.babylonjs.com/how_to/multi_materials
  125139. */
  125140. multiMaterials: MultiMaterial[];
  125141. /**
  125142. * All of the materials added to this scene
  125143. * In the context of a Scene, it is not supposed to be modified manually.
  125144. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  125145. * Note also that the order of the Material within the array is not significant and might change.
  125146. * @see https://doc.babylonjs.com/babylon101/materials
  125147. */
  125148. materials: Material[];
  125149. /**
  125150. * The list of morph target managers added to the scene
  125151. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125152. */
  125153. morphTargetManagers: MorphTargetManager[];
  125154. /**
  125155. * The list of geometries used in the scene.
  125156. */
  125157. geometries: Geometry[];
  125158. /**
  125159. * All of the tranform nodes added to this scene
  125160. * In the context of a Scene, it is not supposed to be modified manually.
  125161. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125162. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125163. * @see https://doc.babylonjs.com/how_to/transformnode
  125164. */
  125165. transformNodes: TransformNode[];
  125166. /**
  125167. * ActionManagers available on the scene.
  125168. */
  125169. actionManagers: AbstractActionManager[];
  125170. /**
  125171. * Textures to keep.
  125172. */
  125173. textures: BaseTexture[];
  125174. /** @hidden */
  125175. protected _environmentTexture: Nullable<BaseTexture>;
  125176. /**
  125177. * Texture used in all pbr material as the reflection texture.
  125178. * As in the majority of the scene they are the same (exception for multi room and so on),
  125179. * this is easier to reference from here than from all the materials.
  125180. */
  125181. get environmentTexture(): Nullable<BaseTexture>;
  125182. set environmentTexture(value: Nullable<BaseTexture>);
  125183. /**
  125184. * The list of postprocesses added to the scene
  125185. */
  125186. postProcesses: PostProcess[];
  125187. /**
  125188. * @returns all meshes, lights, cameras, transformNodes and bones
  125189. */
  125190. getNodes(): Array<Node>;
  125191. }
  125192. }
  125193. declare module BABYLON {
  125194. /**
  125195. * Interface used to define options for Sound class
  125196. */
  125197. export interface ISoundOptions {
  125198. /**
  125199. * Does the sound autoplay once loaded.
  125200. */
  125201. autoplay?: boolean;
  125202. /**
  125203. * Does the sound loop after it finishes playing once.
  125204. */
  125205. loop?: boolean;
  125206. /**
  125207. * Sound's volume
  125208. */
  125209. volume?: number;
  125210. /**
  125211. * Is it a spatial sound?
  125212. */
  125213. spatialSound?: boolean;
  125214. /**
  125215. * Maximum distance to hear that sound
  125216. */
  125217. maxDistance?: number;
  125218. /**
  125219. * Uses user defined attenuation function
  125220. */
  125221. useCustomAttenuation?: boolean;
  125222. /**
  125223. * Define the roll off factor of spatial sounds.
  125224. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125225. */
  125226. rolloffFactor?: number;
  125227. /**
  125228. * Define the reference distance the sound should be heard perfectly.
  125229. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125230. */
  125231. refDistance?: number;
  125232. /**
  125233. * Define the distance attenuation model the sound will follow.
  125234. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125235. */
  125236. distanceModel?: string;
  125237. /**
  125238. * Defines the playback speed (1 by default)
  125239. */
  125240. playbackRate?: number;
  125241. /**
  125242. * Defines if the sound is from a streaming source
  125243. */
  125244. streaming?: boolean;
  125245. /**
  125246. * Defines an optional length (in seconds) inside the sound file
  125247. */
  125248. length?: number;
  125249. /**
  125250. * Defines an optional offset (in seconds) inside the sound file
  125251. */
  125252. offset?: number;
  125253. /**
  125254. * If true, URLs will not be required to state the audio file codec to use.
  125255. */
  125256. skipCodecCheck?: boolean;
  125257. }
  125258. /**
  125259. * Defines a sound that can be played in the application.
  125260. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  125261. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125262. */
  125263. export class Sound {
  125264. /**
  125265. * The name of the sound in the scene.
  125266. */
  125267. name: string;
  125268. /**
  125269. * Does the sound autoplay once loaded.
  125270. */
  125271. autoplay: boolean;
  125272. /**
  125273. * Does the sound loop after it finishes playing once.
  125274. */
  125275. loop: boolean;
  125276. /**
  125277. * Does the sound use a custom attenuation curve to simulate the falloff
  125278. * happening when the source gets further away from the camera.
  125279. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125280. */
  125281. useCustomAttenuation: boolean;
  125282. /**
  125283. * The sound track id this sound belongs to.
  125284. */
  125285. soundTrackId: number;
  125286. /**
  125287. * Is this sound currently played.
  125288. */
  125289. isPlaying: boolean;
  125290. /**
  125291. * Is this sound currently paused.
  125292. */
  125293. isPaused: boolean;
  125294. /**
  125295. * Does this sound enables spatial sound.
  125296. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125297. */
  125298. spatialSound: boolean;
  125299. /**
  125300. * Define the reference distance the sound should be heard perfectly.
  125301. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125302. */
  125303. refDistance: number;
  125304. /**
  125305. * Define the roll off factor of spatial sounds.
  125306. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125307. */
  125308. rolloffFactor: number;
  125309. /**
  125310. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  125311. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125312. */
  125313. maxDistance: number;
  125314. /**
  125315. * Define the distance attenuation model the sound will follow.
  125316. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125317. */
  125318. distanceModel: string;
  125319. /**
  125320. * @hidden
  125321. * Back Compat
  125322. **/
  125323. onended: () => any;
  125324. /**
  125325. * Gets or sets an object used to store user defined information for the sound.
  125326. */
  125327. metadata: any;
  125328. /**
  125329. * Observable event when the current playing sound finishes.
  125330. */
  125331. onEndedObservable: Observable<Sound>;
  125332. private _panningModel;
  125333. private _playbackRate;
  125334. private _streaming;
  125335. private _startTime;
  125336. private _startOffset;
  125337. private _position;
  125338. /** @hidden */
  125339. _positionInEmitterSpace: boolean;
  125340. private _localDirection;
  125341. private _volume;
  125342. private _isReadyToPlay;
  125343. private _isDirectional;
  125344. private _readyToPlayCallback;
  125345. private _audioBuffer;
  125346. private _soundSource;
  125347. private _streamingSource;
  125348. private _soundPanner;
  125349. private _soundGain;
  125350. private _inputAudioNode;
  125351. private _outputAudioNode;
  125352. private _coneInnerAngle;
  125353. private _coneOuterAngle;
  125354. private _coneOuterGain;
  125355. private _scene;
  125356. private _connectedTransformNode;
  125357. private _customAttenuationFunction;
  125358. private _registerFunc;
  125359. private _isOutputConnected;
  125360. private _htmlAudioElement;
  125361. private _urlType;
  125362. private _length?;
  125363. private _offset?;
  125364. /** @hidden */
  125365. static _SceneComponentInitialization: (scene: Scene) => void;
  125366. /**
  125367. * Create a sound and attach it to a scene
  125368. * @param name Name of your sound
  125369. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  125370. * @param scene defines the scene the sound belongs to
  125371. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  125372. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  125373. */
  125374. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  125375. /**
  125376. * Release the sound and its associated resources
  125377. */
  125378. dispose(): void;
  125379. /**
  125380. * Gets if the sounds is ready to be played or not.
  125381. * @returns true if ready, otherwise false
  125382. */
  125383. isReady(): boolean;
  125384. private _soundLoaded;
  125385. /**
  125386. * Sets the data of the sound from an audiobuffer
  125387. * @param audioBuffer The audioBuffer containing the data
  125388. */
  125389. setAudioBuffer(audioBuffer: AudioBuffer): void;
  125390. /**
  125391. * Updates the current sounds options such as maxdistance, loop...
  125392. * @param options A JSON object containing values named as the object properties
  125393. */
  125394. updateOptions(options: ISoundOptions): void;
  125395. private _createSpatialParameters;
  125396. private _updateSpatialParameters;
  125397. /**
  125398. * Switch the panning model to HRTF:
  125399. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125400. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125401. */
  125402. switchPanningModelToHRTF(): void;
  125403. /**
  125404. * Switch the panning model to Equal Power:
  125405. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125406. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125407. */
  125408. switchPanningModelToEqualPower(): void;
  125409. private _switchPanningModel;
  125410. /**
  125411. * Connect this sound to a sound track audio node like gain...
  125412. * @param soundTrackAudioNode the sound track audio node to connect to
  125413. */
  125414. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  125415. /**
  125416. * Transform this sound into a directional source
  125417. * @param coneInnerAngle Size of the inner cone in degree
  125418. * @param coneOuterAngle Size of the outer cone in degree
  125419. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  125420. */
  125421. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  125422. /**
  125423. * Gets or sets the inner angle for the directional cone.
  125424. */
  125425. get directionalConeInnerAngle(): number;
  125426. /**
  125427. * Gets or sets the inner angle for the directional cone.
  125428. */
  125429. set directionalConeInnerAngle(value: number);
  125430. /**
  125431. * Gets or sets the outer angle for the directional cone.
  125432. */
  125433. get directionalConeOuterAngle(): number;
  125434. /**
  125435. * Gets or sets the outer angle for the directional cone.
  125436. */
  125437. set directionalConeOuterAngle(value: number);
  125438. /**
  125439. * Sets the position of the emitter if spatial sound is enabled
  125440. * @param newPosition Defines the new posisiton
  125441. */
  125442. setPosition(newPosition: Vector3): void;
  125443. /**
  125444. * Sets the local direction of the emitter if spatial sound is enabled
  125445. * @param newLocalDirection Defines the new local direction
  125446. */
  125447. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  125448. private _updateDirection;
  125449. /** @hidden */
  125450. updateDistanceFromListener(): void;
  125451. /**
  125452. * Sets a new custom attenuation function for the sound.
  125453. * @param callback Defines the function used for the attenuation
  125454. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  125455. */
  125456. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  125457. /**
  125458. * Play the sound
  125459. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  125460. * @param offset (optional) Start the sound at a specific time in seconds
  125461. * @param length (optional) Sound duration (in seconds)
  125462. */
  125463. play(time?: number, offset?: number, length?: number): void;
  125464. private _onended;
  125465. /**
  125466. * Stop the sound
  125467. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  125468. */
  125469. stop(time?: number): void;
  125470. /**
  125471. * Put the sound in pause
  125472. */
  125473. pause(): void;
  125474. /**
  125475. * Sets a dedicated volume for this sounds
  125476. * @param newVolume Define the new volume of the sound
  125477. * @param time Define time for gradual change to new volume
  125478. */
  125479. setVolume(newVolume: number, time?: number): void;
  125480. /**
  125481. * Set the sound play back rate
  125482. * @param newPlaybackRate Define the playback rate the sound should be played at
  125483. */
  125484. setPlaybackRate(newPlaybackRate: number): void;
  125485. /**
  125486. * Gets the volume of the sound.
  125487. * @returns the volume of the sound
  125488. */
  125489. getVolume(): number;
  125490. /**
  125491. * Attach the sound to a dedicated mesh
  125492. * @param transformNode The transform node to connect the sound with
  125493. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125494. */
  125495. attachToMesh(transformNode: TransformNode): void;
  125496. /**
  125497. * Detach the sound from the previously attached mesh
  125498. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  125499. */
  125500. detachFromMesh(): void;
  125501. private _onRegisterAfterWorldMatrixUpdate;
  125502. /**
  125503. * Clone the current sound in the scene.
  125504. * @returns the new sound clone
  125505. */
  125506. clone(): Nullable<Sound>;
  125507. /**
  125508. * Gets the current underlying audio buffer containing the data
  125509. * @returns the audio buffer
  125510. */
  125511. getAudioBuffer(): Nullable<AudioBuffer>;
  125512. /**
  125513. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  125514. * @returns the source node
  125515. */
  125516. getSoundSource(): Nullable<AudioBufferSourceNode>;
  125517. /**
  125518. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  125519. * @returns the gain node
  125520. */
  125521. getSoundGain(): Nullable<GainNode>;
  125522. /**
  125523. * Serializes the Sound in a JSON representation
  125524. * @returns the JSON representation of the sound
  125525. */
  125526. serialize(): any;
  125527. /**
  125528. * Parse a JSON representation of a sound to innstantiate in a given scene
  125529. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  125530. * @param scene Define the scene the new parsed sound should be created in
  125531. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  125532. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  125533. * @returns the newly parsed sound
  125534. */
  125535. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  125536. }
  125537. }
  125538. declare module BABYLON {
  125539. /**
  125540. * This defines an action helpful to play a defined sound on a triggered action.
  125541. */
  125542. export class PlaySoundAction extends Action {
  125543. private _sound;
  125544. /**
  125545. * Instantiate the action
  125546. * @param triggerOptions defines the trigger options
  125547. * @param sound defines the sound to play
  125548. * @param condition defines the trigger related conditions
  125549. */
  125550. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125551. /** @hidden */
  125552. _prepare(): void;
  125553. /**
  125554. * Execute the action and play the sound.
  125555. */
  125556. execute(): void;
  125557. /**
  125558. * Serializes the actions and its related information.
  125559. * @param parent defines the object to serialize in
  125560. * @returns the serialized object
  125561. */
  125562. serialize(parent: any): any;
  125563. }
  125564. /**
  125565. * This defines an action helpful to stop a defined sound on a triggered action.
  125566. */
  125567. export class StopSoundAction extends Action {
  125568. private _sound;
  125569. /**
  125570. * Instantiate the action
  125571. * @param triggerOptions defines the trigger options
  125572. * @param sound defines the sound to stop
  125573. * @param condition defines the trigger related conditions
  125574. */
  125575. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  125576. /** @hidden */
  125577. _prepare(): void;
  125578. /**
  125579. * Execute the action and stop the sound.
  125580. */
  125581. execute(): void;
  125582. /**
  125583. * Serializes the actions and its related information.
  125584. * @param parent defines the object to serialize in
  125585. * @returns the serialized object
  125586. */
  125587. serialize(parent: any): any;
  125588. }
  125589. }
  125590. declare module BABYLON {
  125591. /**
  125592. * This defines an action responsible to change the value of a property
  125593. * by interpolating between its current value and the newly set one once triggered.
  125594. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125595. */
  125596. export class InterpolateValueAction extends Action {
  125597. /**
  125598. * Defines the path of the property where the value should be interpolated
  125599. */
  125600. propertyPath: string;
  125601. /**
  125602. * Defines the target value at the end of the interpolation.
  125603. */
  125604. value: any;
  125605. /**
  125606. * Defines the time it will take for the property to interpolate to the value.
  125607. */
  125608. duration: number;
  125609. /**
  125610. * Defines if the other scene animations should be stopped when the action has been triggered
  125611. */
  125612. stopOtherAnimations?: boolean;
  125613. /**
  125614. * Defines a callback raised once the interpolation animation has been done.
  125615. */
  125616. onInterpolationDone?: () => void;
  125617. /**
  125618. * Observable triggered once the interpolation animation has been done.
  125619. */
  125620. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  125621. private _target;
  125622. private _effectiveTarget;
  125623. private _property;
  125624. /**
  125625. * Instantiate the action
  125626. * @param triggerOptions defines the trigger options
  125627. * @param target defines the object containing the value to interpolate
  125628. * @param propertyPath defines the path to the property in the target object
  125629. * @param value defines the target value at the end of the interpolation
  125630. * @param duration deines the time it will take for the property to interpolate to the value.
  125631. * @param condition defines the trigger related conditions
  125632. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  125633. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  125634. */
  125635. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  125636. /** @hidden */
  125637. _prepare(): void;
  125638. /**
  125639. * Execute the action starts the value interpolation.
  125640. */
  125641. execute(): void;
  125642. /**
  125643. * Serializes the actions and its related information.
  125644. * @param parent defines the object to serialize in
  125645. * @returns the serialized object
  125646. */
  125647. serialize(parent: any): any;
  125648. }
  125649. }
  125650. declare module BABYLON {
  125651. /**
  125652. * Options allowed during the creation of a sound track.
  125653. */
  125654. export interface ISoundTrackOptions {
  125655. /**
  125656. * The volume the sound track should take during creation
  125657. */
  125658. volume?: number;
  125659. /**
  125660. * Define if the sound track is the main sound track of the scene
  125661. */
  125662. mainTrack?: boolean;
  125663. }
  125664. /**
  125665. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  125666. * It will be also used in a future release to apply effects on a specific track.
  125667. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125668. */
  125669. export class SoundTrack {
  125670. /**
  125671. * The unique identifier of the sound track in the scene.
  125672. */
  125673. id: number;
  125674. /**
  125675. * The list of sounds included in the sound track.
  125676. */
  125677. soundCollection: Array<Sound>;
  125678. private _outputAudioNode;
  125679. private _scene;
  125680. private _connectedAnalyser;
  125681. private _options;
  125682. private _isInitialized;
  125683. /**
  125684. * Creates a new sound track.
  125685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  125686. * @param scene Define the scene the sound track belongs to
  125687. * @param options
  125688. */
  125689. constructor(scene: Scene, options?: ISoundTrackOptions);
  125690. private _initializeSoundTrackAudioGraph;
  125691. /**
  125692. * Release the sound track and its associated resources
  125693. */
  125694. dispose(): void;
  125695. /**
  125696. * Adds a sound to this sound track
  125697. * @param sound define the cound to add
  125698. * @ignoreNaming
  125699. */
  125700. AddSound(sound: Sound): void;
  125701. /**
  125702. * Removes a sound to this sound track
  125703. * @param sound define the cound to remove
  125704. * @ignoreNaming
  125705. */
  125706. RemoveSound(sound: Sound): void;
  125707. /**
  125708. * Set a global volume for the full sound track.
  125709. * @param newVolume Define the new volume of the sound track
  125710. */
  125711. setVolume(newVolume: number): void;
  125712. /**
  125713. * Switch the panning model to HRTF:
  125714. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  125715. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125716. */
  125717. switchPanningModelToHRTF(): void;
  125718. /**
  125719. * Switch the panning model to Equal Power:
  125720. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  125721. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125722. */
  125723. switchPanningModelToEqualPower(): void;
  125724. /**
  125725. * Connect the sound track to an audio analyser allowing some amazing
  125726. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  125727. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  125728. * @param analyser The analyser to connect to the engine
  125729. */
  125730. connectToAnalyser(analyser: Analyser): void;
  125731. }
  125732. }
  125733. declare module BABYLON {
  125734. interface AbstractScene {
  125735. /**
  125736. * The list of sounds used in the scene.
  125737. */
  125738. sounds: Nullable<Array<Sound>>;
  125739. }
  125740. interface Scene {
  125741. /**
  125742. * @hidden
  125743. * Backing field
  125744. */
  125745. _mainSoundTrack: SoundTrack;
  125746. /**
  125747. * The main sound track played by the scene.
  125748. * It cotains your primary collection of sounds.
  125749. */
  125750. mainSoundTrack: SoundTrack;
  125751. /**
  125752. * The list of sound tracks added to the scene
  125753. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125754. */
  125755. soundTracks: Nullable<Array<SoundTrack>>;
  125756. /**
  125757. * Gets a sound using a given name
  125758. * @param name defines the name to search for
  125759. * @return the found sound or null if not found at all.
  125760. */
  125761. getSoundByName(name: string): Nullable<Sound>;
  125762. /**
  125763. * Gets or sets if audio support is enabled
  125764. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125765. */
  125766. audioEnabled: boolean;
  125767. /**
  125768. * Gets or sets if audio will be output to headphones
  125769. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125770. */
  125771. headphone: boolean;
  125772. /**
  125773. * Gets or sets custom audio listener position provider
  125774. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  125775. */
  125776. audioListenerPositionProvider: Nullable<() => Vector3>;
  125777. /**
  125778. * Gets or sets a refresh rate when using 3D audio positioning
  125779. */
  125780. audioPositioningRefreshRate: number;
  125781. }
  125782. /**
  125783. * Defines the sound scene component responsible to manage any sounds
  125784. * in a given scene.
  125785. */
  125786. export class AudioSceneComponent implements ISceneSerializableComponent {
  125787. private static _CameraDirectionLH;
  125788. private static _CameraDirectionRH;
  125789. /**
  125790. * The component name helpfull to identify the component in the list of scene components.
  125791. */
  125792. readonly name: string;
  125793. /**
  125794. * The scene the component belongs to.
  125795. */
  125796. scene: Scene;
  125797. private _audioEnabled;
  125798. /**
  125799. * Gets whether audio is enabled or not.
  125800. * Please use related enable/disable method to switch state.
  125801. */
  125802. get audioEnabled(): boolean;
  125803. private _headphone;
  125804. /**
  125805. * Gets whether audio is outputing to headphone or not.
  125806. * Please use the according Switch methods to change output.
  125807. */
  125808. get headphone(): boolean;
  125809. /**
  125810. * Gets or sets a refresh rate when using 3D audio positioning
  125811. */
  125812. audioPositioningRefreshRate: number;
  125813. private _audioListenerPositionProvider;
  125814. /**
  125815. * Gets the current audio listener position provider
  125816. */
  125817. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  125818. /**
  125819. * Sets a custom listener position for all sounds in the scene
  125820. * By default, this is the position of the first active camera
  125821. */
  125822. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  125823. /**
  125824. * Creates a new instance of the component for the given scene
  125825. * @param scene Defines the scene to register the component in
  125826. */
  125827. constructor(scene: Scene);
  125828. /**
  125829. * Registers the component in a given scene
  125830. */
  125831. register(): void;
  125832. /**
  125833. * Rebuilds the elements related to this component in case of
  125834. * context lost for instance.
  125835. */
  125836. rebuild(): void;
  125837. /**
  125838. * Serializes the component data to the specified json object
  125839. * @param serializationObject The object to serialize to
  125840. */
  125841. serialize(serializationObject: any): void;
  125842. /**
  125843. * Adds all the elements from the container to the scene
  125844. * @param container the container holding the elements
  125845. */
  125846. addFromContainer(container: AbstractScene): void;
  125847. /**
  125848. * Removes all the elements in the container from the scene
  125849. * @param container contains the elements to remove
  125850. * @param dispose if the removed element should be disposed (default: false)
  125851. */
  125852. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125853. /**
  125854. * Disposes the component and the associated ressources.
  125855. */
  125856. dispose(): void;
  125857. /**
  125858. * Disables audio in the associated scene.
  125859. */
  125860. disableAudio(): void;
  125861. /**
  125862. * Enables audio in the associated scene.
  125863. */
  125864. enableAudio(): void;
  125865. /**
  125866. * Switch audio to headphone output.
  125867. */
  125868. switchAudioModeForHeadphones(): void;
  125869. /**
  125870. * Switch audio to normal speakers.
  125871. */
  125872. switchAudioModeForNormalSpeakers(): void;
  125873. private _cachedCameraDirection;
  125874. private _cachedCameraPosition;
  125875. private _lastCheck;
  125876. private _afterRender;
  125877. }
  125878. }
  125879. declare module BABYLON {
  125880. /**
  125881. * Wraps one or more Sound objects and selects one with random weight for playback.
  125882. */
  125883. export class WeightedSound {
  125884. /** When true a Sound will be selected and played when the current playing Sound completes. */
  125885. loop: boolean;
  125886. private _coneInnerAngle;
  125887. private _coneOuterAngle;
  125888. private _volume;
  125889. /** A Sound is currently playing. */
  125890. isPlaying: boolean;
  125891. /** A Sound is currently paused. */
  125892. isPaused: boolean;
  125893. private _sounds;
  125894. private _weights;
  125895. private _currentIndex?;
  125896. /**
  125897. * Creates a new WeightedSound from the list of sounds given.
  125898. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  125899. * @param sounds Array of Sounds that will be selected from.
  125900. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  125901. */
  125902. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  125903. /**
  125904. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  125905. */
  125906. get directionalConeInnerAngle(): number;
  125907. /**
  125908. * The size of cone in degress for a directional sound in which there will be no attenuation.
  125909. */
  125910. set directionalConeInnerAngle(value: number);
  125911. /**
  125912. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  125913. * Listener angles between innerAngle and outerAngle will falloff linearly.
  125914. */
  125915. get directionalConeOuterAngle(): number;
  125916. /**
  125917. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  125918. * Listener angles between innerAngle and outerAngle will falloff linearly.
  125919. */
  125920. set directionalConeOuterAngle(value: number);
  125921. /**
  125922. * Playback volume.
  125923. */
  125924. get volume(): number;
  125925. /**
  125926. * Playback volume.
  125927. */
  125928. set volume(value: number);
  125929. private _onended;
  125930. /**
  125931. * Suspend playback
  125932. */
  125933. pause(): void;
  125934. /**
  125935. * Stop playback
  125936. */
  125937. stop(): void;
  125938. /**
  125939. * Start playback.
  125940. * @param startOffset Position the clip head at a specific time in seconds.
  125941. */
  125942. play(startOffset?: number): void;
  125943. }
  125944. }
  125945. declare module BABYLON {
  125946. /**
  125947. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  125948. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  125949. */
  125950. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  125951. /**
  125952. * Gets the name of the behavior.
  125953. */
  125954. get name(): string;
  125955. /**
  125956. * The easing function used by animations
  125957. */
  125958. static EasingFunction: BackEase;
  125959. /**
  125960. * The easing mode used by animations
  125961. */
  125962. static EasingMode: number;
  125963. /**
  125964. * The duration of the animation, in milliseconds
  125965. */
  125966. transitionDuration: number;
  125967. /**
  125968. * Length of the distance animated by the transition when lower radius is reached
  125969. */
  125970. lowerRadiusTransitionRange: number;
  125971. /**
  125972. * Length of the distance animated by the transition when upper radius is reached
  125973. */
  125974. upperRadiusTransitionRange: number;
  125975. private _autoTransitionRange;
  125976. /**
  125977. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  125978. */
  125979. get autoTransitionRange(): boolean;
  125980. /**
  125981. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  125982. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  125983. */
  125984. set autoTransitionRange(value: boolean);
  125985. private _attachedCamera;
  125986. private _onAfterCheckInputsObserver;
  125987. private _onMeshTargetChangedObserver;
  125988. /**
  125989. * Initializes the behavior.
  125990. */
  125991. init(): void;
  125992. /**
  125993. * Attaches the behavior to its arc rotate camera.
  125994. * @param camera Defines the camera to attach the behavior to
  125995. */
  125996. attach(camera: ArcRotateCamera): void;
  125997. /**
  125998. * Detaches the behavior from its current arc rotate camera.
  125999. */
  126000. detach(): void;
  126001. private _radiusIsAnimating;
  126002. private _radiusBounceTransition;
  126003. private _animatables;
  126004. private _cachedWheelPrecision;
  126005. /**
  126006. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  126007. * @param radiusLimit The limit to check against.
  126008. * @return Bool to indicate if at limit.
  126009. */
  126010. private _isRadiusAtLimit;
  126011. /**
  126012. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  126013. * @param radiusDelta The delta by which to animate to. Can be negative.
  126014. */
  126015. private _applyBoundRadiusAnimation;
  126016. /**
  126017. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  126018. */
  126019. protected _clearAnimationLocks(): void;
  126020. /**
  126021. * Stops and removes all animations that have been applied to the camera
  126022. */
  126023. stopAllAnimations(): void;
  126024. }
  126025. }
  126026. declare module BABYLON {
  126027. /**
  126028. * 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.
  126029. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126030. */
  126031. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  126032. /**
  126033. * Gets the name of the behavior.
  126034. */
  126035. get name(): string;
  126036. private _mode;
  126037. private _radiusScale;
  126038. private _positionScale;
  126039. private _defaultElevation;
  126040. private _elevationReturnTime;
  126041. private _elevationReturnWaitTime;
  126042. private _zoomStopsAnimation;
  126043. private _framingTime;
  126044. /**
  126045. * The easing function used by animations
  126046. */
  126047. static EasingFunction: ExponentialEase;
  126048. /**
  126049. * The easing mode used by animations
  126050. */
  126051. static EasingMode: number;
  126052. /**
  126053. * Sets the current mode used by the behavior
  126054. */
  126055. set mode(mode: number);
  126056. /**
  126057. * Gets current mode used by the behavior.
  126058. */
  126059. get mode(): number;
  126060. /**
  126061. * Sets the scale applied to the radius (1 by default)
  126062. */
  126063. set radiusScale(radius: number);
  126064. /**
  126065. * Gets the scale applied to the radius
  126066. */
  126067. get radiusScale(): number;
  126068. /**
  126069. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126070. */
  126071. set positionScale(scale: number);
  126072. /**
  126073. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126074. */
  126075. get positionScale(): number;
  126076. /**
  126077. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126078. * behaviour is triggered, in radians.
  126079. */
  126080. set defaultElevation(elevation: number);
  126081. /**
  126082. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126083. * behaviour is triggered, in radians.
  126084. */
  126085. get defaultElevation(): number;
  126086. /**
  126087. * Sets the time (in milliseconds) taken to return to the default beta position.
  126088. * Negative value indicates camera should not return to default.
  126089. */
  126090. set elevationReturnTime(speed: number);
  126091. /**
  126092. * Gets the time (in milliseconds) taken to return to the default beta position.
  126093. * Negative value indicates camera should not return to default.
  126094. */
  126095. get elevationReturnTime(): number;
  126096. /**
  126097. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126098. */
  126099. set elevationReturnWaitTime(time: number);
  126100. /**
  126101. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126102. */
  126103. get elevationReturnWaitTime(): number;
  126104. /**
  126105. * Sets the flag that indicates if user zooming should stop animation.
  126106. */
  126107. set zoomStopsAnimation(flag: boolean);
  126108. /**
  126109. * Gets the flag that indicates if user zooming should stop animation.
  126110. */
  126111. get zoomStopsAnimation(): boolean;
  126112. /**
  126113. * Sets the transition time when framing the mesh, in milliseconds
  126114. */
  126115. set framingTime(time: number);
  126116. /**
  126117. * Gets the transition time when framing the mesh, in milliseconds
  126118. */
  126119. get framingTime(): number;
  126120. /**
  126121. * Define if the behavior should automatically change the configured
  126122. * camera limits and sensibilities.
  126123. */
  126124. autoCorrectCameraLimitsAndSensibility: boolean;
  126125. private _onPrePointerObservableObserver;
  126126. private _onAfterCheckInputsObserver;
  126127. private _onMeshTargetChangedObserver;
  126128. private _attachedCamera;
  126129. private _isPointerDown;
  126130. private _lastInteractionTime;
  126131. /**
  126132. * Initializes the behavior.
  126133. */
  126134. init(): void;
  126135. /**
  126136. * Attaches the behavior to its arc rotate camera.
  126137. * @param camera Defines the camera to attach the behavior to
  126138. */
  126139. attach(camera: ArcRotateCamera): void;
  126140. /**
  126141. * Detaches the behavior from its current arc rotate camera.
  126142. */
  126143. detach(): void;
  126144. private _animatables;
  126145. private _betaIsAnimating;
  126146. private _betaTransition;
  126147. private _radiusTransition;
  126148. private _vectorTransition;
  126149. /**
  126150. * Targets the given mesh and updates zoom level accordingly.
  126151. * @param mesh The mesh to target.
  126152. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126153. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126154. */
  126155. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126156. /**
  126157. * Targets the given mesh with its children and updates zoom level accordingly.
  126158. * @param mesh The mesh to target.
  126159. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126160. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126161. */
  126162. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126163. /**
  126164. * Targets the given meshes with their children and updates zoom level accordingly.
  126165. * @param meshes The mesh to target.
  126166. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126167. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126168. */
  126169. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126170. /**
  126171. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  126172. * @param minimumWorld Determines the smaller position of the bounding box extend
  126173. * @param maximumWorld Determines the bigger position of the bounding box extend
  126174. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126175. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126176. */
  126177. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126178. /**
  126179. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  126180. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  126181. * frustum width.
  126182. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  126183. * to fully enclose the mesh in the viewing frustum.
  126184. */
  126185. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  126186. /**
  126187. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  126188. * is automatically returned to its default position (expected to be above ground plane).
  126189. */
  126190. private _maintainCameraAboveGround;
  126191. /**
  126192. * Returns the frustum slope based on the canvas ratio and camera FOV
  126193. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  126194. */
  126195. private _getFrustumSlope;
  126196. /**
  126197. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  126198. */
  126199. private _clearAnimationLocks;
  126200. /**
  126201. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126202. */
  126203. private _applyUserInteraction;
  126204. /**
  126205. * Stops and removes all animations that have been applied to the camera
  126206. */
  126207. stopAllAnimations(): void;
  126208. /**
  126209. * Gets a value indicating if the user is moving the camera
  126210. */
  126211. get isUserIsMoving(): boolean;
  126212. /**
  126213. * The camera can move all the way towards the mesh.
  126214. */
  126215. static IgnoreBoundsSizeMode: number;
  126216. /**
  126217. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  126218. */
  126219. static FitFrustumSidesMode: number;
  126220. }
  126221. }
  126222. declare module BABYLON {
  126223. /**
  126224. * Base class for Camera Pointer Inputs.
  126225. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  126226. * for example usage.
  126227. */
  126228. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  126229. /**
  126230. * Defines the camera the input is attached to.
  126231. */
  126232. abstract camera: Camera;
  126233. /**
  126234. * Whether keyboard modifier keys are pressed at time of last mouse event.
  126235. */
  126236. protected _altKey: boolean;
  126237. protected _ctrlKey: boolean;
  126238. protected _metaKey: boolean;
  126239. protected _shiftKey: boolean;
  126240. /**
  126241. * Which mouse buttons were pressed at time of last mouse event.
  126242. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  126243. */
  126244. protected _buttonsPressed: number;
  126245. /**
  126246. * Defines the buttons associated with the input to handle camera move.
  126247. */
  126248. buttons: number[];
  126249. /**
  126250. * Attach the input controls to a specific dom element to get the input from.
  126251. * @param element Defines the element the controls should be listened from
  126252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126253. */
  126254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126255. /**
  126256. * Detach the current controls from the specified dom element.
  126257. * @param element Defines the element to stop listening the inputs from
  126258. */
  126259. detachControl(element: Nullable<HTMLElement>): void;
  126260. /**
  126261. * Gets the class name of the current input.
  126262. * @returns the class name
  126263. */
  126264. getClassName(): string;
  126265. /**
  126266. * Get the friendly name associated with the input class.
  126267. * @returns the input friendly name
  126268. */
  126269. getSimpleName(): string;
  126270. /**
  126271. * Called on pointer POINTERDOUBLETAP event.
  126272. * Override this method to provide functionality on POINTERDOUBLETAP event.
  126273. */
  126274. protected onDoubleTap(type: string): void;
  126275. /**
  126276. * Called on pointer POINTERMOVE event if only a single touch is active.
  126277. * Override this method to provide functionality.
  126278. */
  126279. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126280. /**
  126281. * Called on pointer POINTERMOVE event if multiple touches are active.
  126282. * Override this method to provide functionality.
  126283. */
  126284. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126285. /**
  126286. * Called on JS contextmenu event.
  126287. * Override this method to provide functionality.
  126288. */
  126289. protected onContextMenu(evt: PointerEvent): void;
  126290. /**
  126291. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126292. * press.
  126293. * Override this method to provide functionality.
  126294. */
  126295. protected onButtonDown(evt: PointerEvent): void;
  126296. /**
  126297. * Called each time a new POINTERUP event occurs. Ie, for each button
  126298. * release.
  126299. * Override this method to provide functionality.
  126300. */
  126301. protected onButtonUp(evt: PointerEvent): void;
  126302. /**
  126303. * Called when window becomes inactive.
  126304. * Override this method to provide functionality.
  126305. */
  126306. protected onLostFocus(): void;
  126307. private _pointerInput;
  126308. private _observer;
  126309. private _onLostFocus;
  126310. private pointA;
  126311. private pointB;
  126312. }
  126313. }
  126314. declare module BABYLON {
  126315. /**
  126316. * Manage the pointers inputs to control an arc rotate camera.
  126317. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126318. */
  126319. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  126320. /**
  126321. * Defines the camera the input is attached to.
  126322. */
  126323. camera: ArcRotateCamera;
  126324. /**
  126325. * Gets the class name of the current input.
  126326. * @returns the class name
  126327. */
  126328. getClassName(): string;
  126329. /**
  126330. * Defines the buttons associated with the input to handle camera move.
  126331. */
  126332. buttons: number[];
  126333. /**
  126334. * Defines the pointer angular sensibility along the X axis or how fast is
  126335. * the camera rotating.
  126336. */
  126337. angularSensibilityX: number;
  126338. /**
  126339. * Defines the pointer angular sensibility along the Y axis or how fast is
  126340. * the camera rotating.
  126341. */
  126342. angularSensibilityY: number;
  126343. /**
  126344. * Defines the pointer pinch precision or how fast is the camera zooming.
  126345. */
  126346. pinchPrecision: number;
  126347. /**
  126348. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  126349. * from 0.
  126350. * It defines the percentage of current camera.radius to use as delta when
  126351. * pinch zoom is used.
  126352. */
  126353. pinchDeltaPercentage: number;
  126354. /**
  126355. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126356. * that any object in the plane at the camera's target point will scale
  126357. * perfectly with finger motion.
  126358. * Overrides pinchDeltaPercentage and pinchPrecision.
  126359. */
  126360. useNaturalPinchZoom: boolean;
  126361. /**
  126362. * Defines the pointer panning sensibility or how fast is the camera moving.
  126363. */
  126364. panningSensibility: number;
  126365. /**
  126366. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  126367. */
  126368. multiTouchPanning: boolean;
  126369. /**
  126370. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  126371. * zoom (pinch) through multitouch.
  126372. */
  126373. multiTouchPanAndZoom: boolean;
  126374. /**
  126375. * Revers pinch action direction.
  126376. */
  126377. pinchInwards: boolean;
  126378. private _isPanClick;
  126379. private _twoFingerActivityCount;
  126380. private _isPinching;
  126381. /**
  126382. * Called on pointer POINTERMOVE event if only a single touch is active.
  126383. */
  126384. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  126385. /**
  126386. * Called on pointer POINTERDOUBLETAP event.
  126387. */
  126388. protected onDoubleTap(type: string): void;
  126389. /**
  126390. * Called on pointer POINTERMOVE event if multiple touches are active.
  126391. */
  126392. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  126393. /**
  126394. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  126395. * press.
  126396. */
  126397. protected onButtonDown(evt: PointerEvent): void;
  126398. /**
  126399. * Called each time a new POINTERUP event occurs. Ie, for each button
  126400. * release.
  126401. */
  126402. protected onButtonUp(evt: PointerEvent): void;
  126403. /**
  126404. * Called when window becomes inactive.
  126405. */
  126406. protected onLostFocus(): void;
  126407. }
  126408. }
  126409. declare module BABYLON {
  126410. /**
  126411. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  126412. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126413. */
  126414. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  126415. /**
  126416. * Defines the camera the input is attached to.
  126417. */
  126418. camera: ArcRotateCamera;
  126419. /**
  126420. * Defines the list of key codes associated with the up action (increase alpha)
  126421. */
  126422. keysUp: number[];
  126423. /**
  126424. * Defines the list of key codes associated with the down action (decrease alpha)
  126425. */
  126426. keysDown: number[];
  126427. /**
  126428. * Defines the list of key codes associated with the left action (increase beta)
  126429. */
  126430. keysLeft: number[];
  126431. /**
  126432. * Defines the list of key codes associated with the right action (decrease beta)
  126433. */
  126434. keysRight: number[];
  126435. /**
  126436. * Defines the list of key codes associated with the reset action.
  126437. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  126438. */
  126439. keysReset: number[];
  126440. /**
  126441. * Defines the panning sensibility of the inputs.
  126442. * (How fast is the camera panning)
  126443. */
  126444. panningSensibility: number;
  126445. /**
  126446. * Defines the zooming sensibility of the inputs.
  126447. * (How fast is the camera zooming)
  126448. */
  126449. zoomingSensibility: number;
  126450. /**
  126451. * Defines whether maintaining the alt key down switch the movement mode from
  126452. * orientation to zoom.
  126453. */
  126454. useAltToZoom: boolean;
  126455. /**
  126456. * Rotation speed of the camera
  126457. */
  126458. angularSpeed: number;
  126459. private _keys;
  126460. private _ctrlPressed;
  126461. private _altPressed;
  126462. private _onCanvasBlurObserver;
  126463. private _onKeyboardObserver;
  126464. private _engine;
  126465. private _scene;
  126466. /**
  126467. * Attach the input controls to a specific dom element to get the input from.
  126468. * @param element Defines the element the controls should be listened from
  126469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126470. */
  126471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126472. /**
  126473. * Detach the current controls from the specified dom element.
  126474. * @param element Defines the element to stop listening the inputs from
  126475. */
  126476. detachControl(element: Nullable<HTMLElement>): void;
  126477. /**
  126478. * Update the current camera state depending on the inputs that have been used this frame.
  126479. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  126480. */
  126481. checkInputs(): void;
  126482. /**
  126483. * Gets the class name of the current intput.
  126484. * @returns the class name
  126485. */
  126486. getClassName(): string;
  126487. /**
  126488. * Get the friendly name associated with the input class.
  126489. * @returns the input friendly name
  126490. */
  126491. getSimpleName(): string;
  126492. }
  126493. }
  126494. declare module BABYLON {
  126495. /**
  126496. * Manage the mouse wheel inputs to control an arc rotate camera.
  126497. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126498. */
  126499. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  126500. /**
  126501. * Defines the camera the input is attached to.
  126502. */
  126503. camera: ArcRotateCamera;
  126504. /**
  126505. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126506. */
  126507. wheelPrecision: number;
  126508. /**
  126509. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  126510. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  126511. */
  126512. wheelDeltaPercentage: number;
  126513. private _wheel;
  126514. private _observer;
  126515. private computeDeltaFromMouseWheelLegacyEvent;
  126516. /**
  126517. * Attach the input controls to a specific dom element to get the input from.
  126518. * @param element Defines the element the controls should be listened from
  126519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126520. */
  126521. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  126522. /**
  126523. * Detach the current controls from the specified dom element.
  126524. * @param element Defines the element to stop listening the inputs from
  126525. */
  126526. detachControl(element: Nullable<HTMLElement>): void;
  126527. /**
  126528. * Gets the class name of the current intput.
  126529. * @returns the class name
  126530. */
  126531. getClassName(): string;
  126532. /**
  126533. * Get the friendly name associated with the input class.
  126534. * @returns the input friendly name
  126535. */
  126536. getSimpleName(): string;
  126537. }
  126538. }
  126539. declare module BABYLON {
  126540. /**
  126541. * Default Inputs manager for the ArcRotateCamera.
  126542. * It groups all the default supported inputs for ease of use.
  126543. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  126544. */
  126545. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  126546. /**
  126547. * Instantiates a new ArcRotateCameraInputsManager.
  126548. * @param camera Defines the camera the inputs belong to
  126549. */
  126550. constructor(camera: ArcRotateCamera);
  126551. /**
  126552. * Add mouse wheel input support to the input manager.
  126553. * @returns the current input manager
  126554. */
  126555. addMouseWheel(): ArcRotateCameraInputsManager;
  126556. /**
  126557. * Add pointers input support to the input manager.
  126558. * @returns the current input manager
  126559. */
  126560. addPointers(): ArcRotateCameraInputsManager;
  126561. /**
  126562. * Add keyboard input support to the input manager.
  126563. * @returns the current input manager
  126564. */
  126565. addKeyboard(): ArcRotateCameraInputsManager;
  126566. }
  126567. }
  126568. declare module BABYLON {
  126569. /**
  126570. * This represents an orbital type of camera.
  126571. *
  126572. * 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.
  126573. * 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.
  126574. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  126575. */
  126576. export class ArcRotateCamera extends TargetCamera {
  126577. /**
  126578. * Defines the rotation angle of the camera along the longitudinal axis.
  126579. */
  126580. alpha: number;
  126581. /**
  126582. * Defines the rotation angle of the camera along the latitudinal axis.
  126583. */
  126584. beta: number;
  126585. /**
  126586. * Defines the radius of the camera from it s target point.
  126587. */
  126588. radius: number;
  126589. protected _target: Vector3;
  126590. protected _targetHost: Nullable<AbstractMesh>;
  126591. /**
  126592. * Defines the target point of the camera.
  126593. * The camera looks towards it form the radius distance.
  126594. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  126595. */
  126596. get target(): Vector3;
  126597. set target(value: Vector3);
  126598. /**
  126599. * Define the current local position of the camera in the scene
  126600. */
  126601. get position(): Vector3;
  126602. set position(newPosition: Vector3);
  126603. protected _upToYMatrix: Matrix;
  126604. protected _YToUpMatrix: Matrix;
  126605. /**
  126606. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  126607. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  126608. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  126609. */
  126610. set upVector(vec: Vector3);
  126611. get upVector(): Vector3;
  126612. /**
  126613. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  126614. */
  126615. setMatUp(): void;
  126616. /**
  126617. * Current inertia value on the longitudinal axis.
  126618. * The bigger this number the longer it will take for the camera to stop.
  126619. */
  126620. inertialAlphaOffset: number;
  126621. /**
  126622. * Current inertia value on the latitudinal axis.
  126623. * The bigger this number the longer it will take for the camera to stop.
  126624. */
  126625. inertialBetaOffset: number;
  126626. /**
  126627. * Current inertia value on the radius axis.
  126628. * The bigger this number the longer it will take for the camera to stop.
  126629. */
  126630. inertialRadiusOffset: number;
  126631. /**
  126632. * Minimum allowed angle on the longitudinal axis.
  126633. * This can help limiting how the Camera is able to move in the scene.
  126634. */
  126635. lowerAlphaLimit: Nullable<number>;
  126636. /**
  126637. * Maximum allowed angle on the longitudinal axis.
  126638. * This can help limiting how the Camera is able to move in the scene.
  126639. */
  126640. upperAlphaLimit: Nullable<number>;
  126641. /**
  126642. * Minimum allowed angle on the latitudinal axis.
  126643. * This can help limiting how the Camera is able to move in the scene.
  126644. */
  126645. lowerBetaLimit: number;
  126646. /**
  126647. * Maximum allowed angle on the latitudinal axis.
  126648. * This can help limiting how the Camera is able to move in the scene.
  126649. */
  126650. upperBetaLimit: number;
  126651. /**
  126652. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  126653. * This can help limiting how the Camera is able to move in the scene.
  126654. */
  126655. lowerRadiusLimit: Nullable<number>;
  126656. /**
  126657. * Maximum allowed distance of the camera to the target (The camera can not get further).
  126658. * This can help limiting how the Camera is able to move in the scene.
  126659. */
  126660. upperRadiusLimit: Nullable<number>;
  126661. /**
  126662. * Defines the current inertia value used during panning of the camera along the X axis.
  126663. */
  126664. inertialPanningX: number;
  126665. /**
  126666. * Defines the current inertia value used during panning of the camera along the Y axis.
  126667. */
  126668. inertialPanningY: number;
  126669. /**
  126670. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  126671. * Basically if your fingers moves away from more than this distance you will be considered
  126672. * in pinch mode.
  126673. */
  126674. pinchToPanMaxDistance: number;
  126675. /**
  126676. * Defines the maximum distance the camera can pan.
  126677. * This could help keeping the cammera always in your scene.
  126678. */
  126679. panningDistanceLimit: Nullable<number>;
  126680. /**
  126681. * Defines the target of the camera before paning.
  126682. */
  126683. panningOriginTarget: Vector3;
  126684. /**
  126685. * Defines the value of the inertia used during panning.
  126686. * 0 would mean stop inertia and one would mean no decelleration at all.
  126687. */
  126688. panningInertia: number;
  126689. /**
  126690. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  126691. */
  126692. get angularSensibilityX(): number;
  126693. set angularSensibilityX(value: number);
  126694. /**
  126695. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  126696. */
  126697. get angularSensibilityY(): number;
  126698. set angularSensibilityY(value: number);
  126699. /**
  126700. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  126701. */
  126702. get pinchPrecision(): number;
  126703. set pinchPrecision(value: number);
  126704. /**
  126705. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  126706. * It will be used instead of pinchDeltaPrecision if different from 0.
  126707. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126708. */
  126709. get pinchDeltaPercentage(): number;
  126710. set pinchDeltaPercentage(value: number);
  126711. /**
  126712. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  126713. * and pinch delta percentage.
  126714. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  126715. * that any object in the plane at the camera's target point will scale
  126716. * perfectly with finger motion.
  126717. */
  126718. get useNaturalPinchZoom(): boolean;
  126719. set useNaturalPinchZoom(value: boolean);
  126720. /**
  126721. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  126722. */
  126723. get panningSensibility(): number;
  126724. set panningSensibility(value: number);
  126725. /**
  126726. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  126727. */
  126728. get keysUp(): number[];
  126729. set keysUp(value: number[]);
  126730. /**
  126731. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  126732. */
  126733. get keysDown(): number[];
  126734. set keysDown(value: number[]);
  126735. /**
  126736. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  126737. */
  126738. get keysLeft(): number[];
  126739. set keysLeft(value: number[]);
  126740. /**
  126741. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  126742. */
  126743. get keysRight(): number[];
  126744. set keysRight(value: number[]);
  126745. /**
  126746. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  126747. */
  126748. get wheelPrecision(): number;
  126749. set wheelPrecision(value: number);
  126750. /**
  126751. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  126752. * It will be used instead of pinchDeltaPrecision if different from 0.
  126753. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  126754. */
  126755. get wheelDeltaPercentage(): number;
  126756. set wheelDeltaPercentage(value: number);
  126757. /**
  126758. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  126759. */
  126760. zoomOnFactor: number;
  126761. /**
  126762. * Defines a screen offset for the camera position.
  126763. */
  126764. targetScreenOffset: Vector2;
  126765. /**
  126766. * Allows the camera to be completely reversed.
  126767. * If false the camera can not arrive upside down.
  126768. */
  126769. allowUpsideDown: boolean;
  126770. /**
  126771. * Define if double tap/click is used to restore the previously saved state of the camera.
  126772. */
  126773. useInputToRestoreState: boolean;
  126774. /** @hidden */
  126775. _viewMatrix: Matrix;
  126776. /** @hidden */
  126777. _useCtrlForPanning: boolean;
  126778. /** @hidden */
  126779. _panningMouseButton: number;
  126780. /**
  126781. * Defines the input associated to the camera.
  126782. */
  126783. inputs: ArcRotateCameraInputsManager;
  126784. /** @hidden */
  126785. _reset: () => void;
  126786. /**
  126787. * Defines the allowed panning axis.
  126788. */
  126789. panningAxis: Vector3;
  126790. protected _localDirection: Vector3;
  126791. protected _transformedDirection: Vector3;
  126792. private _bouncingBehavior;
  126793. /**
  126794. * Gets the bouncing behavior of the camera if it has been enabled.
  126795. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126796. */
  126797. get bouncingBehavior(): Nullable<BouncingBehavior>;
  126798. /**
  126799. * Defines if the bouncing behavior of the camera is enabled on the camera.
  126800. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126801. */
  126802. get useBouncingBehavior(): boolean;
  126803. set useBouncingBehavior(value: boolean);
  126804. private _framingBehavior;
  126805. /**
  126806. * Gets the framing behavior of the camera if it has been enabled.
  126807. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126808. */
  126809. get framingBehavior(): Nullable<FramingBehavior>;
  126810. /**
  126811. * Defines if the framing behavior of the camera is enabled on the camera.
  126812. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126813. */
  126814. get useFramingBehavior(): boolean;
  126815. set useFramingBehavior(value: boolean);
  126816. private _autoRotationBehavior;
  126817. /**
  126818. * Gets the auto rotation behavior of the camera if it has been enabled.
  126819. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126820. */
  126821. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  126822. /**
  126823. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  126824. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126825. */
  126826. get useAutoRotationBehavior(): boolean;
  126827. set useAutoRotationBehavior(value: boolean);
  126828. /**
  126829. * Observable triggered when the mesh target has been changed on the camera.
  126830. */
  126831. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  126832. /**
  126833. * Event raised when the camera is colliding with a mesh.
  126834. */
  126835. onCollide: (collidedMesh: AbstractMesh) => void;
  126836. /**
  126837. * Defines whether the camera should check collision with the objects oh the scene.
  126838. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  126839. */
  126840. checkCollisions: boolean;
  126841. /**
  126842. * Defines the collision radius of the camera.
  126843. * This simulates a sphere around the camera.
  126844. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  126845. */
  126846. collisionRadius: Vector3;
  126847. protected _collider: Collider;
  126848. protected _previousPosition: Vector3;
  126849. protected _collisionVelocity: Vector3;
  126850. protected _newPosition: Vector3;
  126851. protected _previousAlpha: number;
  126852. protected _previousBeta: number;
  126853. protected _previousRadius: number;
  126854. protected _collisionTriggered: boolean;
  126855. protected _targetBoundingCenter: Nullable<Vector3>;
  126856. private _computationVector;
  126857. /**
  126858. * Instantiates a new ArcRotateCamera in a given scene
  126859. * @param name Defines the name of the camera
  126860. * @param alpha Defines the camera rotation along the logitudinal axis
  126861. * @param beta Defines the camera rotation along the latitudinal axis
  126862. * @param radius Defines the camera distance from its target
  126863. * @param target Defines the camera target
  126864. * @param scene Defines the scene the camera belongs to
  126865. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  126866. */
  126867. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  126868. /** @hidden */
  126869. _initCache(): void;
  126870. /** @hidden */
  126871. _updateCache(ignoreParentClass?: boolean): void;
  126872. protected _getTargetPosition(): Vector3;
  126873. private _storedAlpha;
  126874. private _storedBeta;
  126875. private _storedRadius;
  126876. private _storedTarget;
  126877. private _storedTargetScreenOffset;
  126878. /**
  126879. * Stores the current state of the camera (alpha, beta, radius and target)
  126880. * @returns the camera itself
  126881. */
  126882. storeState(): Camera;
  126883. /**
  126884. * @hidden
  126885. * Restored camera state. You must call storeState() first
  126886. */
  126887. _restoreStateValues(): boolean;
  126888. /** @hidden */
  126889. _isSynchronizedViewMatrix(): boolean;
  126890. /**
  126891. * Attached controls to the current camera.
  126892. * @param element Defines the element the controls should be listened from
  126893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  126894. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  126895. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  126896. */
  126897. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  126898. /**
  126899. * Detach the current controls from the camera.
  126900. * The camera will stop reacting to inputs.
  126901. * @param element Defines the element to stop listening the inputs from
  126902. */
  126903. detachControl(element: HTMLElement): void;
  126904. /** @hidden */
  126905. _checkInputs(): void;
  126906. protected _checkLimits(): void;
  126907. /**
  126908. * Rebuilds angles (alpha, beta) and radius from the give position and target
  126909. */
  126910. rebuildAnglesAndRadius(): void;
  126911. /**
  126912. * Use a position to define the current camera related information like alpha, beta and radius
  126913. * @param position Defines the position to set the camera at
  126914. */
  126915. setPosition(position: Vector3): void;
  126916. /**
  126917. * Defines the target the camera should look at.
  126918. * This will automatically adapt alpha beta and radius to fit within the new target.
  126919. * @param target Defines the new target as a Vector or a mesh
  126920. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  126921. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  126922. */
  126923. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  126924. /** @hidden */
  126925. _getViewMatrix(): Matrix;
  126926. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  126927. /**
  126928. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  126929. * @param meshes Defines the mesh to zoom on
  126930. * @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)
  126931. */
  126932. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  126933. /**
  126934. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  126935. * The target will be changed but the radius
  126936. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  126937. * @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)
  126938. */
  126939. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  126940. min: Vector3;
  126941. max: Vector3;
  126942. distance: number;
  126943. }, doNotUpdateMaxZ?: boolean): void;
  126944. /**
  126945. * @override
  126946. * Override Camera.createRigCamera
  126947. */
  126948. createRigCamera(name: string, cameraIndex: number): Camera;
  126949. /**
  126950. * @hidden
  126951. * @override
  126952. * Override Camera._updateRigCameras
  126953. */
  126954. _updateRigCameras(): void;
  126955. /**
  126956. * Destroy the camera and release the current resources hold by it.
  126957. */
  126958. dispose(): void;
  126959. /**
  126960. * Gets the current object class name.
  126961. * @return the class name
  126962. */
  126963. getClassName(): string;
  126964. }
  126965. }
  126966. declare module BABYLON {
  126967. /**
  126968. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  126969. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  126970. */
  126971. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  126972. /**
  126973. * Gets the name of the behavior.
  126974. */
  126975. get name(): string;
  126976. private _zoomStopsAnimation;
  126977. private _idleRotationSpeed;
  126978. private _idleRotationWaitTime;
  126979. private _idleRotationSpinupTime;
  126980. /**
  126981. * Sets the flag that indicates if user zooming should stop animation.
  126982. */
  126983. set zoomStopsAnimation(flag: boolean);
  126984. /**
  126985. * Gets the flag that indicates if user zooming should stop animation.
  126986. */
  126987. get zoomStopsAnimation(): boolean;
  126988. /**
  126989. * Sets the default speed at which the camera rotates around the model.
  126990. */
  126991. set idleRotationSpeed(speed: number);
  126992. /**
  126993. * Gets the default speed at which the camera rotates around the model.
  126994. */
  126995. get idleRotationSpeed(): number;
  126996. /**
  126997. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  126998. */
  126999. set idleRotationWaitTime(time: number);
  127000. /**
  127001. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  127002. */
  127003. get idleRotationWaitTime(): number;
  127004. /**
  127005. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127006. */
  127007. set idleRotationSpinupTime(time: number);
  127008. /**
  127009. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127010. */
  127011. get idleRotationSpinupTime(): number;
  127012. /**
  127013. * Gets a value indicating if the camera is currently rotating because of this behavior
  127014. */
  127015. get rotationInProgress(): boolean;
  127016. private _onPrePointerObservableObserver;
  127017. private _onAfterCheckInputsObserver;
  127018. private _attachedCamera;
  127019. private _isPointerDown;
  127020. private _lastFrameTime;
  127021. private _lastInteractionTime;
  127022. private _cameraRotationSpeed;
  127023. /**
  127024. * Initializes the behavior.
  127025. */
  127026. init(): void;
  127027. /**
  127028. * Attaches the behavior to its arc rotate camera.
  127029. * @param camera Defines the camera to attach the behavior to
  127030. */
  127031. attach(camera: ArcRotateCamera): void;
  127032. /**
  127033. * Detaches the behavior from its current arc rotate camera.
  127034. */
  127035. detach(): void;
  127036. /**
  127037. * Returns true if user is scrolling.
  127038. * @return true if user is scrolling.
  127039. */
  127040. private _userIsZooming;
  127041. private _lastFrameRadius;
  127042. private _shouldAnimationStopForInteraction;
  127043. /**
  127044. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127045. */
  127046. private _applyUserInteraction;
  127047. private _userIsMoving;
  127048. }
  127049. }
  127050. declare module BABYLON {
  127051. /**
  127052. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  127053. */
  127054. export class AttachToBoxBehavior implements Behavior<Mesh> {
  127055. private ui;
  127056. /**
  127057. * The name of the behavior
  127058. */
  127059. name: string;
  127060. /**
  127061. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  127062. */
  127063. distanceAwayFromFace: number;
  127064. /**
  127065. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  127066. */
  127067. distanceAwayFromBottomOfFace: number;
  127068. private _faceVectors;
  127069. private _target;
  127070. private _scene;
  127071. private _onRenderObserver;
  127072. private _tmpMatrix;
  127073. private _tmpVector;
  127074. /**
  127075. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  127076. * @param ui The transform node that should be attched to the mesh
  127077. */
  127078. constructor(ui: TransformNode);
  127079. /**
  127080. * Initializes the behavior
  127081. */
  127082. init(): void;
  127083. private _closestFace;
  127084. private _zeroVector;
  127085. private _lookAtTmpMatrix;
  127086. private _lookAtToRef;
  127087. /**
  127088. * Attaches the AttachToBoxBehavior to the passed in mesh
  127089. * @param target The mesh that the specified node will be attached to
  127090. */
  127091. attach(target: Mesh): void;
  127092. /**
  127093. * Detaches the behavior from the mesh
  127094. */
  127095. detach(): void;
  127096. }
  127097. }
  127098. declare module BABYLON {
  127099. /**
  127100. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  127101. */
  127102. export class FadeInOutBehavior implements Behavior<Mesh> {
  127103. /**
  127104. * Time in milliseconds to delay before fading in (Default: 0)
  127105. */
  127106. delay: number;
  127107. /**
  127108. * Time in milliseconds for the mesh to fade in (Default: 300)
  127109. */
  127110. fadeInTime: number;
  127111. private _millisecondsPerFrame;
  127112. private _hovered;
  127113. private _hoverValue;
  127114. private _ownerNode;
  127115. /**
  127116. * Instatiates the FadeInOutBehavior
  127117. */
  127118. constructor();
  127119. /**
  127120. * The name of the behavior
  127121. */
  127122. get name(): string;
  127123. /**
  127124. * Initializes the behavior
  127125. */
  127126. init(): void;
  127127. /**
  127128. * Attaches the fade behavior on the passed in mesh
  127129. * @param ownerNode The mesh that will be faded in/out once attached
  127130. */
  127131. attach(ownerNode: Mesh): void;
  127132. /**
  127133. * Detaches the behavior from the mesh
  127134. */
  127135. detach(): void;
  127136. /**
  127137. * Triggers the mesh to begin fading in or out
  127138. * @param value if the object should fade in or out (true to fade in)
  127139. */
  127140. fadeIn(value: boolean): void;
  127141. private _update;
  127142. private _setAllVisibility;
  127143. }
  127144. }
  127145. declare module BABYLON {
  127146. /**
  127147. * Class containing a set of static utilities functions for managing Pivots
  127148. * @hidden
  127149. */
  127150. export class PivotTools {
  127151. private static _PivotCached;
  127152. private static _OldPivotPoint;
  127153. private static _PivotTranslation;
  127154. private static _PivotTmpVector;
  127155. private static _PivotPostMultiplyPivotMatrix;
  127156. /** @hidden */
  127157. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  127158. /** @hidden */
  127159. static _RestorePivotPoint(mesh: AbstractMesh): void;
  127160. }
  127161. }
  127162. declare module BABYLON {
  127163. /**
  127164. * Class containing static functions to help procedurally build meshes
  127165. */
  127166. export class PlaneBuilder {
  127167. /**
  127168. * Creates a plane mesh
  127169. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127170. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127171. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127175. * @param name defines the name of the mesh
  127176. * @param options defines the options used to create the mesh
  127177. * @param scene defines the hosting scene
  127178. * @returns the plane mesh
  127179. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127180. */
  127181. static CreatePlane(name: string, options: {
  127182. size?: number;
  127183. width?: number;
  127184. height?: number;
  127185. sideOrientation?: number;
  127186. frontUVs?: Vector4;
  127187. backUVs?: Vector4;
  127188. updatable?: boolean;
  127189. sourcePlane?: Plane;
  127190. }, scene?: Nullable<Scene>): Mesh;
  127191. }
  127192. }
  127193. declare module BABYLON {
  127194. /**
  127195. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  127196. */
  127197. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  127198. private static _AnyMouseID;
  127199. /**
  127200. * Abstract mesh the behavior is set on
  127201. */
  127202. attachedNode: AbstractMesh;
  127203. private _dragPlane;
  127204. private _scene;
  127205. private _pointerObserver;
  127206. private _beforeRenderObserver;
  127207. private static _planeScene;
  127208. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  127209. /**
  127210. * 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)
  127211. */
  127212. maxDragAngle: number;
  127213. /**
  127214. * @hidden
  127215. */
  127216. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  127217. /**
  127218. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127219. */
  127220. currentDraggingPointerID: number;
  127221. /**
  127222. * The last position where the pointer hit the drag plane in world space
  127223. */
  127224. lastDragPosition: Vector3;
  127225. /**
  127226. * If the behavior is currently in a dragging state
  127227. */
  127228. dragging: boolean;
  127229. /**
  127230. * 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)
  127231. */
  127232. dragDeltaRatio: number;
  127233. /**
  127234. * If the drag plane orientation should be updated during the dragging (Default: true)
  127235. */
  127236. updateDragPlane: boolean;
  127237. private _debugMode;
  127238. private _moving;
  127239. /**
  127240. * Fires each time the attached mesh is dragged with the pointer
  127241. * * delta between last drag position and current drag position in world space
  127242. * * dragDistance along the drag axis
  127243. * * dragPlaneNormal normal of the current drag plane used during the drag
  127244. * * dragPlanePoint in world space where the drag intersects the drag plane
  127245. */
  127246. onDragObservable: Observable<{
  127247. delta: Vector3;
  127248. dragPlanePoint: Vector3;
  127249. dragPlaneNormal: Vector3;
  127250. dragDistance: number;
  127251. pointerId: number;
  127252. }>;
  127253. /**
  127254. * Fires each time a drag begins (eg. mouse down on mesh)
  127255. */
  127256. onDragStartObservable: Observable<{
  127257. dragPlanePoint: Vector3;
  127258. pointerId: number;
  127259. }>;
  127260. /**
  127261. * Fires each time a drag ends (eg. mouse release after drag)
  127262. */
  127263. onDragEndObservable: Observable<{
  127264. dragPlanePoint: Vector3;
  127265. pointerId: number;
  127266. }>;
  127267. /**
  127268. * If the attached mesh should be moved when dragged
  127269. */
  127270. moveAttached: boolean;
  127271. /**
  127272. * If the drag behavior will react to drag events (Default: true)
  127273. */
  127274. enabled: boolean;
  127275. /**
  127276. * If pointer events should start and release the drag (Default: true)
  127277. */
  127278. startAndReleaseDragOnPointerEvents: boolean;
  127279. /**
  127280. * If camera controls should be detached during the drag
  127281. */
  127282. detachCameraControls: boolean;
  127283. /**
  127284. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  127285. */
  127286. useObjectOrientationForDragging: boolean;
  127287. private _options;
  127288. /**
  127289. * Gets the options used by the behavior
  127290. */
  127291. get options(): {
  127292. dragAxis?: Vector3;
  127293. dragPlaneNormal?: Vector3;
  127294. };
  127295. /**
  127296. * Sets the options used by the behavior
  127297. */
  127298. set options(options: {
  127299. dragAxis?: Vector3;
  127300. dragPlaneNormal?: Vector3;
  127301. });
  127302. /**
  127303. * Creates a pointer drag behavior that can be attached to a mesh
  127304. * @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)
  127305. */
  127306. constructor(options?: {
  127307. dragAxis?: Vector3;
  127308. dragPlaneNormal?: Vector3;
  127309. });
  127310. /**
  127311. * Predicate to determine if it is valid to move the object to a new position when it is moved
  127312. */
  127313. validateDrag: (targetPosition: Vector3) => boolean;
  127314. /**
  127315. * The name of the behavior
  127316. */
  127317. get name(): string;
  127318. /**
  127319. * Initializes the behavior
  127320. */
  127321. init(): void;
  127322. private _tmpVector;
  127323. private _alternatePickedPoint;
  127324. private _worldDragAxis;
  127325. private _targetPosition;
  127326. private _attachedElement;
  127327. /**
  127328. * Attaches the drag behavior the passed in mesh
  127329. * @param ownerNode The mesh that will be dragged around once attached
  127330. * @param predicate Predicate to use for pick filtering
  127331. */
  127332. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  127333. /**
  127334. * Force relase the drag action by code.
  127335. */
  127336. releaseDrag(): void;
  127337. private _startDragRay;
  127338. private _lastPointerRay;
  127339. /**
  127340. * Simulates the start of a pointer drag event on the behavior
  127341. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  127342. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  127343. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  127344. */
  127345. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127346. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  127347. private _dragDelta;
  127348. protected _moveDrag(ray: Ray): void;
  127349. private _pickWithRayOnDragPlane;
  127350. private _pointA;
  127351. private _pointC;
  127352. private _localAxis;
  127353. private _lookAt;
  127354. private _updateDragPlanePosition;
  127355. /**
  127356. * Detaches the behavior from the mesh
  127357. */
  127358. detach(): void;
  127359. }
  127360. }
  127361. declare module BABYLON {
  127362. /**
  127363. * A behavior that when attached to a mesh will allow the mesh to be scaled
  127364. */
  127365. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  127366. private _dragBehaviorA;
  127367. private _dragBehaviorB;
  127368. private _startDistance;
  127369. private _initialScale;
  127370. private _targetScale;
  127371. private _ownerNode;
  127372. private _sceneRenderObserver;
  127373. /**
  127374. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  127375. */
  127376. constructor();
  127377. /**
  127378. * The name of the behavior
  127379. */
  127380. get name(): string;
  127381. /**
  127382. * Initializes the behavior
  127383. */
  127384. init(): void;
  127385. private _getCurrentDistance;
  127386. /**
  127387. * Attaches the scale behavior the passed in mesh
  127388. * @param ownerNode The mesh that will be scaled around once attached
  127389. */
  127390. attach(ownerNode: Mesh): void;
  127391. /**
  127392. * Detaches the behavior from the mesh
  127393. */
  127394. detach(): void;
  127395. }
  127396. }
  127397. declare module BABYLON {
  127398. /**
  127399. * 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
  127400. */
  127401. export class SixDofDragBehavior implements Behavior<Mesh> {
  127402. private static _virtualScene;
  127403. private _ownerNode;
  127404. private _sceneRenderObserver;
  127405. private _scene;
  127406. private _targetPosition;
  127407. private _virtualOriginMesh;
  127408. private _virtualDragMesh;
  127409. private _pointerObserver;
  127410. private _moving;
  127411. private _startingOrientation;
  127412. private _attachedElement;
  127413. /**
  127414. * 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)
  127415. */
  127416. private zDragFactor;
  127417. /**
  127418. * If the object should rotate to face the drag origin
  127419. */
  127420. rotateDraggedObject: boolean;
  127421. /**
  127422. * If the behavior is currently in a dragging state
  127423. */
  127424. dragging: boolean;
  127425. /**
  127426. * 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)
  127427. */
  127428. dragDeltaRatio: number;
  127429. /**
  127430. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127431. */
  127432. currentDraggingPointerID: number;
  127433. /**
  127434. * If camera controls should be detached during the drag
  127435. */
  127436. detachCameraControls: boolean;
  127437. /**
  127438. * Fires each time a drag starts
  127439. */
  127440. onDragStartObservable: Observable<{}>;
  127441. /**
  127442. * Fires each time a drag ends (eg. mouse release after drag)
  127443. */
  127444. onDragEndObservable: Observable<{}>;
  127445. /**
  127446. * 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
  127447. */
  127448. constructor();
  127449. /**
  127450. * The name of the behavior
  127451. */
  127452. get name(): string;
  127453. /**
  127454. * Initializes the behavior
  127455. */
  127456. init(): void;
  127457. /**
  127458. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  127459. */
  127460. private get _pointerCamera();
  127461. /**
  127462. * Attaches the scale behavior the passed in mesh
  127463. * @param ownerNode The mesh that will be scaled around once attached
  127464. */
  127465. attach(ownerNode: Mesh): void;
  127466. /**
  127467. * Detaches the behavior from the mesh
  127468. */
  127469. detach(): void;
  127470. }
  127471. }
  127472. declare module BABYLON {
  127473. /**
  127474. * Class used to apply inverse kinematics to bones
  127475. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  127476. */
  127477. export class BoneIKController {
  127478. private static _tmpVecs;
  127479. private static _tmpQuat;
  127480. private static _tmpMats;
  127481. /**
  127482. * Gets or sets the target mesh
  127483. */
  127484. targetMesh: AbstractMesh;
  127485. /** Gets or sets the mesh used as pole */
  127486. poleTargetMesh: AbstractMesh;
  127487. /**
  127488. * Gets or sets the bone used as pole
  127489. */
  127490. poleTargetBone: Nullable<Bone>;
  127491. /**
  127492. * Gets or sets the target position
  127493. */
  127494. targetPosition: Vector3;
  127495. /**
  127496. * Gets or sets the pole target position
  127497. */
  127498. poleTargetPosition: Vector3;
  127499. /**
  127500. * Gets or sets the pole target local offset
  127501. */
  127502. poleTargetLocalOffset: Vector3;
  127503. /**
  127504. * Gets or sets the pole angle
  127505. */
  127506. poleAngle: number;
  127507. /**
  127508. * Gets or sets the mesh associated with the controller
  127509. */
  127510. mesh: AbstractMesh;
  127511. /**
  127512. * 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)
  127513. */
  127514. slerpAmount: number;
  127515. private _bone1Quat;
  127516. private _bone1Mat;
  127517. private _bone2Ang;
  127518. private _bone1;
  127519. private _bone2;
  127520. private _bone1Length;
  127521. private _bone2Length;
  127522. private _maxAngle;
  127523. private _maxReach;
  127524. private _rightHandedSystem;
  127525. private _bendAxis;
  127526. private _slerping;
  127527. private _adjustRoll;
  127528. /**
  127529. * Gets or sets maximum allowed angle
  127530. */
  127531. get maxAngle(): number;
  127532. set maxAngle(value: number);
  127533. /**
  127534. * Creates a new BoneIKController
  127535. * @param mesh defines the mesh to control
  127536. * @param bone defines the bone to control
  127537. * @param options defines options to set up the controller
  127538. */
  127539. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  127540. targetMesh?: AbstractMesh;
  127541. poleTargetMesh?: AbstractMesh;
  127542. poleTargetBone?: Bone;
  127543. poleTargetLocalOffset?: Vector3;
  127544. poleAngle?: number;
  127545. bendAxis?: Vector3;
  127546. maxAngle?: number;
  127547. slerpAmount?: number;
  127548. });
  127549. private _setMaxAngle;
  127550. /**
  127551. * Force the controller to update the bones
  127552. */
  127553. update(): void;
  127554. }
  127555. }
  127556. declare module BABYLON {
  127557. /**
  127558. * Class used to make a bone look toward a point in space
  127559. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  127560. */
  127561. export class BoneLookController {
  127562. private static _tmpVecs;
  127563. private static _tmpQuat;
  127564. private static _tmpMats;
  127565. /**
  127566. * The target Vector3 that the bone will look at
  127567. */
  127568. target: Vector3;
  127569. /**
  127570. * The mesh that the bone is attached to
  127571. */
  127572. mesh: AbstractMesh;
  127573. /**
  127574. * The bone that will be looking to the target
  127575. */
  127576. bone: Bone;
  127577. /**
  127578. * The up axis of the coordinate system that is used when the bone is rotated
  127579. */
  127580. upAxis: Vector3;
  127581. /**
  127582. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  127583. */
  127584. upAxisSpace: Space;
  127585. /**
  127586. * Used to make an adjustment to the yaw of the bone
  127587. */
  127588. adjustYaw: number;
  127589. /**
  127590. * Used to make an adjustment to the pitch of the bone
  127591. */
  127592. adjustPitch: number;
  127593. /**
  127594. * Used to make an adjustment to the roll of the bone
  127595. */
  127596. adjustRoll: number;
  127597. /**
  127598. * 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)
  127599. */
  127600. slerpAmount: number;
  127601. private _minYaw;
  127602. private _maxYaw;
  127603. private _minPitch;
  127604. private _maxPitch;
  127605. private _minYawSin;
  127606. private _minYawCos;
  127607. private _maxYawSin;
  127608. private _maxYawCos;
  127609. private _midYawConstraint;
  127610. private _minPitchTan;
  127611. private _maxPitchTan;
  127612. private _boneQuat;
  127613. private _slerping;
  127614. private _transformYawPitch;
  127615. private _transformYawPitchInv;
  127616. private _firstFrameSkipped;
  127617. private _yawRange;
  127618. private _fowardAxis;
  127619. /**
  127620. * Gets or sets the minimum yaw angle that the bone can look to
  127621. */
  127622. get minYaw(): number;
  127623. set minYaw(value: number);
  127624. /**
  127625. * Gets or sets the maximum yaw angle that the bone can look to
  127626. */
  127627. get maxYaw(): number;
  127628. set maxYaw(value: number);
  127629. /**
  127630. * Gets or sets the minimum pitch angle that the bone can look to
  127631. */
  127632. get minPitch(): number;
  127633. set minPitch(value: number);
  127634. /**
  127635. * Gets or sets the maximum pitch angle that the bone can look to
  127636. */
  127637. get maxPitch(): number;
  127638. set maxPitch(value: number);
  127639. /**
  127640. * Create a BoneLookController
  127641. * @param mesh the mesh that the bone belongs to
  127642. * @param bone the bone that will be looking to the target
  127643. * @param target the target Vector3 to look at
  127644. * @param options optional settings:
  127645. * * maxYaw: the maximum angle the bone will yaw to
  127646. * * minYaw: the minimum angle the bone will yaw to
  127647. * * maxPitch: the maximum angle the bone will pitch to
  127648. * * minPitch: the minimum angle the bone will yaw to
  127649. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  127650. * * upAxis: the up axis of the coordinate system
  127651. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  127652. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  127653. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  127654. * * adjustYaw: used to make an adjustment to the yaw of the bone
  127655. * * adjustPitch: used to make an adjustment to the pitch of the bone
  127656. * * adjustRoll: used to make an adjustment to the roll of the bone
  127657. **/
  127658. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  127659. maxYaw?: number;
  127660. minYaw?: number;
  127661. maxPitch?: number;
  127662. minPitch?: number;
  127663. slerpAmount?: number;
  127664. upAxis?: Vector3;
  127665. upAxisSpace?: Space;
  127666. yawAxis?: Vector3;
  127667. pitchAxis?: Vector3;
  127668. adjustYaw?: number;
  127669. adjustPitch?: number;
  127670. adjustRoll?: number;
  127671. });
  127672. /**
  127673. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  127674. */
  127675. update(): void;
  127676. private _getAngleDiff;
  127677. private _getAngleBetween;
  127678. private _isAngleBetween;
  127679. }
  127680. }
  127681. declare module BABYLON {
  127682. /**
  127683. * Manage the gamepad inputs to control an arc rotate camera.
  127684. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127685. */
  127686. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  127687. /**
  127688. * Defines the camera the input is attached to.
  127689. */
  127690. camera: ArcRotateCamera;
  127691. /**
  127692. * Defines the gamepad the input is gathering event from.
  127693. */
  127694. gamepad: Nullable<Gamepad>;
  127695. /**
  127696. * Defines the gamepad rotation sensiblity.
  127697. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  127698. */
  127699. gamepadRotationSensibility: number;
  127700. /**
  127701. * Defines the gamepad move sensiblity.
  127702. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  127703. */
  127704. gamepadMoveSensibility: number;
  127705. private _yAxisScale;
  127706. /**
  127707. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  127708. */
  127709. get invertYAxis(): boolean;
  127710. set invertYAxis(value: boolean);
  127711. private _onGamepadConnectedObserver;
  127712. private _onGamepadDisconnectedObserver;
  127713. /**
  127714. * Attach the input controls to a specific dom element to get the input from.
  127715. * @param element Defines the element the controls should be listened from
  127716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127717. */
  127718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127719. /**
  127720. * Detach the current controls from the specified dom element.
  127721. * @param element Defines the element to stop listening the inputs from
  127722. */
  127723. detachControl(element: Nullable<HTMLElement>): void;
  127724. /**
  127725. * Update the current camera state depending on the inputs that have been used this frame.
  127726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127727. */
  127728. checkInputs(): void;
  127729. /**
  127730. * Gets the class name of the current intput.
  127731. * @returns the class name
  127732. */
  127733. getClassName(): string;
  127734. /**
  127735. * Get the friendly name associated with the input class.
  127736. * @returns the input friendly name
  127737. */
  127738. getSimpleName(): string;
  127739. }
  127740. }
  127741. declare module BABYLON {
  127742. interface ArcRotateCameraInputsManager {
  127743. /**
  127744. * Add orientation input support to the input manager.
  127745. * @returns the current input manager
  127746. */
  127747. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  127748. }
  127749. /**
  127750. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  127751. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127752. */
  127753. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  127754. /**
  127755. * Defines the camera the input is attached to.
  127756. */
  127757. camera: ArcRotateCamera;
  127758. /**
  127759. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  127760. */
  127761. alphaCorrection: number;
  127762. /**
  127763. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  127764. */
  127765. gammaCorrection: number;
  127766. private _alpha;
  127767. private _gamma;
  127768. private _dirty;
  127769. private _deviceOrientationHandler;
  127770. /**
  127771. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  127772. */
  127773. constructor();
  127774. /**
  127775. * Attach the input controls to a specific dom element to get the input from.
  127776. * @param element Defines the element the controls should be listened from
  127777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127778. */
  127779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127780. /** @hidden */
  127781. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  127782. /**
  127783. * Update the current camera state depending on the inputs that have been used this frame.
  127784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127785. */
  127786. checkInputs(): void;
  127787. /**
  127788. * Detach the current controls from the specified dom element.
  127789. * @param element Defines the element to stop listening the inputs from
  127790. */
  127791. detachControl(element: Nullable<HTMLElement>): void;
  127792. /**
  127793. * Gets the class name of the current intput.
  127794. * @returns the class name
  127795. */
  127796. getClassName(): string;
  127797. /**
  127798. * Get the friendly name associated with the input class.
  127799. * @returns the input friendly name
  127800. */
  127801. getSimpleName(): string;
  127802. }
  127803. }
  127804. declare module BABYLON {
  127805. /**
  127806. * Listen to mouse events to control the camera.
  127807. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127808. */
  127809. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  127810. /**
  127811. * Defines the camera the input is attached to.
  127812. */
  127813. camera: FlyCamera;
  127814. /**
  127815. * Defines if touch is enabled. (Default is true.)
  127816. */
  127817. touchEnabled: boolean;
  127818. /**
  127819. * Defines the buttons associated with the input to handle camera rotation.
  127820. */
  127821. buttons: number[];
  127822. /**
  127823. * Assign buttons for Yaw control.
  127824. */
  127825. buttonsYaw: number[];
  127826. /**
  127827. * Assign buttons for Pitch control.
  127828. */
  127829. buttonsPitch: number[];
  127830. /**
  127831. * Assign buttons for Roll control.
  127832. */
  127833. buttonsRoll: number[];
  127834. /**
  127835. * Detect if any button is being pressed while mouse is moved.
  127836. * -1 = Mouse locked.
  127837. * 0 = Left button.
  127838. * 1 = Middle Button.
  127839. * 2 = Right Button.
  127840. */
  127841. activeButton: number;
  127842. /**
  127843. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  127844. * Higher values reduce its sensitivity.
  127845. */
  127846. angularSensibility: number;
  127847. private _observer;
  127848. private _rollObserver;
  127849. private previousPosition;
  127850. private noPreventDefault;
  127851. private element;
  127852. /**
  127853. * Listen to mouse events to control the camera.
  127854. * @param touchEnabled Define if touch is enabled. (Default is true.)
  127855. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127856. */
  127857. constructor(touchEnabled?: boolean);
  127858. /**
  127859. * Attach the mouse control to the HTML DOM element.
  127860. * @param element Defines the element that listens to the input events.
  127861. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  127862. */
  127863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127864. /**
  127865. * Detach the current controls from the specified dom element.
  127866. * @param element Defines the element to stop listening the inputs from
  127867. */
  127868. detachControl(element: Nullable<HTMLElement>): void;
  127869. /**
  127870. * Gets the class name of the current input.
  127871. * @returns the class name.
  127872. */
  127873. getClassName(): string;
  127874. /**
  127875. * Get the friendly name associated with the input class.
  127876. * @returns the input's friendly name.
  127877. */
  127878. getSimpleName(): string;
  127879. private _pointerInput;
  127880. private _onMouseMove;
  127881. /**
  127882. * Rotate camera by mouse offset.
  127883. */
  127884. private rotateCamera;
  127885. }
  127886. }
  127887. declare module BABYLON {
  127888. /**
  127889. * Default Inputs manager for the FlyCamera.
  127890. * It groups all the default supported inputs for ease of use.
  127891. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127892. */
  127893. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  127894. /**
  127895. * Instantiates a new FlyCameraInputsManager.
  127896. * @param camera Defines the camera the inputs belong to.
  127897. */
  127898. constructor(camera: FlyCamera);
  127899. /**
  127900. * Add keyboard input support to the input manager.
  127901. * @returns the new FlyCameraKeyboardMoveInput().
  127902. */
  127903. addKeyboard(): FlyCameraInputsManager;
  127904. /**
  127905. * Add mouse input support to the input manager.
  127906. * @param touchEnabled Enable touch screen support.
  127907. * @returns the new FlyCameraMouseInput().
  127908. */
  127909. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  127910. }
  127911. }
  127912. declare module BABYLON {
  127913. /**
  127914. * This is a flying camera, designed for 3D movement and rotation in all directions,
  127915. * such as in a 3D Space Shooter or a Flight Simulator.
  127916. */
  127917. export class FlyCamera extends TargetCamera {
  127918. /**
  127919. * Define the collision ellipsoid of the camera.
  127920. * This is helpful for simulating a camera body, like a player's body.
  127921. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  127922. */
  127923. ellipsoid: Vector3;
  127924. /**
  127925. * Define an offset for the position of the ellipsoid around the camera.
  127926. * This can be helpful if the camera is attached away from the player's body center,
  127927. * such as at its head.
  127928. */
  127929. ellipsoidOffset: Vector3;
  127930. /**
  127931. * Enable or disable collisions of the camera with the rest of the scene objects.
  127932. */
  127933. checkCollisions: boolean;
  127934. /**
  127935. * Enable or disable gravity on the camera.
  127936. */
  127937. applyGravity: boolean;
  127938. /**
  127939. * Define the current direction the camera is moving to.
  127940. */
  127941. cameraDirection: Vector3;
  127942. /**
  127943. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  127944. * This overrides and empties cameraRotation.
  127945. */
  127946. rotationQuaternion: Quaternion;
  127947. /**
  127948. * Track Roll to maintain the wanted Rolling when looking around.
  127949. */
  127950. _trackRoll: number;
  127951. /**
  127952. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  127953. */
  127954. rollCorrect: number;
  127955. /**
  127956. * Mimic a banked turn, Rolling the camera when Yawing.
  127957. * It's recommended to use rollCorrect = 10 for faster banking correction.
  127958. */
  127959. bankedTurn: boolean;
  127960. /**
  127961. * Limit in radians for how much Roll banking will add. (Default: 90°)
  127962. */
  127963. bankedTurnLimit: number;
  127964. /**
  127965. * Value of 0 disables the banked Roll.
  127966. * Value of 1 is equal to the Yaw angle in radians.
  127967. */
  127968. bankedTurnMultiplier: number;
  127969. /**
  127970. * The inputs manager loads all the input sources, such as keyboard and mouse.
  127971. */
  127972. inputs: FlyCameraInputsManager;
  127973. /**
  127974. * Gets the input sensibility for mouse input.
  127975. * Higher values reduce sensitivity.
  127976. */
  127977. get angularSensibility(): number;
  127978. /**
  127979. * Sets the input sensibility for a mouse input.
  127980. * Higher values reduce sensitivity.
  127981. */
  127982. set angularSensibility(value: number);
  127983. /**
  127984. * Get the keys for camera movement forward.
  127985. */
  127986. get keysForward(): number[];
  127987. /**
  127988. * Set the keys for camera movement forward.
  127989. */
  127990. set keysForward(value: number[]);
  127991. /**
  127992. * Get the keys for camera movement backward.
  127993. */
  127994. get keysBackward(): number[];
  127995. set keysBackward(value: number[]);
  127996. /**
  127997. * Get the keys for camera movement up.
  127998. */
  127999. get keysUp(): number[];
  128000. /**
  128001. * Set the keys for camera movement up.
  128002. */
  128003. set keysUp(value: number[]);
  128004. /**
  128005. * Get the keys for camera movement down.
  128006. */
  128007. get keysDown(): number[];
  128008. /**
  128009. * Set the keys for camera movement down.
  128010. */
  128011. set keysDown(value: number[]);
  128012. /**
  128013. * Get the keys for camera movement left.
  128014. */
  128015. get keysLeft(): number[];
  128016. /**
  128017. * Set the keys for camera movement left.
  128018. */
  128019. set keysLeft(value: number[]);
  128020. /**
  128021. * Set the keys for camera movement right.
  128022. */
  128023. get keysRight(): number[];
  128024. /**
  128025. * Set the keys for camera movement right.
  128026. */
  128027. set keysRight(value: number[]);
  128028. /**
  128029. * Event raised when the camera collides with a mesh in the scene.
  128030. */
  128031. onCollide: (collidedMesh: AbstractMesh) => void;
  128032. private _collider;
  128033. private _needMoveForGravity;
  128034. private _oldPosition;
  128035. private _diffPosition;
  128036. private _newPosition;
  128037. /** @hidden */
  128038. _localDirection: Vector3;
  128039. /** @hidden */
  128040. _transformedDirection: Vector3;
  128041. /**
  128042. * Instantiates a FlyCamera.
  128043. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128044. * such as in a 3D Space Shooter or a Flight Simulator.
  128045. * @param name Define the name of the camera in the scene.
  128046. * @param position Define the starting position of the camera in the scene.
  128047. * @param scene Define the scene the camera belongs to.
  128048. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  128049. */
  128050. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128051. /**
  128052. * Attach a control to the HTML DOM element.
  128053. * @param element Defines the element that listens to the input events.
  128054. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  128055. */
  128056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128057. /**
  128058. * Detach a control from the HTML DOM element.
  128059. * The camera will stop reacting to that input.
  128060. * @param element Defines the element that listens to the input events.
  128061. */
  128062. detachControl(element: HTMLElement): void;
  128063. private _collisionMask;
  128064. /**
  128065. * Get the mask that the camera ignores in collision events.
  128066. */
  128067. get collisionMask(): number;
  128068. /**
  128069. * Set the mask that the camera ignores in collision events.
  128070. */
  128071. set collisionMask(mask: number);
  128072. /** @hidden */
  128073. _collideWithWorld(displacement: Vector3): void;
  128074. /** @hidden */
  128075. private _onCollisionPositionChange;
  128076. /** @hidden */
  128077. _checkInputs(): void;
  128078. /** @hidden */
  128079. _decideIfNeedsToMove(): boolean;
  128080. /** @hidden */
  128081. _updatePosition(): void;
  128082. /**
  128083. * Restore the Roll to its target value at the rate specified.
  128084. * @param rate - Higher means slower restoring.
  128085. * @hidden
  128086. */
  128087. restoreRoll(rate: number): void;
  128088. /**
  128089. * Destroy the camera and release the current resources held by it.
  128090. */
  128091. dispose(): void;
  128092. /**
  128093. * Get the current object class name.
  128094. * @returns the class name.
  128095. */
  128096. getClassName(): string;
  128097. }
  128098. }
  128099. declare module BABYLON {
  128100. /**
  128101. * Listen to keyboard events to control the camera.
  128102. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128103. */
  128104. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  128105. /**
  128106. * Defines the camera the input is attached to.
  128107. */
  128108. camera: FlyCamera;
  128109. /**
  128110. * The list of keyboard keys used to control the forward move of the camera.
  128111. */
  128112. keysForward: number[];
  128113. /**
  128114. * The list of keyboard keys used to control the backward move of the camera.
  128115. */
  128116. keysBackward: number[];
  128117. /**
  128118. * The list of keyboard keys used to control the forward move of the camera.
  128119. */
  128120. keysUp: number[];
  128121. /**
  128122. * The list of keyboard keys used to control the backward move of the camera.
  128123. */
  128124. keysDown: number[];
  128125. /**
  128126. * The list of keyboard keys used to control the right strafe move of the camera.
  128127. */
  128128. keysRight: number[];
  128129. /**
  128130. * The list of keyboard keys used to control the left strafe move of the camera.
  128131. */
  128132. keysLeft: number[];
  128133. private _keys;
  128134. private _onCanvasBlurObserver;
  128135. private _onKeyboardObserver;
  128136. private _engine;
  128137. private _scene;
  128138. /**
  128139. * Attach the input controls to a specific dom element to get the input from.
  128140. * @param element Defines the element the controls should be listened from
  128141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128142. */
  128143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128144. /**
  128145. * Detach the current controls from the specified dom element.
  128146. * @param element Defines the element to stop listening the inputs from
  128147. */
  128148. detachControl(element: Nullable<HTMLElement>): void;
  128149. /**
  128150. * Gets the class name of the current intput.
  128151. * @returns the class name
  128152. */
  128153. getClassName(): string;
  128154. /** @hidden */
  128155. _onLostFocus(e: FocusEvent): void;
  128156. /**
  128157. * Get the friendly name associated with the input class.
  128158. * @returns the input friendly name
  128159. */
  128160. getSimpleName(): string;
  128161. /**
  128162. * Update the current camera state depending on the inputs that have been used this frame.
  128163. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128164. */
  128165. checkInputs(): void;
  128166. }
  128167. }
  128168. declare module BABYLON {
  128169. /**
  128170. * Manage the mouse wheel inputs to control a follow camera.
  128171. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128172. */
  128173. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  128174. /**
  128175. * Defines the camera the input is attached to.
  128176. */
  128177. camera: FollowCamera;
  128178. /**
  128179. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  128180. */
  128181. axisControlRadius: boolean;
  128182. /**
  128183. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  128184. */
  128185. axisControlHeight: boolean;
  128186. /**
  128187. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  128188. */
  128189. axisControlRotation: boolean;
  128190. /**
  128191. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  128192. * relation to mouseWheel events.
  128193. */
  128194. wheelPrecision: number;
  128195. /**
  128196. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128197. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128198. */
  128199. wheelDeltaPercentage: number;
  128200. private _wheel;
  128201. private _observer;
  128202. /**
  128203. * Attach the input controls to a specific dom element to get the input from.
  128204. * @param element Defines the element the controls should be listened from
  128205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128206. */
  128207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128208. /**
  128209. * Detach the current controls from the specified dom element.
  128210. * @param element Defines the element to stop listening the inputs from
  128211. */
  128212. detachControl(element: Nullable<HTMLElement>): void;
  128213. /**
  128214. * Gets the class name of the current intput.
  128215. * @returns the class name
  128216. */
  128217. getClassName(): string;
  128218. /**
  128219. * Get the friendly name associated with the input class.
  128220. * @returns the input friendly name
  128221. */
  128222. getSimpleName(): string;
  128223. }
  128224. }
  128225. declare module BABYLON {
  128226. /**
  128227. * Manage the pointers inputs to control an follow camera.
  128228. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128229. */
  128230. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  128231. /**
  128232. * Defines the camera the input is attached to.
  128233. */
  128234. camera: FollowCamera;
  128235. /**
  128236. * Gets the class name of the current input.
  128237. * @returns the class name
  128238. */
  128239. getClassName(): string;
  128240. /**
  128241. * Defines the pointer angular sensibility along the X axis or how fast is
  128242. * the camera rotating.
  128243. * A negative number will reverse the axis direction.
  128244. */
  128245. angularSensibilityX: number;
  128246. /**
  128247. * Defines the pointer angular sensibility along the Y axis or how fast is
  128248. * the camera rotating.
  128249. * A negative number will reverse the axis direction.
  128250. */
  128251. angularSensibilityY: number;
  128252. /**
  128253. * Defines the pointer pinch precision or how fast is the camera zooming.
  128254. * A negative number will reverse the axis direction.
  128255. */
  128256. pinchPrecision: number;
  128257. /**
  128258. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  128259. * from 0.
  128260. * It defines the percentage of current camera.radius to use as delta when
  128261. * pinch zoom is used.
  128262. */
  128263. pinchDeltaPercentage: number;
  128264. /**
  128265. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  128266. */
  128267. axisXControlRadius: boolean;
  128268. /**
  128269. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  128270. */
  128271. axisXControlHeight: boolean;
  128272. /**
  128273. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  128274. */
  128275. axisXControlRotation: boolean;
  128276. /**
  128277. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  128278. */
  128279. axisYControlRadius: boolean;
  128280. /**
  128281. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  128282. */
  128283. axisYControlHeight: boolean;
  128284. /**
  128285. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  128286. */
  128287. axisYControlRotation: boolean;
  128288. /**
  128289. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  128290. */
  128291. axisPinchControlRadius: boolean;
  128292. /**
  128293. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  128294. */
  128295. axisPinchControlHeight: boolean;
  128296. /**
  128297. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  128298. */
  128299. axisPinchControlRotation: boolean;
  128300. /**
  128301. * Log error messages if basic misconfiguration has occurred.
  128302. */
  128303. warningEnable: boolean;
  128304. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  128305. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  128306. private _warningCounter;
  128307. private _warning;
  128308. }
  128309. }
  128310. declare module BABYLON {
  128311. /**
  128312. * Default Inputs manager for the FollowCamera.
  128313. * It groups all the default supported inputs for ease of use.
  128314. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128315. */
  128316. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  128317. /**
  128318. * Instantiates a new FollowCameraInputsManager.
  128319. * @param camera Defines the camera the inputs belong to
  128320. */
  128321. constructor(camera: FollowCamera);
  128322. /**
  128323. * Add keyboard input support to the input manager.
  128324. * @returns the current input manager
  128325. */
  128326. addKeyboard(): FollowCameraInputsManager;
  128327. /**
  128328. * Add mouse wheel input support to the input manager.
  128329. * @returns the current input manager
  128330. */
  128331. addMouseWheel(): FollowCameraInputsManager;
  128332. /**
  128333. * Add pointers input support to the input manager.
  128334. * @returns the current input manager
  128335. */
  128336. addPointers(): FollowCameraInputsManager;
  128337. /**
  128338. * Add orientation input support to the input manager.
  128339. * @returns the current input manager
  128340. */
  128341. addVRDeviceOrientation(): FollowCameraInputsManager;
  128342. }
  128343. }
  128344. declare module BABYLON {
  128345. /**
  128346. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  128347. * an arc rotate version arcFollowCamera are available.
  128348. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128349. */
  128350. export class FollowCamera extends TargetCamera {
  128351. /**
  128352. * Distance the follow camera should follow an object at
  128353. */
  128354. radius: number;
  128355. /**
  128356. * Minimum allowed distance of the camera to the axis of rotation
  128357. * (The camera can not get closer).
  128358. * This can help limiting how the Camera is able to move in the scene.
  128359. */
  128360. lowerRadiusLimit: Nullable<number>;
  128361. /**
  128362. * Maximum allowed distance of the camera to the axis of rotation
  128363. * (The camera can not get further).
  128364. * This can help limiting how the Camera is able to move in the scene.
  128365. */
  128366. upperRadiusLimit: Nullable<number>;
  128367. /**
  128368. * Define a rotation offset between the camera and the object it follows
  128369. */
  128370. rotationOffset: number;
  128371. /**
  128372. * Minimum allowed angle to camera position relative to target object.
  128373. * This can help limiting how the Camera is able to move in the scene.
  128374. */
  128375. lowerRotationOffsetLimit: Nullable<number>;
  128376. /**
  128377. * Maximum allowed angle to camera position relative to target object.
  128378. * This can help limiting how the Camera is able to move in the scene.
  128379. */
  128380. upperRotationOffsetLimit: Nullable<number>;
  128381. /**
  128382. * Define a height offset between the camera and the object it follows.
  128383. * It can help following an object from the top (like a car chaing a plane)
  128384. */
  128385. heightOffset: number;
  128386. /**
  128387. * Minimum allowed height of camera position relative to target object.
  128388. * This can help limiting how the Camera is able to move in the scene.
  128389. */
  128390. lowerHeightOffsetLimit: Nullable<number>;
  128391. /**
  128392. * Maximum allowed height of camera position relative to target object.
  128393. * This can help limiting how the Camera is able to move in the scene.
  128394. */
  128395. upperHeightOffsetLimit: Nullable<number>;
  128396. /**
  128397. * Define how fast the camera can accelerate to follow it s target.
  128398. */
  128399. cameraAcceleration: number;
  128400. /**
  128401. * Define the speed limit of the camera following an object.
  128402. */
  128403. maxCameraSpeed: number;
  128404. /**
  128405. * Define the target of the camera.
  128406. */
  128407. lockedTarget: Nullable<AbstractMesh>;
  128408. /**
  128409. * Defines the input associated with the camera.
  128410. */
  128411. inputs: FollowCameraInputsManager;
  128412. /**
  128413. * Instantiates the follow camera.
  128414. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128415. * @param name Define the name of the camera in the scene
  128416. * @param position Define the position of the camera
  128417. * @param scene Define the scene the camera belong to
  128418. * @param lockedTarget Define the target of the camera
  128419. */
  128420. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  128421. private _follow;
  128422. /**
  128423. * Attached controls to the current camera.
  128424. * @param element Defines the element the controls should be listened from
  128425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128426. */
  128427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128428. /**
  128429. * Detach the current controls from the camera.
  128430. * The camera will stop reacting to inputs.
  128431. * @param element Defines the element to stop listening the inputs from
  128432. */
  128433. detachControl(element: HTMLElement): void;
  128434. /** @hidden */
  128435. _checkInputs(): void;
  128436. private _checkLimits;
  128437. /**
  128438. * Gets the camera class name.
  128439. * @returns the class name
  128440. */
  128441. getClassName(): string;
  128442. }
  128443. /**
  128444. * Arc Rotate version of the follow camera.
  128445. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  128446. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128447. */
  128448. export class ArcFollowCamera extends TargetCamera {
  128449. /** The longitudinal angle of the camera */
  128450. alpha: number;
  128451. /** The latitudinal angle of the camera */
  128452. beta: number;
  128453. /** The radius of the camera from its target */
  128454. radius: number;
  128455. private _cartesianCoordinates;
  128456. /** Define the camera target (the mesh it should follow) */
  128457. private _meshTarget;
  128458. /**
  128459. * Instantiates a new ArcFollowCamera
  128460. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  128461. * @param name Define the name of the camera
  128462. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  128463. * @param beta Define the rotation angle of the camera around the elevation axis
  128464. * @param radius Define the radius of the camera from its target point
  128465. * @param target Define the target of the camera
  128466. * @param scene Define the scene the camera belongs to
  128467. */
  128468. constructor(name: string,
  128469. /** The longitudinal angle of the camera */
  128470. alpha: number,
  128471. /** The latitudinal angle of the camera */
  128472. beta: number,
  128473. /** The radius of the camera from its target */
  128474. radius: number,
  128475. /** Define the camera target (the mesh it should follow) */
  128476. target: Nullable<AbstractMesh>, scene: Scene);
  128477. private _follow;
  128478. /** @hidden */
  128479. _checkInputs(): void;
  128480. /**
  128481. * Returns the class name of the object.
  128482. * It is mostly used internally for serialization purposes.
  128483. */
  128484. getClassName(): string;
  128485. }
  128486. }
  128487. declare module BABYLON {
  128488. /**
  128489. * Manage the keyboard inputs to control the movement of a follow camera.
  128490. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128491. */
  128492. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  128493. /**
  128494. * Defines the camera the input is attached to.
  128495. */
  128496. camera: FollowCamera;
  128497. /**
  128498. * Defines the list of key codes associated with the up action (increase heightOffset)
  128499. */
  128500. keysHeightOffsetIncr: number[];
  128501. /**
  128502. * Defines the list of key codes associated with the down action (decrease heightOffset)
  128503. */
  128504. keysHeightOffsetDecr: number[];
  128505. /**
  128506. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  128507. */
  128508. keysHeightOffsetModifierAlt: boolean;
  128509. /**
  128510. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  128511. */
  128512. keysHeightOffsetModifierCtrl: boolean;
  128513. /**
  128514. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  128515. */
  128516. keysHeightOffsetModifierShift: boolean;
  128517. /**
  128518. * Defines the list of key codes associated with the left action (increase rotationOffset)
  128519. */
  128520. keysRotationOffsetIncr: number[];
  128521. /**
  128522. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  128523. */
  128524. keysRotationOffsetDecr: number[];
  128525. /**
  128526. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  128527. */
  128528. keysRotationOffsetModifierAlt: boolean;
  128529. /**
  128530. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  128531. */
  128532. keysRotationOffsetModifierCtrl: boolean;
  128533. /**
  128534. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  128535. */
  128536. keysRotationOffsetModifierShift: boolean;
  128537. /**
  128538. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  128539. */
  128540. keysRadiusIncr: number[];
  128541. /**
  128542. * Defines the list of key codes associated with the zoom-out action (increase radius)
  128543. */
  128544. keysRadiusDecr: number[];
  128545. /**
  128546. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  128547. */
  128548. keysRadiusModifierAlt: boolean;
  128549. /**
  128550. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  128551. */
  128552. keysRadiusModifierCtrl: boolean;
  128553. /**
  128554. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  128555. */
  128556. keysRadiusModifierShift: boolean;
  128557. /**
  128558. * Defines the rate of change of heightOffset.
  128559. */
  128560. heightSensibility: number;
  128561. /**
  128562. * Defines the rate of change of rotationOffset.
  128563. */
  128564. rotationSensibility: number;
  128565. /**
  128566. * Defines the rate of change of radius.
  128567. */
  128568. radiusSensibility: number;
  128569. private _keys;
  128570. private _ctrlPressed;
  128571. private _altPressed;
  128572. private _shiftPressed;
  128573. private _onCanvasBlurObserver;
  128574. private _onKeyboardObserver;
  128575. private _engine;
  128576. private _scene;
  128577. /**
  128578. * Attach the input controls to a specific dom element to get the input from.
  128579. * @param element Defines the element the controls should be listened from
  128580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128581. */
  128582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128583. /**
  128584. * Detach the current controls from the specified dom element.
  128585. * @param element Defines the element to stop listening the inputs from
  128586. */
  128587. detachControl(element: Nullable<HTMLElement>): void;
  128588. /**
  128589. * Update the current camera state depending on the inputs that have been used this frame.
  128590. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128591. */
  128592. checkInputs(): void;
  128593. /**
  128594. * Gets the class name of the current input.
  128595. * @returns the class name
  128596. */
  128597. getClassName(): string;
  128598. /**
  128599. * Get the friendly name associated with the input class.
  128600. * @returns the input friendly name
  128601. */
  128602. getSimpleName(): string;
  128603. /**
  128604. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128605. * allow modification of the heightOffset value.
  128606. */
  128607. private _modifierHeightOffset;
  128608. /**
  128609. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128610. * allow modification of the rotationOffset value.
  128611. */
  128612. private _modifierRotationOffset;
  128613. /**
  128614. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  128615. * allow modification of the radius value.
  128616. */
  128617. private _modifierRadius;
  128618. }
  128619. }
  128620. declare module BABYLON {
  128621. interface FreeCameraInputsManager {
  128622. /**
  128623. * @hidden
  128624. */
  128625. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  128626. /**
  128627. * Add orientation input support to the input manager.
  128628. * @returns the current input manager
  128629. */
  128630. addDeviceOrientation(): FreeCameraInputsManager;
  128631. }
  128632. /**
  128633. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  128634. * Screen rotation is taken into account.
  128635. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128636. */
  128637. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  128638. private _camera;
  128639. private _screenOrientationAngle;
  128640. private _constantTranform;
  128641. private _screenQuaternion;
  128642. private _alpha;
  128643. private _beta;
  128644. private _gamma;
  128645. /**
  128646. * Can be used to detect if a device orientation sensor is available on a device
  128647. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  128648. * @returns a promise that will resolve on orientation change
  128649. */
  128650. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  128651. /**
  128652. * @hidden
  128653. */
  128654. _onDeviceOrientationChangedObservable: Observable<void>;
  128655. /**
  128656. * Instantiates a new input
  128657. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128658. */
  128659. constructor();
  128660. /**
  128661. * Define the camera controlled by the input.
  128662. */
  128663. get camera(): FreeCamera;
  128664. set camera(camera: FreeCamera);
  128665. /**
  128666. * Attach the input controls to a specific dom element to get the input from.
  128667. * @param element Defines the element the controls should be listened from
  128668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128669. */
  128670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128671. private _orientationChanged;
  128672. private _deviceOrientation;
  128673. /**
  128674. * Detach the current controls from the specified dom element.
  128675. * @param element Defines the element to stop listening the inputs from
  128676. */
  128677. detachControl(element: Nullable<HTMLElement>): void;
  128678. /**
  128679. * Update the current camera state depending on the inputs that have been used this frame.
  128680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128681. */
  128682. checkInputs(): void;
  128683. /**
  128684. * Gets the class name of the current intput.
  128685. * @returns the class name
  128686. */
  128687. getClassName(): string;
  128688. /**
  128689. * Get the friendly name associated with the input class.
  128690. * @returns the input friendly name
  128691. */
  128692. getSimpleName(): string;
  128693. }
  128694. }
  128695. declare module BABYLON {
  128696. /**
  128697. * Manage the gamepad inputs to control a free camera.
  128698. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128699. */
  128700. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  128701. /**
  128702. * Define the camera the input is attached to.
  128703. */
  128704. camera: FreeCamera;
  128705. /**
  128706. * Define the Gamepad controlling the input
  128707. */
  128708. gamepad: Nullable<Gamepad>;
  128709. /**
  128710. * Defines the gamepad rotation sensiblity.
  128711. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128712. */
  128713. gamepadAngularSensibility: number;
  128714. /**
  128715. * Defines the gamepad move sensiblity.
  128716. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128717. */
  128718. gamepadMoveSensibility: number;
  128719. private _yAxisScale;
  128720. /**
  128721. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128722. */
  128723. get invertYAxis(): boolean;
  128724. set invertYAxis(value: boolean);
  128725. private _onGamepadConnectedObserver;
  128726. private _onGamepadDisconnectedObserver;
  128727. private _cameraTransform;
  128728. private _deltaTransform;
  128729. private _vector3;
  128730. private _vector2;
  128731. /**
  128732. * Attach the input controls to a specific dom element to get the input from.
  128733. * @param element Defines the element the controls should be listened from
  128734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128735. */
  128736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128737. /**
  128738. * Detach the current controls from the specified dom element.
  128739. * @param element Defines the element to stop listening the inputs from
  128740. */
  128741. detachControl(element: Nullable<HTMLElement>): void;
  128742. /**
  128743. * Update the current camera state depending on the inputs that have been used this frame.
  128744. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128745. */
  128746. checkInputs(): void;
  128747. /**
  128748. * Gets the class name of the current intput.
  128749. * @returns the class name
  128750. */
  128751. getClassName(): string;
  128752. /**
  128753. * Get the friendly name associated with the input class.
  128754. * @returns the input friendly name
  128755. */
  128756. getSimpleName(): string;
  128757. }
  128758. }
  128759. declare module BABYLON {
  128760. /**
  128761. * Defines the potential axis of a Joystick
  128762. */
  128763. export enum JoystickAxis {
  128764. /** X axis */
  128765. X = 0,
  128766. /** Y axis */
  128767. Y = 1,
  128768. /** Z axis */
  128769. Z = 2
  128770. }
  128771. /**
  128772. * Represents the different customization options available
  128773. * for VirtualJoystick
  128774. */
  128775. interface VirtualJoystickCustomizations {
  128776. /**
  128777. * Size of the joystick's puck
  128778. */
  128779. puckSize: number;
  128780. /**
  128781. * Size of the joystick's container
  128782. */
  128783. containerSize: number;
  128784. /**
  128785. * Color of the joystick && puck
  128786. */
  128787. color: string;
  128788. /**
  128789. * Image URL for the joystick's puck
  128790. */
  128791. puckImage?: string;
  128792. /**
  128793. * Image URL for the joystick's container
  128794. */
  128795. containerImage?: string;
  128796. /**
  128797. * Defines the unmoving position of the joystick container
  128798. */
  128799. position?: {
  128800. x: number;
  128801. y: number;
  128802. };
  128803. /**
  128804. * Defines whether or not the joystick container is always visible
  128805. */
  128806. alwaysVisible: boolean;
  128807. /**
  128808. * Defines whether or not to limit the movement of the puck to the joystick's container
  128809. */
  128810. limitToContainer: boolean;
  128811. }
  128812. /**
  128813. * Class used to define virtual joystick (used in touch mode)
  128814. */
  128815. export class VirtualJoystick {
  128816. /**
  128817. * Gets or sets a boolean indicating that left and right values must be inverted
  128818. */
  128819. reverseLeftRight: boolean;
  128820. /**
  128821. * Gets or sets a boolean indicating that up and down values must be inverted
  128822. */
  128823. reverseUpDown: boolean;
  128824. /**
  128825. * Gets the offset value for the position (ie. the change of the position value)
  128826. */
  128827. deltaPosition: Vector3;
  128828. /**
  128829. * Gets a boolean indicating if the virtual joystick was pressed
  128830. */
  128831. pressed: boolean;
  128832. /**
  128833. * Canvas the virtual joystick will render onto, default z-index of this is 5
  128834. */
  128835. static Canvas: Nullable<HTMLCanvasElement>;
  128836. /**
  128837. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  128838. */
  128839. limitToContainer: boolean;
  128840. private static _globalJoystickIndex;
  128841. private static _alwaysVisibleSticks;
  128842. private static vjCanvasContext;
  128843. private static vjCanvasWidth;
  128844. private static vjCanvasHeight;
  128845. private static halfWidth;
  128846. private static _GetDefaultOptions;
  128847. private _action;
  128848. private _axisTargetedByLeftAndRight;
  128849. private _axisTargetedByUpAndDown;
  128850. private _joystickSensibility;
  128851. private _inversedSensibility;
  128852. private _joystickPointerID;
  128853. private _joystickColor;
  128854. private _joystickPointerPos;
  128855. private _joystickPreviousPointerPos;
  128856. private _joystickPointerStartPos;
  128857. private _deltaJoystickVector;
  128858. private _leftJoystick;
  128859. private _touches;
  128860. private _joystickPosition;
  128861. private _alwaysVisible;
  128862. private _puckImage;
  128863. private _containerImage;
  128864. private _joystickPuckSize;
  128865. private _joystickContainerSize;
  128866. private _clearPuckSize;
  128867. private _clearContainerSize;
  128868. private _clearPuckSizeOffset;
  128869. private _clearContainerSizeOffset;
  128870. private _onPointerDownHandlerRef;
  128871. private _onPointerMoveHandlerRef;
  128872. private _onPointerUpHandlerRef;
  128873. private _onResize;
  128874. /**
  128875. * Creates a new virtual joystick
  128876. * @param leftJoystick defines that the joystick is for left hand (false by default)
  128877. * @param customizations Defines the options we want to customize the VirtualJoystick
  128878. */
  128879. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  128880. /**
  128881. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  128882. * @param newJoystickSensibility defines the new sensibility
  128883. */
  128884. setJoystickSensibility(newJoystickSensibility: number): void;
  128885. private _onPointerDown;
  128886. private _onPointerMove;
  128887. private _onPointerUp;
  128888. /**
  128889. * Change the color of the virtual joystick
  128890. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  128891. */
  128892. setJoystickColor(newColor: string): void;
  128893. /**
  128894. * Size of the joystick's container
  128895. */
  128896. set containerSize(newSize: number);
  128897. get containerSize(): number;
  128898. /**
  128899. * Size of the joystick's puck
  128900. */
  128901. set puckSize(newSize: number);
  128902. get puckSize(): number;
  128903. /**
  128904. * Clears the set position of the joystick
  128905. */
  128906. clearPosition(): void;
  128907. /**
  128908. * Defines whether or not the joystick container is always visible
  128909. */
  128910. set alwaysVisible(value: boolean);
  128911. get alwaysVisible(): boolean;
  128912. /**
  128913. * Sets the constant position of the Joystick container
  128914. * @param x X axis coordinate
  128915. * @param y Y axis coordinate
  128916. */
  128917. setPosition(x: number, y: number): void;
  128918. /**
  128919. * Defines a callback to call when the joystick is touched
  128920. * @param action defines the callback
  128921. */
  128922. setActionOnTouch(action: () => any): void;
  128923. /**
  128924. * Defines which axis you'd like to control for left & right
  128925. * @param axis defines the axis to use
  128926. */
  128927. setAxisForLeftRight(axis: JoystickAxis): void;
  128928. /**
  128929. * Defines which axis you'd like to control for up & down
  128930. * @param axis defines the axis to use
  128931. */
  128932. setAxisForUpDown(axis: JoystickAxis): void;
  128933. /**
  128934. * Clears the canvas from the previous puck / container draw
  128935. */
  128936. private _clearPreviousDraw;
  128937. /**
  128938. * Loads `urlPath` to be used for the container's image
  128939. * @param urlPath defines the urlPath of an image to use
  128940. */
  128941. setContainerImage(urlPath: string): void;
  128942. /**
  128943. * Loads `urlPath` to be used for the puck's image
  128944. * @param urlPath defines the urlPath of an image to use
  128945. */
  128946. setPuckImage(urlPath: string): void;
  128947. /**
  128948. * Draws the Virtual Joystick's container
  128949. */
  128950. private _drawContainer;
  128951. /**
  128952. * Draws the Virtual Joystick's puck
  128953. */
  128954. private _drawPuck;
  128955. private _drawVirtualJoystick;
  128956. /**
  128957. * Release internal HTML canvas
  128958. */
  128959. releaseCanvas(): void;
  128960. }
  128961. }
  128962. declare module BABYLON {
  128963. interface FreeCameraInputsManager {
  128964. /**
  128965. * Add virtual joystick input support to the input manager.
  128966. * @returns the current input manager
  128967. */
  128968. addVirtualJoystick(): FreeCameraInputsManager;
  128969. }
  128970. /**
  128971. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  128972. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128973. */
  128974. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  128975. /**
  128976. * Defines the camera the input is attached to.
  128977. */
  128978. camera: FreeCamera;
  128979. private _leftjoystick;
  128980. private _rightjoystick;
  128981. /**
  128982. * Gets the left stick of the virtual joystick.
  128983. * @returns The virtual Joystick
  128984. */
  128985. getLeftJoystick(): VirtualJoystick;
  128986. /**
  128987. * Gets the right stick of the virtual joystick.
  128988. * @returns The virtual Joystick
  128989. */
  128990. getRightJoystick(): VirtualJoystick;
  128991. /**
  128992. * Update the current camera state depending on the inputs that have been used this frame.
  128993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128994. */
  128995. checkInputs(): void;
  128996. /**
  128997. * Attach the input controls to a specific dom element to get the input from.
  128998. * @param element Defines the element the controls should be listened from
  128999. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129000. */
  129001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  129002. /**
  129003. * Detach the current controls from the specified dom element.
  129004. * @param element Defines the element to stop listening the inputs from
  129005. */
  129006. detachControl(element: Nullable<HTMLElement>): void;
  129007. /**
  129008. * Gets the class name of the current intput.
  129009. * @returns the class name
  129010. */
  129011. getClassName(): string;
  129012. /**
  129013. * Get the friendly name associated with the input class.
  129014. * @returns the input friendly name
  129015. */
  129016. getSimpleName(): string;
  129017. }
  129018. }
  129019. declare module BABYLON {
  129020. /**
  129021. * This represents a FPS type of camera controlled by touch.
  129022. * This is like a universal camera minus the Gamepad controls.
  129023. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129024. */
  129025. export class TouchCamera extends FreeCamera {
  129026. /**
  129027. * Defines the touch sensibility for rotation.
  129028. * The higher the faster.
  129029. */
  129030. get touchAngularSensibility(): number;
  129031. set touchAngularSensibility(value: number);
  129032. /**
  129033. * Defines the touch sensibility for move.
  129034. * The higher the faster.
  129035. */
  129036. get touchMoveSensibility(): number;
  129037. set touchMoveSensibility(value: number);
  129038. /**
  129039. * Instantiates a new touch camera.
  129040. * This represents a FPS type of camera controlled by touch.
  129041. * This is like a universal camera minus the Gamepad controls.
  129042. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129043. * @param name Define the name of the camera in the scene
  129044. * @param position Define the start position of the camera in the scene
  129045. * @param scene Define the scene the camera belongs to
  129046. */
  129047. constructor(name: string, position: Vector3, scene: Scene);
  129048. /**
  129049. * Gets the current object class name.
  129050. * @return the class name
  129051. */
  129052. getClassName(): string;
  129053. /** @hidden */
  129054. _setupInputs(): void;
  129055. }
  129056. }
  129057. declare module BABYLON {
  129058. /**
  129059. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  129060. * being tilted forward or back and left or right.
  129061. */
  129062. export class DeviceOrientationCamera extends FreeCamera {
  129063. private _initialQuaternion;
  129064. private _quaternionCache;
  129065. private _tmpDragQuaternion;
  129066. private _disablePointerInputWhenUsingDeviceOrientation;
  129067. /**
  129068. * Creates a new device orientation camera
  129069. * @param name The name of the camera
  129070. * @param position The start position camera
  129071. * @param scene The scene the camera belongs to
  129072. */
  129073. constructor(name: string, position: Vector3, scene: Scene);
  129074. /**
  129075. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  129076. */
  129077. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  129078. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  129079. private _dragFactor;
  129080. /**
  129081. * Enabled turning on the y axis when the orientation sensor is active
  129082. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  129083. */
  129084. enableHorizontalDragging(dragFactor?: number): void;
  129085. /**
  129086. * Gets the current instance class name ("DeviceOrientationCamera").
  129087. * This helps avoiding instanceof at run time.
  129088. * @returns the class name
  129089. */
  129090. getClassName(): string;
  129091. /**
  129092. * @hidden
  129093. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  129094. */
  129095. _checkInputs(): void;
  129096. /**
  129097. * Reset the camera to its default orientation on the specified axis only.
  129098. * @param axis The axis to reset
  129099. */
  129100. resetToCurrentRotation(axis?: Axis): void;
  129101. }
  129102. }
  129103. declare module BABYLON {
  129104. /**
  129105. * Defines supported buttons for XBox360 compatible gamepads
  129106. */
  129107. export enum Xbox360Button {
  129108. /** A */
  129109. A = 0,
  129110. /** B */
  129111. B = 1,
  129112. /** X */
  129113. X = 2,
  129114. /** Y */
  129115. Y = 3,
  129116. /** Left button */
  129117. LB = 4,
  129118. /** Right button */
  129119. RB = 5,
  129120. /** Back */
  129121. Back = 8,
  129122. /** Start */
  129123. Start = 9,
  129124. /** Left stick */
  129125. LeftStick = 10,
  129126. /** Right stick */
  129127. RightStick = 11
  129128. }
  129129. /** Defines values for XBox360 DPad */
  129130. export enum Xbox360Dpad {
  129131. /** Up */
  129132. Up = 12,
  129133. /** Down */
  129134. Down = 13,
  129135. /** Left */
  129136. Left = 14,
  129137. /** Right */
  129138. Right = 15
  129139. }
  129140. /**
  129141. * Defines a XBox360 gamepad
  129142. */
  129143. export class Xbox360Pad extends Gamepad {
  129144. private _leftTrigger;
  129145. private _rightTrigger;
  129146. private _onlefttriggerchanged;
  129147. private _onrighttriggerchanged;
  129148. private _onbuttondown;
  129149. private _onbuttonup;
  129150. private _ondpaddown;
  129151. private _ondpadup;
  129152. /** Observable raised when a button is pressed */
  129153. onButtonDownObservable: Observable<Xbox360Button>;
  129154. /** Observable raised when a button is released */
  129155. onButtonUpObservable: Observable<Xbox360Button>;
  129156. /** Observable raised when a pad is pressed */
  129157. onPadDownObservable: Observable<Xbox360Dpad>;
  129158. /** Observable raised when a pad is released */
  129159. onPadUpObservable: Observable<Xbox360Dpad>;
  129160. private _buttonA;
  129161. private _buttonB;
  129162. private _buttonX;
  129163. private _buttonY;
  129164. private _buttonBack;
  129165. private _buttonStart;
  129166. private _buttonLB;
  129167. private _buttonRB;
  129168. private _buttonLeftStick;
  129169. private _buttonRightStick;
  129170. private _dPadUp;
  129171. private _dPadDown;
  129172. private _dPadLeft;
  129173. private _dPadRight;
  129174. private _isXboxOnePad;
  129175. /**
  129176. * Creates a new XBox360 gamepad object
  129177. * @param id defines the id of this gamepad
  129178. * @param index defines its index
  129179. * @param gamepad defines the internal HTML gamepad object
  129180. * @param xboxOne defines if it is a XBox One gamepad
  129181. */
  129182. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  129183. /**
  129184. * Defines the callback to call when left trigger is pressed
  129185. * @param callback defines the callback to use
  129186. */
  129187. onlefttriggerchanged(callback: (value: number) => void): void;
  129188. /**
  129189. * Defines the callback to call when right trigger is pressed
  129190. * @param callback defines the callback to use
  129191. */
  129192. onrighttriggerchanged(callback: (value: number) => void): void;
  129193. /**
  129194. * Gets the left trigger value
  129195. */
  129196. get leftTrigger(): number;
  129197. /**
  129198. * Sets the left trigger value
  129199. */
  129200. set leftTrigger(newValue: number);
  129201. /**
  129202. * Gets the right trigger value
  129203. */
  129204. get rightTrigger(): number;
  129205. /**
  129206. * Sets the right trigger value
  129207. */
  129208. set rightTrigger(newValue: number);
  129209. /**
  129210. * Defines the callback to call when a button is pressed
  129211. * @param callback defines the callback to use
  129212. */
  129213. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  129214. /**
  129215. * Defines the callback to call when a button is released
  129216. * @param callback defines the callback to use
  129217. */
  129218. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  129219. /**
  129220. * Defines the callback to call when a pad is pressed
  129221. * @param callback defines the callback to use
  129222. */
  129223. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  129224. /**
  129225. * Defines the callback to call when a pad is released
  129226. * @param callback defines the callback to use
  129227. */
  129228. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  129229. private _setButtonValue;
  129230. private _setDPadValue;
  129231. /**
  129232. * Gets the value of the `A` button
  129233. */
  129234. get buttonA(): number;
  129235. /**
  129236. * Sets the value of the `A` button
  129237. */
  129238. set buttonA(value: number);
  129239. /**
  129240. * Gets the value of the `B` button
  129241. */
  129242. get buttonB(): number;
  129243. /**
  129244. * Sets the value of the `B` button
  129245. */
  129246. set buttonB(value: number);
  129247. /**
  129248. * Gets the value of the `X` button
  129249. */
  129250. get buttonX(): number;
  129251. /**
  129252. * Sets the value of the `X` button
  129253. */
  129254. set buttonX(value: number);
  129255. /**
  129256. * Gets the value of the `Y` button
  129257. */
  129258. get buttonY(): number;
  129259. /**
  129260. * Sets the value of the `Y` button
  129261. */
  129262. set buttonY(value: number);
  129263. /**
  129264. * Gets the value of the `Start` button
  129265. */
  129266. get buttonStart(): number;
  129267. /**
  129268. * Sets the value of the `Start` button
  129269. */
  129270. set buttonStart(value: number);
  129271. /**
  129272. * Gets the value of the `Back` button
  129273. */
  129274. get buttonBack(): number;
  129275. /**
  129276. * Sets the value of the `Back` button
  129277. */
  129278. set buttonBack(value: number);
  129279. /**
  129280. * Gets the value of the `Left` button
  129281. */
  129282. get buttonLB(): number;
  129283. /**
  129284. * Sets the value of the `Left` button
  129285. */
  129286. set buttonLB(value: number);
  129287. /**
  129288. * Gets the value of the `Right` button
  129289. */
  129290. get buttonRB(): number;
  129291. /**
  129292. * Sets the value of the `Right` button
  129293. */
  129294. set buttonRB(value: number);
  129295. /**
  129296. * Gets the value of the Left joystick
  129297. */
  129298. get buttonLeftStick(): number;
  129299. /**
  129300. * Sets the value of the Left joystick
  129301. */
  129302. set buttonLeftStick(value: number);
  129303. /**
  129304. * Gets the value of the Right joystick
  129305. */
  129306. get buttonRightStick(): number;
  129307. /**
  129308. * Sets the value of the Right joystick
  129309. */
  129310. set buttonRightStick(value: number);
  129311. /**
  129312. * Gets the value of D-pad up
  129313. */
  129314. get dPadUp(): number;
  129315. /**
  129316. * Sets the value of D-pad up
  129317. */
  129318. set dPadUp(value: number);
  129319. /**
  129320. * Gets the value of D-pad down
  129321. */
  129322. get dPadDown(): number;
  129323. /**
  129324. * Sets the value of D-pad down
  129325. */
  129326. set dPadDown(value: number);
  129327. /**
  129328. * Gets the value of D-pad left
  129329. */
  129330. get dPadLeft(): number;
  129331. /**
  129332. * Sets the value of D-pad left
  129333. */
  129334. set dPadLeft(value: number);
  129335. /**
  129336. * Gets the value of D-pad right
  129337. */
  129338. get dPadRight(): number;
  129339. /**
  129340. * Sets the value of D-pad right
  129341. */
  129342. set dPadRight(value: number);
  129343. /**
  129344. * Force the gamepad to synchronize with device values
  129345. */
  129346. update(): void;
  129347. /**
  129348. * Disposes the gamepad
  129349. */
  129350. dispose(): void;
  129351. }
  129352. }
  129353. declare module BABYLON {
  129354. /**
  129355. * Defines supported buttons for DualShock compatible gamepads
  129356. */
  129357. export enum DualShockButton {
  129358. /** Cross */
  129359. Cross = 0,
  129360. /** Circle */
  129361. Circle = 1,
  129362. /** Square */
  129363. Square = 2,
  129364. /** Triangle */
  129365. Triangle = 3,
  129366. /** L1 */
  129367. L1 = 4,
  129368. /** R1 */
  129369. R1 = 5,
  129370. /** Share */
  129371. Share = 8,
  129372. /** Options */
  129373. Options = 9,
  129374. /** Left stick */
  129375. LeftStick = 10,
  129376. /** Right stick */
  129377. RightStick = 11
  129378. }
  129379. /** Defines values for DualShock DPad */
  129380. export enum DualShockDpad {
  129381. /** Up */
  129382. Up = 12,
  129383. /** Down */
  129384. Down = 13,
  129385. /** Left */
  129386. Left = 14,
  129387. /** Right */
  129388. Right = 15
  129389. }
  129390. /**
  129391. * Defines a DualShock gamepad
  129392. */
  129393. export class DualShockPad extends Gamepad {
  129394. private _leftTrigger;
  129395. private _rightTrigger;
  129396. private _onlefttriggerchanged;
  129397. private _onrighttriggerchanged;
  129398. private _onbuttondown;
  129399. private _onbuttonup;
  129400. private _ondpaddown;
  129401. private _ondpadup;
  129402. /** Observable raised when a button is pressed */
  129403. onButtonDownObservable: Observable<DualShockButton>;
  129404. /** Observable raised when a button is released */
  129405. onButtonUpObservable: Observable<DualShockButton>;
  129406. /** Observable raised when a pad is pressed */
  129407. onPadDownObservable: Observable<DualShockDpad>;
  129408. /** Observable raised when a pad is released */
  129409. onPadUpObservable: Observable<DualShockDpad>;
  129410. private _buttonCross;
  129411. private _buttonCircle;
  129412. private _buttonSquare;
  129413. private _buttonTriangle;
  129414. private _buttonShare;
  129415. private _buttonOptions;
  129416. private _buttonL1;
  129417. private _buttonR1;
  129418. private _buttonLeftStick;
  129419. private _buttonRightStick;
  129420. private _dPadUp;
  129421. private _dPadDown;
  129422. private _dPadLeft;
  129423. private _dPadRight;
  129424. /**
  129425. * Creates a new DualShock gamepad object
  129426. * @param id defines the id of this gamepad
  129427. * @param index defines its index
  129428. * @param gamepad defines the internal HTML gamepad object
  129429. */
  129430. constructor(id: string, index: number, gamepad: any);
  129431. /**
  129432. * Defines the callback to call when left trigger is pressed
  129433. * @param callback defines the callback to use
  129434. */
  129435. onlefttriggerchanged(callback: (value: number) => void): void;
  129436. /**
  129437. * Defines the callback to call when right trigger is pressed
  129438. * @param callback defines the callback to use
  129439. */
  129440. onrighttriggerchanged(callback: (value: number) => void): void;
  129441. /**
  129442. * Gets the left trigger value
  129443. */
  129444. get leftTrigger(): number;
  129445. /**
  129446. * Sets the left trigger value
  129447. */
  129448. set leftTrigger(newValue: number);
  129449. /**
  129450. * Gets the right trigger value
  129451. */
  129452. get rightTrigger(): number;
  129453. /**
  129454. * Sets the right trigger value
  129455. */
  129456. set rightTrigger(newValue: number);
  129457. /**
  129458. * Defines the callback to call when a button is pressed
  129459. * @param callback defines the callback to use
  129460. */
  129461. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  129462. /**
  129463. * Defines the callback to call when a button is released
  129464. * @param callback defines the callback to use
  129465. */
  129466. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  129467. /**
  129468. * Defines the callback to call when a pad is pressed
  129469. * @param callback defines the callback to use
  129470. */
  129471. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  129472. /**
  129473. * Defines the callback to call when a pad is released
  129474. * @param callback defines the callback to use
  129475. */
  129476. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  129477. private _setButtonValue;
  129478. private _setDPadValue;
  129479. /**
  129480. * Gets the value of the `Cross` button
  129481. */
  129482. get buttonCross(): number;
  129483. /**
  129484. * Sets the value of the `Cross` button
  129485. */
  129486. set buttonCross(value: number);
  129487. /**
  129488. * Gets the value of the `Circle` button
  129489. */
  129490. get buttonCircle(): number;
  129491. /**
  129492. * Sets the value of the `Circle` button
  129493. */
  129494. set buttonCircle(value: number);
  129495. /**
  129496. * Gets the value of the `Square` button
  129497. */
  129498. get buttonSquare(): number;
  129499. /**
  129500. * Sets the value of the `Square` button
  129501. */
  129502. set buttonSquare(value: number);
  129503. /**
  129504. * Gets the value of the `Triangle` button
  129505. */
  129506. get buttonTriangle(): number;
  129507. /**
  129508. * Sets the value of the `Triangle` button
  129509. */
  129510. set buttonTriangle(value: number);
  129511. /**
  129512. * Gets the value of the `Options` button
  129513. */
  129514. get buttonOptions(): number;
  129515. /**
  129516. * Sets the value of the `Options` button
  129517. */
  129518. set buttonOptions(value: number);
  129519. /**
  129520. * Gets the value of the `Share` button
  129521. */
  129522. get buttonShare(): number;
  129523. /**
  129524. * Sets the value of the `Share` button
  129525. */
  129526. set buttonShare(value: number);
  129527. /**
  129528. * Gets the value of the `L1` button
  129529. */
  129530. get buttonL1(): number;
  129531. /**
  129532. * Sets the value of the `L1` button
  129533. */
  129534. set buttonL1(value: number);
  129535. /**
  129536. * Gets the value of the `R1` button
  129537. */
  129538. get buttonR1(): number;
  129539. /**
  129540. * Sets the value of the `R1` button
  129541. */
  129542. set buttonR1(value: number);
  129543. /**
  129544. * Gets the value of the Left joystick
  129545. */
  129546. get buttonLeftStick(): number;
  129547. /**
  129548. * Sets the value of the Left joystick
  129549. */
  129550. set buttonLeftStick(value: number);
  129551. /**
  129552. * Gets the value of the Right joystick
  129553. */
  129554. get buttonRightStick(): number;
  129555. /**
  129556. * Sets the value of the Right joystick
  129557. */
  129558. set buttonRightStick(value: number);
  129559. /**
  129560. * Gets the value of D-pad up
  129561. */
  129562. get dPadUp(): number;
  129563. /**
  129564. * Sets the value of D-pad up
  129565. */
  129566. set dPadUp(value: number);
  129567. /**
  129568. * Gets the value of D-pad down
  129569. */
  129570. get dPadDown(): number;
  129571. /**
  129572. * Sets the value of D-pad down
  129573. */
  129574. set dPadDown(value: number);
  129575. /**
  129576. * Gets the value of D-pad left
  129577. */
  129578. get dPadLeft(): number;
  129579. /**
  129580. * Sets the value of D-pad left
  129581. */
  129582. set dPadLeft(value: number);
  129583. /**
  129584. * Gets the value of D-pad right
  129585. */
  129586. get dPadRight(): number;
  129587. /**
  129588. * Sets the value of D-pad right
  129589. */
  129590. set dPadRight(value: number);
  129591. /**
  129592. * Force the gamepad to synchronize with device values
  129593. */
  129594. update(): void;
  129595. /**
  129596. * Disposes the gamepad
  129597. */
  129598. dispose(): void;
  129599. }
  129600. }
  129601. declare module BABYLON {
  129602. /**
  129603. * Manager for handling gamepads
  129604. */
  129605. export class GamepadManager {
  129606. private _scene?;
  129607. private _babylonGamepads;
  129608. private _oneGamepadConnected;
  129609. /** @hidden */
  129610. _isMonitoring: boolean;
  129611. private _gamepadEventSupported;
  129612. private _gamepadSupport?;
  129613. /**
  129614. * observable to be triggered when the gamepad controller has been connected
  129615. */
  129616. onGamepadConnectedObservable: Observable<Gamepad>;
  129617. /**
  129618. * observable to be triggered when the gamepad controller has been disconnected
  129619. */
  129620. onGamepadDisconnectedObservable: Observable<Gamepad>;
  129621. private _onGamepadConnectedEvent;
  129622. private _onGamepadDisconnectedEvent;
  129623. /**
  129624. * Initializes the gamepad manager
  129625. * @param _scene BabylonJS scene
  129626. */
  129627. constructor(_scene?: Scene | undefined);
  129628. /**
  129629. * The gamepads in the game pad manager
  129630. */
  129631. get gamepads(): Gamepad[];
  129632. /**
  129633. * Get the gamepad controllers based on type
  129634. * @param type The type of gamepad controller
  129635. * @returns Nullable gamepad
  129636. */
  129637. getGamepadByType(type?: number): Nullable<Gamepad>;
  129638. /**
  129639. * Disposes the gamepad manager
  129640. */
  129641. dispose(): void;
  129642. private _addNewGamepad;
  129643. private _startMonitoringGamepads;
  129644. private _stopMonitoringGamepads;
  129645. /** @hidden */
  129646. _checkGamepadsStatus(): void;
  129647. private _updateGamepadObjects;
  129648. }
  129649. }
  129650. declare module BABYLON {
  129651. interface Scene {
  129652. /** @hidden */
  129653. _gamepadManager: Nullable<GamepadManager>;
  129654. /**
  129655. * Gets the gamepad manager associated with the scene
  129656. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  129657. */
  129658. gamepadManager: GamepadManager;
  129659. }
  129660. /**
  129661. * Interface representing a free camera inputs manager
  129662. */
  129663. interface FreeCameraInputsManager {
  129664. /**
  129665. * Adds gamepad input support to the FreeCameraInputsManager.
  129666. * @returns the FreeCameraInputsManager
  129667. */
  129668. addGamepad(): FreeCameraInputsManager;
  129669. }
  129670. /**
  129671. * Interface representing an arc rotate camera inputs manager
  129672. */
  129673. interface ArcRotateCameraInputsManager {
  129674. /**
  129675. * Adds gamepad input support to the ArcRotateCamera InputManager.
  129676. * @returns the camera inputs manager
  129677. */
  129678. addGamepad(): ArcRotateCameraInputsManager;
  129679. }
  129680. /**
  129681. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  129682. */
  129683. export class GamepadSystemSceneComponent implements ISceneComponent {
  129684. /**
  129685. * The component name helpfull to identify the component in the list of scene components.
  129686. */
  129687. readonly name: string;
  129688. /**
  129689. * The scene the component belongs to.
  129690. */
  129691. scene: Scene;
  129692. /**
  129693. * Creates a new instance of the component for the given scene
  129694. * @param scene Defines the scene to register the component in
  129695. */
  129696. constructor(scene: Scene);
  129697. /**
  129698. * Registers the component in a given scene
  129699. */
  129700. register(): void;
  129701. /**
  129702. * Rebuilds the elements related to this component in case of
  129703. * context lost for instance.
  129704. */
  129705. rebuild(): void;
  129706. /**
  129707. * Disposes the component and the associated ressources
  129708. */
  129709. dispose(): void;
  129710. private _beforeCameraUpdate;
  129711. }
  129712. }
  129713. declare module BABYLON {
  129714. /**
  129715. * 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,
  129716. * which still works and will still be found in many Playgrounds.
  129717. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129718. */
  129719. export class UniversalCamera extends TouchCamera {
  129720. /**
  129721. * Defines the gamepad rotation sensiblity.
  129722. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129723. */
  129724. get gamepadAngularSensibility(): number;
  129725. set gamepadAngularSensibility(value: number);
  129726. /**
  129727. * Defines the gamepad move sensiblity.
  129728. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129729. */
  129730. get gamepadMoveSensibility(): number;
  129731. set gamepadMoveSensibility(value: number);
  129732. /**
  129733. * 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,
  129734. * which still works and will still be found in many Playgrounds.
  129735. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129736. * @param name Define the name of the camera in the scene
  129737. * @param position Define the start position of the camera in the scene
  129738. * @param scene Define the scene the camera belongs to
  129739. */
  129740. constructor(name: string, position: Vector3, scene: Scene);
  129741. /**
  129742. * Gets the current object class name.
  129743. * @return the class name
  129744. */
  129745. getClassName(): string;
  129746. }
  129747. }
  129748. declare module BABYLON {
  129749. /**
  129750. * This represents a FPS type of camera. This is only here for back compat purpose.
  129751. * Please use the UniversalCamera instead as both are identical.
  129752. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129753. */
  129754. export class GamepadCamera extends UniversalCamera {
  129755. /**
  129756. * Instantiates a new Gamepad Camera
  129757. * This represents a FPS type of camera. This is only here for back compat purpose.
  129758. * Please use the UniversalCamera instead as both are identical.
  129759. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129760. * @param name Define the name of the camera in the scene
  129761. * @param position Define the start position of the camera in the scene
  129762. * @param scene Define the scene the camera belongs to
  129763. */
  129764. constructor(name: string, position: Vector3, scene: Scene);
  129765. /**
  129766. * Gets the current object class name.
  129767. * @return the class name
  129768. */
  129769. getClassName(): string;
  129770. }
  129771. }
  129772. declare module BABYLON {
  129773. /** @hidden */
  129774. export var passPixelShader: {
  129775. name: string;
  129776. shader: string;
  129777. };
  129778. }
  129779. declare module BABYLON {
  129780. /** @hidden */
  129781. export var passCubePixelShader: {
  129782. name: string;
  129783. shader: string;
  129784. };
  129785. }
  129786. declare module BABYLON {
  129787. /**
  129788. * PassPostProcess which produces an output the same as it's input
  129789. */
  129790. export class PassPostProcess extends PostProcess {
  129791. /**
  129792. * Gets a string identifying the name of the class
  129793. * @returns "PassPostProcess" string
  129794. */
  129795. getClassName(): string;
  129796. /**
  129797. * Creates the PassPostProcess
  129798. * @param name The name of the effect.
  129799. * @param options The required width/height ratio to downsize to before computing the render pass.
  129800. * @param camera The camera to apply the render pass to.
  129801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129802. * @param engine The engine which the post process will be applied. (default: current engine)
  129803. * @param reusable If the post process can be reused on the same frame. (default: false)
  129804. * @param textureType The type of texture to be used when performing the post processing.
  129805. * @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)
  129806. */
  129807. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129808. /** @hidden */
  129809. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  129810. }
  129811. /**
  129812. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  129813. */
  129814. export class PassCubePostProcess extends PostProcess {
  129815. private _face;
  129816. /**
  129817. * Gets or sets the cube face to display.
  129818. * * 0 is +X
  129819. * * 1 is -X
  129820. * * 2 is +Y
  129821. * * 3 is -Y
  129822. * * 4 is +Z
  129823. * * 5 is -Z
  129824. */
  129825. get face(): number;
  129826. set face(value: number);
  129827. /**
  129828. * Gets a string identifying the name of the class
  129829. * @returns "PassCubePostProcess" string
  129830. */
  129831. getClassName(): string;
  129832. /**
  129833. * Creates the PassCubePostProcess
  129834. * @param name The name of the effect.
  129835. * @param options The required width/height ratio to downsize to before computing the render pass.
  129836. * @param camera The camera to apply the render pass to.
  129837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129838. * @param engine The engine which the post process will be applied. (default: current engine)
  129839. * @param reusable If the post process can be reused on the same frame. (default: false)
  129840. * @param textureType The type of texture to be used when performing the post processing.
  129841. * @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)
  129842. */
  129843. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129844. /** @hidden */
  129845. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  129846. }
  129847. }
  129848. declare module BABYLON {
  129849. /** @hidden */
  129850. export var anaglyphPixelShader: {
  129851. name: string;
  129852. shader: string;
  129853. };
  129854. }
  129855. declare module BABYLON {
  129856. /**
  129857. * Postprocess used to generate anaglyphic rendering
  129858. */
  129859. export class AnaglyphPostProcess extends PostProcess {
  129860. private _passedProcess;
  129861. /**
  129862. * Gets a string identifying the name of the class
  129863. * @returns "AnaglyphPostProcess" string
  129864. */
  129865. getClassName(): string;
  129866. /**
  129867. * Creates a new AnaglyphPostProcess
  129868. * @param name defines postprocess name
  129869. * @param options defines creation options or target ratio scale
  129870. * @param rigCameras defines cameras using this postprocess
  129871. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  129872. * @param engine defines hosting engine
  129873. * @param reusable defines if the postprocess will be reused multiple times per frame
  129874. */
  129875. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  129876. }
  129877. }
  129878. declare module BABYLON {
  129879. /**
  129880. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  129881. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129882. */
  129883. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  129884. /**
  129885. * Creates a new AnaglyphArcRotateCamera
  129886. * @param name defines camera name
  129887. * @param alpha defines alpha angle (in radians)
  129888. * @param beta defines beta angle (in radians)
  129889. * @param radius defines radius
  129890. * @param target defines camera target
  129891. * @param interaxialDistance defines distance between each color axis
  129892. * @param scene defines the hosting scene
  129893. */
  129894. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  129895. /**
  129896. * Gets camera class name
  129897. * @returns AnaglyphArcRotateCamera
  129898. */
  129899. getClassName(): string;
  129900. }
  129901. }
  129902. declare module BABYLON {
  129903. /**
  129904. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  129905. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129906. */
  129907. export class AnaglyphFreeCamera extends FreeCamera {
  129908. /**
  129909. * Creates a new AnaglyphFreeCamera
  129910. * @param name defines camera name
  129911. * @param position defines initial position
  129912. * @param interaxialDistance defines distance between each color axis
  129913. * @param scene defines the hosting scene
  129914. */
  129915. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129916. /**
  129917. * Gets camera class name
  129918. * @returns AnaglyphFreeCamera
  129919. */
  129920. getClassName(): string;
  129921. }
  129922. }
  129923. declare module BABYLON {
  129924. /**
  129925. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  129926. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129927. */
  129928. export class AnaglyphGamepadCamera extends GamepadCamera {
  129929. /**
  129930. * Creates a new AnaglyphGamepadCamera
  129931. * @param name defines camera name
  129932. * @param position defines initial position
  129933. * @param interaxialDistance defines distance between each color axis
  129934. * @param scene defines the hosting scene
  129935. */
  129936. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129937. /**
  129938. * Gets camera class name
  129939. * @returns AnaglyphGamepadCamera
  129940. */
  129941. getClassName(): string;
  129942. }
  129943. }
  129944. declare module BABYLON {
  129945. /**
  129946. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  129947. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  129948. */
  129949. export class AnaglyphUniversalCamera extends UniversalCamera {
  129950. /**
  129951. * Creates a new AnaglyphUniversalCamera
  129952. * @param name defines camera name
  129953. * @param position defines initial position
  129954. * @param interaxialDistance defines distance between each color axis
  129955. * @param scene defines the hosting scene
  129956. */
  129957. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  129958. /**
  129959. * Gets camera class name
  129960. * @returns AnaglyphUniversalCamera
  129961. */
  129962. getClassName(): string;
  129963. }
  129964. }
  129965. declare module BABYLON {
  129966. /**
  129967. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  129968. * @see https://doc.babylonjs.com/features/cameras
  129969. */
  129970. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  129971. /**
  129972. * Creates a new StereoscopicArcRotateCamera
  129973. * @param name defines camera name
  129974. * @param alpha defines alpha angle (in radians)
  129975. * @param beta defines beta angle (in radians)
  129976. * @param radius defines radius
  129977. * @param target defines camera target
  129978. * @param interaxialDistance defines distance between each color axis
  129979. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  129980. * @param scene defines the hosting scene
  129981. */
  129982. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  129983. /**
  129984. * Gets camera class name
  129985. * @returns StereoscopicArcRotateCamera
  129986. */
  129987. getClassName(): string;
  129988. }
  129989. }
  129990. declare module BABYLON {
  129991. /**
  129992. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  129993. * @see https://doc.babylonjs.com/features/cameras
  129994. */
  129995. export class StereoscopicFreeCamera extends FreeCamera {
  129996. /**
  129997. * Creates a new StereoscopicFreeCamera
  129998. * @param name defines camera name
  129999. * @param position defines initial position
  130000. * @param interaxialDistance defines distance between each color axis
  130001. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130002. * @param scene defines the hosting scene
  130003. */
  130004. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130005. /**
  130006. * Gets camera class name
  130007. * @returns StereoscopicFreeCamera
  130008. */
  130009. getClassName(): string;
  130010. }
  130011. }
  130012. declare module BABYLON {
  130013. /**
  130014. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  130015. * @see https://doc.babylonjs.com/features/cameras
  130016. */
  130017. export class StereoscopicGamepadCamera extends GamepadCamera {
  130018. /**
  130019. * Creates a new StereoscopicGamepadCamera
  130020. * @param name defines camera name
  130021. * @param position defines initial position
  130022. * @param interaxialDistance defines distance between each color axis
  130023. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130024. * @param scene defines the hosting scene
  130025. */
  130026. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130027. /**
  130028. * Gets camera class name
  130029. * @returns StereoscopicGamepadCamera
  130030. */
  130031. getClassName(): string;
  130032. }
  130033. }
  130034. declare module BABYLON {
  130035. /**
  130036. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  130037. * @see https://doc.babylonjs.com/features/cameras
  130038. */
  130039. export class StereoscopicUniversalCamera extends UniversalCamera {
  130040. /**
  130041. * Creates a new StereoscopicUniversalCamera
  130042. * @param name defines camera name
  130043. * @param position defines initial position
  130044. * @param interaxialDistance defines distance between each color axis
  130045. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130046. * @param scene defines the hosting scene
  130047. */
  130048. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130049. /**
  130050. * Gets camera class name
  130051. * @returns StereoscopicUniversalCamera
  130052. */
  130053. getClassName(): string;
  130054. }
  130055. }
  130056. declare module BABYLON {
  130057. /**
  130058. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  130059. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130060. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130061. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130062. */
  130063. export class VirtualJoysticksCamera extends FreeCamera {
  130064. /**
  130065. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  130066. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130067. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130068. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130069. * @param name Define the name of the camera in the scene
  130070. * @param position Define the start position of the camera in the scene
  130071. * @param scene Define the scene the camera belongs to
  130072. */
  130073. constructor(name: string, position: Vector3, scene: Scene);
  130074. /**
  130075. * Gets the current object class name.
  130076. * @return the class name
  130077. */
  130078. getClassName(): string;
  130079. }
  130080. }
  130081. declare module BABYLON {
  130082. /**
  130083. * This represents all the required metrics to create a VR camera.
  130084. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  130085. */
  130086. export class VRCameraMetrics {
  130087. /**
  130088. * Define the horizontal resolution off the screen.
  130089. */
  130090. hResolution: number;
  130091. /**
  130092. * Define the vertical resolution off the screen.
  130093. */
  130094. vResolution: number;
  130095. /**
  130096. * Define the horizontal screen size.
  130097. */
  130098. hScreenSize: number;
  130099. /**
  130100. * Define the vertical screen size.
  130101. */
  130102. vScreenSize: number;
  130103. /**
  130104. * Define the vertical screen center position.
  130105. */
  130106. vScreenCenter: number;
  130107. /**
  130108. * Define the distance of the eyes to the screen.
  130109. */
  130110. eyeToScreenDistance: number;
  130111. /**
  130112. * Define the distance between both lenses
  130113. */
  130114. lensSeparationDistance: number;
  130115. /**
  130116. * Define the distance between both viewer's eyes.
  130117. */
  130118. interpupillaryDistance: number;
  130119. /**
  130120. * Define the distortion factor of the VR postprocess.
  130121. * Please, touch with care.
  130122. */
  130123. distortionK: number[];
  130124. /**
  130125. * Define the chromatic aberration correction factors for the VR post process.
  130126. */
  130127. chromaAbCorrection: number[];
  130128. /**
  130129. * Define the scale factor of the post process.
  130130. * The smaller the better but the slower.
  130131. */
  130132. postProcessScaleFactor: number;
  130133. /**
  130134. * Define an offset for the lens center.
  130135. */
  130136. lensCenterOffset: number;
  130137. /**
  130138. * Define if the current vr camera should compensate the distortion of the lense or not.
  130139. */
  130140. compensateDistortion: boolean;
  130141. /**
  130142. * Defines if multiview should be enabled when rendering (Default: false)
  130143. */
  130144. multiviewEnabled: boolean;
  130145. /**
  130146. * Gets the rendering aspect ratio based on the provided resolutions.
  130147. */
  130148. get aspectRatio(): number;
  130149. /**
  130150. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  130151. */
  130152. get aspectRatioFov(): number;
  130153. /**
  130154. * @hidden
  130155. */
  130156. get leftHMatrix(): Matrix;
  130157. /**
  130158. * @hidden
  130159. */
  130160. get rightHMatrix(): Matrix;
  130161. /**
  130162. * @hidden
  130163. */
  130164. get leftPreViewMatrix(): Matrix;
  130165. /**
  130166. * @hidden
  130167. */
  130168. get rightPreViewMatrix(): Matrix;
  130169. /**
  130170. * Get the default VRMetrics based on the most generic setup.
  130171. * @returns the default vr metrics
  130172. */
  130173. static GetDefault(): VRCameraMetrics;
  130174. }
  130175. }
  130176. declare module BABYLON {
  130177. /** @hidden */
  130178. export var vrDistortionCorrectionPixelShader: {
  130179. name: string;
  130180. shader: string;
  130181. };
  130182. }
  130183. declare module BABYLON {
  130184. /**
  130185. * VRDistortionCorrectionPostProcess used for mobile VR
  130186. */
  130187. export class VRDistortionCorrectionPostProcess extends PostProcess {
  130188. private _isRightEye;
  130189. private _distortionFactors;
  130190. private _postProcessScaleFactor;
  130191. private _lensCenterOffset;
  130192. private _scaleIn;
  130193. private _scaleFactor;
  130194. private _lensCenter;
  130195. /**
  130196. * Gets a string identifying the name of the class
  130197. * @returns "VRDistortionCorrectionPostProcess" string
  130198. */
  130199. getClassName(): string;
  130200. /**
  130201. * Initializes the VRDistortionCorrectionPostProcess
  130202. * @param name The name of the effect.
  130203. * @param camera The camera to apply the render pass to.
  130204. * @param isRightEye If this is for the right eye distortion
  130205. * @param vrMetrics All the required metrics for the VR camera
  130206. */
  130207. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  130208. }
  130209. }
  130210. declare module BABYLON {
  130211. /**
  130212. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  130213. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130214. */
  130215. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  130216. /**
  130217. * Creates a new VRDeviceOrientationArcRotateCamera
  130218. * @param name defines camera name
  130219. * @param alpha defines the camera rotation along the logitudinal axis
  130220. * @param beta defines the camera rotation along the latitudinal axis
  130221. * @param radius defines the camera distance from its target
  130222. * @param target defines the camera target
  130223. * @param scene defines the scene the camera belongs to
  130224. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130225. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130226. */
  130227. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130228. /**
  130229. * Gets camera class name
  130230. * @returns VRDeviceOrientationArcRotateCamera
  130231. */
  130232. getClassName(): string;
  130233. }
  130234. }
  130235. declare module BABYLON {
  130236. /**
  130237. * Camera used to simulate VR rendering (based on FreeCamera)
  130238. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130239. */
  130240. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  130241. /**
  130242. * Creates a new VRDeviceOrientationFreeCamera
  130243. * @param name defines camera name
  130244. * @param position defines the start position of the camera
  130245. * @param scene defines the scene the camera belongs to
  130246. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130247. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130248. */
  130249. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130250. /**
  130251. * Gets camera class name
  130252. * @returns VRDeviceOrientationFreeCamera
  130253. */
  130254. getClassName(): string;
  130255. }
  130256. }
  130257. declare module BABYLON {
  130258. /**
  130259. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  130260. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130261. */
  130262. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  130263. /**
  130264. * Creates a new VRDeviceOrientationGamepadCamera
  130265. * @param name defines camera name
  130266. * @param position defines the start position of the camera
  130267. * @param scene defines the scene the camera belongs to
  130268. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130269. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130270. */
  130271. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130272. /**
  130273. * Gets camera class name
  130274. * @returns VRDeviceOrientationGamepadCamera
  130275. */
  130276. getClassName(): string;
  130277. }
  130278. }
  130279. declare module BABYLON {
  130280. /**
  130281. * A class extending Texture allowing drawing on a texture
  130282. * @see https://doc.babylonjs.com/how_to/dynamictexture
  130283. */
  130284. export class DynamicTexture extends Texture {
  130285. private _generateMipMaps;
  130286. private _canvas;
  130287. private _context;
  130288. /**
  130289. * Creates a DynamicTexture
  130290. * @param name defines the name of the texture
  130291. * @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
  130292. * @param scene defines the scene where you want the texture
  130293. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  130294. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130295. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  130296. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  130297. */
  130298. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  130299. /**
  130300. * Get the current class name of the texture useful for serialization or dynamic coding.
  130301. * @returns "DynamicTexture"
  130302. */
  130303. getClassName(): string;
  130304. /**
  130305. * Gets the current state of canRescale
  130306. */
  130307. get canRescale(): boolean;
  130308. private _recreate;
  130309. /**
  130310. * Scales the texture
  130311. * @param ratio the scale factor to apply to both width and height
  130312. */
  130313. scale(ratio: number): void;
  130314. /**
  130315. * Resizes the texture
  130316. * @param width the new width
  130317. * @param height the new height
  130318. */
  130319. scaleTo(width: number, height: number): void;
  130320. /**
  130321. * Gets the context of the canvas used by the texture
  130322. * @returns the canvas context of the dynamic texture
  130323. */
  130324. getContext(): CanvasRenderingContext2D;
  130325. /**
  130326. * Clears the texture
  130327. */
  130328. clear(): void;
  130329. /**
  130330. * Updates the texture
  130331. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130332. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  130333. */
  130334. update(invertY?: boolean, premulAlpha?: boolean): void;
  130335. /**
  130336. * Draws text onto the texture
  130337. * @param text defines the text to be drawn
  130338. * @param x defines the placement of the text from the left
  130339. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  130340. * @param font defines the font to be used with font-style, font-size, font-name
  130341. * @param color defines the color used for the text
  130342. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  130343. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  130344. * @param update defines whether texture is immediately update (default is true)
  130345. */
  130346. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  130347. /**
  130348. * Clones the texture
  130349. * @returns the clone of the texture.
  130350. */
  130351. clone(): DynamicTexture;
  130352. /**
  130353. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  130354. * @returns a serialized dynamic texture object
  130355. */
  130356. serialize(): any;
  130357. private _IsCanvasElement;
  130358. /** @hidden */
  130359. _rebuild(): void;
  130360. }
  130361. }
  130362. declare module BABYLON {
  130363. /**
  130364. * Class containing static functions to help procedurally build meshes
  130365. */
  130366. export class GroundBuilder {
  130367. /**
  130368. * Creates a ground mesh
  130369. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130370. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130372. * @param name defines the name of the mesh
  130373. * @param options defines the options used to create the mesh
  130374. * @param scene defines the hosting scene
  130375. * @returns the ground mesh
  130376. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130377. */
  130378. static CreateGround(name: string, options: {
  130379. width?: number;
  130380. height?: number;
  130381. subdivisions?: number;
  130382. subdivisionsX?: number;
  130383. subdivisionsY?: number;
  130384. updatable?: boolean;
  130385. }, scene: any): Mesh;
  130386. /**
  130387. * Creates a tiled ground mesh
  130388. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130389. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130390. * * 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
  130391. * * 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
  130392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130393. * @param name defines the name of the mesh
  130394. * @param options defines the options used to create the mesh
  130395. * @param scene defines the hosting scene
  130396. * @returns the tiled ground mesh
  130397. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130398. */
  130399. static CreateTiledGround(name: string, options: {
  130400. xmin: number;
  130401. zmin: number;
  130402. xmax: number;
  130403. zmax: number;
  130404. subdivisions?: {
  130405. w: number;
  130406. h: number;
  130407. };
  130408. precision?: {
  130409. w: number;
  130410. h: number;
  130411. };
  130412. updatable?: boolean;
  130413. }, scene?: Nullable<Scene>): Mesh;
  130414. /**
  130415. * Creates a ground mesh from a height map
  130416. * * The parameter `url` sets the URL of the height map image resource.
  130417. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130418. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130419. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130420. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130421. * * 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.
  130422. * * 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).
  130423. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130425. * @param name defines the name of the mesh
  130426. * @param url defines the url to the height map
  130427. * @param options defines the options used to create the mesh
  130428. * @param scene defines the hosting scene
  130429. * @returns the ground mesh
  130430. * @see https://doc.babylonjs.com/babylon101/height_map
  130431. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130432. */
  130433. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130434. width?: number;
  130435. height?: number;
  130436. subdivisions?: number;
  130437. minHeight?: number;
  130438. maxHeight?: number;
  130439. colorFilter?: Color3;
  130440. alphaFilter?: number;
  130441. updatable?: boolean;
  130442. onReady?: (mesh: GroundMesh) => void;
  130443. }, scene?: Nullable<Scene>): GroundMesh;
  130444. }
  130445. }
  130446. declare module BABYLON {
  130447. /**
  130448. * Class containing static functions to help procedurally build meshes
  130449. */
  130450. export class TorusBuilder {
  130451. /**
  130452. * Creates a torus mesh
  130453. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130454. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130455. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130459. * @param name defines the name of the mesh
  130460. * @param options defines the options used to create the mesh
  130461. * @param scene defines the hosting scene
  130462. * @returns the torus mesh
  130463. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130464. */
  130465. static CreateTorus(name: string, options: {
  130466. diameter?: number;
  130467. thickness?: number;
  130468. tessellation?: number;
  130469. updatable?: boolean;
  130470. sideOrientation?: number;
  130471. frontUVs?: Vector4;
  130472. backUVs?: Vector4;
  130473. }, scene: any): Mesh;
  130474. }
  130475. }
  130476. declare module BABYLON {
  130477. /**
  130478. * Class containing static functions to help procedurally build meshes
  130479. */
  130480. export class CylinderBuilder {
  130481. /**
  130482. * Creates a cylinder or a cone mesh
  130483. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130484. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130485. * * 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.
  130486. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130487. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130488. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130489. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130490. * * 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).
  130491. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130492. * * 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).
  130493. * * 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
  130494. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130495. * * 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
  130496. * * 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.
  130497. * * If `enclose` is false, a ring surface is one element.
  130498. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130499. * * 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
  130500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130503. * @param name defines the name of the mesh
  130504. * @param options defines the options used to create the mesh
  130505. * @param scene defines the hosting scene
  130506. * @returns the cylinder mesh
  130507. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130508. */
  130509. static CreateCylinder(name: string, options: {
  130510. height?: number;
  130511. diameterTop?: number;
  130512. diameterBottom?: number;
  130513. diameter?: number;
  130514. tessellation?: number;
  130515. subdivisions?: number;
  130516. arc?: number;
  130517. faceColors?: Color4[];
  130518. faceUV?: Vector4[];
  130519. updatable?: boolean;
  130520. hasRings?: boolean;
  130521. enclose?: boolean;
  130522. cap?: number;
  130523. sideOrientation?: number;
  130524. frontUVs?: Vector4;
  130525. backUVs?: Vector4;
  130526. }, scene: any): Mesh;
  130527. }
  130528. }
  130529. declare module BABYLON {
  130530. /**
  130531. * States of the webXR experience
  130532. */
  130533. export enum WebXRState {
  130534. /**
  130535. * Transitioning to being in XR mode
  130536. */
  130537. ENTERING_XR = 0,
  130538. /**
  130539. * Transitioning to non XR mode
  130540. */
  130541. EXITING_XR = 1,
  130542. /**
  130543. * In XR mode and presenting
  130544. */
  130545. IN_XR = 2,
  130546. /**
  130547. * Not entered XR mode
  130548. */
  130549. NOT_IN_XR = 3
  130550. }
  130551. /**
  130552. * Abstraction of the XR render target
  130553. */
  130554. export interface WebXRRenderTarget extends IDisposable {
  130555. /**
  130556. * xrpresent context of the canvas which can be used to display/mirror xr content
  130557. */
  130558. canvasContext: WebGLRenderingContext;
  130559. /**
  130560. * xr layer for the canvas
  130561. */
  130562. xrLayer: Nullable<XRWebGLLayer>;
  130563. /**
  130564. * Initializes the xr layer for the session
  130565. * @param xrSession xr session
  130566. * @returns a promise that will resolve once the XR Layer has been created
  130567. */
  130568. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130569. }
  130570. }
  130571. declare module BABYLON {
  130572. /**
  130573. * COnfiguration object for WebXR output canvas
  130574. */
  130575. export class WebXRManagedOutputCanvasOptions {
  130576. /**
  130577. * An optional canvas in case you wish to create it yourself and provide it here.
  130578. * If not provided, a new canvas will be created
  130579. */
  130580. canvasElement?: HTMLCanvasElement;
  130581. /**
  130582. * Options for this XR Layer output
  130583. */
  130584. canvasOptions?: XRWebGLLayerOptions;
  130585. /**
  130586. * CSS styling for a newly created canvas (if not provided)
  130587. */
  130588. newCanvasCssStyle?: string;
  130589. /**
  130590. * Get the default values of the configuration object
  130591. * @param engine defines the engine to use (can be null)
  130592. * @returns default values of this configuration object
  130593. */
  130594. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  130595. }
  130596. /**
  130597. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  130598. */
  130599. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  130600. private _options;
  130601. private _canvas;
  130602. private _engine;
  130603. private _originalCanvasSize;
  130604. /**
  130605. * Rendering context of the canvas which can be used to display/mirror xr content
  130606. */
  130607. canvasContext: WebGLRenderingContext;
  130608. /**
  130609. * xr layer for the canvas
  130610. */
  130611. xrLayer: Nullable<XRWebGLLayer>;
  130612. /**
  130613. * Obseervers registered here will be triggered when the xr layer was initialized
  130614. */
  130615. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  130616. /**
  130617. * Initializes the canvas to be added/removed upon entering/exiting xr
  130618. * @param _xrSessionManager The XR Session manager
  130619. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  130620. */
  130621. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  130622. /**
  130623. * Disposes of the object
  130624. */
  130625. dispose(): void;
  130626. /**
  130627. * Initializes the xr layer for the session
  130628. * @param xrSession xr session
  130629. * @returns a promise that will resolve once the XR Layer has been created
  130630. */
  130631. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  130632. private _addCanvas;
  130633. private _removeCanvas;
  130634. private _setCanvasSize;
  130635. private _setManagedOutputCanvas;
  130636. }
  130637. }
  130638. declare module BABYLON {
  130639. /**
  130640. * Manages an XRSession to work with Babylon's engine
  130641. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  130642. */
  130643. export class WebXRSessionManager implements IDisposable {
  130644. /** The scene which the session should be created for */
  130645. scene: Scene;
  130646. private _referenceSpace;
  130647. private _rttProvider;
  130648. private _sessionEnded;
  130649. private _xrNavigator;
  130650. private baseLayer;
  130651. /**
  130652. * The base reference space from which the session started. good if you want to reset your
  130653. * reference space
  130654. */
  130655. baseReferenceSpace: XRReferenceSpace;
  130656. /**
  130657. * Current XR frame
  130658. */
  130659. currentFrame: Nullable<XRFrame>;
  130660. /** WebXR timestamp updated every frame */
  130661. currentTimestamp: number;
  130662. /**
  130663. * Used just in case of a failure to initialize an immersive session.
  130664. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  130665. */
  130666. defaultHeightCompensation: number;
  130667. /**
  130668. * Fires every time a new xrFrame arrives which can be used to update the camera
  130669. */
  130670. onXRFrameObservable: Observable<XRFrame>;
  130671. /**
  130672. * Fires when the reference space changed
  130673. */
  130674. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  130675. /**
  130676. * Fires when the xr session is ended either by the device or manually done
  130677. */
  130678. onXRSessionEnded: Observable<any>;
  130679. /**
  130680. * Fires when the xr session is ended either by the device or manually done
  130681. */
  130682. onXRSessionInit: Observable<XRSession>;
  130683. /**
  130684. * Underlying xr session
  130685. */
  130686. session: XRSession;
  130687. /**
  130688. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  130689. * or get the offset the player is currently at.
  130690. */
  130691. viewerReferenceSpace: XRReferenceSpace;
  130692. /**
  130693. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  130694. * @param scene The scene which the session should be created for
  130695. */
  130696. constructor(
  130697. /** The scene which the session should be created for */
  130698. scene: Scene);
  130699. /**
  130700. * The current reference space used in this session. This reference space can constantly change!
  130701. * It is mainly used to offset the camera's position.
  130702. */
  130703. get referenceSpace(): XRReferenceSpace;
  130704. /**
  130705. * Set a new reference space and triggers the observable
  130706. */
  130707. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  130708. /**
  130709. * Disposes of the session manager
  130710. */
  130711. dispose(): void;
  130712. /**
  130713. * Stops the xrSession and restores the render loop
  130714. * @returns Promise which resolves after it exits XR
  130715. */
  130716. exitXRAsync(): Promise<void>;
  130717. /**
  130718. * Gets the correct render target texture to be rendered this frame for this eye
  130719. * @param eye the eye for which to get the render target
  130720. * @returns the render target for the specified eye
  130721. */
  130722. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  130723. /**
  130724. * Creates a WebXRRenderTarget object for the XR session
  130725. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  130726. * @param options optional options to provide when creating a new render target
  130727. * @returns a WebXR render target to which the session can render
  130728. */
  130729. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  130730. /**
  130731. * Initializes the manager
  130732. * After initialization enterXR can be called to start an XR session
  130733. * @returns Promise which resolves after it is initialized
  130734. */
  130735. initializeAsync(): Promise<void>;
  130736. /**
  130737. * Initializes an xr session
  130738. * @param xrSessionMode mode to initialize
  130739. * @param xrSessionInit defines optional and required values to pass to the session builder
  130740. * @returns a promise which will resolve once the session has been initialized
  130741. */
  130742. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  130743. /**
  130744. * Checks if a session would be supported for the creation options specified
  130745. * @param sessionMode session mode to check if supported eg. immersive-vr
  130746. * @returns A Promise that resolves to true if supported and false if not
  130747. */
  130748. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130749. /**
  130750. * Resets the reference space to the one started the session
  130751. */
  130752. resetReferenceSpace(): void;
  130753. /**
  130754. * Starts rendering to the xr layer
  130755. */
  130756. runXRRenderLoop(): void;
  130757. /**
  130758. * Sets the reference space on the xr session
  130759. * @param referenceSpaceType space to set
  130760. * @returns a promise that will resolve once the reference space has been set
  130761. */
  130762. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130763. /**
  130764. * Updates the render state of the session
  130765. * @param state state to set
  130766. * @returns a promise that resolves once the render state has been updated
  130767. */
  130768. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  130769. /**
  130770. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  130771. * @param sessionMode defines the session to test
  130772. * @returns a promise with boolean as final value
  130773. */
  130774. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  130775. private _createRenderTargetTexture;
  130776. }
  130777. }
  130778. declare module BABYLON {
  130779. /**
  130780. * WebXR Camera which holds the views for the xrSession
  130781. * @see https://doc.babylonjs.com/how_to/webxr_camera
  130782. */
  130783. export class WebXRCamera extends FreeCamera {
  130784. private _xrSessionManager;
  130785. private _firstFrame;
  130786. private _referenceQuaternion;
  130787. private _referencedPosition;
  130788. private _xrInvPositionCache;
  130789. private _xrInvQuaternionCache;
  130790. /**
  130791. * Observable raised before camera teleportation
  130792. */
  130793. onBeforeCameraTeleport: Observable<Vector3>;
  130794. /**
  130795. * Observable raised after camera teleportation
  130796. */
  130797. onAfterCameraTeleport: Observable<Vector3>;
  130798. /**
  130799. * Should position compensation execute on first frame.
  130800. * This is used when copying the position from a native (non XR) camera
  130801. */
  130802. compensateOnFirstFrame: boolean;
  130803. /**
  130804. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  130805. * @param name the name of the camera
  130806. * @param scene the scene to add the camera to
  130807. * @param _xrSessionManager a constructed xr session manager
  130808. */
  130809. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  130810. /**
  130811. * Return the user's height, unrelated to the current ground.
  130812. * This will be the y position of this camera, when ground level is 0.
  130813. */
  130814. get realWorldHeight(): number;
  130815. /** @hidden */
  130816. _updateForDualEyeDebugging(): void;
  130817. /**
  130818. * Sets this camera's transformation based on a non-vr camera
  130819. * @param otherCamera the non-vr camera to copy the transformation from
  130820. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  130821. */
  130822. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  130823. /**
  130824. * Gets the current instance class name ("WebXRCamera").
  130825. * @returns the class name
  130826. */
  130827. getClassName(): string;
  130828. private _rotate180;
  130829. private _updateFromXRSession;
  130830. private _updateNumberOfRigCameras;
  130831. private _updateReferenceSpace;
  130832. private _updateReferenceSpaceOffset;
  130833. }
  130834. }
  130835. declare module BABYLON {
  130836. /**
  130837. * Defining the interface required for a (webxr) feature
  130838. */
  130839. export interface IWebXRFeature extends IDisposable {
  130840. /**
  130841. * Is this feature attached
  130842. */
  130843. attached: boolean;
  130844. /**
  130845. * Should auto-attach be disabled?
  130846. */
  130847. disableAutoAttach: boolean;
  130848. /**
  130849. * Attach the feature to the session
  130850. * Will usually be called by the features manager
  130851. *
  130852. * @param force should attachment be forced (even when already attached)
  130853. * @returns true if successful.
  130854. */
  130855. attach(force?: boolean): boolean;
  130856. /**
  130857. * Detach the feature from the session
  130858. * Will usually be called by the features manager
  130859. *
  130860. * @returns true if successful.
  130861. */
  130862. detach(): boolean;
  130863. /**
  130864. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  130865. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  130866. *
  130867. * @returns whether or not the feature is compatible in this environment
  130868. */
  130869. isCompatible(): boolean;
  130870. /**
  130871. * Was this feature disposed;
  130872. */
  130873. isDisposed: boolean;
  130874. /**
  130875. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  130876. */
  130877. xrNativeFeatureName?: string;
  130878. /**
  130879. * A list of (Babylon WebXR) features this feature depends on
  130880. */
  130881. dependsOn?: string[];
  130882. }
  130883. /**
  130884. * A list of the currently available features without referencing them
  130885. */
  130886. export class WebXRFeatureName {
  130887. /**
  130888. * The name of the anchor system feature
  130889. */
  130890. static readonly ANCHOR_SYSTEM: string;
  130891. /**
  130892. * The name of the background remover feature
  130893. */
  130894. static readonly BACKGROUND_REMOVER: string;
  130895. /**
  130896. * The name of the hit test feature
  130897. */
  130898. static readonly HIT_TEST: string;
  130899. /**
  130900. * physics impostors for xr controllers feature
  130901. */
  130902. static readonly PHYSICS_CONTROLLERS: string;
  130903. /**
  130904. * The name of the plane detection feature
  130905. */
  130906. static readonly PLANE_DETECTION: string;
  130907. /**
  130908. * The name of the pointer selection feature
  130909. */
  130910. static readonly POINTER_SELECTION: string;
  130911. /**
  130912. * The name of the teleportation feature
  130913. */
  130914. static readonly TELEPORTATION: string;
  130915. /**
  130916. * The name of the feature points feature.
  130917. */
  130918. static readonly FEATURE_POINTS: string;
  130919. /**
  130920. * The name of the hand tracking feature.
  130921. */
  130922. static readonly HAND_TRACKING: string;
  130923. }
  130924. /**
  130925. * Defining the constructor of a feature. Used to register the modules.
  130926. */
  130927. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  130928. /**
  130929. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  130930. * It is mainly used in AR sessions.
  130931. *
  130932. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  130933. */
  130934. export class WebXRFeaturesManager implements IDisposable {
  130935. private _xrSessionManager;
  130936. private static readonly _AvailableFeatures;
  130937. private _features;
  130938. /**
  130939. * constructs a new features manages.
  130940. *
  130941. * @param _xrSessionManager an instance of WebXRSessionManager
  130942. */
  130943. constructor(_xrSessionManager: WebXRSessionManager);
  130944. /**
  130945. * Used to register a module. After calling this function a developer can use this feature in the scene.
  130946. * Mainly used internally.
  130947. *
  130948. * @param featureName the name of the feature to register
  130949. * @param constructorFunction the function used to construct the module
  130950. * @param version the (babylon) version of the module
  130951. * @param stable is that a stable version of this module
  130952. */
  130953. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  130954. /**
  130955. * Returns a constructor of a specific feature.
  130956. *
  130957. * @param featureName the name of the feature to construct
  130958. * @param version the version of the feature to load
  130959. * @param xrSessionManager the xrSessionManager. Used to construct the module
  130960. * @param options optional options provided to the module.
  130961. * @returns a function that, when called, will return a new instance of this feature
  130962. */
  130963. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  130964. /**
  130965. * Can be used to return the list of features currently registered
  130966. *
  130967. * @returns an Array of available features
  130968. */
  130969. static GetAvailableFeatures(): string[];
  130970. /**
  130971. * Gets the versions available for a specific feature
  130972. * @param featureName the name of the feature
  130973. * @returns an array with the available versions
  130974. */
  130975. static GetAvailableVersions(featureName: string): string[];
  130976. /**
  130977. * Return the latest unstable version of this feature
  130978. * @param featureName the name of the feature to search
  130979. * @returns the version number. if not found will return -1
  130980. */
  130981. static GetLatestVersionOfFeature(featureName: string): number;
  130982. /**
  130983. * Return the latest stable version of this feature
  130984. * @param featureName the name of the feature to search
  130985. * @returns the version number. if not found will return -1
  130986. */
  130987. static GetStableVersionOfFeature(featureName: string): number;
  130988. /**
  130989. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  130990. * Can be used during a session to start a feature
  130991. * @param featureName the name of feature to attach
  130992. */
  130993. attachFeature(featureName: string): void;
  130994. /**
  130995. * Can be used inside a session or when the session ends to detach a specific feature
  130996. * @param featureName the name of the feature to detach
  130997. */
  130998. detachFeature(featureName: string): void;
  130999. /**
  131000. * Used to disable an already-enabled feature
  131001. * The feature will be disposed and will be recreated once enabled.
  131002. * @param featureName the feature to disable
  131003. * @returns true if disable was successful
  131004. */
  131005. disableFeature(featureName: string | {
  131006. Name: string;
  131007. }): boolean;
  131008. /**
  131009. * dispose this features manager
  131010. */
  131011. dispose(): void;
  131012. /**
  131013. * 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.
  131014. * 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.
  131015. *
  131016. * @param featureName the name of the feature to load or the class of the feature
  131017. * @param version optional version to load. if not provided the latest version will be enabled
  131018. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  131019. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  131020. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  131021. * @returns a new constructed feature or throws an error if feature not found.
  131022. */
  131023. enableFeature(featureName: string | {
  131024. Name: string;
  131025. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  131026. /**
  131027. * get the implementation of an enabled feature.
  131028. * @param featureName the name of the feature to load
  131029. * @returns the feature class, if found
  131030. */
  131031. getEnabledFeature(featureName: string): IWebXRFeature;
  131032. /**
  131033. * Get the list of enabled features
  131034. * @returns an array of enabled features
  131035. */
  131036. getEnabledFeatures(): string[];
  131037. /**
  131038. * This function will exten the session creation configuration object with enabled features.
  131039. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  131040. * according to the defined "required" variable, provided during enableFeature call
  131041. * @param xrSessionInit the xr Session init object to extend
  131042. *
  131043. * @returns an extended XRSessionInit object
  131044. */
  131045. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  131046. }
  131047. }
  131048. declare module BABYLON {
  131049. /**
  131050. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  131051. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  131052. */
  131053. export class WebXRExperienceHelper implements IDisposable {
  131054. private scene;
  131055. private _nonVRCamera;
  131056. private _originalSceneAutoClear;
  131057. private _supported;
  131058. /**
  131059. * Camera used to render xr content
  131060. */
  131061. camera: WebXRCamera;
  131062. /** A features manager for this xr session */
  131063. featuresManager: WebXRFeaturesManager;
  131064. /**
  131065. * Observers registered here will be triggered after the camera's initial transformation is set
  131066. * This can be used to set a different ground level or an extra rotation.
  131067. *
  131068. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  131069. * to the position set after this observable is done executing.
  131070. */
  131071. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  131072. /**
  131073. * Fires when the state of the experience helper has changed
  131074. */
  131075. onStateChangedObservable: Observable<WebXRState>;
  131076. /** Session manager used to keep track of xr session */
  131077. sessionManager: WebXRSessionManager;
  131078. /**
  131079. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  131080. */
  131081. state: WebXRState;
  131082. /**
  131083. * Creates a WebXRExperienceHelper
  131084. * @param scene The scene the helper should be created in
  131085. */
  131086. private constructor();
  131087. /**
  131088. * Creates the experience helper
  131089. * @param scene the scene to attach the experience helper to
  131090. * @returns a promise for the experience helper
  131091. */
  131092. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  131093. /**
  131094. * Disposes of the experience helper
  131095. */
  131096. dispose(): void;
  131097. /**
  131098. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  131099. * @param sessionMode options for the XR session
  131100. * @param referenceSpaceType frame of reference of the XR session
  131101. * @param renderTarget the output canvas that will be used to enter XR mode
  131102. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  131103. * @returns promise that resolves after xr mode has entered
  131104. */
  131105. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  131106. /**
  131107. * Exits XR mode and returns the scene to its original state
  131108. * @returns promise that resolves after xr mode has exited
  131109. */
  131110. exitXRAsync(): Promise<void>;
  131111. private _nonXRToXRCamera;
  131112. private _setState;
  131113. }
  131114. }
  131115. declare module BABYLON {
  131116. /**
  131117. * X-Y values for axes in WebXR
  131118. */
  131119. export interface IWebXRMotionControllerAxesValue {
  131120. /**
  131121. * The value of the x axis
  131122. */
  131123. x: number;
  131124. /**
  131125. * The value of the y-axis
  131126. */
  131127. y: number;
  131128. }
  131129. /**
  131130. * changed / previous values for the values of this component
  131131. */
  131132. export interface IWebXRMotionControllerComponentChangesValues<T> {
  131133. /**
  131134. * current (this frame) value
  131135. */
  131136. current: T;
  131137. /**
  131138. * previous (last change) value
  131139. */
  131140. previous: T;
  131141. }
  131142. /**
  131143. * Represents changes in the component between current frame and last values recorded
  131144. */
  131145. export interface IWebXRMotionControllerComponentChanges {
  131146. /**
  131147. * will be populated with previous and current values if axes changed
  131148. */
  131149. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  131150. /**
  131151. * will be populated with previous and current values if pressed changed
  131152. */
  131153. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131154. /**
  131155. * will be populated with previous and current values if touched changed
  131156. */
  131157. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131158. /**
  131159. * will be populated with previous and current values if value changed
  131160. */
  131161. value?: IWebXRMotionControllerComponentChangesValues<number>;
  131162. }
  131163. /**
  131164. * This class represents a single component (for example button or thumbstick) of a motion controller
  131165. */
  131166. export class WebXRControllerComponent implements IDisposable {
  131167. /**
  131168. * the id of this component
  131169. */
  131170. id: string;
  131171. /**
  131172. * the type of the component
  131173. */
  131174. type: MotionControllerComponentType;
  131175. private _buttonIndex;
  131176. private _axesIndices;
  131177. private _axes;
  131178. private _changes;
  131179. private _currentValue;
  131180. private _hasChanges;
  131181. private _pressed;
  131182. private _touched;
  131183. /**
  131184. * button component type
  131185. */
  131186. static BUTTON_TYPE: MotionControllerComponentType;
  131187. /**
  131188. * squeeze component type
  131189. */
  131190. static SQUEEZE_TYPE: MotionControllerComponentType;
  131191. /**
  131192. * Thumbstick component type
  131193. */
  131194. static THUMBSTICK_TYPE: MotionControllerComponentType;
  131195. /**
  131196. * Touchpad component type
  131197. */
  131198. static TOUCHPAD_TYPE: MotionControllerComponentType;
  131199. /**
  131200. * trigger component type
  131201. */
  131202. static TRIGGER_TYPE: MotionControllerComponentType;
  131203. /**
  131204. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  131205. * the axes data changes
  131206. */
  131207. onAxisValueChangedObservable: Observable<{
  131208. x: number;
  131209. y: number;
  131210. }>;
  131211. /**
  131212. * Observers registered here will be triggered when the state of a button changes
  131213. * State change is either pressed / touched / value
  131214. */
  131215. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  131216. /**
  131217. * Creates a new component for a motion controller.
  131218. * It is created by the motion controller itself
  131219. *
  131220. * @param id the id of this component
  131221. * @param type the type of the component
  131222. * @param _buttonIndex index in the buttons array of the gamepad
  131223. * @param _axesIndices indices of the values in the axes array of the gamepad
  131224. */
  131225. constructor(
  131226. /**
  131227. * the id of this component
  131228. */
  131229. id: string,
  131230. /**
  131231. * the type of the component
  131232. */
  131233. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  131234. /**
  131235. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  131236. */
  131237. get axes(): IWebXRMotionControllerAxesValue;
  131238. /**
  131239. * Get the changes. Elements will be populated only if they changed with their previous and current value
  131240. */
  131241. get changes(): IWebXRMotionControllerComponentChanges;
  131242. /**
  131243. * Return whether or not the component changed the last frame
  131244. */
  131245. get hasChanges(): boolean;
  131246. /**
  131247. * is the button currently pressed
  131248. */
  131249. get pressed(): boolean;
  131250. /**
  131251. * is the button currently touched
  131252. */
  131253. get touched(): boolean;
  131254. /**
  131255. * Get the current value of this component
  131256. */
  131257. get value(): number;
  131258. /**
  131259. * Dispose this component
  131260. */
  131261. dispose(): void;
  131262. /**
  131263. * Are there axes correlating to this component
  131264. * @return true is axes data is available
  131265. */
  131266. isAxes(): boolean;
  131267. /**
  131268. * Is this component a button (hence - pressable)
  131269. * @returns true if can be pressed
  131270. */
  131271. isButton(): boolean;
  131272. /**
  131273. * update this component using the gamepad object it is in. Called on every frame
  131274. * @param nativeController the native gamepad controller object
  131275. */
  131276. update(nativeController: IMinimalMotionControllerObject): void;
  131277. }
  131278. }
  131279. declare module BABYLON {
  131280. /**
  131281. * Interface used to represent data loading progression
  131282. */
  131283. export interface ISceneLoaderProgressEvent {
  131284. /**
  131285. * Defines if data length to load can be evaluated
  131286. */
  131287. readonly lengthComputable: boolean;
  131288. /**
  131289. * Defines the loaded data length
  131290. */
  131291. readonly loaded: number;
  131292. /**
  131293. * Defines the data length to load
  131294. */
  131295. readonly total: number;
  131296. }
  131297. /**
  131298. * Interface used by SceneLoader plugins to define supported file extensions
  131299. */
  131300. export interface ISceneLoaderPluginExtensions {
  131301. /**
  131302. * Defines the list of supported extensions
  131303. */
  131304. [extension: string]: {
  131305. isBinary: boolean;
  131306. };
  131307. }
  131308. /**
  131309. * Interface used by SceneLoader plugin factory
  131310. */
  131311. export interface ISceneLoaderPluginFactory {
  131312. /**
  131313. * Defines the name of the factory
  131314. */
  131315. name: string;
  131316. /**
  131317. * Function called to create a new plugin
  131318. * @return the new plugin
  131319. */
  131320. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  131321. /**
  131322. * The callback that returns true if the data can be directly loaded.
  131323. * @param data string containing the file data
  131324. * @returns if the data can be loaded directly
  131325. */
  131326. canDirectLoad?(data: string): boolean;
  131327. }
  131328. /**
  131329. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  131330. */
  131331. export interface ISceneLoaderPluginBase {
  131332. /**
  131333. * The friendly name of this plugin.
  131334. */
  131335. name: string;
  131336. /**
  131337. * The file extensions supported by this plugin.
  131338. */
  131339. extensions: string | ISceneLoaderPluginExtensions;
  131340. /**
  131341. * The callback called when loading from a url.
  131342. * @param scene scene loading this url
  131343. * @param url url to load
  131344. * @param onSuccess callback called when the file successfully loads
  131345. * @param onProgress callback called while file is loading (if the server supports this mode)
  131346. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  131347. * @param onError callback called when the file fails to load
  131348. * @returns a file request object
  131349. */
  131350. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131351. /**
  131352. * The callback called when loading from a file object.
  131353. * @param scene scene loading this file
  131354. * @param file defines the file to load
  131355. * @param onSuccess defines the callback to call when data is loaded
  131356. * @param onProgress defines the callback to call during loading process
  131357. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  131358. * @param onError defines the callback to call when an error occurs
  131359. * @returns a file request object
  131360. */
  131361. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  131362. /**
  131363. * The callback that returns true if the data can be directly loaded.
  131364. * @param data string containing the file data
  131365. * @returns if the data can be loaded directly
  131366. */
  131367. canDirectLoad?(data: string): boolean;
  131368. /**
  131369. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  131370. * @param scene scene loading this data
  131371. * @param data string containing the data
  131372. * @returns data to pass to the plugin
  131373. */
  131374. directLoad?(scene: Scene, data: string): any;
  131375. /**
  131376. * The callback that allows custom handling of the root url based on the response url.
  131377. * @param rootUrl the original root url
  131378. * @param responseURL the response url if available
  131379. * @returns the new root url
  131380. */
  131381. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  131382. }
  131383. /**
  131384. * Interface used to define a SceneLoader plugin
  131385. */
  131386. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  131387. /**
  131388. * Import meshes into a scene.
  131389. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131390. * @param scene The scene to import into
  131391. * @param data The data to import
  131392. * @param rootUrl The root url for scene and resources
  131393. * @param meshes The meshes array to import into
  131394. * @param particleSystems The particle systems array to import into
  131395. * @param skeletons The skeletons array to import into
  131396. * @param onError The callback when import fails
  131397. * @returns True if successful or false otherwise
  131398. */
  131399. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  131400. /**
  131401. * Load into a scene.
  131402. * @param scene The scene to load into
  131403. * @param data The data to import
  131404. * @param rootUrl The root url for scene and resources
  131405. * @param onError The callback when import fails
  131406. * @returns True if successful or false otherwise
  131407. */
  131408. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  131409. /**
  131410. * Load into an asset container.
  131411. * @param scene The scene to load into
  131412. * @param data The data to import
  131413. * @param rootUrl The root url for scene and resources
  131414. * @param onError The callback when import fails
  131415. * @returns The loaded asset container
  131416. */
  131417. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  131418. }
  131419. /**
  131420. * Interface used to define an async SceneLoader plugin
  131421. */
  131422. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  131423. /**
  131424. * Import meshes into a scene.
  131425. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131426. * @param scene The scene to import into
  131427. * @param data The data to import
  131428. * @param rootUrl The root url for scene and resources
  131429. * @param onProgress The callback when the load progresses
  131430. * @param fileName Defines the name of the file to load
  131431. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  131432. */
  131433. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  131434. meshes: AbstractMesh[];
  131435. particleSystems: IParticleSystem[];
  131436. skeletons: Skeleton[];
  131437. animationGroups: AnimationGroup[];
  131438. }>;
  131439. /**
  131440. * Load into a scene.
  131441. * @param scene The scene to load into
  131442. * @param data The data to import
  131443. * @param rootUrl The root url for scene and resources
  131444. * @param onProgress The callback when the load progresses
  131445. * @param fileName Defines the name of the file to load
  131446. * @returns Nothing
  131447. */
  131448. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  131449. /**
  131450. * Load into an asset container.
  131451. * @param scene The scene to load into
  131452. * @param data The data to import
  131453. * @param rootUrl The root url for scene and resources
  131454. * @param onProgress The callback when the load progresses
  131455. * @param fileName Defines the name of the file to load
  131456. * @returns The loaded asset container
  131457. */
  131458. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  131459. }
  131460. /**
  131461. * Mode that determines how to handle old animation groups before loading new ones.
  131462. */
  131463. export enum SceneLoaderAnimationGroupLoadingMode {
  131464. /**
  131465. * Reset all old animations to initial state then dispose them.
  131466. */
  131467. Clean = 0,
  131468. /**
  131469. * Stop all old animations.
  131470. */
  131471. Stop = 1,
  131472. /**
  131473. * Restart old animations from first frame.
  131474. */
  131475. Sync = 2,
  131476. /**
  131477. * Old animations remains untouched.
  131478. */
  131479. NoSync = 3
  131480. }
  131481. /**
  131482. * Defines a plugin registered by the SceneLoader
  131483. */
  131484. interface IRegisteredPlugin {
  131485. /**
  131486. * Defines the plugin to use
  131487. */
  131488. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131489. /**
  131490. * Defines if the plugin supports binary data
  131491. */
  131492. isBinary: boolean;
  131493. }
  131494. /**
  131495. * Class used to load scene from various file formats using registered plugins
  131496. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  131497. */
  131498. export class SceneLoader {
  131499. /**
  131500. * No logging while loading
  131501. */
  131502. static readonly NO_LOGGING: number;
  131503. /**
  131504. * Minimal logging while loading
  131505. */
  131506. static readonly MINIMAL_LOGGING: number;
  131507. /**
  131508. * Summary logging while loading
  131509. */
  131510. static readonly SUMMARY_LOGGING: number;
  131511. /**
  131512. * Detailled logging while loading
  131513. */
  131514. static readonly DETAILED_LOGGING: number;
  131515. /**
  131516. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  131517. */
  131518. static get ForceFullSceneLoadingForIncremental(): boolean;
  131519. static set ForceFullSceneLoadingForIncremental(value: boolean);
  131520. /**
  131521. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  131522. */
  131523. static get ShowLoadingScreen(): boolean;
  131524. static set ShowLoadingScreen(value: boolean);
  131525. /**
  131526. * Defines the current logging level (while loading the scene)
  131527. * @ignorenaming
  131528. */
  131529. static get loggingLevel(): number;
  131530. static set loggingLevel(value: number);
  131531. /**
  131532. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  131533. */
  131534. static get CleanBoneMatrixWeights(): boolean;
  131535. static set CleanBoneMatrixWeights(value: boolean);
  131536. /**
  131537. * Event raised when a plugin is used to load a scene
  131538. */
  131539. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  131540. private static _registeredPlugins;
  131541. private static _showingLoadingScreen;
  131542. /**
  131543. * Gets the default plugin (used to load Babylon files)
  131544. * @returns the .babylon plugin
  131545. */
  131546. static GetDefaultPlugin(): IRegisteredPlugin;
  131547. private static _GetPluginForExtension;
  131548. private static _GetPluginForDirectLoad;
  131549. private static _GetPluginForFilename;
  131550. private static _GetDirectLoad;
  131551. private static _LoadData;
  131552. private static _GetFileInfo;
  131553. /**
  131554. * Gets a plugin that can load the given extension
  131555. * @param extension defines the extension to load
  131556. * @returns a plugin or null if none works
  131557. */
  131558. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  131559. /**
  131560. * Gets a boolean indicating that the given extension can be loaded
  131561. * @param extension defines the extension to load
  131562. * @returns true if the extension is supported
  131563. */
  131564. static IsPluginForExtensionAvailable(extension: string): boolean;
  131565. /**
  131566. * Adds a new plugin to the list of registered plugins
  131567. * @param plugin defines the plugin to add
  131568. */
  131569. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  131570. /**
  131571. * Import meshes into a scene
  131572. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131573. * @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)
  131574. * @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)
  131575. * @param scene the instance of BABYLON.Scene to append to
  131576. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  131577. * @param onProgress a callback with a progress event for each file being loaded
  131578. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131579. * @param pluginExtension the extension used to determine the plugin
  131580. * @returns The loaded plugin
  131581. */
  131582. 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>;
  131583. /**
  131584. * Import meshes into a scene
  131585. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  131586. * @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)
  131587. * @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)
  131588. * @param scene the instance of BABYLON.Scene to append to
  131589. * @param onProgress a callback with a progress event for each file being loaded
  131590. * @param pluginExtension the extension used to determine the plugin
  131591. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  131592. */
  131593. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  131594. meshes: AbstractMesh[];
  131595. particleSystems: IParticleSystem[];
  131596. skeletons: Skeleton[];
  131597. animationGroups: AnimationGroup[];
  131598. }>;
  131599. /**
  131600. * Load a scene
  131601. * @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)
  131602. * @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)
  131603. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131604. * @param onSuccess a callback with the scene when import succeeds
  131605. * @param onProgress a callback with a progress event for each file being loaded
  131606. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131607. * @param pluginExtension the extension used to determine the plugin
  131608. * @returns The loaded plugin
  131609. */
  131610. 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>;
  131611. /**
  131612. * Load a scene
  131613. * @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)
  131614. * @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)
  131615. * @param engine is the instance of BABYLON.Engine to use to create the scene
  131616. * @param onProgress a callback with a progress event for each file being loaded
  131617. * @param pluginExtension the extension used to determine the plugin
  131618. * @returns The loaded scene
  131619. */
  131620. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131621. /**
  131622. * Append a scene
  131623. * @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)
  131624. * @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)
  131625. * @param scene is the instance of BABYLON.Scene to append to
  131626. * @param onSuccess a callback with the scene when import succeeds
  131627. * @param onProgress a callback with a progress event for each file being loaded
  131628. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131629. * @param pluginExtension the extension used to determine the plugin
  131630. * @returns The loaded plugin
  131631. */
  131632. 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>;
  131633. /**
  131634. * Append a scene
  131635. * @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)
  131636. * @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)
  131637. * @param scene is the instance of BABYLON.Scene to append to
  131638. * @param onProgress a callback with a progress event for each file being loaded
  131639. * @param pluginExtension the extension used to determine the plugin
  131640. * @returns The given scene
  131641. */
  131642. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  131643. /**
  131644. * Load a scene into an asset container
  131645. * @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)
  131646. * @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)
  131647. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131648. * @param onSuccess a callback with the scene when import succeeds
  131649. * @param onProgress a callback with a progress event for each file being loaded
  131650. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131651. * @param pluginExtension the extension used to determine the plugin
  131652. * @returns The loaded plugin
  131653. */
  131654. 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>;
  131655. /**
  131656. * Load a scene into an asset container
  131657. * @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)
  131658. * @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)
  131659. * @param scene is the instance of Scene to append to
  131660. * @param onProgress a callback with a progress event for each file being loaded
  131661. * @param pluginExtension the extension used to determine the plugin
  131662. * @returns The loaded asset container
  131663. */
  131664. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  131665. /**
  131666. * Import animations from a file into a scene
  131667. * @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)
  131668. * @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)
  131669. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131670. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131671. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131672. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131673. * @param onSuccess a callback with the scene when import succeeds
  131674. * @param onProgress a callback with a progress event for each file being loaded
  131675. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131676. * @param pluginExtension the extension used to determine the plugin
  131677. */
  131678. 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;
  131679. /**
  131680. * Import animations from a file into a scene
  131681. * @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)
  131682. * @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)
  131683. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  131684. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  131685. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  131686. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  131687. * @param onSuccess a callback with the scene when import succeeds
  131688. * @param onProgress a callback with a progress event for each file being loaded
  131689. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  131690. * @param pluginExtension the extension used to determine the plugin
  131691. * @returns the updated scene with imported animations
  131692. */
  131693. 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>;
  131694. }
  131695. }
  131696. declare module BABYLON {
  131697. /**
  131698. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  131699. */
  131700. export type MotionControllerHandedness = "none" | "left" | "right";
  131701. /**
  131702. * The type of components available in motion controllers.
  131703. * This is not the name of the component.
  131704. */
  131705. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  131706. /**
  131707. * The state of a controller component
  131708. */
  131709. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  131710. /**
  131711. * The schema of motion controller layout.
  131712. * No object will be initialized using this interface
  131713. * This is used just to define the profile.
  131714. */
  131715. export interface IMotionControllerLayout {
  131716. /**
  131717. * Path to load the assets. Usually relative to the base path
  131718. */
  131719. assetPath: string;
  131720. /**
  131721. * Available components (unsorted)
  131722. */
  131723. components: {
  131724. /**
  131725. * A map of component Ids
  131726. */
  131727. [componentId: string]: {
  131728. /**
  131729. * The type of input the component outputs
  131730. */
  131731. type: MotionControllerComponentType;
  131732. /**
  131733. * The indices of this component in the gamepad object
  131734. */
  131735. gamepadIndices: {
  131736. /**
  131737. * Index of button
  131738. */
  131739. button?: number;
  131740. /**
  131741. * If available, index of x-axis
  131742. */
  131743. xAxis?: number;
  131744. /**
  131745. * If available, index of y-axis
  131746. */
  131747. yAxis?: number;
  131748. };
  131749. /**
  131750. * The mesh's root node name
  131751. */
  131752. rootNodeName: string;
  131753. /**
  131754. * Animation definitions for this model
  131755. */
  131756. visualResponses: {
  131757. [stateKey: string]: {
  131758. /**
  131759. * What property will be animated
  131760. */
  131761. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  131762. /**
  131763. * What states influence this visual response
  131764. */
  131765. states: MotionControllerComponentStateType[];
  131766. /**
  131767. * Type of animation - movement or visibility
  131768. */
  131769. valueNodeProperty: "transform" | "visibility";
  131770. /**
  131771. * Base node name to move. Its position will be calculated according to the min and max nodes
  131772. */
  131773. valueNodeName?: string;
  131774. /**
  131775. * Minimum movement node
  131776. */
  131777. minNodeName?: string;
  131778. /**
  131779. * Max movement node
  131780. */
  131781. maxNodeName?: string;
  131782. };
  131783. };
  131784. /**
  131785. * If touch enabled, what is the name of node to display user feedback
  131786. */
  131787. touchPointNodeName?: string;
  131788. };
  131789. };
  131790. /**
  131791. * Is it xr standard mapping or not
  131792. */
  131793. gamepadMapping: "" | "xr-standard";
  131794. /**
  131795. * Base root node of this entire model
  131796. */
  131797. rootNodeName: string;
  131798. /**
  131799. * Defines the main button component id
  131800. */
  131801. selectComponentId: string;
  131802. }
  131803. /**
  131804. * A definition for the layout map in the input profile
  131805. */
  131806. export interface IMotionControllerLayoutMap {
  131807. /**
  131808. * Layouts with handedness type as a key
  131809. */
  131810. [handedness: string]: IMotionControllerLayout;
  131811. }
  131812. /**
  131813. * The XR Input profile schema
  131814. * Profiles can be found here:
  131815. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  131816. */
  131817. export interface IMotionControllerProfile {
  131818. /**
  131819. * fallback profiles for this profileId
  131820. */
  131821. fallbackProfileIds: string[];
  131822. /**
  131823. * The layout map, with handedness as key
  131824. */
  131825. layouts: IMotionControllerLayoutMap;
  131826. /**
  131827. * The id of this profile
  131828. * correlates to the profile(s) in the xrInput.profiles array
  131829. */
  131830. profileId: string;
  131831. }
  131832. /**
  131833. * A helper-interface for the 3 meshes needed for controller button animation
  131834. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  131835. */
  131836. export interface IMotionControllerButtonMeshMap {
  131837. /**
  131838. * the mesh that defines the pressed value mesh position.
  131839. * This is used to find the max-position of this button
  131840. */
  131841. pressedMesh: AbstractMesh;
  131842. /**
  131843. * the mesh that defines the unpressed value mesh position.
  131844. * This is used to find the min (or initial) position of this button
  131845. */
  131846. unpressedMesh: AbstractMesh;
  131847. /**
  131848. * The mesh that will be changed when value changes
  131849. */
  131850. valueMesh: AbstractMesh;
  131851. }
  131852. /**
  131853. * A helper-interface for the 3 meshes needed for controller axis animation.
  131854. * This will be expanded when touchpad animations are fully supported
  131855. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  131856. */
  131857. export interface IMotionControllerMeshMap {
  131858. /**
  131859. * the mesh that defines the maximum value mesh position.
  131860. */
  131861. maxMesh?: AbstractMesh;
  131862. /**
  131863. * the mesh that defines the minimum value mesh position.
  131864. */
  131865. minMesh?: AbstractMesh;
  131866. /**
  131867. * The mesh that will be changed when axis value changes
  131868. */
  131869. valueMesh?: AbstractMesh;
  131870. }
  131871. /**
  131872. * The elements needed for change-detection of the gamepad objects in motion controllers
  131873. */
  131874. export interface IMinimalMotionControllerObject {
  131875. /**
  131876. * Available axes of this controller
  131877. */
  131878. axes: number[];
  131879. /**
  131880. * An array of available buttons
  131881. */
  131882. buttons: Array<{
  131883. /**
  131884. * Value of the button/trigger
  131885. */
  131886. value: number;
  131887. /**
  131888. * If the button/trigger is currently touched
  131889. */
  131890. touched: boolean;
  131891. /**
  131892. * If the button/trigger is currently pressed
  131893. */
  131894. pressed: boolean;
  131895. }>;
  131896. /**
  131897. * EXPERIMENTAL haptic support.
  131898. */
  131899. hapticActuators?: Array<{
  131900. pulse: (value: number, duration: number) => Promise<boolean>;
  131901. }>;
  131902. }
  131903. /**
  131904. * An Abstract Motion controller
  131905. * This class receives an xrInput and a profile layout and uses those to initialize the components
  131906. * Each component has an observable to check for changes in value and state
  131907. */
  131908. export abstract class WebXRAbstractMotionController implements IDisposable {
  131909. protected scene: Scene;
  131910. protected layout: IMotionControllerLayout;
  131911. /**
  131912. * The gamepad object correlating to this controller
  131913. */
  131914. gamepadObject: IMinimalMotionControllerObject;
  131915. /**
  131916. * handedness (left/right/none) of this controller
  131917. */
  131918. handedness: MotionControllerHandedness;
  131919. private _initComponent;
  131920. private _modelReady;
  131921. /**
  131922. * A map of components (WebXRControllerComponent) in this motion controller
  131923. * Components have a ComponentType and can also have both button and axis definitions
  131924. */
  131925. readonly components: {
  131926. [id: string]: WebXRControllerComponent;
  131927. };
  131928. /**
  131929. * Disable the model's animation. Can be set at any time.
  131930. */
  131931. disableAnimation: boolean;
  131932. /**
  131933. * Observers registered here will be triggered when the model of this controller is done loading
  131934. */
  131935. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  131936. /**
  131937. * The profile id of this motion controller
  131938. */
  131939. abstract profileId: string;
  131940. /**
  131941. * The root mesh of the model. It is null if the model was not yet initialized
  131942. */
  131943. rootMesh: Nullable<AbstractMesh>;
  131944. /**
  131945. * constructs a new abstract motion controller
  131946. * @param scene the scene to which the model of the controller will be added
  131947. * @param layout The profile layout to load
  131948. * @param gamepadObject The gamepad object correlating to this controller
  131949. * @param handedness handedness (left/right/none) of this controller
  131950. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  131951. */
  131952. constructor(scene: Scene, layout: IMotionControllerLayout,
  131953. /**
  131954. * The gamepad object correlating to this controller
  131955. */
  131956. gamepadObject: IMinimalMotionControllerObject,
  131957. /**
  131958. * handedness (left/right/none) of this controller
  131959. */
  131960. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  131961. /**
  131962. * Dispose this controller, the model mesh and all its components
  131963. */
  131964. dispose(): void;
  131965. /**
  131966. * Returns all components of specific type
  131967. * @param type the type to search for
  131968. * @return an array of components with this type
  131969. */
  131970. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  131971. /**
  131972. * get a component based an its component id as defined in layout.components
  131973. * @param id the id of the component
  131974. * @returns the component correlates to the id or undefined if not found
  131975. */
  131976. getComponent(id: string): WebXRControllerComponent;
  131977. /**
  131978. * Get the list of components available in this motion controller
  131979. * @returns an array of strings correlating to available components
  131980. */
  131981. getComponentIds(): string[];
  131982. /**
  131983. * Get the first component of specific type
  131984. * @param type type of component to find
  131985. * @return a controller component or null if not found
  131986. */
  131987. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  131988. /**
  131989. * Get the main (Select) component of this controller as defined in the layout
  131990. * @returns the main component of this controller
  131991. */
  131992. getMainComponent(): WebXRControllerComponent;
  131993. /**
  131994. * Loads the model correlating to this controller
  131995. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  131996. * @returns A promise fulfilled with the result of the model loading
  131997. */
  131998. loadModel(): Promise<boolean>;
  131999. /**
  132000. * Update this model using the current XRFrame
  132001. * @param xrFrame the current xr frame to use and update the model
  132002. */
  132003. updateFromXRFrame(xrFrame: XRFrame): void;
  132004. /**
  132005. * Backwards compatibility due to a deeply-integrated typo
  132006. */
  132007. get handness(): XREye;
  132008. /**
  132009. * Pulse (vibrate) this controller
  132010. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  132011. * Consecutive calls to this function will cancel the last pulse call
  132012. *
  132013. * @param value the strength of the pulse in 0.0...1.0 range
  132014. * @param duration Duration of the pulse in milliseconds
  132015. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  132016. * @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
  132017. */
  132018. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  132019. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132020. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132021. /**
  132022. * Moves the axis on the controller mesh based on its current state
  132023. * @param axis the index of the axis
  132024. * @param axisValue the value of the axis which determines the meshes new position
  132025. * @hidden
  132026. */
  132027. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  132028. /**
  132029. * Update the model itself with the current frame data
  132030. * @param xrFrame the frame to use for updating the model mesh
  132031. */
  132032. protected updateModel(xrFrame: XRFrame): void;
  132033. /**
  132034. * Get the filename and path for this controller's model
  132035. * @returns a map of filename and path
  132036. */
  132037. protected abstract _getFilenameAndPath(): {
  132038. filename: string;
  132039. path: string;
  132040. };
  132041. /**
  132042. * This function is called before the mesh is loaded. It checks for loading constraints.
  132043. * For example, this function can check if the GLB loader is available
  132044. * If this function returns false, the generic controller will be loaded instead
  132045. * @returns Is the client ready to load the mesh
  132046. */
  132047. protected abstract _getModelLoadingConstraints(): boolean;
  132048. /**
  132049. * This function will be called after the model was successfully loaded and can be used
  132050. * for mesh transformations before it is available for the user
  132051. * @param meshes the loaded meshes
  132052. */
  132053. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  132054. /**
  132055. * Set the root mesh for this controller. Important for the WebXR controller class
  132056. * @param meshes the loaded meshes
  132057. */
  132058. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  132059. /**
  132060. * A function executed each frame that updates the mesh (if needed)
  132061. * @param xrFrame the current xrFrame
  132062. */
  132063. protected abstract _updateModel(xrFrame: XRFrame): void;
  132064. private _getGenericFilenameAndPath;
  132065. private _getGenericParentMesh;
  132066. }
  132067. }
  132068. declare module BABYLON {
  132069. /**
  132070. * A generic trigger-only motion controller for WebXR
  132071. */
  132072. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  132073. /**
  132074. * Static version of the profile id of this controller
  132075. */
  132076. static ProfileId: string;
  132077. profileId: string;
  132078. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  132079. protected _getFilenameAndPath(): {
  132080. filename: string;
  132081. path: string;
  132082. };
  132083. protected _getModelLoadingConstraints(): boolean;
  132084. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  132085. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132086. protected _updateModel(): void;
  132087. }
  132088. }
  132089. declare module BABYLON {
  132090. /**
  132091. * Class containing static functions to help procedurally build meshes
  132092. */
  132093. export class SphereBuilder {
  132094. /**
  132095. * Creates a sphere mesh
  132096. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  132097. * * 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`)
  132098. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  132099. * * 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
  132100. * * 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)
  132101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132104. * @param name defines the name of the mesh
  132105. * @param options defines the options used to create the mesh
  132106. * @param scene defines the hosting scene
  132107. * @returns the sphere mesh
  132108. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  132109. */
  132110. static CreateSphere(name: string, options: {
  132111. segments?: number;
  132112. diameter?: number;
  132113. diameterX?: number;
  132114. diameterY?: number;
  132115. diameterZ?: number;
  132116. arc?: number;
  132117. slice?: number;
  132118. sideOrientation?: number;
  132119. frontUVs?: Vector4;
  132120. backUVs?: Vector4;
  132121. updatable?: boolean;
  132122. }, scene?: Nullable<Scene>): Mesh;
  132123. }
  132124. }
  132125. declare module BABYLON {
  132126. /**
  132127. * A profiled motion controller has its profile loaded from an online repository.
  132128. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  132129. */
  132130. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  132131. private _repositoryUrl;
  132132. private _buttonMeshMapping;
  132133. private _touchDots;
  132134. /**
  132135. * The profile ID of this controller. Will be populated when the controller initializes.
  132136. */
  132137. profileId: string;
  132138. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  132139. dispose(): void;
  132140. protected _getFilenameAndPath(): {
  132141. filename: string;
  132142. path: string;
  132143. };
  132144. protected _getModelLoadingConstraints(): boolean;
  132145. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  132146. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132147. protected _updateModel(_xrFrame: XRFrame): void;
  132148. }
  132149. }
  132150. declare module BABYLON {
  132151. /**
  132152. * A construction function type to create a new controller based on an xrInput object
  132153. */
  132154. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  132155. /**
  132156. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  132157. *
  132158. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  132159. * it should be replaced with auto-loaded controllers.
  132160. *
  132161. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  132162. */
  132163. export class WebXRMotionControllerManager {
  132164. private static _AvailableControllers;
  132165. private static _Fallbacks;
  132166. private static _ProfileLoadingPromises;
  132167. private static _ProfilesList;
  132168. /**
  132169. * The base URL of the online controller repository. Can be changed at any time.
  132170. */
  132171. static BaseRepositoryUrl: string;
  132172. /**
  132173. * Which repository gets priority - local or online
  132174. */
  132175. static PrioritizeOnlineRepository: boolean;
  132176. /**
  132177. * Use the online repository, or use only locally-defined controllers
  132178. */
  132179. static UseOnlineRepository: boolean;
  132180. /**
  132181. * Clear the cache used for profile loading and reload when requested again
  132182. */
  132183. static ClearProfilesCache(): void;
  132184. /**
  132185. * Register the default fallbacks.
  132186. * This function is called automatically when this file is imported.
  132187. */
  132188. static DefaultFallbacks(): void;
  132189. /**
  132190. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  132191. * @param profileId the profile to which a fallback needs to be found
  132192. * @return an array with corresponding fallback profiles
  132193. */
  132194. static FindFallbackWithProfileId(profileId: string): string[];
  132195. /**
  132196. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  132197. * The order of search:
  132198. *
  132199. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  132200. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  132201. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  132202. * 4) return the generic trigger controller if none were found
  132203. *
  132204. * @param xrInput the xrInput to which a new controller is initialized
  132205. * @param scene the scene to which the model will be added
  132206. * @param forceProfile force a certain profile for this controller
  132207. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  132208. */
  132209. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  132210. /**
  132211. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  132212. *
  132213. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  132214. *
  132215. * @param type the profile type to register
  132216. * @param constructFunction the function to be called when loading this profile
  132217. */
  132218. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  132219. /**
  132220. * Register a fallback to a specific profile.
  132221. * @param profileId the profileId that will receive the fallbacks
  132222. * @param fallbacks A list of fallback profiles
  132223. */
  132224. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  132225. /**
  132226. * Will update the list of profiles available in the repository
  132227. * @return a promise that resolves to a map of profiles available online
  132228. */
  132229. static UpdateProfilesList(): Promise<{
  132230. [profile: string]: string;
  132231. }>;
  132232. private static _LoadProfileFromRepository;
  132233. private static _LoadProfilesFromAvailableControllers;
  132234. }
  132235. }
  132236. declare module BABYLON {
  132237. /**
  132238. * Configuration options for the WebXR controller creation
  132239. */
  132240. export interface IWebXRControllerOptions {
  132241. /**
  132242. * Should the controller mesh be animated when a user interacts with it
  132243. * The pressed buttons / thumbstick and touchpad animations will be disabled
  132244. */
  132245. disableMotionControllerAnimation?: boolean;
  132246. /**
  132247. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  132248. */
  132249. doNotLoadControllerMesh?: boolean;
  132250. /**
  132251. * Force a specific controller type for this controller.
  132252. * This can be used when creating your own profile or when testing different controllers
  132253. */
  132254. forceControllerProfile?: string;
  132255. /**
  132256. * Defines a rendering group ID for meshes that will be loaded.
  132257. * This is for the default controllers only.
  132258. */
  132259. renderingGroupId?: number;
  132260. }
  132261. /**
  132262. * Represents an XR controller
  132263. */
  132264. export class WebXRInputSource {
  132265. private _scene;
  132266. /** The underlying input source for the controller */
  132267. inputSource: XRInputSource;
  132268. private _options;
  132269. private _tmpVector;
  132270. private _uniqueId;
  132271. private _disposed;
  132272. /**
  132273. * 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
  132274. */
  132275. grip?: AbstractMesh;
  132276. /**
  132277. * If available, this is the gamepad object related to this controller.
  132278. * Using this object it is possible to get click events and trackpad changes of the
  132279. * webxr controller that is currently being used.
  132280. */
  132281. motionController?: WebXRAbstractMotionController;
  132282. /**
  132283. * Event that fires when the controller is removed/disposed.
  132284. * The object provided as event data is this controller, after associated assets were disposed.
  132285. * uniqueId is still available.
  132286. */
  132287. onDisposeObservable: Observable<WebXRInputSource>;
  132288. /**
  132289. * Will be triggered when the mesh associated with the motion controller is done loading.
  132290. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  132291. * A shortened version of controller -> motion controller -> on mesh loaded.
  132292. */
  132293. onMeshLoadedObservable: Observable<AbstractMesh>;
  132294. /**
  132295. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  132296. */
  132297. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  132298. /**
  132299. * Pointer which can be used to select objects or attach a visible laser to
  132300. */
  132301. pointer: AbstractMesh;
  132302. /**
  132303. * Creates the input source object
  132304. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  132305. * @param _scene the scene which the controller should be associated to
  132306. * @param inputSource the underlying input source for the controller
  132307. * @param _options options for this controller creation
  132308. */
  132309. constructor(_scene: Scene,
  132310. /** The underlying input source for the controller */
  132311. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  132312. /**
  132313. * Get this controllers unique id
  132314. */
  132315. get uniqueId(): string;
  132316. /**
  132317. * Disposes of the object
  132318. */
  132319. dispose(): void;
  132320. /**
  132321. * Gets a world space ray coming from the pointer or grip
  132322. * @param result the resulting ray
  132323. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  132324. */
  132325. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  132326. /**
  132327. * Updates the controller pose based on the given XRFrame
  132328. * @param xrFrame xr frame to update the pose with
  132329. * @param referenceSpace reference space to use
  132330. */
  132331. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  132332. }
  132333. }
  132334. declare module BABYLON {
  132335. /**
  132336. * The schema for initialization options of the XR Input class
  132337. */
  132338. export interface IWebXRInputOptions {
  132339. /**
  132340. * If set to true no model will be automatically loaded
  132341. */
  132342. doNotLoadControllerMeshes?: boolean;
  132343. /**
  132344. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  132345. * If not found, the xr input profile data will be used.
  132346. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  132347. */
  132348. forceInputProfile?: string;
  132349. /**
  132350. * Do not send a request to the controller repository to load the profile.
  132351. *
  132352. * Instead, use the controllers available in babylon itself.
  132353. */
  132354. disableOnlineControllerRepository?: boolean;
  132355. /**
  132356. * A custom URL for the controllers repository
  132357. */
  132358. customControllersRepositoryURL?: string;
  132359. /**
  132360. * Should the controller model's components not move according to the user input
  132361. */
  132362. disableControllerAnimation?: boolean;
  132363. /**
  132364. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  132365. */
  132366. controllerOptions?: IWebXRControllerOptions;
  132367. }
  132368. /**
  132369. * XR input used to track XR inputs such as controllers/rays
  132370. */
  132371. export class WebXRInput implements IDisposable {
  132372. /**
  132373. * the xr session manager for this session
  132374. */
  132375. xrSessionManager: WebXRSessionManager;
  132376. /**
  132377. * the WebXR camera for this session. Mainly used for teleportation
  132378. */
  132379. xrCamera: WebXRCamera;
  132380. private readonly options;
  132381. /**
  132382. * XR controllers being tracked
  132383. */
  132384. controllers: Array<WebXRInputSource>;
  132385. private _frameObserver;
  132386. private _sessionEndedObserver;
  132387. private _sessionInitObserver;
  132388. /**
  132389. * Event when a controller has been connected/added
  132390. */
  132391. onControllerAddedObservable: Observable<WebXRInputSource>;
  132392. /**
  132393. * Event when a controller has been removed/disconnected
  132394. */
  132395. onControllerRemovedObservable: Observable<WebXRInputSource>;
  132396. /**
  132397. * Initializes the WebXRInput
  132398. * @param xrSessionManager the xr session manager for this session
  132399. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  132400. * @param options = initialization options for this xr input
  132401. */
  132402. constructor(
  132403. /**
  132404. * the xr session manager for this session
  132405. */
  132406. xrSessionManager: WebXRSessionManager,
  132407. /**
  132408. * the WebXR camera for this session. Mainly used for teleportation
  132409. */
  132410. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  132411. private _onInputSourcesChange;
  132412. private _addAndRemoveControllers;
  132413. /**
  132414. * Disposes of the object
  132415. */
  132416. dispose(): void;
  132417. }
  132418. }
  132419. declare module BABYLON {
  132420. /**
  132421. * This is the base class for all WebXR features.
  132422. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  132423. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  132424. */
  132425. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  132426. protected _xrSessionManager: WebXRSessionManager;
  132427. private _attached;
  132428. private _removeOnDetach;
  132429. /**
  132430. * Is this feature disposed?
  132431. */
  132432. isDisposed: boolean;
  132433. /**
  132434. * Should auto-attach be disabled?
  132435. */
  132436. disableAutoAttach: boolean;
  132437. /**
  132438. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  132439. */
  132440. xrNativeFeatureName: string;
  132441. /**
  132442. * Construct a new (abstract) WebXR feature
  132443. * @param _xrSessionManager the xr session manager for this feature
  132444. */
  132445. constructor(_xrSessionManager: WebXRSessionManager);
  132446. /**
  132447. * Is this feature attached
  132448. */
  132449. get attached(): boolean;
  132450. /**
  132451. * attach this feature
  132452. *
  132453. * @param force should attachment be forced (even when already attached)
  132454. * @returns true if successful, false is failed or already attached
  132455. */
  132456. attach(force?: boolean): boolean;
  132457. /**
  132458. * detach this feature.
  132459. *
  132460. * @returns true if successful, false if failed or already detached
  132461. */
  132462. detach(): boolean;
  132463. /**
  132464. * Dispose this feature and all of the resources attached
  132465. */
  132466. dispose(): void;
  132467. /**
  132468. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132469. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132470. *
  132471. * @returns whether or not the feature is compatible in this environment
  132472. */
  132473. isCompatible(): boolean;
  132474. /**
  132475. * This is used to register callbacks that will automatically be removed when detach is called.
  132476. * @param observable the observable to which the observer will be attached
  132477. * @param callback the callback to register
  132478. */
  132479. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  132480. /**
  132481. * Code in this function will be executed on each xrFrame received from the browser.
  132482. * This function will not execute after the feature is detached.
  132483. * @param _xrFrame the current frame
  132484. */
  132485. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  132486. }
  132487. }
  132488. declare module BABYLON {
  132489. /**
  132490. * Renders a layer on top of an existing scene
  132491. */
  132492. export class UtilityLayerRenderer implements IDisposable {
  132493. /** the original scene that will be rendered on top of */
  132494. originalScene: Scene;
  132495. private _pointerCaptures;
  132496. private _lastPointerEvents;
  132497. private static _DefaultUtilityLayer;
  132498. private static _DefaultKeepDepthUtilityLayer;
  132499. private _sharedGizmoLight;
  132500. private _renderCamera;
  132501. /**
  132502. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  132503. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  132504. * @returns the camera that is used when rendering the utility layer
  132505. */
  132506. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  132507. /**
  132508. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  132509. * @param cam the camera that should be used when rendering the utility layer
  132510. */
  132511. setRenderCamera(cam: Nullable<Camera>): void;
  132512. /**
  132513. * @hidden
  132514. * Light which used by gizmos to get light shading
  132515. */
  132516. _getSharedGizmoLight(): HemisphericLight;
  132517. /**
  132518. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  132519. */
  132520. pickUtilitySceneFirst: boolean;
  132521. /**
  132522. * 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)
  132523. */
  132524. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  132525. /**
  132526. * 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)
  132527. */
  132528. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  132529. /**
  132530. * The scene that is rendered on top of the original scene
  132531. */
  132532. utilityLayerScene: Scene;
  132533. /**
  132534. * If the utility layer should automatically be rendered on top of existing scene
  132535. */
  132536. shouldRender: boolean;
  132537. /**
  132538. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  132539. */
  132540. onlyCheckPointerDownEvents: boolean;
  132541. /**
  132542. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  132543. */
  132544. processAllEvents: boolean;
  132545. /**
  132546. * Observable raised when the pointer move from the utility layer scene to the main scene
  132547. */
  132548. onPointerOutObservable: Observable<number>;
  132549. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  132550. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  132551. private _afterRenderObserver;
  132552. private _sceneDisposeObserver;
  132553. private _originalPointerObserver;
  132554. /**
  132555. * Instantiates a UtilityLayerRenderer
  132556. * @param originalScene the original scene that will be rendered on top of
  132557. * @param handleEvents boolean indicating if the utility layer should handle events
  132558. */
  132559. constructor(
  132560. /** the original scene that will be rendered on top of */
  132561. originalScene: Scene, handleEvents?: boolean);
  132562. private _notifyObservers;
  132563. /**
  132564. * Renders the utility layers scene on top of the original scene
  132565. */
  132566. render(): void;
  132567. /**
  132568. * Disposes of the renderer
  132569. */
  132570. dispose(): void;
  132571. private _updateCamera;
  132572. }
  132573. }
  132574. declare module BABYLON {
  132575. /**
  132576. * Options interface for the pointer selection module
  132577. */
  132578. export interface IWebXRControllerPointerSelectionOptions {
  132579. /**
  132580. * if provided, this scene will be used to render meshes.
  132581. */
  132582. customUtilityLayerScene?: Scene;
  132583. /**
  132584. * 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)
  132585. * If not disabled, the last picked point will be used to execute a pointer up event
  132586. * If disabled, pointer up event will be triggered right after the pointer down event.
  132587. * Used in screen and gaze target ray mode only
  132588. */
  132589. disablePointerUpOnTouchOut: boolean;
  132590. /**
  132591. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  132592. */
  132593. forceGazeMode: boolean;
  132594. /**
  132595. * 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
  132596. * to start a new countdown to the pointer down event.
  132597. * Defaults to 1.
  132598. */
  132599. gazeModePointerMovedFactor?: number;
  132600. /**
  132601. * Different button type to use instead of the main component
  132602. */
  132603. overrideButtonId?: string;
  132604. /**
  132605. * use this rendering group id for the meshes (optional)
  132606. */
  132607. renderingGroupId?: number;
  132608. /**
  132609. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  132610. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  132611. * 3000 means 3 seconds between pointing at something and selecting it
  132612. */
  132613. timeToSelect?: number;
  132614. /**
  132615. * Should meshes created here be added to a utility layer or the main scene
  132616. */
  132617. useUtilityLayer?: boolean;
  132618. /**
  132619. * Optional WebXR camera to be used for gaze selection
  132620. */
  132621. gazeCamera?: WebXRCamera;
  132622. /**
  132623. * the xr input to use with this pointer selection
  132624. */
  132625. xrInput: WebXRInput;
  132626. }
  132627. /**
  132628. * A module that will enable pointer selection for motion controllers of XR Input Sources
  132629. */
  132630. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  132631. private readonly _options;
  132632. private static _idCounter;
  132633. private _attachController;
  132634. private _controllers;
  132635. private _scene;
  132636. private _tmpVectorForPickCompare;
  132637. /**
  132638. * The module's name
  132639. */
  132640. static readonly Name: string;
  132641. /**
  132642. * The (Babylon) version of this module.
  132643. * This is an integer representing the implementation version.
  132644. * This number does not correspond to the WebXR specs version
  132645. */
  132646. static readonly Version: number;
  132647. /**
  132648. * Disable lighting on the laser pointer (so it will always be visible)
  132649. */
  132650. disablePointerLighting: boolean;
  132651. /**
  132652. * Disable lighting on the selection mesh (so it will always be visible)
  132653. */
  132654. disableSelectionMeshLighting: boolean;
  132655. /**
  132656. * Should the laser pointer be displayed
  132657. */
  132658. displayLaserPointer: boolean;
  132659. /**
  132660. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  132661. */
  132662. displaySelectionMesh: boolean;
  132663. /**
  132664. * This color will be set to the laser pointer when selection is triggered
  132665. */
  132666. laserPointerPickedColor: Color3;
  132667. /**
  132668. * Default color of the laser pointer
  132669. */
  132670. laserPointerDefaultColor: Color3;
  132671. /**
  132672. * default color of the selection ring
  132673. */
  132674. selectionMeshDefaultColor: Color3;
  132675. /**
  132676. * This color will be applied to the selection ring when selection is triggered
  132677. */
  132678. selectionMeshPickedColor: Color3;
  132679. /**
  132680. * Optional filter to be used for ray selection. This predicate shares behavior with
  132681. * scene.pointerMovePredicate which takes priority if it is also assigned.
  132682. */
  132683. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  132684. /**
  132685. * constructs a new background remover module
  132686. * @param _xrSessionManager the session manager for this module
  132687. * @param _options read-only options to be used in this module
  132688. */
  132689. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  132690. /**
  132691. * attach this feature
  132692. * Will usually be called by the features manager
  132693. *
  132694. * @returns true if successful.
  132695. */
  132696. attach(): boolean;
  132697. /**
  132698. * detach this feature.
  132699. * Will usually be called by the features manager
  132700. *
  132701. * @returns true if successful.
  132702. */
  132703. detach(): boolean;
  132704. /**
  132705. * Will get the mesh under a specific pointer.
  132706. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  132707. * @param controllerId the controllerId to check
  132708. * @returns The mesh under pointer or null if no mesh is under the pointer
  132709. */
  132710. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  132711. /**
  132712. * Get the xr controller that correlates to the pointer id in the pointer event
  132713. *
  132714. * @param id the pointer id to search for
  132715. * @returns the controller that correlates to this id or null if not found
  132716. */
  132717. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  132718. protected _onXRFrame(_xrFrame: XRFrame): void;
  132719. private _attachGazeMode;
  132720. private _attachScreenRayMode;
  132721. private _attachTrackedPointerRayMode;
  132722. private _convertNormalToDirectionOfRay;
  132723. private _detachController;
  132724. private _generateNewMeshPair;
  132725. private _pickingMoved;
  132726. private _updatePointerDistance;
  132727. /** @hidden */
  132728. get lasterPointerDefaultColor(): Color3;
  132729. }
  132730. }
  132731. declare module BABYLON {
  132732. /**
  132733. * Button which can be used to enter a different mode of XR
  132734. */
  132735. export class WebXREnterExitUIButton {
  132736. /** button element */
  132737. element: HTMLElement;
  132738. /** XR initialization options for the button */
  132739. sessionMode: XRSessionMode;
  132740. /** Reference space type */
  132741. referenceSpaceType: XRReferenceSpaceType;
  132742. /**
  132743. * Creates a WebXREnterExitUIButton
  132744. * @param element button element
  132745. * @param sessionMode XR initialization session mode
  132746. * @param referenceSpaceType the type of reference space to be used
  132747. */
  132748. constructor(
  132749. /** button element */
  132750. element: HTMLElement,
  132751. /** XR initialization options for the button */
  132752. sessionMode: XRSessionMode,
  132753. /** Reference space type */
  132754. referenceSpaceType: XRReferenceSpaceType);
  132755. /**
  132756. * Extendable function which can be used to update the button's visuals when the state changes
  132757. * @param activeButton the current active button in the UI
  132758. */
  132759. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  132760. }
  132761. /**
  132762. * Options to create the webXR UI
  132763. */
  132764. export class WebXREnterExitUIOptions {
  132765. /**
  132766. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  132767. */
  132768. customButtons?: Array<WebXREnterExitUIButton>;
  132769. /**
  132770. * A reference space type to use when creating the default button.
  132771. * Default is local-floor
  132772. */
  132773. referenceSpaceType?: XRReferenceSpaceType;
  132774. /**
  132775. * Context to enter xr with
  132776. */
  132777. renderTarget?: Nullable<WebXRRenderTarget>;
  132778. /**
  132779. * A session mode to use when creating the default button.
  132780. * Default is immersive-vr
  132781. */
  132782. sessionMode?: XRSessionMode;
  132783. /**
  132784. * A list of optional features to init the session with
  132785. */
  132786. optionalFeatures?: string[];
  132787. /**
  132788. * A list of optional features to init the session with
  132789. */
  132790. requiredFeatures?: string[];
  132791. }
  132792. /**
  132793. * UI to allow the user to enter/exit XR mode
  132794. */
  132795. export class WebXREnterExitUI implements IDisposable {
  132796. private scene;
  132797. /** version of the options passed to this UI */
  132798. options: WebXREnterExitUIOptions;
  132799. private _activeButton;
  132800. private _buttons;
  132801. /**
  132802. * The HTML Div Element to which buttons are added.
  132803. */
  132804. readonly overlay: HTMLDivElement;
  132805. /**
  132806. * Fired every time the active button is changed.
  132807. *
  132808. * When xr is entered via a button that launches xr that button will be the callback parameter
  132809. *
  132810. * When exiting xr the callback parameter will be null)
  132811. */
  132812. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  132813. /**
  132814. *
  132815. * @param scene babylon scene object to use
  132816. * @param options (read-only) version of the options passed to this UI
  132817. */
  132818. private constructor();
  132819. /**
  132820. * Creates UI to allow the user to enter/exit XR mode
  132821. * @param scene the scene to add the ui to
  132822. * @param helper the xr experience helper to enter/exit xr with
  132823. * @param options options to configure the UI
  132824. * @returns the created ui
  132825. */
  132826. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  132827. /**
  132828. * Disposes of the XR UI component
  132829. */
  132830. dispose(): void;
  132831. private _updateButtons;
  132832. }
  132833. }
  132834. declare module BABYLON {
  132835. /**
  132836. * Class containing static functions to help procedurally build meshes
  132837. */
  132838. export class LinesBuilder {
  132839. /**
  132840. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  132841. * * 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
  132842. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  132843. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  132844. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  132845. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  132846. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  132847. * * 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
  132848. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  132849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  132851. * @param name defines the name of the new line system
  132852. * @param options defines the options used to create the line system
  132853. * @param scene defines the hosting scene
  132854. * @returns a new line system mesh
  132855. */
  132856. static CreateLineSystem(name: string, options: {
  132857. lines: Vector3[][];
  132858. updatable?: boolean;
  132859. instance?: Nullable<LinesMesh>;
  132860. colors?: Nullable<Color4[][]>;
  132861. useVertexAlpha?: boolean;
  132862. }, scene: Nullable<Scene>): LinesMesh;
  132863. /**
  132864. * Creates a line mesh
  132865. * 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
  132866. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  132867. * * The parameter `points` is an array successive Vector3
  132868. * * 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
  132869. * * The optional parameter `colors` is an array of successive Color4, one per line point
  132870. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  132871. * * When updating an instance, remember that only point positions can change, not the number of points
  132872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  132874. * @param name defines the name of the new line system
  132875. * @param options defines the options used to create the line system
  132876. * @param scene defines the hosting scene
  132877. * @returns a new line mesh
  132878. */
  132879. static CreateLines(name: string, options: {
  132880. points: Vector3[];
  132881. updatable?: boolean;
  132882. instance?: Nullable<LinesMesh>;
  132883. colors?: Color4[];
  132884. useVertexAlpha?: boolean;
  132885. }, scene?: Nullable<Scene>): LinesMesh;
  132886. /**
  132887. * Creates a dashed line mesh
  132888. * * 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
  132889. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  132890. * * The parameter `points` is an array successive Vector3
  132891. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  132892. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  132893. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  132894. * * 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
  132895. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  132896. * * When updating an instance, remember that only point positions can change, not the number of points
  132897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132898. * @param name defines the name of the mesh
  132899. * @param options defines the options used to create the mesh
  132900. * @param scene defines the hosting scene
  132901. * @returns the dashed line mesh
  132902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  132903. */
  132904. static CreateDashedLines(name: string, options: {
  132905. points: Vector3[];
  132906. dashSize?: number;
  132907. gapSize?: number;
  132908. dashNb?: number;
  132909. updatable?: boolean;
  132910. instance?: LinesMesh;
  132911. useVertexAlpha?: boolean;
  132912. }, scene?: Nullable<Scene>): LinesMesh;
  132913. }
  132914. }
  132915. declare module BABYLON {
  132916. /**
  132917. * Construction options for a timer
  132918. */
  132919. export interface ITimerOptions<T> {
  132920. /**
  132921. * Time-to-end
  132922. */
  132923. timeout: number;
  132924. /**
  132925. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  132926. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  132927. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  132928. */
  132929. contextObservable: Observable<T>;
  132930. /**
  132931. * Optional parameters when adding an observer to the observable
  132932. */
  132933. observableParameters?: {
  132934. mask?: number;
  132935. insertFirst?: boolean;
  132936. scope?: any;
  132937. };
  132938. /**
  132939. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  132940. */
  132941. breakCondition?: (data?: ITimerData<T>) => boolean;
  132942. /**
  132943. * Will be triggered when the time condition has met
  132944. */
  132945. onEnded?: (data: ITimerData<any>) => void;
  132946. /**
  132947. * Will be triggered when the break condition has met (prematurely ended)
  132948. */
  132949. onAborted?: (data: ITimerData<any>) => void;
  132950. /**
  132951. * Optional function to execute on each tick (or count)
  132952. */
  132953. onTick?: (data: ITimerData<any>) => void;
  132954. }
  132955. /**
  132956. * An interface defining the data sent by the timer
  132957. */
  132958. export interface ITimerData<T> {
  132959. /**
  132960. * When did it start
  132961. */
  132962. startTime: number;
  132963. /**
  132964. * Time now
  132965. */
  132966. currentTime: number;
  132967. /**
  132968. * Time passed since started
  132969. */
  132970. deltaTime: number;
  132971. /**
  132972. * How much is completed, in [0.0...1.0].
  132973. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  132974. */
  132975. completeRate: number;
  132976. /**
  132977. * What the registered observable sent in the last count
  132978. */
  132979. payload: T;
  132980. }
  132981. /**
  132982. * The current state of the timer
  132983. */
  132984. export enum TimerState {
  132985. /**
  132986. * Timer initialized, not yet started
  132987. */
  132988. INIT = 0,
  132989. /**
  132990. * Timer started and counting
  132991. */
  132992. STARTED = 1,
  132993. /**
  132994. * Timer ended (whether aborted or time reached)
  132995. */
  132996. ENDED = 2
  132997. }
  132998. /**
  132999. * A simple version of the timer. Will take options and start the timer immediately after calling it
  133000. *
  133001. * @param options options with which to initialize this timer
  133002. */
  133003. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  133004. /**
  133005. * An advanced implementation of a timer class
  133006. */
  133007. export class AdvancedTimer<T = any> implements IDisposable {
  133008. /**
  133009. * Will notify each time the timer calculates the remaining time
  133010. */
  133011. onEachCountObservable: Observable<ITimerData<T>>;
  133012. /**
  133013. * Will trigger when the timer was aborted due to the break condition
  133014. */
  133015. onTimerAbortedObservable: Observable<ITimerData<T>>;
  133016. /**
  133017. * Will trigger when the timer ended successfully
  133018. */
  133019. onTimerEndedObservable: Observable<ITimerData<T>>;
  133020. /**
  133021. * Will trigger when the timer state has changed
  133022. */
  133023. onStateChangedObservable: Observable<TimerState>;
  133024. private _observer;
  133025. private _contextObservable;
  133026. private _observableParameters;
  133027. private _startTime;
  133028. private _timer;
  133029. private _state;
  133030. private _breakCondition;
  133031. private _timeToEnd;
  133032. private _breakOnNextTick;
  133033. /**
  133034. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  133035. * @param options construction options for this advanced timer
  133036. */
  133037. constructor(options: ITimerOptions<T>);
  133038. /**
  133039. * set a breaking condition for this timer. Default is to never break during count
  133040. * @param predicate the new break condition. Returns true to break, false otherwise
  133041. */
  133042. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  133043. /**
  133044. * Reset ALL associated observables in this advanced timer
  133045. */
  133046. clearObservables(): void;
  133047. /**
  133048. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  133049. *
  133050. * @param timeToEnd how much time to measure until timer ended
  133051. */
  133052. start(timeToEnd?: number): void;
  133053. /**
  133054. * Will force a stop on the next tick.
  133055. */
  133056. stop(): void;
  133057. /**
  133058. * Dispose this timer, clearing all resources
  133059. */
  133060. dispose(): void;
  133061. private _setState;
  133062. private _tick;
  133063. private _stop;
  133064. }
  133065. }
  133066. declare module BABYLON {
  133067. /**
  133068. * The options container for the teleportation module
  133069. */
  133070. export interface IWebXRTeleportationOptions {
  133071. /**
  133072. * if provided, this scene will be used to render meshes.
  133073. */
  133074. customUtilityLayerScene?: Scene;
  133075. /**
  133076. * Values to configure the default target mesh
  133077. */
  133078. defaultTargetMeshOptions?: {
  133079. /**
  133080. * Fill color of the teleportation area
  133081. */
  133082. teleportationFillColor?: string;
  133083. /**
  133084. * Border color for the teleportation area
  133085. */
  133086. teleportationBorderColor?: string;
  133087. /**
  133088. * Disable the mesh's animation sequence
  133089. */
  133090. disableAnimation?: boolean;
  133091. /**
  133092. * Disable lighting on the material or the ring and arrow
  133093. */
  133094. disableLighting?: boolean;
  133095. /**
  133096. * Override the default material of the torus and arrow
  133097. */
  133098. torusArrowMaterial?: Material;
  133099. };
  133100. /**
  133101. * A list of meshes to use as floor meshes.
  133102. * Meshes can be added and removed after initializing the feature using the
  133103. * addFloorMesh and removeFloorMesh functions
  133104. * If empty, rotation will still work
  133105. */
  133106. floorMeshes?: AbstractMesh[];
  133107. /**
  133108. * use this rendering group id for the meshes (optional)
  133109. */
  133110. renderingGroupId?: number;
  133111. /**
  133112. * Should teleportation move only to snap points
  133113. */
  133114. snapPointsOnly?: boolean;
  133115. /**
  133116. * An array of points to which the teleportation will snap to.
  133117. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  133118. */
  133119. snapPositions?: Vector3[];
  133120. /**
  133121. * How close should the teleportation ray be in order to snap to position.
  133122. * Default to 0.8 units (meters)
  133123. */
  133124. snapToPositionRadius?: number;
  133125. /**
  133126. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  133127. * If you want to support rotation, make sure your mesh has a direction indicator.
  133128. *
  133129. * When left untouched, the default mesh will be initialized.
  133130. */
  133131. teleportationTargetMesh?: AbstractMesh;
  133132. /**
  133133. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  133134. */
  133135. timeToTeleport?: number;
  133136. /**
  133137. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  133138. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  133139. */
  133140. useMainComponentOnly?: boolean;
  133141. /**
  133142. * Should meshes created here be added to a utility layer or the main scene
  133143. */
  133144. useUtilityLayer?: boolean;
  133145. /**
  133146. * Babylon XR Input class for controller
  133147. */
  133148. xrInput: WebXRInput;
  133149. /**
  133150. * Meshes that the teleportation ray cannot go through
  133151. */
  133152. pickBlockerMeshes?: AbstractMesh[];
  133153. }
  133154. /**
  133155. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  133156. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  133157. * the input of the attached controllers.
  133158. */
  133159. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  133160. private _options;
  133161. private _controllers;
  133162. private _currentTeleportationControllerId;
  133163. private _floorMeshes;
  133164. private _quadraticBezierCurve;
  133165. private _selectionFeature;
  133166. private _snapToPositions;
  133167. private _snappedToPoint;
  133168. private _teleportationRingMaterial?;
  133169. private _tmpRay;
  133170. private _tmpVector;
  133171. private _tmpQuaternion;
  133172. /**
  133173. * The module's name
  133174. */
  133175. static readonly Name: string;
  133176. /**
  133177. * The (Babylon) version of this module.
  133178. * This is an integer representing the implementation version.
  133179. * This number does not correspond to the webxr specs version
  133180. */
  133181. static readonly Version: number;
  133182. /**
  133183. * Is movement backwards enabled
  133184. */
  133185. backwardsMovementEnabled: boolean;
  133186. /**
  133187. * Distance to travel when moving backwards
  133188. */
  133189. backwardsTeleportationDistance: number;
  133190. /**
  133191. * The distance from the user to the inspection point in the direction of the controller
  133192. * A higher number will allow the user to move further
  133193. * defaults to 5 (meters, in xr units)
  133194. */
  133195. parabolicCheckRadius: number;
  133196. /**
  133197. * Should the module support parabolic ray on top of direct ray
  133198. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  133199. * Very helpful when moving between floors / different heights
  133200. */
  133201. parabolicRayEnabled: boolean;
  133202. /**
  133203. * How much rotation should be applied when rotating right and left
  133204. */
  133205. rotationAngle: number;
  133206. /**
  133207. * Is rotation enabled when moving forward?
  133208. * Disabling this feature will prevent the user from deciding the direction when teleporting
  133209. */
  133210. rotationEnabled: boolean;
  133211. /**
  133212. * constructs a new anchor system
  133213. * @param _xrSessionManager an instance of WebXRSessionManager
  133214. * @param _options configuration object for this feature
  133215. */
  133216. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  133217. /**
  133218. * Get the snapPointsOnly flag
  133219. */
  133220. get snapPointsOnly(): boolean;
  133221. /**
  133222. * Sets the snapPointsOnly flag
  133223. * @param snapToPoints should teleportation be exclusively to snap points
  133224. */
  133225. set snapPointsOnly(snapToPoints: boolean);
  133226. /**
  133227. * Add a new mesh to the floor meshes array
  133228. * @param mesh the mesh to use as floor mesh
  133229. */
  133230. addFloorMesh(mesh: AbstractMesh): void;
  133231. /**
  133232. * Add a new snap-to point to fix teleportation to this position
  133233. * @param newSnapPoint The new Snap-To point
  133234. */
  133235. addSnapPoint(newSnapPoint: Vector3): void;
  133236. attach(): boolean;
  133237. detach(): boolean;
  133238. dispose(): void;
  133239. /**
  133240. * Remove a mesh from the floor meshes array
  133241. * @param mesh the mesh to remove
  133242. */
  133243. removeFloorMesh(mesh: AbstractMesh): void;
  133244. /**
  133245. * Remove a mesh from the floor meshes array using its name
  133246. * @param name the mesh name to remove
  133247. */
  133248. removeFloorMeshByName(name: string): void;
  133249. /**
  133250. * 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
  133251. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  133252. * @returns was the point found and removed or not
  133253. */
  133254. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  133255. /**
  133256. * This function sets a selection feature that will be disabled when
  133257. * the forward ray is shown and will be reattached when hidden.
  133258. * This is used to remove the selection rays when moving.
  133259. * @param selectionFeature the feature to disable when forward movement is enabled
  133260. */
  133261. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  133262. protected _onXRFrame(_xrFrame: XRFrame): void;
  133263. private _attachController;
  133264. private _createDefaultTargetMesh;
  133265. private _detachController;
  133266. private _findClosestSnapPointWithRadius;
  133267. private _setTargetMeshPosition;
  133268. private _setTargetMeshVisibility;
  133269. private _showParabolicPath;
  133270. private _teleportForward;
  133271. }
  133272. }
  133273. declare module BABYLON {
  133274. /**
  133275. * Options for the default xr helper
  133276. */
  133277. export class WebXRDefaultExperienceOptions {
  133278. /**
  133279. * Enable or disable default UI to enter XR
  133280. */
  133281. disableDefaultUI?: boolean;
  133282. /**
  133283. * Should teleportation not initialize. defaults to false.
  133284. */
  133285. disableTeleportation?: boolean;
  133286. /**
  133287. * Floor meshes that will be used for teleport
  133288. */
  133289. floorMeshes?: Array<AbstractMesh>;
  133290. /**
  133291. * If set to true, the first frame will not be used to reset position
  133292. * The first frame is mainly used when copying transformation from the old camera
  133293. * Mainly used in AR
  133294. */
  133295. ignoreNativeCameraTransformation?: boolean;
  133296. /**
  133297. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  133298. */
  133299. inputOptions?: IWebXRInputOptions;
  133300. /**
  133301. * optional configuration for the output canvas
  133302. */
  133303. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  133304. /**
  133305. * optional UI options. This can be used among other to change session mode and reference space type
  133306. */
  133307. uiOptions?: WebXREnterExitUIOptions;
  133308. /**
  133309. * When loading teleportation and pointer select, use stable versions instead of latest.
  133310. */
  133311. useStablePlugins?: boolean;
  133312. /**
  133313. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  133314. */
  133315. renderingGroupId?: number;
  133316. /**
  133317. * A list of optional features to init the session with
  133318. * If set to true, all features we support will be added
  133319. */
  133320. optionalFeatures?: boolean | string[];
  133321. }
  133322. /**
  133323. * Default experience which provides a similar setup to the previous webVRExperience
  133324. */
  133325. export class WebXRDefaultExperience {
  133326. /**
  133327. * Base experience
  133328. */
  133329. baseExperience: WebXRExperienceHelper;
  133330. /**
  133331. * Enables ui for entering/exiting xr
  133332. */
  133333. enterExitUI: WebXREnterExitUI;
  133334. /**
  133335. * Input experience extension
  133336. */
  133337. input: WebXRInput;
  133338. /**
  133339. * Enables laser pointer and selection
  133340. */
  133341. pointerSelection: WebXRControllerPointerSelection;
  133342. /**
  133343. * Default target xr should render to
  133344. */
  133345. renderTarget: WebXRRenderTarget;
  133346. /**
  133347. * Enables teleportation
  133348. */
  133349. teleportation: WebXRMotionControllerTeleportation;
  133350. private constructor();
  133351. /**
  133352. * Creates the default xr experience
  133353. * @param scene scene
  133354. * @param options options for basic configuration
  133355. * @returns resulting WebXRDefaultExperience
  133356. */
  133357. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133358. /**
  133359. * DIsposes of the experience helper
  133360. */
  133361. dispose(): void;
  133362. }
  133363. }
  133364. declare module BABYLON {
  133365. /**
  133366. * Options to modify the vr teleportation behavior.
  133367. */
  133368. export interface VRTeleportationOptions {
  133369. /**
  133370. * The name of the mesh which should be used as the teleportation floor. (default: null)
  133371. */
  133372. floorMeshName?: string;
  133373. /**
  133374. * A list of meshes to be used as the teleportation floor. (default: empty)
  133375. */
  133376. floorMeshes?: Mesh[];
  133377. /**
  133378. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  133379. */
  133380. teleportationMode?: number;
  133381. /**
  133382. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  133383. */
  133384. teleportationTime?: number;
  133385. /**
  133386. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  133387. */
  133388. teleportationSpeed?: number;
  133389. /**
  133390. * The easing function used in the animation or null for Linear. (default CircleEase)
  133391. */
  133392. easingFunction?: EasingFunction;
  133393. }
  133394. /**
  133395. * Options to modify the vr experience helper's behavior.
  133396. */
  133397. export interface VRExperienceHelperOptions extends WebVROptions {
  133398. /**
  133399. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  133400. */
  133401. createDeviceOrientationCamera?: boolean;
  133402. /**
  133403. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  133404. */
  133405. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  133406. /**
  133407. * Uses the main button on the controller to toggle the laser casted. (default: true)
  133408. */
  133409. laserToggle?: boolean;
  133410. /**
  133411. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  133412. */
  133413. floorMeshes?: Mesh[];
  133414. /**
  133415. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  133416. */
  133417. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  133418. /**
  133419. * Defines if WebXR should be used instead of WebVR (if available)
  133420. */
  133421. useXR?: boolean;
  133422. }
  133423. /**
  133424. * Event containing information after VR has been entered
  133425. */
  133426. export class OnAfterEnteringVRObservableEvent {
  133427. /**
  133428. * If entering vr was successful
  133429. */
  133430. success: boolean;
  133431. }
  133432. /**
  133433. * Helps to quickly add VR support to an existing scene.
  133434. * See https://doc.babylonjs.com/how_to/webvr_helper
  133435. */
  133436. export class VRExperienceHelper {
  133437. /** Options to modify the vr experience helper's behavior. */
  133438. webVROptions: VRExperienceHelperOptions;
  133439. private _scene;
  133440. private _position;
  133441. private _btnVR;
  133442. private _btnVRDisplayed;
  133443. private _webVRsupported;
  133444. private _webVRready;
  133445. private _webVRrequesting;
  133446. private _webVRpresenting;
  133447. private _hasEnteredVR;
  133448. private _fullscreenVRpresenting;
  133449. private _inputElement;
  133450. private _webVRCamera;
  133451. private _vrDeviceOrientationCamera;
  133452. private _deviceOrientationCamera;
  133453. private _existingCamera;
  133454. private _onKeyDown;
  133455. private _onVrDisplayPresentChange;
  133456. private _onVRDisplayChanged;
  133457. private _onVRRequestPresentStart;
  133458. private _onVRRequestPresentComplete;
  133459. /**
  133460. * 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)
  133461. */
  133462. enableGazeEvenWhenNoPointerLock: boolean;
  133463. /**
  133464. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  133465. */
  133466. exitVROnDoubleTap: boolean;
  133467. /**
  133468. * Observable raised right before entering VR.
  133469. */
  133470. onEnteringVRObservable: Observable<VRExperienceHelper>;
  133471. /**
  133472. * Observable raised when entering VR has completed.
  133473. */
  133474. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  133475. /**
  133476. * Observable raised when exiting VR.
  133477. */
  133478. onExitingVRObservable: Observable<VRExperienceHelper>;
  133479. /**
  133480. * Observable raised when controller mesh is loaded.
  133481. */
  133482. onControllerMeshLoadedObservable: Observable<WebVRController>;
  133483. /** Return this.onEnteringVRObservable
  133484. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  133485. */
  133486. get onEnteringVR(): Observable<VRExperienceHelper>;
  133487. /** Return this.onExitingVRObservable
  133488. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  133489. */
  133490. get onExitingVR(): Observable<VRExperienceHelper>;
  133491. /** Return this.onControllerMeshLoadedObservable
  133492. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  133493. */
  133494. get onControllerMeshLoaded(): Observable<WebVRController>;
  133495. private _rayLength;
  133496. private _useCustomVRButton;
  133497. private _teleportationRequested;
  133498. private _teleportActive;
  133499. private _floorMeshName;
  133500. private _floorMeshesCollection;
  133501. private _teleportationMode;
  133502. private _teleportationTime;
  133503. private _teleportationSpeed;
  133504. private _teleportationEasing;
  133505. private _rotationAllowed;
  133506. private _teleportBackwardsVector;
  133507. private _teleportationTarget;
  133508. private _isDefaultTeleportationTarget;
  133509. private _postProcessMove;
  133510. private _teleportationFillColor;
  133511. private _teleportationBorderColor;
  133512. private _rotationAngle;
  133513. private _haloCenter;
  133514. private _cameraGazer;
  133515. private _padSensibilityUp;
  133516. private _padSensibilityDown;
  133517. private _leftController;
  133518. private _rightController;
  133519. private _gazeColor;
  133520. private _laserColor;
  133521. private _pickedLaserColor;
  133522. private _pickedGazeColor;
  133523. /**
  133524. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  133525. */
  133526. onNewMeshSelected: Observable<AbstractMesh>;
  133527. /**
  133528. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  133529. * This observable will provide the mesh and the controller used to select the mesh
  133530. */
  133531. onMeshSelectedWithController: Observable<{
  133532. mesh: AbstractMesh;
  133533. controller: WebVRController;
  133534. }>;
  133535. /**
  133536. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  133537. */
  133538. onNewMeshPicked: Observable<PickingInfo>;
  133539. private _circleEase;
  133540. /**
  133541. * Observable raised before camera teleportation
  133542. */
  133543. onBeforeCameraTeleport: Observable<Vector3>;
  133544. /**
  133545. * Observable raised after camera teleportation
  133546. */
  133547. onAfterCameraTeleport: Observable<Vector3>;
  133548. /**
  133549. * Observable raised when current selected mesh gets unselected
  133550. */
  133551. onSelectedMeshUnselected: Observable<AbstractMesh>;
  133552. private _raySelectionPredicate;
  133553. /**
  133554. * To be optionaly changed by user to define custom ray selection
  133555. */
  133556. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133557. /**
  133558. * To be optionaly changed by user to define custom selection logic (after ray selection)
  133559. */
  133560. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  133561. /**
  133562. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  133563. */
  133564. teleportationEnabled: boolean;
  133565. private _defaultHeight;
  133566. private _teleportationInitialized;
  133567. private _interactionsEnabled;
  133568. private _interactionsRequested;
  133569. private _displayGaze;
  133570. private _displayLaserPointer;
  133571. /**
  133572. * The mesh used to display where the user is going to teleport.
  133573. */
  133574. get teleportationTarget(): Mesh;
  133575. /**
  133576. * Sets the mesh to be used to display where the user is going to teleport.
  133577. */
  133578. set teleportationTarget(value: Mesh);
  133579. /**
  133580. * 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
  133581. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  133582. * See https://doc.babylonjs.com/resources/baking_transformations
  133583. */
  133584. get gazeTrackerMesh(): Mesh;
  133585. set gazeTrackerMesh(value: Mesh);
  133586. /**
  133587. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  133588. */
  133589. updateGazeTrackerScale: boolean;
  133590. /**
  133591. * If the gaze trackers color should be updated when selecting meshes
  133592. */
  133593. updateGazeTrackerColor: boolean;
  133594. /**
  133595. * If the controller laser color should be updated when selecting meshes
  133596. */
  133597. updateControllerLaserColor: boolean;
  133598. /**
  133599. * The gaze tracking mesh corresponding to the left controller
  133600. */
  133601. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  133602. /**
  133603. * The gaze tracking mesh corresponding to the right controller
  133604. */
  133605. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  133606. /**
  133607. * If the ray of the gaze should be displayed.
  133608. */
  133609. get displayGaze(): boolean;
  133610. /**
  133611. * Sets if the ray of the gaze should be displayed.
  133612. */
  133613. set displayGaze(value: boolean);
  133614. /**
  133615. * If the ray of the LaserPointer should be displayed.
  133616. */
  133617. get displayLaserPointer(): boolean;
  133618. /**
  133619. * Sets if the ray of the LaserPointer should be displayed.
  133620. */
  133621. set displayLaserPointer(value: boolean);
  133622. /**
  133623. * The deviceOrientationCamera used as the camera when not in VR.
  133624. */
  133625. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  133626. /**
  133627. * Based on the current WebVR support, returns the current VR camera used.
  133628. */
  133629. get currentVRCamera(): Nullable<Camera>;
  133630. /**
  133631. * The webVRCamera which is used when in VR.
  133632. */
  133633. get webVRCamera(): WebVRFreeCamera;
  133634. /**
  133635. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  133636. */
  133637. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  133638. /**
  133639. * The html button that is used to trigger entering into VR.
  133640. */
  133641. get vrButton(): Nullable<HTMLButtonElement>;
  133642. private get _teleportationRequestInitiated();
  133643. /**
  133644. * Defines whether or not Pointer lock should be requested when switching to
  133645. * full screen.
  133646. */
  133647. requestPointerLockOnFullScreen: boolean;
  133648. /**
  133649. * If asking to force XR, this will be populated with the default xr experience
  133650. */
  133651. xr: WebXRDefaultExperience;
  133652. /**
  133653. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  133654. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  133655. */
  133656. xrTestDone: boolean;
  133657. /**
  133658. * Instantiates a VRExperienceHelper.
  133659. * Helps to quickly add VR support to an existing scene.
  133660. * @param scene The scene the VRExperienceHelper belongs to.
  133661. * @param webVROptions Options to modify the vr experience helper's behavior.
  133662. */
  133663. constructor(scene: Scene,
  133664. /** Options to modify the vr experience helper's behavior. */
  133665. webVROptions?: VRExperienceHelperOptions);
  133666. private completeVRInit;
  133667. private _onDefaultMeshLoaded;
  133668. private _onResize;
  133669. private _onFullscreenChange;
  133670. /**
  133671. * Gets a value indicating if we are currently in VR mode.
  133672. */
  133673. get isInVRMode(): boolean;
  133674. private onVrDisplayPresentChange;
  133675. private onVRDisplayChanged;
  133676. private moveButtonToBottomRight;
  133677. private displayVRButton;
  133678. private updateButtonVisibility;
  133679. private _cachedAngularSensibility;
  133680. /**
  133681. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  133682. * Otherwise, will use the fullscreen API.
  133683. */
  133684. enterVR(): void;
  133685. /**
  133686. * Attempt to exit VR, or fullscreen.
  133687. */
  133688. exitVR(): void;
  133689. /**
  133690. * The position of the vr experience helper.
  133691. */
  133692. get position(): Vector3;
  133693. /**
  133694. * Sets the position of the vr experience helper.
  133695. */
  133696. set position(value: Vector3);
  133697. /**
  133698. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  133699. */
  133700. enableInteractions(): void;
  133701. private get _noControllerIsActive();
  133702. private beforeRender;
  133703. private _isTeleportationFloor;
  133704. /**
  133705. * Adds a floor mesh to be used for teleportation.
  133706. * @param floorMesh the mesh to be used for teleportation.
  133707. */
  133708. addFloorMesh(floorMesh: Mesh): void;
  133709. /**
  133710. * Removes a floor mesh from being used for teleportation.
  133711. * @param floorMesh the mesh to be removed.
  133712. */
  133713. removeFloorMesh(floorMesh: Mesh): void;
  133714. /**
  133715. * Enables interactions and teleportation using the VR controllers and gaze.
  133716. * @param vrTeleportationOptions options to modify teleportation behavior.
  133717. */
  133718. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  133719. private _onNewGamepadConnected;
  133720. private _tryEnableInteractionOnController;
  133721. private _onNewGamepadDisconnected;
  133722. private _enableInteractionOnController;
  133723. private _checkTeleportWithRay;
  133724. private _checkRotate;
  133725. private _checkTeleportBackwards;
  133726. private _enableTeleportationOnController;
  133727. private _createTeleportationCircles;
  133728. private _displayTeleportationTarget;
  133729. private _hideTeleportationTarget;
  133730. private _rotateCamera;
  133731. private _moveTeleportationSelectorTo;
  133732. private _workingVector;
  133733. private _workingQuaternion;
  133734. private _workingMatrix;
  133735. /**
  133736. * Time Constant Teleportation Mode
  133737. */
  133738. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  133739. /**
  133740. * Speed Constant Teleportation Mode
  133741. */
  133742. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  133743. /**
  133744. * Teleports the users feet to the desired location
  133745. * @param location The location where the user's feet should be placed
  133746. */
  133747. teleportCamera(location: Vector3): void;
  133748. private _convertNormalToDirectionOfRay;
  133749. private _castRayAndSelectObject;
  133750. private _notifySelectedMeshUnselected;
  133751. /**
  133752. * Permanently set new colors for the laser pointer
  133753. * @param color the new laser color
  133754. * @param pickedColor the new laser color when picked mesh detected
  133755. */
  133756. setLaserColor(color: Color3, pickedColor?: Color3): void;
  133757. /**
  133758. * Set lighting enabled / disabled on the laser pointer of both controllers
  133759. * @param enabled should the lighting be enabled on the laser pointer
  133760. */
  133761. setLaserLightingState(enabled?: boolean): void;
  133762. /**
  133763. * Permanently set new colors for the gaze pointer
  133764. * @param color the new gaze color
  133765. * @param pickedColor the new gaze color when picked mesh detected
  133766. */
  133767. setGazeColor(color: Color3, pickedColor?: Color3): void;
  133768. /**
  133769. * Sets the color of the laser ray from the vr controllers.
  133770. * @param color new color for the ray.
  133771. */
  133772. changeLaserColor(color: Color3): void;
  133773. /**
  133774. * Sets the color of the ray from the vr headsets gaze.
  133775. * @param color new color for the ray.
  133776. */
  133777. changeGazeColor(color: Color3): void;
  133778. /**
  133779. * Exits VR and disposes of the vr experience helper
  133780. */
  133781. dispose(): void;
  133782. /**
  133783. * Gets the name of the VRExperienceHelper class
  133784. * @returns "VRExperienceHelper"
  133785. */
  133786. getClassName(): string;
  133787. }
  133788. }
  133789. declare module BABYLON {
  133790. /**
  133791. * Contains an array of blocks representing the octree
  133792. */
  133793. export interface IOctreeContainer<T> {
  133794. /**
  133795. * Blocks within the octree
  133796. */
  133797. blocks: Array<OctreeBlock<T>>;
  133798. }
  133799. /**
  133800. * Class used to store a cell in an octree
  133801. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133802. */
  133803. export class OctreeBlock<T> {
  133804. /**
  133805. * Gets the content of the current block
  133806. */
  133807. entries: T[];
  133808. /**
  133809. * Gets the list of block children
  133810. */
  133811. blocks: Array<OctreeBlock<T>>;
  133812. private _depth;
  133813. private _maxDepth;
  133814. private _capacity;
  133815. private _minPoint;
  133816. private _maxPoint;
  133817. private _boundingVectors;
  133818. private _creationFunc;
  133819. /**
  133820. * Creates a new block
  133821. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  133822. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  133823. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133824. * @param depth defines the current depth of this block in the octree
  133825. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  133826. * @param creationFunc defines a callback to call when an element is added to the block
  133827. */
  133828. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  133829. /**
  133830. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  133831. */
  133832. get capacity(): number;
  133833. /**
  133834. * Gets the minimum vector (in world space) of the block's bounding box
  133835. */
  133836. get minPoint(): Vector3;
  133837. /**
  133838. * Gets the maximum vector (in world space) of the block's bounding box
  133839. */
  133840. get maxPoint(): Vector3;
  133841. /**
  133842. * Add a new element to this block
  133843. * @param entry defines the element to add
  133844. */
  133845. addEntry(entry: T): void;
  133846. /**
  133847. * Remove an element from this block
  133848. * @param entry defines the element to remove
  133849. */
  133850. removeEntry(entry: T): void;
  133851. /**
  133852. * Add an array of elements to this block
  133853. * @param entries defines the array of elements to add
  133854. */
  133855. addEntries(entries: T[]): void;
  133856. /**
  133857. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  133858. * @param frustumPlanes defines the frustum planes to test
  133859. * @param selection defines the array to store current content if selection is positive
  133860. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133861. */
  133862. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  133863. /**
  133864. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  133865. * @param sphereCenter defines the bounding sphere center
  133866. * @param sphereRadius defines the bounding sphere radius
  133867. * @param selection defines the array to store current content if selection is positive
  133868. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133869. */
  133870. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  133871. /**
  133872. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  133873. * @param ray defines the ray to test with
  133874. * @param selection defines the array to store current content if selection is positive
  133875. */
  133876. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  133877. /**
  133878. * Subdivide the content into child blocks (this block will then be empty)
  133879. */
  133880. createInnerBlocks(): void;
  133881. /**
  133882. * @hidden
  133883. */
  133884. 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;
  133885. }
  133886. }
  133887. declare module BABYLON {
  133888. /**
  133889. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  133890. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133891. */
  133892. export class Octree<T> {
  133893. /** 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.) */
  133894. maxDepth: number;
  133895. /**
  133896. * Blocks within the octree containing objects
  133897. */
  133898. blocks: Array<OctreeBlock<T>>;
  133899. /**
  133900. * Content stored in the octree
  133901. */
  133902. dynamicContent: T[];
  133903. private _maxBlockCapacity;
  133904. private _selectionContent;
  133905. private _creationFunc;
  133906. /**
  133907. * Creates a octree
  133908. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133909. * @param creationFunc function to be used to instatiate the octree
  133910. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  133911. * @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.)
  133912. */
  133913. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  133914. /** 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.) */
  133915. maxDepth?: number);
  133916. /**
  133917. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  133918. * @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);
  133919. * @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);
  133920. * @param entries meshes to be added to the octree blocks
  133921. */
  133922. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  133923. /**
  133924. * Adds a mesh to the octree
  133925. * @param entry Mesh to add to the octree
  133926. */
  133927. addMesh(entry: T): void;
  133928. /**
  133929. * Remove an element from the octree
  133930. * @param entry defines the element to remove
  133931. */
  133932. removeMesh(entry: T): void;
  133933. /**
  133934. * Selects an array of meshes within the frustum
  133935. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  133936. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  133937. * @returns array of meshes within the frustum
  133938. */
  133939. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  133940. /**
  133941. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  133942. * @param sphereCenter defines the bounding sphere center
  133943. * @param sphereRadius defines the bounding sphere radius
  133944. * @param allowDuplicate defines if the selection array can contains duplicated entries
  133945. * @returns an array of objects that intersect the sphere
  133946. */
  133947. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  133948. /**
  133949. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  133950. * @param ray defines the ray to test with
  133951. * @returns array of intersected objects
  133952. */
  133953. intersectsRay(ray: Ray): SmartArray<T>;
  133954. /**
  133955. * Adds a mesh into the octree block if it intersects the block
  133956. */
  133957. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  133958. /**
  133959. * Adds a submesh into the octree block if it intersects the block
  133960. */
  133961. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  133962. }
  133963. }
  133964. declare module BABYLON {
  133965. interface Scene {
  133966. /**
  133967. * @hidden
  133968. * Backing Filed
  133969. */
  133970. _selectionOctree: Octree<AbstractMesh>;
  133971. /**
  133972. * Gets the octree used to boost mesh selection (picking)
  133973. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133974. */
  133975. selectionOctree: Octree<AbstractMesh>;
  133976. /**
  133977. * Creates or updates the octree used to boost selection (picking)
  133978. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133979. * @param maxCapacity defines the maximum capacity per leaf
  133980. * @param maxDepth defines the maximum depth of the octree
  133981. * @returns an octree of AbstractMesh
  133982. */
  133983. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  133984. }
  133985. interface AbstractMesh {
  133986. /**
  133987. * @hidden
  133988. * Backing Field
  133989. */
  133990. _submeshesOctree: Octree<SubMesh>;
  133991. /**
  133992. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  133993. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  133994. * @param maxCapacity defines the maximum size of each block (64 by default)
  133995. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  133996. * @returns the new octree
  133997. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  133998. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  133999. */
  134000. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  134001. }
  134002. /**
  134003. * Defines the octree scene component responsible to manage any octrees
  134004. * in a given scene.
  134005. */
  134006. export class OctreeSceneComponent {
  134007. /**
  134008. * The component name help to identify the component in the list of scene components.
  134009. */
  134010. readonly name: string;
  134011. /**
  134012. * The scene the component belongs to.
  134013. */
  134014. scene: Scene;
  134015. /**
  134016. * Indicates if the meshes have been checked to make sure they are isEnabled()
  134017. */
  134018. readonly checksIsEnabled: boolean;
  134019. /**
  134020. * Creates a new instance of the component for the given scene
  134021. * @param scene Defines the scene to register the component in
  134022. */
  134023. constructor(scene: Scene);
  134024. /**
  134025. * Registers the component in a given scene
  134026. */
  134027. register(): void;
  134028. /**
  134029. * Return the list of active meshes
  134030. * @returns the list of active meshes
  134031. */
  134032. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  134033. /**
  134034. * Return the list of active sub meshes
  134035. * @param mesh The mesh to get the candidates sub meshes from
  134036. * @returns the list of active sub meshes
  134037. */
  134038. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  134039. private _tempRay;
  134040. /**
  134041. * Return the list of sub meshes intersecting with a given local ray
  134042. * @param mesh defines the mesh to find the submesh for
  134043. * @param localRay defines the ray in local space
  134044. * @returns the list of intersecting sub meshes
  134045. */
  134046. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  134047. /**
  134048. * Return the list of sub meshes colliding with a collider
  134049. * @param mesh defines the mesh to find the submesh for
  134050. * @param collider defines the collider to evaluate the collision against
  134051. * @returns the list of colliding sub meshes
  134052. */
  134053. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  134054. /**
  134055. * Rebuilds the elements related to this component in case of
  134056. * context lost for instance.
  134057. */
  134058. rebuild(): void;
  134059. /**
  134060. * Disposes the component and the associated ressources.
  134061. */
  134062. dispose(): void;
  134063. }
  134064. }
  134065. declare module BABYLON {
  134066. /**
  134067. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  134068. */
  134069. export class Gizmo implements IDisposable {
  134070. /** The utility layer the gizmo will be added to */
  134071. gizmoLayer: UtilityLayerRenderer;
  134072. /**
  134073. * The root mesh of the gizmo
  134074. */
  134075. _rootMesh: Mesh;
  134076. private _attachedMesh;
  134077. private _attachedNode;
  134078. /**
  134079. * Ratio for the scale of the gizmo (Default: 1)
  134080. */
  134081. protected _scaleRatio: number;
  134082. /**
  134083. * boolean updated by pointermove when a gizmo mesh is hovered
  134084. */
  134085. protected _isHovered: boolean;
  134086. /**
  134087. * Ratio for the scale of the gizmo (Default: 1)
  134088. */
  134089. set scaleRatio(value: number);
  134090. get scaleRatio(): number;
  134091. /**
  134092. * True when the mouse pointer is hovered a gizmo mesh
  134093. */
  134094. get isHovered(): boolean;
  134095. /**
  134096. * If a custom mesh has been set (Default: false)
  134097. */
  134098. protected _customMeshSet: boolean;
  134099. /**
  134100. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  134101. * * When set, interactions will be enabled
  134102. */
  134103. get attachedMesh(): Nullable<AbstractMesh>;
  134104. set attachedMesh(value: Nullable<AbstractMesh>);
  134105. /**
  134106. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  134107. * * When set, interactions will be enabled
  134108. */
  134109. get attachedNode(): Nullable<Node>;
  134110. set attachedNode(value: Nullable<Node>);
  134111. /**
  134112. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134113. * @param mesh The mesh to replace the default mesh of the gizmo
  134114. */
  134115. setCustomMesh(mesh: Mesh): void;
  134116. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  134117. /**
  134118. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  134119. */
  134120. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134121. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134122. /**
  134123. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  134124. */
  134125. updateGizmoPositionToMatchAttachedMesh: boolean;
  134126. /**
  134127. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  134128. */
  134129. updateScale: boolean;
  134130. protected _interactionsEnabled: boolean;
  134131. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134132. private _beforeRenderObserver;
  134133. private _tempQuaternion;
  134134. private _tempVector;
  134135. private _tempVector2;
  134136. private _tempMatrix1;
  134137. private _tempMatrix2;
  134138. private _rightHandtoLeftHandMatrix;
  134139. /**
  134140. * Creates a gizmo
  134141. * @param gizmoLayer The utility layer the gizmo will be added to
  134142. */
  134143. constructor(
  134144. /** The utility layer the gizmo will be added to */
  134145. gizmoLayer?: UtilityLayerRenderer);
  134146. /**
  134147. * Updates the gizmo to match the attached mesh's position/rotation
  134148. */
  134149. protected _update(): void;
  134150. /**
  134151. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  134152. * @param value Node, TransformNode or mesh
  134153. */
  134154. protected _matrixChanged(): void;
  134155. /**
  134156. * Disposes of the gizmo
  134157. */
  134158. dispose(): void;
  134159. }
  134160. }
  134161. declare module BABYLON {
  134162. /**
  134163. * Single plane drag gizmo
  134164. */
  134165. export class PlaneDragGizmo extends Gizmo {
  134166. /**
  134167. * Drag behavior responsible for the gizmos dragging interactions
  134168. */
  134169. dragBehavior: PointerDragBehavior;
  134170. private _pointerObserver;
  134171. /**
  134172. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134173. */
  134174. snapDistance: number;
  134175. /**
  134176. * Event that fires each time the gizmo snaps to a new location.
  134177. * * snapDistance is the the change in distance
  134178. */
  134179. onSnapObservable: Observable<{
  134180. snapDistance: number;
  134181. }>;
  134182. private _plane;
  134183. private _coloredMaterial;
  134184. private _hoverMaterial;
  134185. private _isEnabled;
  134186. private _parent;
  134187. /** @hidden */
  134188. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  134189. /** @hidden */
  134190. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134191. /**
  134192. * Creates a PlaneDragGizmo
  134193. * @param gizmoLayer The utility layer the gizmo will be added to
  134194. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  134195. * @param color The color of the gizmo
  134196. */
  134197. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  134198. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134199. /**
  134200. * If the gizmo is enabled
  134201. */
  134202. set isEnabled(value: boolean);
  134203. get isEnabled(): boolean;
  134204. /**
  134205. * Disposes of the gizmo
  134206. */
  134207. dispose(): void;
  134208. }
  134209. }
  134210. declare module BABYLON {
  134211. /**
  134212. * Gizmo that enables dragging a mesh along 3 axis
  134213. */
  134214. export class PositionGizmo extends Gizmo {
  134215. /**
  134216. * Internal gizmo used for interactions on the x axis
  134217. */
  134218. xGizmo: AxisDragGizmo;
  134219. /**
  134220. * Internal gizmo used for interactions on the y axis
  134221. */
  134222. yGizmo: AxisDragGizmo;
  134223. /**
  134224. * Internal gizmo used for interactions on the z axis
  134225. */
  134226. zGizmo: AxisDragGizmo;
  134227. /**
  134228. * Internal gizmo used for interactions on the yz plane
  134229. */
  134230. xPlaneGizmo: PlaneDragGizmo;
  134231. /**
  134232. * Internal gizmo used for interactions on the xz plane
  134233. */
  134234. yPlaneGizmo: PlaneDragGizmo;
  134235. /**
  134236. * Internal gizmo used for interactions on the xy plane
  134237. */
  134238. zPlaneGizmo: PlaneDragGizmo;
  134239. /**
  134240. * private variables
  134241. */
  134242. private _meshAttached;
  134243. private _nodeAttached;
  134244. private _snapDistance;
  134245. /** Fires an event when any of it's sub gizmos are dragged */
  134246. onDragStartObservable: Observable<unknown>;
  134247. /** Fires an event when any of it's sub gizmos are released from dragging */
  134248. onDragEndObservable: Observable<unknown>;
  134249. /**
  134250. * If set to true, planar drag is enabled
  134251. */
  134252. private _planarGizmoEnabled;
  134253. get attachedMesh(): Nullable<AbstractMesh>;
  134254. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134255. get attachedNode(): Nullable<Node>;
  134256. set attachedNode(node: Nullable<Node>);
  134257. /**
  134258. * True when the mouse pointer is hovering a gizmo mesh
  134259. */
  134260. get isHovered(): boolean;
  134261. /**
  134262. * Creates a PositionGizmo
  134263. * @param gizmoLayer The utility layer the gizmo will be added to
  134264. @param thickness display gizmo axis thickness
  134265. */
  134266. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134267. /**
  134268. * If the planar drag gizmo is enabled
  134269. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  134270. */
  134271. set planarGizmoEnabled(value: boolean);
  134272. get planarGizmoEnabled(): boolean;
  134273. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134274. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134275. /**
  134276. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134277. */
  134278. set snapDistance(value: number);
  134279. get snapDistance(): number;
  134280. /**
  134281. * Ratio for the scale of the gizmo (Default: 1)
  134282. */
  134283. set scaleRatio(value: number);
  134284. get scaleRatio(): number;
  134285. /**
  134286. * Disposes of the gizmo
  134287. */
  134288. dispose(): void;
  134289. /**
  134290. * CustomMeshes are not supported by this gizmo
  134291. * @param mesh The mesh to replace the default mesh of the gizmo
  134292. */
  134293. setCustomMesh(mesh: Mesh): void;
  134294. }
  134295. }
  134296. declare module BABYLON {
  134297. /**
  134298. * Single axis drag gizmo
  134299. */
  134300. export class AxisDragGizmo extends Gizmo {
  134301. /**
  134302. * Drag behavior responsible for the gizmos dragging interactions
  134303. */
  134304. dragBehavior: PointerDragBehavior;
  134305. private _pointerObserver;
  134306. /**
  134307. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134308. */
  134309. snapDistance: number;
  134310. /**
  134311. * Event that fires each time the gizmo snaps to a new location.
  134312. * * snapDistance is the the change in distance
  134313. */
  134314. onSnapObservable: Observable<{
  134315. snapDistance: number;
  134316. }>;
  134317. private _isEnabled;
  134318. private _parent;
  134319. private _arrow;
  134320. private _coloredMaterial;
  134321. private _hoverMaterial;
  134322. /** @hidden */
  134323. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  134324. /** @hidden */
  134325. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  134326. /**
  134327. * Creates an AxisDragGizmo
  134328. * @param gizmoLayer The utility layer the gizmo will be added to
  134329. * @param dragAxis The axis which the gizmo will be able to drag on
  134330. * @param color The color of the gizmo
  134331. * @param thickness display gizmo axis thickness
  134332. */
  134333. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  134334. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134335. /**
  134336. * If the gizmo is enabled
  134337. */
  134338. set isEnabled(value: boolean);
  134339. get isEnabled(): boolean;
  134340. /**
  134341. * Disposes of the gizmo
  134342. */
  134343. dispose(): void;
  134344. }
  134345. }
  134346. declare module BABYLON.Debug {
  134347. /**
  134348. * The Axes viewer will show 3 axes in a specific point in space
  134349. */
  134350. export class AxesViewer {
  134351. private _xAxis;
  134352. private _yAxis;
  134353. private _zAxis;
  134354. private _scaleLinesFactor;
  134355. private _instanced;
  134356. /**
  134357. * Gets the hosting scene
  134358. */
  134359. scene: Nullable<Scene>;
  134360. /**
  134361. * Gets or sets a number used to scale line length
  134362. */
  134363. scaleLines: number;
  134364. /** Gets the node hierarchy used to render x-axis */
  134365. get xAxis(): TransformNode;
  134366. /** Gets the node hierarchy used to render y-axis */
  134367. get yAxis(): TransformNode;
  134368. /** Gets the node hierarchy used to render z-axis */
  134369. get zAxis(): TransformNode;
  134370. /**
  134371. * Creates a new AxesViewer
  134372. * @param scene defines the hosting scene
  134373. * @param scaleLines defines a number used to scale line length (1 by default)
  134374. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  134375. * @param xAxis defines the node hierarchy used to render the x-axis
  134376. * @param yAxis defines the node hierarchy used to render the y-axis
  134377. * @param zAxis defines the node hierarchy used to render the z-axis
  134378. */
  134379. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  134380. /**
  134381. * Force the viewer to update
  134382. * @param position defines the position of the viewer
  134383. * @param xaxis defines the x axis of the viewer
  134384. * @param yaxis defines the y axis of the viewer
  134385. * @param zaxis defines the z axis of the viewer
  134386. */
  134387. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  134388. /**
  134389. * Creates an instance of this axes viewer.
  134390. * @returns a new axes viewer with instanced meshes
  134391. */
  134392. createInstance(): AxesViewer;
  134393. /** Releases resources */
  134394. dispose(): void;
  134395. private static _SetRenderingGroupId;
  134396. }
  134397. }
  134398. declare module BABYLON.Debug {
  134399. /**
  134400. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  134401. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  134402. */
  134403. export class BoneAxesViewer extends AxesViewer {
  134404. /**
  134405. * Gets or sets the target mesh where to display the axes viewer
  134406. */
  134407. mesh: Nullable<Mesh>;
  134408. /**
  134409. * Gets or sets the target bone where to display the axes viewer
  134410. */
  134411. bone: Nullable<Bone>;
  134412. /** Gets current position */
  134413. pos: Vector3;
  134414. /** Gets direction of X axis */
  134415. xaxis: Vector3;
  134416. /** Gets direction of Y axis */
  134417. yaxis: Vector3;
  134418. /** Gets direction of Z axis */
  134419. zaxis: Vector3;
  134420. /**
  134421. * Creates a new BoneAxesViewer
  134422. * @param scene defines the hosting scene
  134423. * @param bone defines the target bone
  134424. * @param mesh defines the target mesh
  134425. * @param scaleLines defines a scaling factor for line length (1 by default)
  134426. */
  134427. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  134428. /**
  134429. * Force the viewer to update
  134430. */
  134431. update(): void;
  134432. /** Releases resources */
  134433. dispose(): void;
  134434. }
  134435. }
  134436. declare module BABYLON {
  134437. /**
  134438. * Interface used to define scene explorer extensibility option
  134439. */
  134440. export interface IExplorerExtensibilityOption {
  134441. /**
  134442. * Define the option label
  134443. */
  134444. label: string;
  134445. /**
  134446. * Defines the action to execute on click
  134447. */
  134448. action: (entity: any) => void;
  134449. }
  134450. /**
  134451. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  134452. */
  134453. export interface IExplorerExtensibilityGroup {
  134454. /**
  134455. * Defines a predicate to test if a given type mut be extended
  134456. */
  134457. predicate: (entity: any) => boolean;
  134458. /**
  134459. * Gets the list of options added to a type
  134460. */
  134461. entries: IExplorerExtensibilityOption[];
  134462. }
  134463. /**
  134464. * Interface used to define the options to use to create the Inspector
  134465. */
  134466. export interface IInspectorOptions {
  134467. /**
  134468. * Display in overlay mode (default: false)
  134469. */
  134470. overlay?: boolean;
  134471. /**
  134472. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  134473. */
  134474. globalRoot?: HTMLElement;
  134475. /**
  134476. * Display the Scene explorer
  134477. */
  134478. showExplorer?: boolean;
  134479. /**
  134480. * Display the property inspector
  134481. */
  134482. showInspector?: boolean;
  134483. /**
  134484. * Display in embed mode (both panes on the right)
  134485. */
  134486. embedMode?: boolean;
  134487. /**
  134488. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  134489. */
  134490. handleResize?: boolean;
  134491. /**
  134492. * Allow the panes to popup (default: true)
  134493. */
  134494. enablePopup?: boolean;
  134495. /**
  134496. * Allow the panes to be closed by users (default: true)
  134497. */
  134498. enableClose?: boolean;
  134499. /**
  134500. * Optional list of extensibility entries
  134501. */
  134502. explorerExtensibility?: IExplorerExtensibilityGroup[];
  134503. /**
  134504. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  134505. */
  134506. inspectorURL?: string;
  134507. /**
  134508. * Optional initial tab (default to DebugLayerTab.Properties)
  134509. */
  134510. initialTab?: DebugLayerTab;
  134511. }
  134512. interface Scene {
  134513. /**
  134514. * @hidden
  134515. * Backing field
  134516. */
  134517. _debugLayer: DebugLayer;
  134518. /**
  134519. * Gets the debug layer (aka Inspector) associated with the scene
  134520. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134521. */
  134522. debugLayer: DebugLayer;
  134523. }
  134524. /**
  134525. * Enum of inspector action tab
  134526. */
  134527. export enum DebugLayerTab {
  134528. /**
  134529. * Properties tag (default)
  134530. */
  134531. Properties = 0,
  134532. /**
  134533. * Debug tab
  134534. */
  134535. Debug = 1,
  134536. /**
  134537. * Statistics tab
  134538. */
  134539. Statistics = 2,
  134540. /**
  134541. * Tools tab
  134542. */
  134543. Tools = 3,
  134544. /**
  134545. * Settings tab
  134546. */
  134547. Settings = 4
  134548. }
  134549. /**
  134550. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134551. * what is happening in your scene
  134552. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134553. */
  134554. export class DebugLayer {
  134555. /**
  134556. * Define the url to get the inspector script from.
  134557. * By default it uses the babylonjs CDN.
  134558. * @ignoreNaming
  134559. */
  134560. static InspectorURL: string;
  134561. private _scene;
  134562. private BJSINSPECTOR;
  134563. private _onPropertyChangedObservable?;
  134564. /**
  134565. * Observable triggered when a property is changed through the inspector.
  134566. */
  134567. get onPropertyChangedObservable(): any;
  134568. /**
  134569. * Instantiates a new debug layer.
  134570. * The debug layer (aka Inspector) is the go to tool in order to better understand
  134571. * what is happening in your scene
  134572. * @see https://doc.babylonjs.com/features/playground_debuglayer
  134573. * @param scene Defines the scene to inspect
  134574. */
  134575. constructor(scene: Scene);
  134576. /** Creates the inspector window. */
  134577. private _createInspector;
  134578. /**
  134579. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  134580. * @param entity defines the entity to select
  134581. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  134582. */
  134583. select(entity: any, lineContainerTitles?: string | string[]): void;
  134584. /** Get the inspector from bundle or global */
  134585. private _getGlobalInspector;
  134586. /**
  134587. * Get if the inspector is visible or not.
  134588. * @returns true if visible otherwise, false
  134589. */
  134590. isVisible(): boolean;
  134591. /**
  134592. * Hide the inspector and close its window.
  134593. */
  134594. hide(): void;
  134595. /**
  134596. * Update the scene in the inspector
  134597. */
  134598. setAsActiveScene(): void;
  134599. /**
  134600. * Launch the debugLayer.
  134601. * @param config Define the configuration of the inspector
  134602. * @return a promise fulfilled when the debug layer is visible
  134603. */
  134604. show(config?: IInspectorOptions): Promise<DebugLayer>;
  134605. }
  134606. }
  134607. declare module BABYLON {
  134608. /**
  134609. * Class containing static functions to help procedurally build meshes
  134610. */
  134611. export class BoxBuilder {
  134612. /**
  134613. * Creates a box mesh
  134614. * * The parameter `size` sets the size (float) of each box side (default 1)
  134615. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134616. * * 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)
  134617. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134621. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134622. * @param name defines the name of the mesh
  134623. * @param options defines the options used to create the mesh
  134624. * @param scene defines the hosting scene
  134625. * @returns the box mesh
  134626. */
  134627. static CreateBox(name: string, options: {
  134628. size?: number;
  134629. width?: number;
  134630. height?: number;
  134631. depth?: number;
  134632. faceUV?: Vector4[];
  134633. faceColors?: Color4[];
  134634. sideOrientation?: number;
  134635. frontUVs?: Vector4;
  134636. backUVs?: Vector4;
  134637. wrap?: boolean;
  134638. topBaseAt?: number;
  134639. bottomBaseAt?: number;
  134640. updatable?: boolean;
  134641. }, scene?: Nullable<Scene>): Mesh;
  134642. }
  134643. }
  134644. declare module BABYLON.Debug {
  134645. /**
  134646. * Used to show the physics impostor around the specific mesh
  134647. */
  134648. export class PhysicsViewer {
  134649. /** @hidden */
  134650. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  134651. /** @hidden */
  134652. protected _meshes: Array<Nullable<AbstractMesh>>;
  134653. /** @hidden */
  134654. protected _scene: Nullable<Scene>;
  134655. /** @hidden */
  134656. protected _numMeshes: number;
  134657. /** @hidden */
  134658. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  134659. private _renderFunction;
  134660. private _utilityLayer;
  134661. private _debugBoxMesh;
  134662. private _debugSphereMesh;
  134663. private _debugCylinderMesh;
  134664. private _debugMaterial;
  134665. private _debugMeshMeshes;
  134666. /**
  134667. * Creates a new PhysicsViewer
  134668. * @param scene defines the hosting scene
  134669. */
  134670. constructor(scene: Scene);
  134671. /** @hidden */
  134672. protected _updateDebugMeshes(): void;
  134673. /**
  134674. * Renders a specified physic impostor
  134675. * @param impostor defines the impostor to render
  134676. * @param targetMesh defines the mesh represented by the impostor
  134677. * @returns the new debug mesh used to render the impostor
  134678. */
  134679. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  134680. /**
  134681. * Hides a specified physic impostor
  134682. * @param impostor defines the impostor to hide
  134683. */
  134684. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  134685. private _getDebugMaterial;
  134686. private _getDebugBoxMesh;
  134687. private _getDebugSphereMesh;
  134688. private _getDebugCylinderMesh;
  134689. private _getDebugMeshMesh;
  134690. private _getDebugMesh;
  134691. /** Releases all resources */
  134692. dispose(): void;
  134693. }
  134694. }
  134695. declare module BABYLON {
  134696. /**
  134697. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134698. * in order to better appreciate the issue one might have.
  134699. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134700. */
  134701. export class RayHelper {
  134702. /**
  134703. * Defines the ray we are currently tryin to visualize.
  134704. */
  134705. ray: Nullable<Ray>;
  134706. private _renderPoints;
  134707. private _renderLine;
  134708. private _renderFunction;
  134709. private _scene;
  134710. private _onAfterRenderObserver;
  134711. private _onAfterStepObserver;
  134712. private _attachedToMesh;
  134713. private _meshSpaceDirection;
  134714. private _meshSpaceOrigin;
  134715. /**
  134716. * Helper function to create a colored helper in a scene in one line.
  134717. * @param ray Defines the ray we are currently tryin to visualize
  134718. * @param scene Defines the scene the ray is used in
  134719. * @param color Defines the color we want to see the ray in
  134720. * @returns The newly created ray helper.
  134721. */
  134722. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  134723. /**
  134724. * Instantiate a new ray helper.
  134725. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  134726. * in order to better appreciate the issue one might have.
  134727. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  134728. * @param ray Defines the ray we are currently tryin to visualize
  134729. */
  134730. constructor(ray: Ray);
  134731. /**
  134732. * Shows the ray we are willing to debug.
  134733. * @param scene Defines the scene the ray needs to be rendered in
  134734. * @param color Defines the color the ray needs to be rendered in
  134735. */
  134736. show(scene: Scene, color?: Color3): void;
  134737. /**
  134738. * Hides the ray we are debugging.
  134739. */
  134740. hide(): void;
  134741. private _render;
  134742. /**
  134743. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  134744. * @param mesh Defines the mesh we want the helper attached to
  134745. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  134746. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  134747. * @param length Defines the length of the ray
  134748. */
  134749. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  134750. /**
  134751. * Detach the ray helper from the mesh it has previously been attached to.
  134752. */
  134753. detachFromMesh(): void;
  134754. private _updateToMesh;
  134755. /**
  134756. * Dispose the helper and release its associated resources.
  134757. */
  134758. dispose(): void;
  134759. }
  134760. }
  134761. declare module BABYLON {
  134762. /**
  134763. * Defines the options associated with the creation of a SkeletonViewer.
  134764. */
  134765. export interface ISkeletonViewerOptions {
  134766. /** Should the system pause animations before building the Viewer? */
  134767. pauseAnimations: boolean;
  134768. /** Should the system return the skeleton to rest before building? */
  134769. returnToRest: boolean;
  134770. /** public Display Mode of the Viewer */
  134771. displayMode: number;
  134772. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134773. displayOptions: ISkeletonViewerDisplayOptions;
  134774. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  134775. computeBonesUsingShaders: boolean;
  134776. /** Flag ignore non weighted bones */
  134777. useAllBones: boolean;
  134778. }
  134779. /**
  134780. * Defines how to display the various bone meshes for the viewer.
  134781. */
  134782. export interface ISkeletonViewerDisplayOptions {
  134783. /** How far down to start tapering the bone spurs */
  134784. midStep?: number;
  134785. /** How big is the midStep? */
  134786. midStepFactor?: number;
  134787. /** Base for the Sphere Size */
  134788. sphereBaseSize?: number;
  134789. /** The ratio of the sphere to the longest bone in units */
  134790. sphereScaleUnit?: number;
  134791. /** Ratio for the Sphere Size */
  134792. sphereFactor?: number;
  134793. /** Whether a spur should attach its far end to the child bone position */
  134794. spurFollowsChild?: boolean;
  134795. /** Whether to show local axes or not */
  134796. showLocalAxes?: boolean;
  134797. /** Length of each local axis */
  134798. localAxesSize?: number;
  134799. }
  134800. /**
  134801. * Defines the constructor options for the BoneWeight Shader.
  134802. */
  134803. export interface IBoneWeightShaderOptions {
  134804. /** Skeleton to Map */
  134805. skeleton: Skeleton;
  134806. /** Colors for Uninfluenced bones */
  134807. colorBase?: Color3;
  134808. /** Colors for 0.0-0.25 Weight bones */
  134809. colorZero?: Color3;
  134810. /** Color for 0.25-0.5 Weight Influence */
  134811. colorQuarter?: Color3;
  134812. /** Color for 0.5-0.75 Weight Influence */
  134813. colorHalf?: Color3;
  134814. /** Color for 0.75-1 Weight Influence */
  134815. colorFull?: Color3;
  134816. /** Color for Zero Weight Influence */
  134817. targetBoneIndex?: number;
  134818. }
  134819. /**
  134820. * Simple structure of the gradient steps for the Color Map.
  134821. */
  134822. export interface ISkeletonMapShaderColorMapKnot {
  134823. /** Color of the Knot */
  134824. color: Color3;
  134825. /** Location of the Knot */
  134826. location: number;
  134827. }
  134828. /**
  134829. * Defines the constructor options for the SkeletonMap Shader.
  134830. */
  134831. export interface ISkeletonMapShaderOptions {
  134832. /** Skeleton to Map */
  134833. skeleton: Skeleton;
  134834. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  134835. colorMap?: ISkeletonMapShaderColorMapKnot[];
  134836. }
  134837. }
  134838. declare module BABYLON {
  134839. /**
  134840. * Class containing static functions to help procedurally build meshes
  134841. */
  134842. export class RibbonBuilder {
  134843. /**
  134844. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134845. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134846. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134847. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134848. * * 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
  134849. * * 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
  134850. * * 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
  134851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134853. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134854. * * 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
  134855. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134856. * * 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
  134857. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134859. * @param name defines the name of the mesh
  134860. * @param options defines the options used to create the mesh
  134861. * @param scene defines the hosting scene
  134862. * @returns the ribbon mesh
  134863. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134864. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134865. */
  134866. static CreateRibbon(name: string, options: {
  134867. pathArray: Vector3[][];
  134868. closeArray?: boolean;
  134869. closePath?: boolean;
  134870. offset?: number;
  134871. updatable?: boolean;
  134872. sideOrientation?: number;
  134873. frontUVs?: Vector4;
  134874. backUVs?: Vector4;
  134875. instance?: Mesh;
  134876. invertUV?: boolean;
  134877. uvs?: Vector2[];
  134878. colors?: Color4[];
  134879. }, scene?: Nullable<Scene>): Mesh;
  134880. }
  134881. }
  134882. declare module BABYLON {
  134883. /**
  134884. * Class containing static functions to help procedurally build meshes
  134885. */
  134886. export class ShapeBuilder {
  134887. /**
  134888. * 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.
  134889. * * 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.
  134890. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134891. * * 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.
  134892. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134893. * * 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
  134894. * * 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
  134895. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134898. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134900. * @param name defines the name of the mesh
  134901. * @param options defines the options used to create the mesh
  134902. * @param scene defines the hosting scene
  134903. * @returns the extruded shape mesh
  134904. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134906. */
  134907. static ExtrudeShape(name: string, options: {
  134908. shape: Vector3[];
  134909. path: Vector3[];
  134910. scale?: number;
  134911. rotation?: number;
  134912. cap?: number;
  134913. updatable?: boolean;
  134914. sideOrientation?: number;
  134915. frontUVs?: Vector4;
  134916. backUVs?: Vector4;
  134917. instance?: Mesh;
  134918. invertUV?: boolean;
  134919. }, scene?: Nullable<Scene>): Mesh;
  134920. /**
  134921. * Creates an custom extruded shape mesh.
  134922. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134923. * * 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.
  134924. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134925. * * 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
  134926. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134927. * * 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
  134928. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134929. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134930. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134931. * * 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
  134932. * * 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
  134933. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134936. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134938. * @param name defines the name of the mesh
  134939. * @param options defines the options used to create the mesh
  134940. * @param scene defines the hosting scene
  134941. * @returns the custom extruded shape mesh
  134942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134943. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134945. */
  134946. static ExtrudeShapeCustom(name: string, options: {
  134947. shape: Vector3[];
  134948. path: Vector3[];
  134949. scaleFunction?: any;
  134950. rotationFunction?: any;
  134951. ribbonCloseArray?: boolean;
  134952. ribbonClosePath?: boolean;
  134953. cap?: number;
  134954. updatable?: boolean;
  134955. sideOrientation?: number;
  134956. frontUVs?: Vector4;
  134957. backUVs?: Vector4;
  134958. instance?: Mesh;
  134959. invertUV?: boolean;
  134960. }, scene?: Nullable<Scene>): Mesh;
  134961. private static _ExtrudeShapeGeneric;
  134962. }
  134963. }
  134964. declare module BABYLON.Debug {
  134965. /**
  134966. * Class used to render a debug view of a given skeleton
  134967. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  134968. */
  134969. export class SkeletonViewer {
  134970. /** defines the skeleton to render */
  134971. skeleton: Skeleton;
  134972. /** defines the mesh attached to the skeleton */
  134973. mesh: AbstractMesh;
  134974. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  134975. autoUpdateBonesMatrices: boolean;
  134976. /** defines the rendering group id to use with the viewer */
  134977. renderingGroupId: number;
  134978. /** is the options for the viewer */
  134979. options: Partial<ISkeletonViewerOptions>;
  134980. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  134981. static readonly DISPLAY_LINES: number;
  134982. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  134983. static readonly DISPLAY_SPHERES: number;
  134984. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  134985. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  134986. /** public static method to create a BoneWeight Shader
  134987. * @param options The constructor options
  134988. * @param scene The scene that the shader is scoped to
  134989. * @returns The created ShaderMaterial
  134990. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  134991. */
  134992. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  134993. /** public static method to create a BoneWeight Shader
  134994. * @param options The constructor options
  134995. * @param scene The scene that the shader is scoped to
  134996. * @returns The created ShaderMaterial
  134997. */
  134998. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  134999. /** private static method to create a BoneWeight Shader
  135000. * @param size The size of the buffer to create (usually the bone count)
  135001. * @param colorMap The gradient data to generate
  135002. * @param scene The scene that the shader is scoped to
  135003. * @returns an Array of floats from the color gradient values
  135004. */
  135005. private static _CreateBoneMapColorBuffer;
  135006. /** If SkeletonViewer scene scope. */
  135007. private _scene;
  135008. /** Gets or sets the color used to render the skeleton */
  135009. color: Color3;
  135010. /** Array of the points of the skeleton fo the line view. */
  135011. private _debugLines;
  135012. /** The SkeletonViewers Mesh. */
  135013. private _debugMesh;
  135014. /** The local axes Meshes. */
  135015. private _localAxes;
  135016. /** If SkeletonViewer is enabled. */
  135017. private _isEnabled;
  135018. /** If SkeletonViewer is ready. */
  135019. private _ready;
  135020. /** SkeletonViewer render observable. */
  135021. private _obs;
  135022. /** The Utility Layer to render the gizmos in. */
  135023. private _utilityLayer;
  135024. private _boneIndices;
  135025. /** Gets the Scene. */
  135026. get scene(): Scene;
  135027. /** Gets the utilityLayer. */
  135028. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  135029. /** Checks Ready Status. */
  135030. get isReady(): Boolean;
  135031. /** Sets Ready Status. */
  135032. set ready(value: boolean);
  135033. /** Gets the debugMesh */
  135034. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  135035. /** Sets the debugMesh */
  135036. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  135037. /** Gets the displayMode */
  135038. get displayMode(): number;
  135039. /** Sets the displayMode */
  135040. set displayMode(value: number);
  135041. /**
  135042. * Creates a new SkeletonViewer
  135043. * @param skeleton defines the skeleton to render
  135044. * @param mesh defines the mesh attached to the skeleton
  135045. * @param scene defines the hosting scene
  135046. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  135047. * @param renderingGroupId defines the rendering group id to use with the viewer
  135048. * @param options All of the extra constructor options for the SkeletonViewer
  135049. */
  135050. constructor(
  135051. /** defines the skeleton to render */
  135052. skeleton: Skeleton,
  135053. /** defines the mesh attached to the skeleton */
  135054. mesh: AbstractMesh,
  135055. /** The Scene scope*/
  135056. scene: Scene,
  135057. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135058. autoUpdateBonesMatrices?: boolean,
  135059. /** defines the rendering group id to use with the viewer */
  135060. renderingGroupId?: number,
  135061. /** is the options for the viewer */
  135062. options?: Partial<ISkeletonViewerOptions>);
  135063. /** The Dynamic bindings for the update functions */
  135064. private _bindObs;
  135065. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  135066. update(): void;
  135067. /** Gets or sets a boolean indicating if the viewer is enabled */
  135068. set isEnabled(value: boolean);
  135069. get isEnabled(): boolean;
  135070. private _getBonePosition;
  135071. private _getLinesForBonesWithLength;
  135072. private _getLinesForBonesNoLength;
  135073. /** function to revert the mesh and scene back to the initial state. */
  135074. private _revert;
  135075. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  135076. private _getAbsoluteBindPoseToRef;
  135077. /** function to build and bind sphere joint points and spur bone representations. */
  135078. private _buildSpheresAndSpurs;
  135079. private _buildLocalAxes;
  135080. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  135081. private _displayLinesUpdate;
  135082. /** Changes the displayMode of the skeleton viewer
  135083. * @param mode The displayMode numerical value
  135084. */
  135085. changeDisplayMode(mode: number): void;
  135086. /** Sets a display option of the skeleton viewer
  135087. *
  135088. * | Option | Type | Default | Description |
  135089. * | ---------------- | ------- | ------- | ----------- |
  135090. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135091. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135092. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135093. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135094. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  135095. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  135096. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  135097. *
  135098. * @param option String of the option name
  135099. * @param value The numerical option value
  135100. */
  135101. changeDisplayOptions(option: string, value: number): void;
  135102. /** Release associated resources */
  135103. dispose(): void;
  135104. }
  135105. }
  135106. declare module BABYLON {
  135107. /**
  135108. * Enum for Device Types
  135109. */
  135110. export enum DeviceType {
  135111. /** Generic */
  135112. Generic = 0,
  135113. /** Keyboard */
  135114. Keyboard = 1,
  135115. /** Mouse */
  135116. Mouse = 2,
  135117. /** Touch Pointers */
  135118. Touch = 3,
  135119. /** PS4 Dual Shock */
  135120. DualShock = 4,
  135121. /** Xbox */
  135122. Xbox = 5,
  135123. /** Switch Controller */
  135124. Switch = 6
  135125. }
  135126. /**
  135127. * Enum for All Pointers (Touch/Mouse)
  135128. */
  135129. export enum PointerInput {
  135130. /** Horizontal Axis */
  135131. Horizontal = 0,
  135132. /** Vertical Axis */
  135133. Vertical = 1,
  135134. /** Left Click or Touch */
  135135. LeftClick = 2,
  135136. /** Middle Click */
  135137. MiddleClick = 3,
  135138. /** Right Click */
  135139. RightClick = 4,
  135140. /** Browser Back */
  135141. BrowserBack = 5,
  135142. /** Browser Forward */
  135143. BrowserForward = 6
  135144. }
  135145. /**
  135146. * Enum for Dual Shock Gamepad
  135147. */
  135148. export enum DualShockInput {
  135149. /** Cross */
  135150. Cross = 0,
  135151. /** Circle */
  135152. Circle = 1,
  135153. /** Square */
  135154. Square = 2,
  135155. /** Triangle */
  135156. Triangle = 3,
  135157. /** L1 */
  135158. L1 = 4,
  135159. /** R1 */
  135160. R1 = 5,
  135161. /** L2 */
  135162. L2 = 6,
  135163. /** R2 */
  135164. R2 = 7,
  135165. /** Share */
  135166. Share = 8,
  135167. /** Options */
  135168. Options = 9,
  135169. /** L3 */
  135170. L3 = 10,
  135171. /** R3 */
  135172. R3 = 11,
  135173. /** DPadUp */
  135174. DPadUp = 12,
  135175. /** DPadDown */
  135176. DPadDown = 13,
  135177. /** DPadLeft */
  135178. DPadLeft = 14,
  135179. /** DRight */
  135180. DPadRight = 15,
  135181. /** Home */
  135182. Home = 16,
  135183. /** TouchPad */
  135184. TouchPad = 17,
  135185. /** LStickXAxis */
  135186. LStickXAxis = 18,
  135187. /** LStickYAxis */
  135188. LStickYAxis = 19,
  135189. /** RStickXAxis */
  135190. RStickXAxis = 20,
  135191. /** RStickYAxis */
  135192. RStickYAxis = 21
  135193. }
  135194. /**
  135195. * Enum for Xbox Gamepad
  135196. */
  135197. export enum XboxInput {
  135198. /** A */
  135199. A = 0,
  135200. /** B */
  135201. B = 1,
  135202. /** X */
  135203. X = 2,
  135204. /** Y */
  135205. Y = 3,
  135206. /** LB */
  135207. LB = 4,
  135208. /** RB */
  135209. RB = 5,
  135210. /** LT */
  135211. LT = 6,
  135212. /** RT */
  135213. RT = 7,
  135214. /** Back */
  135215. Back = 8,
  135216. /** Start */
  135217. Start = 9,
  135218. /** LS */
  135219. LS = 10,
  135220. /** RS */
  135221. RS = 11,
  135222. /** DPadUp */
  135223. DPadUp = 12,
  135224. /** DPadDown */
  135225. DPadDown = 13,
  135226. /** DPadLeft */
  135227. DPadLeft = 14,
  135228. /** DRight */
  135229. DPadRight = 15,
  135230. /** Home */
  135231. Home = 16,
  135232. /** LStickXAxis */
  135233. LStickXAxis = 17,
  135234. /** LStickYAxis */
  135235. LStickYAxis = 18,
  135236. /** RStickXAxis */
  135237. RStickXAxis = 19,
  135238. /** RStickYAxis */
  135239. RStickYAxis = 20
  135240. }
  135241. /**
  135242. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  135243. */
  135244. export enum SwitchInput {
  135245. /** B */
  135246. B = 0,
  135247. /** A */
  135248. A = 1,
  135249. /** Y */
  135250. Y = 2,
  135251. /** X */
  135252. X = 3,
  135253. /** L */
  135254. L = 4,
  135255. /** R */
  135256. R = 5,
  135257. /** ZL */
  135258. ZL = 6,
  135259. /** ZR */
  135260. ZR = 7,
  135261. /** Minus */
  135262. Minus = 8,
  135263. /** Plus */
  135264. Plus = 9,
  135265. /** LS */
  135266. LS = 10,
  135267. /** RS */
  135268. RS = 11,
  135269. /** DPadUp */
  135270. DPadUp = 12,
  135271. /** DPadDown */
  135272. DPadDown = 13,
  135273. /** DPadLeft */
  135274. DPadLeft = 14,
  135275. /** DRight */
  135276. DPadRight = 15,
  135277. /** Home */
  135278. Home = 16,
  135279. /** Capture */
  135280. Capture = 17,
  135281. /** LStickXAxis */
  135282. LStickXAxis = 18,
  135283. /** LStickYAxis */
  135284. LStickYAxis = 19,
  135285. /** RStickXAxis */
  135286. RStickXAxis = 20,
  135287. /** RStickYAxis */
  135288. RStickYAxis = 21
  135289. }
  135290. }
  135291. declare module BABYLON {
  135292. /**
  135293. * This class will take all inputs from Keyboard, Pointer, and
  135294. * any Gamepads and provide a polling system that all devices
  135295. * will use. This class assumes that there will only be one
  135296. * pointer device and one keyboard.
  135297. */
  135298. export class DeviceInputSystem implements IDisposable {
  135299. /**
  135300. * Callback to be triggered when a device is connected
  135301. */
  135302. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135303. /**
  135304. * Callback to be triggered when a device is disconnected
  135305. */
  135306. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  135307. /**
  135308. * Callback to be triggered when event driven input is updated
  135309. */
  135310. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  135311. private _inputs;
  135312. private _gamepads;
  135313. private _keyboardActive;
  135314. private _pointerActive;
  135315. private _elementToAttachTo;
  135316. private _keyboardDownEvent;
  135317. private _keyboardUpEvent;
  135318. private _pointerMoveEvent;
  135319. private _pointerDownEvent;
  135320. private _pointerUpEvent;
  135321. private _gamepadConnectedEvent;
  135322. private _gamepadDisconnectedEvent;
  135323. private static _MAX_KEYCODES;
  135324. private static _MAX_POINTER_INPUTS;
  135325. private constructor();
  135326. /**
  135327. * Creates a new DeviceInputSystem instance
  135328. * @param engine Engine to pull input element from
  135329. * @returns The new instance
  135330. */
  135331. static Create(engine: Engine): DeviceInputSystem;
  135332. /**
  135333. * Checks for current device input value, given an id and input index
  135334. * @param deviceName Id of connected device
  135335. * @param inputIndex Index of device input
  135336. * @returns Current value of input
  135337. */
  135338. /**
  135339. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  135340. * @param deviceType Enum specifiying device type
  135341. * @param deviceSlot "Slot" or index that device is referenced in
  135342. * @param inputIndex Id of input to be checked
  135343. * @returns Current value of input
  135344. */
  135345. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  135346. /**
  135347. * Dispose of all the eventlisteners
  135348. */
  135349. dispose(): void;
  135350. /**
  135351. * Add device and inputs to device array
  135352. * @param deviceType Enum specifiying device type
  135353. * @param deviceSlot "Slot" or index that device is referenced in
  135354. * @param numberOfInputs Number of input entries to create for given device
  135355. */
  135356. private _registerDevice;
  135357. /**
  135358. * Given a specific device name, remove that device from the device map
  135359. * @param deviceType Enum specifiying device type
  135360. * @param deviceSlot "Slot" or index that device is referenced in
  135361. */
  135362. private _unregisterDevice;
  135363. /**
  135364. * Handle all actions that come from keyboard interaction
  135365. */
  135366. private _handleKeyActions;
  135367. /**
  135368. * Handle all actions that come from pointer interaction
  135369. */
  135370. private _handlePointerActions;
  135371. /**
  135372. * Handle all actions that come from gamepad interaction
  135373. */
  135374. private _handleGamepadActions;
  135375. /**
  135376. * Update all non-event based devices with each frame
  135377. * @param deviceType Enum specifiying device type
  135378. * @param deviceSlot "Slot" or index that device is referenced in
  135379. * @param inputIndex Id of input to be checked
  135380. */
  135381. private _updateDevice;
  135382. /**
  135383. * Gets DeviceType from the device name
  135384. * @param deviceName Name of Device from DeviceInputSystem
  135385. * @returns DeviceType enum value
  135386. */
  135387. private _getGamepadDeviceType;
  135388. }
  135389. }
  135390. declare module BABYLON {
  135391. /**
  135392. * Type to handle enforcement of inputs
  135393. */
  135394. 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;
  135395. }
  135396. declare module BABYLON {
  135397. /**
  135398. * Class that handles all input for a specific device
  135399. */
  135400. export class DeviceSource<T extends DeviceType> {
  135401. /** Type of device */
  135402. readonly deviceType: DeviceType;
  135403. /** "Slot" or index that device is referenced in */
  135404. readonly deviceSlot: number;
  135405. /**
  135406. * Observable to handle device input changes per device
  135407. */
  135408. readonly onInputChangedObservable: Observable<{
  135409. inputIndex: DeviceInput<T>;
  135410. previousState: Nullable<number>;
  135411. currentState: Nullable<number>;
  135412. }>;
  135413. private readonly _deviceInputSystem;
  135414. /**
  135415. * Default Constructor
  135416. * @param deviceInputSystem Reference to DeviceInputSystem
  135417. * @param deviceType Type of device
  135418. * @param deviceSlot "Slot" or index that device is referenced in
  135419. */
  135420. constructor(deviceInputSystem: DeviceInputSystem,
  135421. /** Type of device */
  135422. deviceType: DeviceType,
  135423. /** "Slot" or index that device is referenced in */
  135424. deviceSlot?: number);
  135425. /**
  135426. * Get input for specific input
  135427. * @param inputIndex index of specific input on device
  135428. * @returns Input value from DeviceInputSystem
  135429. */
  135430. getInput(inputIndex: DeviceInput<T>): number;
  135431. }
  135432. /**
  135433. * Class to keep track of devices
  135434. */
  135435. export class DeviceSourceManager implements IDisposable {
  135436. /**
  135437. * Observable to be triggered when before a device is connected
  135438. */
  135439. readonly onBeforeDeviceConnectedObservable: Observable<{
  135440. deviceType: DeviceType;
  135441. deviceSlot: number;
  135442. }>;
  135443. /**
  135444. * Observable to be triggered when before a device is disconnected
  135445. */
  135446. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  135447. deviceType: DeviceType;
  135448. deviceSlot: number;
  135449. }>;
  135450. /**
  135451. * Observable to be triggered when after a device is connected
  135452. */
  135453. readonly onAfterDeviceConnectedObservable: Observable<{
  135454. deviceType: DeviceType;
  135455. deviceSlot: number;
  135456. }>;
  135457. /**
  135458. * Observable to be triggered when after a device is disconnected
  135459. */
  135460. readonly onAfterDeviceDisconnectedObservable: Observable<{
  135461. deviceType: DeviceType;
  135462. deviceSlot: number;
  135463. }>;
  135464. private readonly _devices;
  135465. private readonly _firstDevice;
  135466. private readonly _deviceInputSystem;
  135467. /**
  135468. * Default Constructor
  135469. * @param engine engine to pull input element from
  135470. */
  135471. constructor(engine: Engine);
  135472. /**
  135473. * Gets a DeviceSource, given a type and slot
  135474. * @param deviceType Enum specifying device type
  135475. * @param deviceSlot "Slot" or index that device is referenced in
  135476. * @returns DeviceSource object
  135477. */
  135478. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  135479. /**
  135480. * Gets an array of DeviceSource objects for a given device type
  135481. * @param deviceType Enum specifying device type
  135482. * @returns Array of DeviceSource objects
  135483. */
  135484. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  135485. /**
  135486. * Dispose of DeviceInputSystem and other parts
  135487. */
  135488. dispose(): void;
  135489. /**
  135490. * Function to add device name to device list
  135491. * @param deviceType Enum specifying device type
  135492. * @param deviceSlot "Slot" or index that device is referenced in
  135493. */
  135494. private _addDevice;
  135495. /**
  135496. * Function to remove device name to device list
  135497. * @param deviceType Enum specifying device type
  135498. * @param deviceSlot "Slot" or index that device is referenced in
  135499. */
  135500. private _removeDevice;
  135501. /**
  135502. * Updates array storing first connected device of each type
  135503. * @param type Type of Device
  135504. */
  135505. private _updateFirstDevices;
  135506. }
  135507. }
  135508. declare module BABYLON {
  135509. /**
  135510. * Options to create the null engine
  135511. */
  135512. export class NullEngineOptions {
  135513. /**
  135514. * Render width (Default: 512)
  135515. */
  135516. renderWidth: number;
  135517. /**
  135518. * Render height (Default: 256)
  135519. */
  135520. renderHeight: number;
  135521. /**
  135522. * Texture size (Default: 512)
  135523. */
  135524. textureSize: number;
  135525. /**
  135526. * If delta time between frames should be constant
  135527. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135528. */
  135529. deterministicLockstep: boolean;
  135530. /**
  135531. * Maximum about of steps between frames (Default: 4)
  135532. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135533. */
  135534. lockstepMaxSteps: number;
  135535. /**
  135536. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  135537. */
  135538. useHighPrecisionMatrix?: boolean;
  135539. }
  135540. /**
  135541. * The null engine class provides support for headless version of babylon.js.
  135542. * This can be used in server side scenario or for testing purposes
  135543. */
  135544. export class NullEngine extends Engine {
  135545. private _options;
  135546. /**
  135547. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  135548. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135549. * @returns true if engine is in deterministic lock step mode
  135550. */
  135551. isDeterministicLockStep(): boolean;
  135552. /**
  135553. * Gets the max steps when engine is running in deterministic lock step
  135554. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135555. * @returns the max steps
  135556. */
  135557. getLockstepMaxSteps(): number;
  135558. /**
  135559. * Gets the current hardware scaling level.
  135560. * By default the hardware scaling level is computed from the window device ratio.
  135561. * 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.
  135562. * @returns a number indicating the current hardware scaling level
  135563. */
  135564. getHardwareScalingLevel(): number;
  135565. constructor(options?: NullEngineOptions);
  135566. /**
  135567. * Creates a vertex buffer
  135568. * @param vertices the data for the vertex buffer
  135569. * @returns the new WebGL static buffer
  135570. */
  135571. createVertexBuffer(vertices: FloatArray): DataBuffer;
  135572. /**
  135573. * Creates a new index buffer
  135574. * @param indices defines the content of the index buffer
  135575. * @param updatable defines if the index buffer must be updatable
  135576. * @returns a new webGL buffer
  135577. */
  135578. createIndexBuffer(indices: IndicesArray): DataBuffer;
  135579. /**
  135580. * Clear the current render buffer or the current render target (if any is set up)
  135581. * @param color defines the color to use
  135582. * @param backBuffer defines if the back buffer must be cleared
  135583. * @param depth defines if the depth buffer must be cleared
  135584. * @param stencil defines if the stencil buffer must be cleared
  135585. */
  135586. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  135587. /**
  135588. * Gets the current render width
  135589. * @param useScreen defines if screen size must be used (or the current render target if any)
  135590. * @returns a number defining the current render width
  135591. */
  135592. getRenderWidth(useScreen?: boolean): number;
  135593. /**
  135594. * Gets the current render height
  135595. * @param useScreen defines if screen size must be used (or the current render target if any)
  135596. * @returns a number defining the current render height
  135597. */
  135598. getRenderHeight(useScreen?: boolean): number;
  135599. /**
  135600. * Set the WebGL's viewport
  135601. * @param viewport defines the viewport element to be used
  135602. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  135603. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  135604. */
  135605. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  135606. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  135607. /**
  135608. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  135609. * @param pipelineContext defines the pipeline context to use
  135610. * @param uniformsNames defines the list of uniform names
  135611. * @returns an array of webGL uniform locations
  135612. */
  135613. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  135614. /**
  135615. * Gets the lsit of active attributes for a given webGL program
  135616. * @param pipelineContext defines the pipeline context to use
  135617. * @param attributesNames defines the list of attribute names to get
  135618. * @returns an array of indices indicating the offset of each attribute
  135619. */
  135620. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  135621. /**
  135622. * Binds an effect to the webGL context
  135623. * @param effect defines the effect to bind
  135624. */
  135625. bindSamplers(effect: Effect): void;
  135626. /**
  135627. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  135628. * @param effect defines the effect to activate
  135629. */
  135630. enableEffect(effect: Effect): void;
  135631. /**
  135632. * Set various states to the webGL context
  135633. * @param culling defines backface culling state
  135634. * @param zOffset defines the value to apply to zOffset (0 by default)
  135635. * @param force defines if states must be applied even if cache is up to date
  135636. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  135637. */
  135638. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  135639. /**
  135640. * Set the value of an uniform to an array of int32
  135641. * @param uniform defines the webGL uniform location where to store the value
  135642. * @param array defines the array of int32 to store
  135643. * @returns true if value was set
  135644. */
  135645. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135646. /**
  135647. * Set the value of an uniform to an array of int32 (stored as vec2)
  135648. * @param uniform defines the webGL uniform location where to store the value
  135649. * @param array defines the array of int32 to store
  135650. * @returns true if value was set
  135651. */
  135652. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135653. /**
  135654. * Set the value of an uniform to an array of int32 (stored as vec3)
  135655. * @param uniform defines the webGL uniform location where to store the value
  135656. * @param array defines the array of int32 to store
  135657. * @returns true if value was set
  135658. */
  135659. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135660. /**
  135661. * Set the value of an uniform to an array of int32 (stored as vec4)
  135662. * @param uniform defines the webGL uniform location where to store the value
  135663. * @param array defines the array of int32 to store
  135664. * @returns true if value was set
  135665. */
  135666. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  135667. /**
  135668. * Set the value of an uniform to an array of float32
  135669. * @param uniform defines the webGL uniform location where to store the value
  135670. * @param array defines the array of float32 to store
  135671. * @returns true if value was set
  135672. */
  135673. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135674. /**
  135675. * Set the value of an uniform to an array of float32 (stored as vec2)
  135676. * @param uniform defines the webGL uniform location where to store the value
  135677. * @param array defines the array of float32 to store
  135678. * @returns true if value was set
  135679. */
  135680. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135681. /**
  135682. * Set the value of an uniform to an array of float32 (stored as vec3)
  135683. * @param uniform defines the webGL uniform location where to store the value
  135684. * @param array defines the array of float32 to store
  135685. * @returns true if value was set
  135686. */
  135687. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135688. /**
  135689. * Set the value of an uniform to an array of float32 (stored as vec4)
  135690. * @param uniform defines the webGL uniform location where to store the value
  135691. * @param array defines the array of float32 to store
  135692. * @returns true if value was set
  135693. */
  135694. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  135695. /**
  135696. * Set the value of an uniform to an array of number
  135697. * @param uniform defines the webGL uniform location where to store the value
  135698. * @param array defines the array of number to store
  135699. * @returns true if value was set
  135700. */
  135701. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  135702. /**
  135703. * Set the value of an uniform to an array of number (stored as vec2)
  135704. * @param uniform defines the webGL uniform location where to store the value
  135705. * @param array defines the array of number to store
  135706. * @returns true if value was set
  135707. */
  135708. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  135709. /**
  135710. * Set the value of an uniform to an array of number (stored as vec3)
  135711. * @param uniform defines the webGL uniform location where to store the value
  135712. * @param array defines the array of number to store
  135713. * @returns true if value was set
  135714. */
  135715. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  135716. /**
  135717. * Set the value of an uniform to an array of number (stored as vec4)
  135718. * @param uniform defines the webGL uniform location where to store the value
  135719. * @param array defines the array of number to store
  135720. * @returns true if value was set
  135721. */
  135722. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  135723. /**
  135724. * Set the value of an uniform to an array of float32 (stored as matrices)
  135725. * @param uniform defines the webGL uniform location where to store the value
  135726. * @param matrices defines the array of float32 to store
  135727. * @returns true if value was set
  135728. */
  135729. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  135730. /**
  135731. * Set the value of an uniform to a matrix (3x3)
  135732. * @param uniform defines the webGL uniform location where to store the value
  135733. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  135734. * @returns true if value was set
  135735. */
  135736. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135737. /**
  135738. * Set the value of an uniform to a matrix (2x2)
  135739. * @param uniform defines the webGL uniform location where to store the value
  135740. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  135741. * @returns true if value was set
  135742. */
  135743. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  135744. /**
  135745. * Set the value of an uniform to a number (float)
  135746. * @param uniform defines the webGL uniform location where to store the value
  135747. * @param value defines the float number to store
  135748. * @returns true if value was set
  135749. */
  135750. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  135751. /**
  135752. * Set the value of an uniform to a vec2
  135753. * @param uniform defines the webGL uniform location where to store the value
  135754. * @param x defines the 1st component of the value
  135755. * @param y defines the 2nd component of the value
  135756. * @returns true if value was set
  135757. */
  135758. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  135759. /**
  135760. * Set the value of an uniform to a vec3
  135761. * @param uniform defines the webGL uniform location where to store the value
  135762. * @param x defines the 1st component of the value
  135763. * @param y defines the 2nd component of the value
  135764. * @param z defines the 3rd component of the value
  135765. * @returns true if value was set
  135766. */
  135767. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  135768. /**
  135769. * Set the value of an uniform to a boolean
  135770. * @param uniform defines the webGL uniform location where to store the value
  135771. * @param bool defines the boolean to store
  135772. * @returns true if value was set
  135773. */
  135774. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  135775. /**
  135776. * Set the value of an uniform to a vec4
  135777. * @param uniform defines the webGL uniform location where to store the value
  135778. * @param x defines the 1st component of the value
  135779. * @param y defines the 2nd component of the value
  135780. * @param z defines the 3rd component of the value
  135781. * @param w defines the 4th component of the value
  135782. * @returns true if value was set
  135783. */
  135784. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  135785. /**
  135786. * Sets the current alpha mode
  135787. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  135788. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  135789. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  135790. */
  135791. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  135792. /**
  135793. * Bind webGl buffers directly to the webGL context
  135794. * @param vertexBuffers defines the vertex buffer to bind
  135795. * @param indexBuffer defines the index buffer to bind
  135796. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  135797. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  135798. * @param effect defines the effect associated with the vertex buffer
  135799. */
  135800. bindBuffers(vertexBuffers: {
  135801. [key: string]: VertexBuffer;
  135802. }, indexBuffer: DataBuffer, effect: Effect): void;
  135803. /**
  135804. * Force the entire cache to be cleared
  135805. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  135806. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  135807. */
  135808. wipeCaches(bruteForce?: boolean): void;
  135809. /**
  135810. * Send a draw order
  135811. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  135812. * @param indexStart defines the starting index
  135813. * @param indexCount defines the number of index to draw
  135814. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135815. */
  135816. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  135817. /**
  135818. * Draw a list of indexed primitives
  135819. * @param fillMode defines the primitive to use
  135820. * @param indexStart defines the starting index
  135821. * @param indexCount defines the number of index to draw
  135822. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135823. */
  135824. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  135825. /**
  135826. * Draw a list of unindexed primitives
  135827. * @param fillMode defines the primitive to use
  135828. * @param verticesStart defines the index of first vertex to draw
  135829. * @param verticesCount defines the count of vertices to draw
  135830. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  135831. */
  135832. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  135833. /** @hidden */
  135834. _createTexture(): WebGLTexture;
  135835. /** @hidden */
  135836. _releaseTexture(texture: InternalTexture): void;
  135837. /**
  135838. * Usually called from Texture.ts.
  135839. * Passed information to create a WebGLTexture
  135840. * @param urlArg defines a value which contains one of the following:
  135841. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  135842. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  135843. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  135844. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  135845. * @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)
  135846. * @param scene needed for loading to the correct scene
  135847. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  135848. * @param onLoad optional callback to be called upon successful completion
  135849. * @param onError optional callback to be called upon failure
  135850. * @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
  135851. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  135852. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  135853. * @param forcedExtension defines the extension to use to pick the right loader
  135854. * @param mimeType defines an optional mime type
  135855. * @returns a InternalTexture for assignment back into BABYLON.Texture
  135856. */
  135857. 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;
  135858. /**
  135859. * Creates a new render target texture
  135860. * @param size defines the size of the texture
  135861. * @param options defines the options used to create the texture
  135862. * @returns a new render target texture stored in an InternalTexture
  135863. */
  135864. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  135865. /**
  135866. * Update the sampling mode of a given texture
  135867. * @param samplingMode defines the required sampling mode
  135868. * @param texture defines the texture to update
  135869. */
  135870. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  135871. /**
  135872. * Binds the frame buffer to the specified texture.
  135873. * @param texture The texture to render to or null for the default canvas
  135874. * @param faceIndex The face of the texture to render to in case of cube texture
  135875. * @param requiredWidth The width of the target to render to
  135876. * @param requiredHeight The height of the target to render to
  135877. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  135878. * @param lodLevel defines le lod level to bind to the frame buffer
  135879. */
  135880. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  135881. /**
  135882. * Unbind the current render target texture from the webGL context
  135883. * @param texture defines the render target texture to unbind
  135884. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  135885. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  135886. */
  135887. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  135888. /**
  135889. * Creates a dynamic vertex buffer
  135890. * @param vertices the data for the dynamic vertex buffer
  135891. * @returns the new WebGL dynamic buffer
  135892. */
  135893. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  135894. /**
  135895. * Update the content of a dynamic texture
  135896. * @param texture defines the texture to update
  135897. * @param canvas defines the canvas containing the source
  135898. * @param invertY defines if data must be stored with Y axis inverted
  135899. * @param premulAlpha defines if alpha is stored as premultiplied
  135900. * @param format defines the format of the data
  135901. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  135902. */
  135903. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  135904. /**
  135905. * Gets a boolean indicating if all created effects are ready
  135906. * @returns true if all effects are ready
  135907. */
  135908. areAllEffectsReady(): boolean;
  135909. /**
  135910. * @hidden
  135911. * Get the current error code of the webGL context
  135912. * @returns the error code
  135913. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  135914. */
  135915. getError(): number;
  135916. /** @hidden */
  135917. _getUnpackAlignement(): number;
  135918. /** @hidden */
  135919. _unpackFlipY(value: boolean): void;
  135920. /**
  135921. * Update a dynamic index buffer
  135922. * @param indexBuffer defines the target index buffer
  135923. * @param indices defines the data to update
  135924. * @param offset defines the offset in the target index buffer where update should start
  135925. */
  135926. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  135927. /**
  135928. * Updates a dynamic vertex buffer.
  135929. * @param vertexBuffer the vertex buffer to update
  135930. * @param vertices the data used to update the vertex buffer
  135931. * @param byteOffset the byte offset of the data (optional)
  135932. * @param byteLength the byte length of the data (optional)
  135933. */
  135934. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  135935. /** @hidden */
  135936. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  135937. /** @hidden */
  135938. _bindTexture(channel: number, texture: InternalTexture): void;
  135939. protected _deleteBuffer(buffer: WebGLBuffer): void;
  135940. /**
  135941. * 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
  135942. */
  135943. releaseEffects(): void;
  135944. displayLoadingUI(): void;
  135945. hideLoadingUI(): void;
  135946. /** @hidden */
  135947. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135948. /** @hidden */
  135949. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135950. /** @hidden */
  135951. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  135952. /** @hidden */
  135953. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  135954. }
  135955. }
  135956. declare module BABYLON {
  135957. /**
  135958. * @hidden
  135959. **/
  135960. export class _TimeToken {
  135961. _startTimeQuery: Nullable<WebGLQuery>;
  135962. _endTimeQuery: Nullable<WebGLQuery>;
  135963. _timeElapsedQuery: Nullable<WebGLQuery>;
  135964. _timeElapsedQueryEnded: boolean;
  135965. }
  135966. }
  135967. declare module BABYLON {
  135968. /** @hidden */
  135969. export class _OcclusionDataStorage {
  135970. /** @hidden */
  135971. occlusionInternalRetryCounter: number;
  135972. /** @hidden */
  135973. isOcclusionQueryInProgress: boolean;
  135974. /** @hidden */
  135975. isOccluded: boolean;
  135976. /** @hidden */
  135977. occlusionRetryCount: number;
  135978. /** @hidden */
  135979. occlusionType: number;
  135980. /** @hidden */
  135981. occlusionQueryAlgorithmType: number;
  135982. }
  135983. interface Engine {
  135984. /**
  135985. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  135986. * @return the new query
  135987. */
  135988. createQuery(): WebGLQuery;
  135989. /**
  135990. * Delete and release a webGL query
  135991. * @param query defines the query to delete
  135992. * @return the current engine
  135993. */
  135994. deleteQuery(query: WebGLQuery): Engine;
  135995. /**
  135996. * Check if a given query has resolved and got its value
  135997. * @param query defines the query to check
  135998. * @returns true if the query got its value
  135999. */
  136000. isQueryResultAvailable(query: WebGLQuery): boolean;
  136001. /**
  136002. * Gets the value of a given query
  136003. * @param query defines the query to check
  136004. * @returns the value of the query
  136005. */
  136006. getQueryResult(query: WebGLQuery): number;
  136007. /**
  136008. * Initiates an occlusion query
  136009. * @param algorithmType defines the algorithm to use
  136010. * @param query defines the query to use
  136011. * @returns the current engine
  136012. * @see https://doc.babylonjs.com/features/occlusionquery
  136013. */
  136014. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  136015. /**
  136016. * Ends an occlusion query
  136017. * @see https://doc.babylonjs.com/features/occlusionquery
  136018. * @param algorithmType defines the algorithm to use
  136019. * @returns the current engine
  136020. */
  136021. endOcclusionQuery(algorithmType: number): Engine;
  136022. /**
  136023. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  136024. * Please note that only one query can be issued at a time
  136025. * @returns a time token used to track the time span
  136026. */
  136027. startTimeQuery(): Nullable<_TimeToken>;
  136028. /**
  136029. * Ends a time query
  136030. * @param token defines the token used to measure the time span
  136031. * @returns the time spent (in ns)
  136032. */
  136033. endTimeQuery(token: _TimeToken): int;
  136034. /** @hidden */
  136035. _currentNonTimestampToken: Nullable<_TimeToken>;
  136036. /** @hidden */
  136037. _createTimeQuery(): WebGLQuery;
  136038. /** @hidden */
  136039. _deleteTimeQuery(query: WebGLQuery): void;
  136040. /** @hidden */
  136041. _getGlAlgorithmType(algorithmType: number): number;
  136042. /** @hidden */
  136043. _getTimeQueryResult(query: WebGLQuery): any;
  136044. /** @hidden */
  136045. _getTimeQueryAvailability(query: WebGLQuery): any;
  136046. }
  136047. interface AbstractMesh {
  136048. /**
  136049. * Backing filed
  136050. * @hidden
  136051. */
  136052. __occlusionDataStorage: _OcclusionDataStorage;
  136053. /**
  136054. * Access property
  136055. * @hidden
  136056. */
  136057. _occlusionDataStorage: _OcclusionDataStorage;
  136058. /**
  136059. * 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.
  136060. * The default value is -1 which means don't break the query and wait till the result
  136061. * @see https://doc.babylonjs.com/features/occlusionquery
  136062. */
  136063. occlusionRetryCount: number;
  136064. /**
  136065. * 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:
  136066. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  136067. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  136068. * * 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.
  136069. * @see https://doc.babylonjs.com/features/occlusionquery
  136070. */
  136071. occlusionType: number;
  136072. /**
  136073. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  136074. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  136075. * * 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.
  136076. * @see https://doc.babylonjs.com/features/occlusionquery
  136077. */
  136078. occlusionQueryAlgorithmType: number;
  136079. /**
  136080. * 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
  136081. * @see https://doc.babylonjs.com/features/occlusionquery
  136082. */
  136083. isOccluded: boolean;
  136084. /**
  136085. * Flag to check the progress status of the query
  136086. * @see https://doc.babylonjs.com/features/occlusionquery
  136087. */
  136088. isOcclusionQueryInProgress: boolean;
  136089. }
  136090. }
  136091. declare module BABYLON {
  136092. /** @hidden */
  136093. export var _forceTransformFeedbackToBundle: boolean;
  136094. interface Engine {
  136095. /**
  136096. * Creates a webGL transform feedback object
  136097. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  136098. * @returns the webGL transform feedback object
  136099. */
  136100. createTransformFeedback(): WebGLTransformFeedback;
  136101. /**
  136102. * Delete a webGL transform feedback object
  136103. * @param value defines the webGL transform feedback object to delete
  136104. */
  136105. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  136106. /**
  136107. * Bind a webGL transform feedback object to the webgl context
  136108. * @param value defines the webGL transform feedback object to bind
  136109. */
  136110. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  136111. /**
  136112. * Begins a transform feedback operation
  136113. * @param usePoints defines if points or triangles must be used
  136114. */
  136115. beginTransformFeedback(usePoints: boolean): void;
  136116. /**
  136117. * Ends a transform feedback operation
  136118. */
  136119. endTransformFeedback(): void;
  136120. /**
  136121. * Specify the varyings to use with transform feedback
  136122. * @param program defines the associated webGL program
  136123. * @param value defines the list of strings representing the varying names
  136124. */
  136125. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  136126. /**
  136127. * Bind a webGL buffer for a transform feedback operation
  136128. * @param value defines the webGL buffer to bind
  136129. */
  136130. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  136131. }
  136132. }
  136133. declare module BABYLON {
  136134. /**
  136135. * Class used to define an additional view for the engine
  136136. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136137. */
  136138. export class EngineView {
  136139. /** Defines the canvas where to render the view */
  136140. target: HTMLCanvasElement;
  136141. /** Defines an optional camera used to render the view (will use active camera else) */
  136142. camera?: Camera;
  136143. }
  136144. interface Engine {
  136145. /**
  136146. * Gets or sets the HTML element to use for attaching events
  136147. */
  136148. inputElement: Nullable<HTMLElement>;
  136149. /**
  136150. * Gets the current engine view
  136151. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136152. */
  136153. activeView: Nullable<EngineView>;
  136154. /** Gets or sets the list of views */
  136155. views: EngineView[];
  136156. /**
  136157. * Register a new child canvas
  136158. * @param canvas defines the canvas to register
  136159. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  136160. * @returns the associated view
  136161. */
  136162. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  136163. /**
  136164. * Remove a registered child canvas
  136165. * @param canvas defines the canvas to remove
  136166. * @returns the current engine
  136167. */
  136168. unRegisterView(canvas: HTMLCanvasElement): Engine;
  136169. }
  136170. }
  136171. declare module BABYLON {
  136172. interface Engine {
  136173. /** @hidden */
  136174. _excludedCompressedTextures: string[];
  136175. /** @hidden */
  136176. _textureFormatInUse: string;
  136177. /**
  136178. * Gets the list of texture formats supported
  136179. */
  136180. readonly texturesSupported: Array<string>;
  136181. /**
  136182. * Gets the texture format in use
  136183. */
  136184. readonly textureFormatInUse: Nullable<string>;
  136185. /**
  136186. * Set the compressed texture extensions or file names to skip.
  136187. *
  136188. * @param skippedFiles defines the list of those texture files you want to skip
  136189. * Example: [".dds", ".env", "myfile.png"]
  136190. */
  136191. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  136192. /**
  136193. * Set the compressed texture format to use, based on the formats you have, and the formats
  136194. * supported by the hardware / browser.
  136195. *
  136196. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  136197. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  136198. * to API arguments needed to compressed textures. This puts the burden on the container
  136199. * generator to house the arcane code for determining these for current & future formats.
  136200. *
  136201. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136202. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136203. *
  136204. * Note: The result of this call is not taken into account when a texture is base64.
  136205. *
  136206. * @param formatsAvailable defines the list of those format families you have created
  136207. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  136208. *
  136209. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  136210. * @returns The extension selected.
  136211. */
  136212. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  136213. }
  136214. }
  136215. declare module BABYLON {
  136216. /** @hidden */
  136217. export var rgbdEncodePixelShader: {
  136218. name: string;
  136219. shader: string;
  136220. };
  136221. }
  136222. declare module BABYLON {
  136223. /**
  136224. * Raw texture data and descriptor sufficient for WebGL texture upload
  136225. */
  136226. export interface EnvironmentTextureInfo {
  136227. /**
  136228. * Version of the environment map
  136229. */
  136230. version: number;
  136231. /**
  136232. * Width of image
  136233. */
  136234. width: number;
  136235. /**
  136236. * Irradiance information stored in the file.
  136237. */
  136238. irradiance: any;
  136239. /**
  136240. * Specular information stored in the file.
  136241. */
  136242. specular: any;
  136243. }
  136244. /**
  136245. * Defines One Image in the file. It requires only the position in the file
  136246. * as well as the length.
  136247. */
  136248. interface BufferImageData {
  136249. /**
  136250. * Length of the image data.
  136251. */
  136252. length: number;
  136253. /**
  136254. * Position of the data from the null terminator delimiting the end of the JSON.
  136255. */
  136256. position: number;
  136257. }
  136258. /**
  136259. * Defines the specular data enclosed in the file.
  136260. * This corresponds to the version 1 of the data.
  136261. */
  136262. export interface EnvironmentTextureSpecularInfoV1 {
  136263. /**
  136264. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  136265. */
  136266. specularDataPosition?: number;
  136267. /**
  136268. * This contains all the images data needed to reconstruct the cubemap.
  136269. */
  136270. mipmaps: Array<BufferImageData>;
  136271. /**
  136272. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  136273. */
  136274. lodGenerationScale: number;
  136275. }
  136276. /**
  136277. * Sets of helpers addressing the serialization and deserialization of environment texture
  136278. * stored in a BabylonJS env file.
  136279. * Those files are usually stored as .env files.
  136280. */
  136281. export class EnvironmentTextureTools {
  136282. /**
  136283. * Magic number identifying the env file.
  136284. */
  136285. private static _MagicBytes;
  136286. /**
  136287. * Gets the environment info from an env file.
  136288. * @param data The array buffer containing the .env bytes.
  136289. * @returns the environment file info (the json header) if successfully parsed.
  136290. */
  136291. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  136292. /**
  136293. * Creates an environment texture from a loaded cube texture.
  136294. * @param texture defines the cube texture to convert in env file
  136295. * @return a promise containing the environment data if succesfull.
  136296. */
  136297. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  136298. /**
  136299. * Creates a JSON representation of the spherical data.
  136300. * @param texture defines the texture containing the polynomials
  136301. * @return the JSON representation of the spherical info
  136302. */
  136303. private static _CreateEnvTextureIrradiance;
  136304. /**
  136305. * Creates the ArrayBufferViews used for initializing environment texture image data.
  136306. * @param data the image data
  136307. * @param info parameters that determine what views will be created for accessing the underlying buffer
  136308. * @return the views described by info providing access to the underlying buffer
  136309. */
  136310. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  136311. /**
  136312. * Uploads the texture info contained in the env file to the GPU.
  136313. * @param texture defines the internal texture to upload to
  136314. * @param data defines the data to load
  136315. * @param info defines the texture info retrieved through the GetEnvInfo method
  136316. * @returns a promise
  136317. */
  136318. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  136319. private static _OnImageReadyAsync;
  136320. /**
  136321. * Uploads the levels of image data to the GPU.
  136322. * @param texture defines the internal texture to upload to
  136323. * @param imageData defines the array buffer views of image data [mipmap][face]
  136324. * @returns a promise
  136325. */
  136326. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  136327. /**
  136328. * Uploads spherical polynomials information to the texture.
  136329. * @param texture defines the texture we are trying to upload the information to
  136330. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  136331. */
  136332. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  136333. /** @hidden */
  136334. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  136335. }
  136336. }
  136337. declare module BABYLON {
  136338. /**
  136339. * Class used to inline functions in shader code
  136340. */
  136341. export class ShaderCodeInliner {
  136342. private static readonly _RegexpFindFunctionNameAndType;
  136343. private _sourceCode;
  136344. private _functionDescr;
  136345. private _numMaxIterations;
  136346. /** Gets or sets the token used to mark the functions to inline */
  136347. inlineToken: string;
  136348. /** Gets or sets the debug mode */
  136349. debug: boolean;
  136350. /** Gets the code after the inlining process */
  136351. get code(): string;
  136352. /**
  136353. * Initializes the inliner
  136354. * @param sourceCode shader code source to inline
  136355. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  136356. */
  136357. constructor(sourceCode: string, numMaxIterations?: number);
  136358. /**
  136359. * Start the processing of the shader code
  136360. */
  136361. processCode(): void;
  136362. private _collectFunctions;
  136363. private _processInlining;
  136364. private _extractBetweenMarkers;
  136365. private _skipWhitespaces;
  136366. private _removeComments;
  136367. private _replaceFunctionCallsByCode;
  136368. private _findBackward;
  136369. private _escapeRegExp;
  136370. private _replaceNames;
  136371. }
  136372. }
  136373. declare module BABYLON {
  136374. /**
  136375. * Container for accessors for natively-stored mesh data buffers.
  136376. */
  136377. class NativeDataBuffer extends DataBuffer {
  136378. /**
  136379. * Accessor value used to identify/retrieve a natively-stored index buffer.
  136380. */
  136381. nativeIndexBuffer?: any;
  136382. /**
  136383. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  136384. */
  136385. nativeVertexBuffer?: any;
  136386. }
  136387. /** @hidden */
  136388. class NativeTexture extends InternalTexture {
  136389. getInternalTexture(): InternalTexture;
  136390. getViewCount(): number;
  136391. }
  136392. /** @hidden */
  136393. export class NativeEngine extends Engine {
  136394. private readonly _native;
  136395. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  136396. private readonly INVALID_HANDLE;
  136397. private _boundBuffersVertexArray;
  136398. private _currentDepthTest;
  136399. getHardwareScalingLevel(): number;
  136400. constructor();
  136401. dispose(): void;
  136402. /**
  136403. * Can be used to override the current requestAnimationFrame requester.
  136404. * @hidden
  136405. */
  136406. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  136407. /**
  136408. * Override default engine behavior.
  136409. * @param color
  136410. * @param backBuffer
  136411. * @param depth
  136412. * @param stencil
  136413. */
  136414. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  136415. /**
  136416. * Gets host document
  136417. * @returns the host document object
  136418. */
  136419. getHostDocument(): Nullable<Document>;
  136420. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136421. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  136422. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  136423. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  136424. [key: string]: VertexBuffer;
  136425. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136426. bindBuffers(vertexBuffers: {
  136427. [key: string]: VertexBuffer;
  136428. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  136429. recordVertexArrayObject(vertexBuffers: {
  136430. [key: string]: VertexBuffer;
  136431. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  136432. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136433. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  136434. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136435. /**
  136436. * Draw a list of indexed primitives
  136437. * @param fillMode defines the primitive to use
  136438. * @param indexStart defines the starting index
  136439. * @param indexCount defines the number of index to draw
  136440. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136441. */
  136442. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136443. /**
  136444. * Draw a list of unindexed primitives
  136445. * @param fillMode defines the primitive to use
  136446. * @param verticesStart defines the index of first vertex to draw
  136447. * @param verticesCount defines the count of vertices to draw
  136448. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136449. */
  136450. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136451. createPipelineContext(): IPipelineContext;
  136452. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  136453. /** @hidden */
  136454. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  136455. /** @hidden */
  136456. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  136457. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136458. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  136459. protected _setProgram(program: WebGLProgram): void;
  136460. _releaseEffect(effect: Effect): void;
  136461. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  136462. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  136463. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  136464. bindSamplers(effect: Effect): void;
  136465. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  136466. getRenderWidth(useScreen?: boolean): number;
  136467. getRenderHeight(useScreen?: boolean): number;
  136468. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  136469. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136470. /**
  136471. * Set the z offset to apply to current rendering
  136472. * @param value defines the offset to apply
  136473. */
  136474. setZOffset(value: number): void;
  136475. /**
  136476. * Gets the current value of the zOffset
  136477. * @returns the current zOffset state
  136478. */
  136479. getZOffset(): number;
  136480. /**
  136481. * Enable or disable depth buffering
  136482. * @param enable defines the state to set
  136483. */
  136484. setDepthBuffer(enable: boolean): void;
  136485. /**
  136486. * Gets a boolean indicating if depth writing is enabled
  136487. * @returns the current depth writing state
  136488. */
  136489. getDepthWrite(): boolean;
  136490. setDepthFunctionToGreater(): void;
  136491. setDepthFunctionToGreaterOrEqual(): void;
  136492. setDepthFunctionToLess(): void;
  136493. setDepthFunctionToLessOrEqual(): void;
  136494. /**
  136495. * Enable or disable depth writing
  136496. * @param enable defines the state to set
  136497. */
  136498. setDepthWrite(enable: boolean): void;
  136499. /**
  136500. * Enable or disable color writing
  136501. * @param enable defines the state to set
  136502. */
  136503. setColorWrite(enable: boolean): void;
  136504. /**
  136505. * Gets a boolean indicating if color writing is enabled
  136506. * @returns the current color writing state
  136507. */
  136508. getColorWrite(): boolean;
  136509. /**
  136510. * Sets alpha constants used by some alpha blending modes
  136511. * @param r defines the red component
  136512. * @param g defines the green component
  136513. * @param b defines the blue component
  136514. * @param a defines the alpha component
  136515. */
  136516. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  136517. /**
  136518. * Sets the current alpha mode
  136519. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  136520. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136521. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136522. */
  136523. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136524. /**
  136525. * Gets the current alpha mode
  136526. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136527. * @returns the current alpha mode
  136528. */
  136529. getAlphaMode(): number;
  136530. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  136531. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136532. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136533. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136534. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136535. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136536. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136537. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136538. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136539. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136540. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136541. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136542. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136543. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136544. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136545. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136546. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136547. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136548. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136549. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136550. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  136551. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  136552. wipeCaches(bruteForce?: boolean): void;
  136553. _createTexture(): WebGLTexture;
  136554. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  136555. /**
  136556. * Update the content of a dynamic texture
  136557. * @param texture defines the texture to update
  136558. * @param canvas defines the canvas containing the source
  136559. * @param invertY defines if data must be stored with Y axis inverted
  136560. * @param premulAlpha defines if alpha is stored as premultiplied
  136561. * @param format defines the format of the data
  136562. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136563. */
  136564. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136565. /**
  136566. * Usually called from Texture.ts.
  136567. * Passed information to create a WebGLTexture
  136568. * @param url defines a value which contains one of the following:
  136569. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136570. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136571. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136572. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136573. * @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)
  136574. * @param scene needed for loading to the correct scene
  136575. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136576. * @param onLoad optional callback to be called upon successful completion
  136577. * @param onError optional callback to be called upon failure
  136578. * @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
  136579. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136580. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136581. * @param forcedExtension defines the extension to use to pick the right loader
  136582. * @param mimeType defines an optional mime type
  136583. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136584. */
  136585. 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;
  136586. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  136587. _releaseFramebufferObjects(texture: InternalTexture): void;
  136588. /**
  136589. * Creates a cube texture
  136590. * @param rootUrl defines the url where the files to load is located
  136591. * @param scene defines the current scene
  136592. * @param files defines the list of files to load (1 per face)
  136593. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  136594. * @param onLoad defines an optional callback raised when the texture is loaded
  136595. * @param onError defines an optional callback raised if there is an issue to load the texture
  136596. * @param format defines the format of the data
  136597. * @param forcedExtension defines the extension to use to pick the right loader
  136598. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  136599. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  136600. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  136601. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  136602. * @returns the cube texture as an InternalTexture
  136603. */
  136604. 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;
  136605. createRenderTargetTexture(size: number | {
  136606. width: number;
  136607. height: number;
  136608. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  136609. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136610. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136611. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136612. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  136613. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  136614. /**
  136615. * Updates a dynamic vertex buffer.
  136616. * @param vertexBuffer the vertex buffer to update
  136617. * @param data the data used to update the vertex buffer
  136618. * @param byteOffset the byte offset of the data (optional)
  136619. * @param byteLength the byte length of the data (optional)
  136620. */
  136621. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  136622. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  136623. private _updateAnisotropicLevel;
  136624. private _getAddressMode;
  136625. /** @hidden */
  136626. _bindTexture(channel: number, texture: InternalTexture): void;
  136627. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  136628. releaseEffects(): void;
  136629. /** @hidden */
  136630. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136631. /** @hidden */
  136632. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136633. /** @hidden */
  136634. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136635. /** @hidden */
  136636. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136637. private _getNativeSamplingMode;
  136638. private _getNativeTextureFormat;
  136639. private _getNativeAlphaMode;
  136640. private _getNativeAttribType;
  136641. }
  136642. }
  136643. declare module BABYLON {
  136644. /**
  136645. * Gather the list of clipboard event types as constants.
  136646. */
  136647. export class ClipboardEventTypes {
  136648. /**
  136649. * The clipboard event is fired when a copy command is active (pressed).
  136650. */
  136651. static readonly COPY: number;
  136652. /**
  136653. * The clipboard event is fired when a cut command is active (pressed).
  136654. */
  136655. static readonly CUT: number;
  136656. /**
  136657. * The clipboard event is fired when a paste command is active (pressed).
  136658. */
  136659. static readonly PASTE: number;
  136660. }
  136661. /**
  136662. * This class is used to store clipboard related info for the onClipboardObservable event.
  136663. */
  136664. export class ClipboardInfo {
  136665. /**
  136666. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136667. */
  136668. type: number;
  136669. /**
  136670. * Defines the related dom event
  136671. */
  136672. event: ClipboardEvent;
  136673. /**
  136674. *Creates an instance of ClipboardInfo.
  136675. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  136676. * @param event Defines the related dom event
  136677. */
  136678. constructor(
  136679. /**
  136680. * Defines the type of event (BABYLON.ClipboardEventTypes)
  136681. */
  136682. type: number,
  136683. /**
  136684. * Defines the related dom event
  136685. */
  136686. event: ClipboardEvent);
  136687. /**
  136688. * Get the clipboard event's type from the keycode.
  136689. * @param keyCode Defines the keyCode for the current keyboard event.
  136690. * @return {number}
  136691. */
  136692. static GetTypeFromCharacter(keyCode: number): number;
  136693. }
  136694. }
  136695. declare module BABYLON {
  136696. /**
  136697. * Google Daydream controller
  136698. */
  136699. export class DaydreamController extends WebVRController {
  136700. /**
  136701. * Base Url for the controller model.
  136702. */
  136703. static MODEL_BASE_URL: string;
  136704. /**
  136705. * File name for the controller model.
  136706. */
  136707. static MODEL_FILENAME: string;
  136708. /**
  136709. * Gamepad Id prefix used to identify Daydream Controller.
  136710. */
  136711. static readonly GAMEPAD_ID_PREFIX: string;
  136712. /**
  136713. * Creates a new DaydreamController from a gamepad
  136714. * @param vrGamepad the gamepad that the controller should be created from
  136715. */
  136716. constructor(vrGamepad: any);
  136717. /**
  136718. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136719. * @param scene scene in which to add meshes
  136720. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136721. */
  136722. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136723. /**
  136724. * Called once for each button that changed state since the last frame
  136725. * @param buttonIdx Which button index changed
  136726. * @param state New state of the button
  136727. * @param changes Which properties on the state changed since last frame
  136728. */
  136729. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136730. }
  136731. }
  136732. declare module BABYLON {
  136733. /**
  136734. * Gear VR Controller
  136735. */
  136736. export class GearVRController extends WebVRController {
  136737. /**
  136738. * Base Url for the controller model.
  136739. */
  136740. static MODEL_BASE_URL: string;
  136741. /**
  136742. * File name for the controller model.
  136743. */
  136744. static MODEL_FILENAME: string;
  136745. /**
  136746. * Gamepad Id prefix used to identify this controller.
  136747. */
  136748. static readonly GAMEPAD_ID_PREFIX: string;
  136749. private readonly _buttonIndexToObservableNameMap;
  136750. /**
  136751. * Creates a new GearVRController from a gamepad
  136752. * @param vrGamepad the gamepad that the controller should be created from
  136753. */
  136754. constructor(vrGamepad: any);
  136755. /**
  136756. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136757. * @param scene scene in which to add meshes
  136758. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136759. */
  136760. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136761. /**
  136762. * Called once for each button that changed state since the last frame
  136763. * @param buttonIdx Which button index changed
  136764. * @param state New state of the button
  136765. * @param changes Which properties on the state changed since last frame
  136766. */
  136767. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136768. }
  136769. }
  136770. declare module BABYLON {
  136771. /**
  136772. * Generic Controller
  136773. */
  136774. export class GenericController extends WebVRController {
  136775. /**
  136776. * Base Url for the controller model.
  136777. */
  136778. static readonly MODEL_BASE_URL: string;
  136779. /**
  136780. * File name for the controller model.
  136781. */
  136782. static readonly MODEL_FILENAME: string;
  136783. /**
  136784. * Creates a new GenericController from a gamepad
  136785. * @param vrGamepad the gamepad that the controller should be created from
  136786. */
  136787. constructor(vrGamepad: any);
  136788. /**
  136789. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136790. * @param scene scene in which to add meshes
  136791. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136792. */
  136793. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136794. /**
  136795. * Called once for each button that changed state since the last frame
  136796. * @param buttonIdx Which button index changed
  136797. * @param state New state of the button
  136798. * @param changes Which properties on the state changed since last frame
  136799. */
  136800. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136801. }
  136802. }
  136803. declare module BABYLON {
  136804. /**
  136805. * Oculus Touch Controller
  136806. */
  136807. export class OculusTouchController extends WebVRController {
  136808. /**
  136809. * Base Url for the controller model.
  136810. */
  136811. static MODEL_BASE_URL: string;
  136812. /**
  136813. * File name for the left controller model.
  136814. */
  136815. static MODEL_LEFT_FILENAME: string;
  136816. /**
  136817. * File name for the right controller model.
  136818. */
  136819. static MODEL_RIGHT_FILENAME: string;
  136820. /**
  136821. * Base Url for the Quest controller model.
  136822. */
  136823. static QUEST_MODEL_BASE_URL: string;
  136824. /**
  136825. * @hidden
  136826. * If the controllers are running on a device that needs the updated Quest controller models
  136827. */
  136828. static _IsQuest: boolean;
  136829. /**
  136830. * Fired when the secondary trigger on this controller is modified
  136831. */
  136832. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  136833. /**
  136834. * Fired when the thumb rest on this controller is modified
  136835. */
  136836. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  136837. /**
  136838. * Creates a new OculusTouchController from a gamepad
  136839. * @param vrGamepad the gamepad that the controller should be created from
  136840. */
  136841. constructor(vrGamepad: any);
  136842. /**
  136843. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136844. * @param scene scene in which to add meshes
  136845. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136846. */
  136847. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136848. /**
  136849. * Fired when the A button on this controller is modified
  136850. */
  136851. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136852. /**
  136853. * Fired when the B button on this controller is modified
  136854. */
  136855. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136856. /**
  136857. * Fired when the X button on this controller is modified
  136858. */
  136859. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136860. /**
  136861. * Fired when the Y button on this controller is modified
  136862. */
  136863. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136864. /**
  136865. * Called once for each button that changed state since the last frame
  136866. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  136867. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  136868. * 2) secondary trigger (same)
  136869. * 3) A (right) X (left), touch, pressed = value
  136870. * 4) B / Y
  136871. * 5) thumb rest
  136872. * @param buttonIdx Which button index changed
  136873. * @param state New state of the button
  136874. * @param changes Which properties on the state changed since last frame
  136875. */
  136876. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136877. }
  136878. }
  136879. declare module BABYLON {
  136880. /**
  136881. * Vive Controller
  136882. */
  136883. export class ViveController extends WebVRController {
  136884. /**
  136885. * Base Url for the controller model.
  136886. */
  136887. static MODEL_BASE_URL: string;
  136888. /**
  136889. * File name for the controller model.
  136890. */
  136891. static MODEL_FILENAME: string;
  136892. /**
  136893. * Creates a new ViveController from a gamepad
  136894. * @param vrGamepad the gamepad that the controller should be created from
  136895. */
  136896. constructor(vrGamepad: any);
  136897. /**
  136898. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  136899. * @param scene scene in which to add meshes
  136900. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  136901. */
  136902. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  136903. /**
  136904. * Fired when the left button on this controller is modified
  136905. */
  136906. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136907. /**
  136908. * Fired when the right button on this controller is modified
  136909. */
  136910. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136911. /**
  136912. * Fired when the menu button on this controller is modified
  136913. */
  136914. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136915. /**
  136916. * Called once for each button that changed state since the last frame
  136917. * Vive mapping:
  136918. * 0: touchpad
  136919. * 1: trigger
  136920. * 2: left AND right buttons
  136921. * 3: menu button
  136922. * @param buttonIdx Which button index changed
  136923. * @param state New state of the button
  136924. * @param changes Which properties on the state changed since last frame
  136925. */
  136926. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  136927. }
  136928. }
  136929. declare module BABYLON {
  136930. /**
  136931. * Defines the WindowsMotionController object that the state of the windows motion controller
  136932. */
  136933. export class WindowsMotionController extends WebVRController {
  136934. /**
  136935. * The base url used to load the left and right controller models
  136936. */
  136937. static MODEL_BASE_URL: string;
  136938. /**
  136939. * The name of the left controller model file
  136940. */
  136941. static MODEL_LEFT_FILENAME: string;
  136942. /**
  136943. * The name of the right controller model file
  136944. */
  136945. static MODEL_RIGHT_FILENAME: string;
  136946. /**
  136947. * The controller name prefix for this controller type
  136948. */
  136949. static readonly GAMEPAD_ID_PREFIX: string;
  136950. /**
  136951. * The controller id pattern for this controller type
  136952. */
  136953. private static readonly GAMEPAD_ID_PATTERN;
  136954. private _loadedMeshInfo;
  136955. protected readonly _mapping: {
  136956. buttons: string[];
  136957. buttonMeshNames: {
  136958. trigger: string;
  136959. menu: string;
  136960. grip: string;
  136961. thumbstick: string;
  136962. trackpad: string;
  136963. };
  136964. buttonObservableNames: {
  136965. trigger: string;
  136966. menu: string;
  136967. grip: string;
  136968. thumbstick: string;
  136969. trackpad: string;
  136970. };
  136971. axisMeshNames: string[];
  136972. pointingPoseMeshName: string;
  136973. };
  136974. /**
  136975. * Fired when the trackpad on this controller is clicked
  136976. */
  136977. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  136978. /**
  136979. * Fired when the trackpad on this controller is modified
  136980. */
  136981. onTrackpadValuesChangedObservable: Observable<StickValues>;
  136982. /**
  136983. * The current x and y values of this controller's trackpad
  136984. */
  136985. trackpad: StickValues;
  136986. /**
  136987. * Creates a new WindowsMotionController from a gamepad
  136988. * @param vrGamepad the gamepad that the controller should be created from
  136989. */
  136990. constructor(vrGamepad: any);
  136991. /**
  136992. * Fired when the trigger on this controller is modified
  136993. */
  136994. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136995. /**
  136996. * Fired when the menu button on this controller is modified
  136997. */
  136998. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  136999. /**
  137000. * Fired when the grip button on this controller is modified
  137001. */
  137002. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137003. /**
  137004. * Fired when the thumbstick button on this controller is modified
  137005. */
  137006. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137007. /**
  137008. * Fired when the touchpad button on this controller is modified
  137009. */
  137010. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137011. /**
  137012. * Fired when the touchpad values on this controller are modified
  137013. */
  137014. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  137015. protected _updateTrackpad(): void;
  137016. /**
  137017. * Called once per frame by the engine.
  137018. */
  137019. update(): void;
  137020. /**
  137021. * Called once for each button that changed state since the last frame
  137022. * @param buttonIdx Which button index changed
  137023. * @param state New state of the button
  137024. * @param changes Which properties on the state changed since last frame
  137025. */
  137026. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137027. /**
  137028. * Moves the buttons on the controller mesh based on their current state
  137029. * @param buttonName the name of the button to move
  137030. * @param buttonValue the value of the button which determines the buttons new position
  137031. */
  137032. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  137033. /**
  137034. * Moves the axis on the controller mesh based on its current state
  137035. * @param axis the index of the axis
  137036. * @param axisValue the value of the axis which determines the meshes new position
  137037. * @hidden
  137038. */
  137039. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  137040. /**
  137041. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137042. * @param scene scene in which to add meshes
  137043. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137044. */
  137045. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  137046. /**
  137047. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  137048. * can be transformed by button presses and axes values, based on this._mapping.
  137049. *
  137050. * @param scene scene in which the meshes exist
  137051. * @param meshes list of meshes that make up the controller model to process
  137052. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  137053. */
  137054. private processModel;
  137055. private createMeshInfo;
  137056. /**
  137057. * Gets the ray of the controller in the direction the controller is pointing
  137058. * @param length the length the resulting ray should be
  137059. * @returns a ray in the direction the controller is pointing
  137060. */
  137061. getForwardRay(length?: number): Ray;
  137062. /**
  137063. * Disposes of the controller
  137064. */
  137065. dispose(): void;
  137066. }
  137067. /**
  137068. * This class represents a new windows motion controller in XR.
  137069. */
  137070. export class XRWindowsMotionController extends WindowsMotionController {
  137071. /**
  137072. * Changing the original WIndowsMotionController mapping to fir the new mapping
  137073. */
  137074. protected readonly _mapping: {
  137075. buttons: string[];
  137076. buttonMeshNames: {
  137077. trigger: string;
  137078. menu: string;
  137079. grip: string;
  137080. thumbstick: string;
  137081. trackpad: string;
  137082. };
  137083. buttonObservableNames: {
  137084. trigger: string;
  137085. menu: string;
  137086. grip: string;
  137087. thumbstick: string;
  137088. trackpad: string;
  137089. };
  137090. axisMeshNames: string[];
  137091. pointingPoseMeshName: string;
  137092. };
  137093. /**
  137094. * Construct a new XR-Based windows motion controller
  137095. *
  137096. * @param gamepadInfo the gamepad object from the browser
  137097. */
  137098. constructor(gamepadInfo: any);
  137099. /**
  137100. * holds the thumbstick values (X,Y)
  137101. */
  137102. thumbstickValues: StickValues;
  137103. /**
  137104. * Fired when the thumbstick on this controller is clicked
  137105. */
  137106. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  137107. /**
  137108. * Fired when the thumbstick on this controller is modified
  137109. */
  137110. onThumbstickValuesChangedObservable: Observable<StickValues>;
  137111. /**
  137112. * Fired when the touchpad button on this controller is modified
  137113. */
  137114. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137115. /**
  137116. * Fired when the touchpad values on this controller are modified
  137117. */
  137118. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137119. /**
  137120. * Fired when the thumbstick button on this controller is modified
  137121. * here to prevent breaking changes
  137122. */
  137123. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137124. /**
  137125. * updating the thumbstick(!) and not the trackpad.
  137126. * This is named this way due to the difference between WebVR and XR and to avoid
  137127. * changing the parent class.
  137128. */
  137129. protected _updateTrackpad(): void;
  137130. /**
  137131. * Disposes the class with joy
  137132. */
  137133. dispose(): void;
  137134. }
  137135. }
  137136. declare module BABYLON {
  137137. /**
  137138. * Class containing static functions to help procedurally build meshes
  137139. */
  137140. export class PolyhedronBuilder {
  137141. /**
  137142. * Creates a polyhedron mesh
  137143. * * 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
  137144. * * The parameter `size` (positive float, default 1) sets the polygon size
  137145. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  137146. * * 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`
  137147. * * 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
  137148. * * 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)`)
  137149. * * 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
  137150. * * 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
  137151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137154. * @param name defines the name of the mesh
  137155. * @param options defines the options used to create the mesh
  137156. * @param scene defines the hosting scene
  137157. * @returns the polyhedron mesh
  137158. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  137159. */
  137160. static CreatePolyhedron(name: string, options: {
  137161. type?: number;
  137162. size?: number;
  137163. sizeX?: number;
  137164. sizeY?: number;
  137165. sizeZ?: number;
  137166. custom?: any;
  137167. faceUV?: Vector4[];
  137168. faceColors?: Color4[];
  137169. flat?: boolean;
  137170. updatable?: boolean;
  137171. sideOrientation?: number;
  137172. frontUVs?: Vector4;
  137173. backUVs?: Vector4;
  137174. }, scene?: Nullable<Scene>): Mesh;
  137175. }
  137176. }
  137177. declare module BABYLON {
  137178. /**
  137179. * Gizmo that enables scaling a mesh along 3 axis
  137180. */
  137181. export class ScaleGizmo extends Gizmo {
  137182. /**
  137183. * Internal gizmo used for interactions on the x axis
  137184. */
  137185. xGizmo: AxisScaleGizmo;
  137186. /**
  137187. * Internal gizmo used for interactions on the y axis
  137188. */
  137189. yGizmo: AxisScaleGizmo;
  137190. /**
  137191. * Internal gizmo used for interactions on the z axis
  137192. */
  137193. zGizmo: AxisScaleGizmo;
  137194. /**
  137195. * Internal gizmo used to scale all axis equally
  137196. */
  137197. uniformScaleGizmo: AxisScaleGizmo;
  137198. private _meshAttached;
  137199. private _nodeAttached;
  137200. private _snapDistance;
  137201. private _uniformScalingMesh;
  137202. private _octahedron;
  137203. private _sensitivity;
  137204. /** Fires an event when any of it's sub gizmos are dragged */
  137205. onDragStartObservable: Observable<unknown>;
  137206. /** Fires an event when any of it's sub gizmos are released from dragging */
  137207. onDragEndObservable: Observable<unknown>;
  137208. get attachedMesh(): Nullable<AbstractMesh>;
  137209. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137210. get attachedNode(): Nullable<Node>;
  137211. set attachedNode(node: Nullable<Node>);
  137212. /**
  137213. * True when the mouse pointer is hovering a gizmo mesh
  137214. */
  137215. get isHovered(): boolean;
  137216. /**
  137217. * Creates a ScaleGizmo
  137218. * @param gizmoLayer The utility layer the gizmo will be added to
  137219. * @param thickness display gizmo axis thickness
  137220. */
  137221. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  137222. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137223. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137224. /**
  137225. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137226. */
  137227. set snapDistance(value: number);
  137228. get snapDistance(): number;
  137229. /**
  137230. * Ratio for the scale of the gizmo (Default: 1)
  137231. */
  137232. set scaleRatio(value: number);
  137233. get scaleRatio(): number;
  137234. /**
  137235. * Sensitivity factor for dragging (Default: 1)
  137236. */
  137237. set sensitivity(value: number);
  137238. get sensitivity(): number;
  137239. /**
  137240. * Disposes of the gizmo
  137241. */
  137242. dispose(): void;
  137243. }
  137244. }
  137245. declare module BABYLON {
  137246. /**
  137247. * Single axis scale gizmo
  137248. */
  137249. export class AxisScaleGizmo extends Gizmo {
  137250. /**
  137251. * Drag behavior responsible for the gizmos dragging interactions
  137252. */
  137253. dragBehavior: PointerDragBehavior;
  137254. private _pointerObserver;
  137255. /**
  137256. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137257. */
  137258. snapDistance: number;
  137259. /**
  137260. * Event that fires each time the gizmo snaps to a new location.
  137261. * * snapDistance is the the change in distance
  137262. */
  137263. onSnapObservable: Observable<{
  137264. snapDistance: number;
  137265. }>;
  137266. /**
  137267. * If the scaling operation should be done on all axis (default: false)
  137268. */
  137269. uniformScaling: boolean;
  137270. /**
  137271. * Custom sensitivity value for the drag strength
  137272. */
  137273. sensitivity: number;
  137274. private _isEnabled;
  137275. private _parent;
  137276. private _arrow;
  137277. private _coloredMaterial;
  137278. private _hoverMaterial;
  137279. /**
  137280. * Creates an AxisScaleGizmo
  137281. * @param gizmoLayer The utility layer the gizmo will be added to
  137282. * @param dragAxis The axis which the gizmo will be able to scale on
  137283. * @param color The color of the gizmo
  137284. * @param thickness display gizmo axis thickness
  137285. */
  137286. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  137287. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137288. /**
  137289. * If the gizmo is enabled
  137290. */
  137291. set isEnabled(value: boolean);
  137292. get isEnabled(): boolean;
  137293. /**
  137294. * Disposes of the gizmo
  137295. */
  137296. dispose(): void;
  137297. /**
  137298. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  137299. * @param mesh The mesh to replace the default mesh of the gizmo
  137300. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  137301. */
  137302. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  137303. }
  137304. }
  137305. declare module BABYLON {
  137306. /**
  137307. * Bounding box gizmo
  137308. */
  137309. export class BoundingBoxGizmo extends Gizmo {
  137310. private _lineBoundingBox;
  137311. private _rotateSpheresParent;
  137312. private _scaleBoxesParent;
  137313. private _boundingDimensions;
  137314. private _renderObserver;
  137315. private _pointerObserver;
  137316. private _scaleDragSpeed;
  137317. private _tmpQuaternion;
  137318. private _tmpVector;
  137319. private _tmpRotationMatrix;
  137320. /**
  137321. * 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)
  137322. */
  137323. ignoreChildren: boolean;
  137324. /**
  137325. * 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)
  137326. */
  137327. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  137328. /**
  137329. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  137330. */
  137331. rotationSphereSize: number;
  137332. /**
  137333. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  137334. */
  137335. scaleBoxSize: number;
  137336. /**
  137337. * 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)
  137338. */
  137339. fixedDragMeshScreenSize: boolean;
  137340. /**
  137341. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  137342. */
  137343. fixedDragMeshScreenSizeDistanceFactor: number;
  137344. /**
  137345. * Fired when a rotation sphere or scale box is dragged
  137346. */
  137347. onDragStartObservable: Observable<{}>;
  137348. /**
  137349. * Fired when a scale box is dragged
  137350. */
  137351. onScaleBoxDragObservable: Observable<{}>;
  137352. /**
  137353. * Fired when a scale box drag is ended
  137354. */
  137355. onScaleBoxDragEndObservable: Observable<{}>;
  137356. /**
  137357. * Fired when a rotation sphere is dragged
  137358. */
  137359. onRotationSphereDragObservable: Observable<{}>;
  137360. /**
  137361. * Fired when a rotation sphere drag is ended
  137362. */
  137363. onRotationSphereDragEndObservable: Observable<{}>;
  137364. /**
  137365. * 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)
  137366. */
  137367. scalePivot: Nullable<Vector3>;
  137368. /**
  137369. * Mesh used as a pivot to rotate the attached node
  137370. */
  137371. private _anchorMesh;
  137372. private _existingMeshScale;
  137373. private _dragMesh;
  137374. private pointerDragBehavior;
  137375. private coloredMaterial;
  137376. private hoverColoredMaterial;
  137377. /**
  137378. * Sets the color of the bounding box gizmo
  137379. * @param color the color to set
  137380. */
  137381. setColor(color: Color3): void;
  137382. /**
  137383. * Creates an BoundingBoxGizmo
  137384. * @param gizmoLayer The utility layer the gizmo will be added to
  137385. * @param color The color of the gizmo
  137386. */
  137387. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  137388. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  137389. private _selectNode;
  137390. /**
  137391. * Updates the bounding box information for the Gizmo
  137392. */
  137393. updateBoundingBox(): void;
  137394. private _updateRotationSpheres;
  137395. private _updateScaleBoxes;
  137396. /**
  137397. * Enables rotation on the specified axis and disables rotation on the others
  137398. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  137399. */
  137400. setEnabledRotationAxis(axis: string): void;
  137401. /**
  137402. * Enables/disables scaling
  137403. * @param enable if scaling should be enabled
  137404. * @param homogeneousScaling defines if scaling should only be homogeneous
  137405. */
  137406. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  137407. private _updateDummy;
  137408. /**
  137409. * Enables a pointer drag behavior on the bounding box of the gizmo
  137410. */
  137411. enableDragBehavior(): void;
  137412. /**
  137413. * Disposes of the gizmo
  137414. */
  137415. dispose(): void;
  137416. /**
  137417. * 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)
  137418. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  137419. * @returns the bounding box mesh with the passed in mesh as a child
  137420. */
  137421. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  137422. /**
  137423. * CustomMeshes are not supported by this gizmo
  137424. * @param mesh The mesh to replace the default mesh of the gizmo
  137425. */
  137426. setCustomMesh(mesh: Mesh): void;
  137427. }
  137428. }
  137429. declare module BABYLON {
  137430. /**
  137431. * Single plane rotation gizmo
  137432. */
  137433. export class PlaneRotationGizmo extends Gizmo {
  137434. /**
  137435. * Drag behavior responsible for the gizmos dragging interactions
  137436. */
  137437. dragBehavior: PointerDragBehavior;
  137438. private _pointerObserver;
  137439. /**
  137440. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  137441. */
  137442. snapDistance: number;
  137443. /**
  137444. * Event that fires each time the gizmo snaps to a new location.
  137445. * * snapDistance is the the change in distance
  137446. */
  137447. onSnapObservable: Observable<{
  137448. snapDistance: number;
  137449. }>;
  137450. private _isEnabled;
  137451. private _parent;
  137452. /**
  137453. * Creates a PlaneRotationGizmo
  137454. * @param gizmoLayer The utility layer the gizmo will be added to
  137455. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  137456. * @param color The color of the gizmo
  137457. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137458. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137459. * @param thickness display gizmo axis thickness
  137460. */
  137461. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  137462. protected _attachedNodeChanged(value: Nullable<Node>): void;
  137463. /**
  137464. * If the gizmo is enabled
  137465. */
  137466. set isEnabled(value: boolean);
  137467. get isEnabled(): boolean;
  137468. /**
  137469. * Disposes of the gizmo
  137470. */
  137471. dispose(): void;
  137472. }
  137473. }
  137474. declare module BABYLON {
  137475. /**
  137476. * Gizmo that enables rotating a mesh along 3 axis
  137477. */
  137478. export class RotationGizmo extends Gizmo {
  137479. /**
  137480. * Internal gizmo used for interactions on the x axis
  137481. */
  137482. xGizmo: PlaneRotationGizmo;
  137483. /**
  137484. * Internal gizmo used for interactions on the y axis
  137485. */
  137486. yGizmo: PlaneRotationGizmo;
  137487. /**
  137488. * Internal gizmo used for interactions on the z axis
  137489. */
  137490. zGizmo: PlaneRotationGizmo;
  137491. /** Fires an event when any of it's sub gizmos are dragged */
  137492. onDragStartObservable: Observable<unknown>;
  137493. /** Fires an event when any of it's sub gizmos are released from dragging */
  137494. onDragEndObservable: Observable<unknown>;
  137495. private _meshAttached;
  137496. private _nodeAttached;
  137497. get attachedMesh(): Nullable<AbstractMesh>;
  137498. set attachedMesh(mesh: Nullable<AbstractMesh>);
  137499. get attachedNode(): Nullable<Node>;
  137500. set attachedNode(node: Nullable<Node>);
  137501. /**
  137502. * True when the mouse pointer is hovering a gizmo mesh
  137503. */
  137504. get isHovered(): boolean;
  137505. /**
  137506. * Creates a RotationGizmo
  137507. * @param gizmoLayer The utility layer the gizmo will be added to
  137508. * @param tessellation Amount of tessellation to be used when creating rotation circles
  137509. * @param useEulerRotation Use and update Euler angle instead of quaternion
  137510. * @param thickness display gizmo axis thickness
  137511. */
  137512. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  137513. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  137514. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  137515. /**
  137516. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  137517. */
  137518. set snapDistance(value: number);
  137519. get snapDistance(): number;
  137520. /**
  137521. * Ratio for the scale of the gizmo (Default: 1)
  137522. */
  137523. set scaleRatio(value: number);
  137524. get scaleRatio(): number;
  137525. /**
  137526. * Disposes of the gizmo
  137527. */
  137528. dispose(): void;
  137529. /**
  137530. * CustomMeshes are not supported by this gizmo
  137531. * @param mesh The mesh to replace the default mesh of the gizmo
  137532. */
  137533. setCustomMesh(mesh: Mesh): void;
  137534. }
  137535. }
  137536. declare module BABYLON {
  137537. /**
  137538. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  137539. */
  137540. export class GizmoManager implements IDisposable {
  137541. private scene;
  137542. /**
  137543. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  137544. */
  137545. gizmos: {
  137546. positionGizmo: Nullable<PositionGizmo>;
  137547. rotationGizmo: Nullable<RotationGizmo>;
  137548. scaleGizmo: Nullable<ScaleGizmo>;
  137549. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  137550. };
  137551. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  137552. clearGizmoOnEmptyPointerEvent: boolean;
  137553. /** Fires an event when the manager is attached to a mesh */
  137554. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  137555. /** Fires an event when the manager is attached to a node */
  137556. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  137557. private _gizmosEnabled;
  137558. private _pointerObserver;
  137559. private _attachedMesh;
  137560. private _attachedNode;
  137561. private _boundingBoxColor;
  137562. private _defaultUtilityLayer;
  137563. private _defaultKeepDepthUtilityLayer;
  137564. private _thickness;
  137565. /**
  137566. * When bounding box gizmo is enabled, this can be used to track drag/end events
  137567. */
  137568. boundingBoxDragBehavior: SixDofDragBehavior;
  137569. /**
  137570. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  137571. */
  137572. attachableMeshes: Nullable<Array<AbstractMesh>>;
  137573. /**
  137574. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  137575. */
  137576. attachableNodes: Nullable<Array<Node>>;
  137577. /**
  137578. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  137579. */
  137580. usePointerToAttachGizmos: boolean;
  137581. /**
  137582. * Utility layer that the bounding box gizmo belongs to
  137583. */
  137584. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  137585. /**
  137586. * Utility layer that all gizmos besides bounding box belong to
  137587. */
  137588. get utilityLayer(): UtilityLayerRenderer;
  137589. /**
  137590. * True when the mouse pointer is hovering a gizmo mesh
  137591. */
  137592. get isHovered(): boolean;
  137593. /**
  137594. * Instatiates a gizmo manager
  137595. * @param scene the scene to overlay the gizmos on top of
  137596. * @param thickness display gizmo axis thickness
  137597. */
  137598. constructor(scene: Scene, thickness?: number);
  137599. /**
  137600. * Attaches a set of gizmos to the specified mesh
  137601. * @param mesh The mesh the gizmo's should be attached to
  137602. */
  137603. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137604. /**
  137605. * Attaches a set of gizmos to the specified node
  137606. * @param node The node the gizmo's should be attached to
  137607. */
  137608. attachToNode(node: Nullable<Node>): void;
  137609. /**
  137610. * If the position gizmo is enabled
  137611. */
  137612. set positionGizmoEnabled(value: boolean);
  137613. get positionGizmoEnabled(): boolean;
  137614. /**
  137615. * If the rotation gizmo is enabled
  137616. */
  137617. set rotationGizmoEnabled(value: boolean);
  137618. get rotationGizmoEnabled(): boolean;
  137619. /**
  137620. * If the scale gizmo is enabled
  137621. */
  137622. set scaleGizmoEnabled(value: boolean);
  137623. get scaleGizmoEnabled(): boolean;
  137624. /**
  137625. * If the boundingBox gizmo is enabled
  137626. */
  137627. set boundingBoxGizmoEnabled(value: boolean);
  137628. get boundingBoxGizmoEnabled(): boolean;
  137629. /**
  137630. * Disposes of the gizmo manager
  137631. */
  137632. dispose(): void;
  137633. }
  137634. }
  137635. declare module BABYLON {
  137636. /**
  137637. * A directional light is defined by a direction (what a surprise!).
  137638. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  137639. * 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.
  137640. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137641. */
  137642. export class DirectionalLight extends ShadowLight {
  137643. private _shadowFrustumSize;
  137644. /**
  137645. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  137646. */
  137647. get shadowFrustumSize(): number;
  137648. /**
  137649. * Specifies a fix frustum size for the shadow generation.
  137650. */
  137651. set shadowFrustumSize(value: number);
  137652. private _shadowOrthoScale;
  137653. /**
  137654. * Gets the shadow projection scale against the optimal computed one.
  137655. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137656. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137657. */
  137658. get shadowOrthoScale(): number;
  137659. /**
  137660. * Sets the shadow projection scale against the optimal computed one.
  137661. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  137662. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  137663. */
  137664. set shadowOrthoScale(value: number);
  137665. /**
  137666. * Automatically compute the projection matrix to best fit (including all the casters)
  137667. * on each frame.
  137668. */
  137669. autoUpdateExtends: boolean;
  137670. /**
  137671. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  137672. * on each frame. autoUpdateExtends must be set to true for this to work
  137673. */
  137674. autoCalcShadowZBounds: boolean;
  137675. private _orthoLeft;
  137676. private _orthoRight;
  137677. private _orthoTop;
  137678. private _orthoBottom;
  137679. /**
  137680. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  137681. * The directional light is emitted from everywhere in the given direction.
  137682. * It can cast shadows.
  137683. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137684. * @param name The friendly name of the light
  137685. * @param direction The direction of the light
  137686. * @param scene The scene the light belongs to
  137687. */
  137688. constructor(name: string, direction: Vector3, scene: Scene);
  137689. /**
  137690. * Returns the string "DirectionalLight".
  137691. * @return The class name
  137692. */
  137693. getClassName(): string;
  137694. /**
  137695. * Returns the integer 1.
  137696. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137697. */
  137698. getTypeID(): number;
  137699. /**
  137700. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  137701. * Returns the DirectionalLight Shadow projection matrix.
  137702. */
  137703. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137704. /**
  137705. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  137706. * Returns the DirectionalLight Shadow projection matrix.
  137707. */
  137708. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  137709. /**
  137710. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  137711. * Returns the DirectionalLight Shadow projection matrix.
  137712. */
  137713. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137714. protected _buildUniformLayout(): void;
  137715. /**
  137716. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  137717. * @param effect The effect to update
  137718. * @param lightIndex The index of the light in the effect to update
  137719. * @returns The directional light
  137720. */
  137721. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  137722. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  137723. /**
  137724. * Gets the minZ used for shadow according to both the scene and the light.
  137725. *
  137726. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137727. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137728. * @param activeCamera The camera we are returning the min for
  137729. * @returns the depth min z
  137730. */
  137731. getDepthMinZ(activeCamera: Camera): number;
  137732. /**
  137733. * Gets the maxZ used for shadow according to both the scene and the light.
  137734. *
  137735. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  137736. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137737. * @param activeCamera The camera we are returning the max for
  137738. * @returns the depth max z
  137739. */
  137740. getDepthMaxZ(activeCamera: Camera): number;
  137741. /**
  137742. * Prepares the list of defines specific to the light type.
  137743. * @param defines the list of defines
  137744. * @param lightIndex defines the index of the light for the effect
  137745. */
  137746. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137747. }
  137748. }
  137749. declare module BABYLON {
  137750. /**
  137751. * Class containing static functions to help procedurally build meshes
  137752. */
  137753. export class HemisphereBuilder {
  137754. /**
  137755. * Creates a hemisphere mesh
  137756. * @param name defines the name of the mesh
  137757. * @param options defines the options used to create the mesh
  137758. * @param scene defines the hosting scene
  137759. * @returns the hemisphere mesh
  137760. */
  137761. static CreateHemisphere(name: string, options: {
  137762. segments?: number;
  137763. diameter?: number;
  137764. sideOrientation?: number;
  137765. }, scene: any): Mesh;
  137766. }
  137767. }
  137768. declare module BABYLON {
  137769. /**
  137770. * A spot light is defined by a position, a direction, an angle, and an exponent.
  137771. * These values define a cone of light starting from the position, emitting toward the direction.
  137772. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  137773. * and the exponent defines the speed of the decay of the light with distance (reach).
  137774. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137775. */
  137776. export class SpotLight extends ShadowLight {
  137777. private _angle;
  137778. private _innerAngle;
  137779. private _cosHalfAngle;
  137780. private _lightAngleScale;
  137781. private _lightAngleOffset;
  137782. /**
  137783. * Gets the cone angle of the spot light in Radians.
  137784. */
  137785. get angle(): number;
  137786. /**
  137787. * Sets the cone angle of the spot light in Radians.
  137788. */
  137789. set angle(value: number);
  137790. /**
  137791. * Only used in gltf falloff mode, this defines the angle where
  137792. * the directional falloff will start before cutting at angle which could be seen
  137793. * as outer angle.
  137794. */
  137795. get innerAngle(): number;
  137796. /**
  137797. * Only used in gltf falloff mode, this defines the angle where
  137798. * the directional falloff will start before cutting at angle which could be seen
  137799. * as outer angle.
  137800. */
  137801. set innerAngle(value: number);
  137802. private _shadowAngleScale;
  137803. /**
  137804. * Allows scaling the angle of the light for shadow generation only.
  137805. */
  137806. get shadowAngleScale(): number;
  137807. /**
  137808. * Allows scaling the angle of the light for shadow generation only.
  137809. */
  137810. set shadowAngleScale(value: number);
  137811. /**
  137812. * The light decay speed with the distance from the emission spot.
  137813. */
  137814. exponent: number;
  137815. private _projectionTextureMatrix;
  137816. /**
  137817. * Allows reading the projecton texture
  137818. */
  137819. get projectionTextureMatrix(): Matrix;
  137820. protected _projectionTextureLightNear: number;
  137821. /**
  137822. * Gets the near clip of the Spotlight for texture projection.
  137823. */
  137824. get projectionTextureLightNear(): number;
  137825. /**
  137826. * Sets the near clip of the Spotlight for texture projection.
  137827. */
  137828. set projectionTextureLightNear(value: number);
  137829. protected _projectionTextureLightFar: number;
  137830. /**
  137831. * Gets the far clip of the Spotlight for texture projection.
  137832. */
  137833. get projectionTextureLightFar(): number;
  137834. /**
  137835. * Sets the far clip of the Spotlight for texture projection.
  137836. */
  137837. set projectionTextureLightFar(value: number);
  137838. protected _projectionTextureUpDirection: Vector3;
  137839. /**
  137840. * Gets the Up vector of the Spotlight for texture projection.
  137841. */
  137842. get projectionTextureUpDirection(): Vector3;
  137843. /**
  137844. * Sets the Up vector of the Spotlight for texture projection.
  137845. */
  137846. set projectionTextureUpDirection(value: Vector3);
  137847. private _projectionTexture;
  137848. /**
  137849. * Gets the projection texture of the light.
  137850. */
  137851. get projectionTexture(): Nullable<BaseTexture>;
  137852. /**
  137853. * Sets the projection texture of the light.
  137854. */
  137855. set projectionTexture(value: Nullable<BaseTexture>);
  137856. private _projectionTextureViewLightDirty;
  137857. private _projectionTextureProjectionLightDirty;
  137858. private _projectionTextureDirty;
  137859. private _projectionTextureViewTargetVector;
  137860. private _projectionTextureViewLightMatrix;
  137861. private _projectionTextureProjectionLightMatrix;
  137862. private _projectionTextureScalingMatrix;
  137863. /**
  137864. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  137865. * It can cast shadows.
  137866. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137867. * @param name The light friendly name
  137868. * @param position The position of the spot light in the scene
  137869. * @param direction The direction of the light in the scene
  137870. * @param angle The cone angle of the light in Radians
  137871. * @param exponent The light decay speed with the distance from the emission spot
  137872. * @param scene The scene the lights belongs to
  137873. */
  137874. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  137875. /**
  137876. * Returns the string "SpotLight".
  137877. * @returns the class name
  137878. */
  137879. getClassName(): string;
  137880. /**
  137881. * Returns the integer 2.
  137882. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137883. */
  137884. getTypeID(): number;
  137885. /**
  137886. * Overrides the direction setter to recompute the projection texture view light Matrix.
  137887. */
  137888. protected _setDirection(value: Vector3): void;
  137889. /**
  137890. * Overrides the position setter to recompute the projection texture view light Matrix.
  137891. */
  137892. protected _setPosition(value: Vector3): void;
  137893. /**
  137894. * 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.
  137895. * Returns the SpotLight.
  137896. */
  137897. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137898. protected _computeProjectionTextureViewLightMatrix(): void;
  137899. protected _computeProjectionTextureProjectionLightMatrix(): void;
  137900. /**
  137901. * Main function for light texture projection matrix computing.
  137902. */
  137903. protected _computeProjectionTextureMatrix(): void;
  137904. protected _buildUniformLayout(): void;
  137905. private _computeAngleValues;
  137906. /**
  137907. * Sets the passed Effect "effect" with the Light textures.
  137908. * @param effect The effect to update
  137909. * @param lightIndex The index of the light in the effect to update
  137910. * @returns The light
  137911. */
  137912. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  137913. /**
  137914. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  137915. * @param effect The effect to update
  137916. * @param lightIndex The index of the light in the effect to update
  137917. * @returns The spot light
  137918. */
  137919. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  137920. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137921. /**
  137922. * Disposes the light and the associated resources.
  137923. */
  137924. dispose(): void;
  137925. /**
  137926. * Prepares the list of defines specific to the light type.
  137927. * @param defines the list of defines
  137928. * @param lightIndex defines the index of the light for the effect
  137929. */
  137930. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137931. }
  137932. }
  137933. declare module BABYLON {
  137934. /**
  137935. * Gizmo that enables viewing a light
  137936. */
  137937. export class LightGizmo extends Gizmo {
  137938. private _lightMesh;
  137939. private _material;
  137940. private _cachedPosition;
  137941. private _cachedForward;
  137942. private _attachedMeshParent;
  137943. private _pointerObserver;
  137944. /**
  137945. * Event that fires each time the gizmo is clicked
  137946. */
  137947. onClickedObservable: Observable<Light>;
  137948. /**
  137949. * Creates a LightGizmo
  137950. * @param gizmoLayer The utility layer the gizmo will be added to
  137951. */
  137952. constructor(gizmoLayer?: UtilityLayerRenderer);
  137953. private _light;
  137954. /**
  137955. * The light that the gizmo is attached to
  137956. */
  137957. set light(light: Nullable<Light>);
  137958. get light(): Nullable<Light>;
  137959. /**
  137960. * Gets the material used to render the light gizmo
  137961. */
  137962. get material(): StandardMaterial;
  137963. /**
  137964. * @hidden
  137965. * Updates the gizmo to match the attached mesh's position/rotation
  137966. */
  137967. protected _update(): void;
  137968. private static _Scale;
  137969. /**
  137970. * Creates the lines for a light mesh
  137971. */
  137972. private static _CreateLightLines;
  137973. /**
  137974. * Disposes of the light gizmo
  137975. */
  137976. dispose(): void;
  137977. private static _CreateHemisphericLightMesh;
  137978. private static _CreatePointLightMesh;
  137979. private static _CreateSpotLightMesh;
  137980. private static _CreateDirectionalLightMesh;
  137981. }
  137982. }
  137983. declare module BABYLON {
  137984. /**
  137985. * Gizmo that enables viewing a camera
  137986. */
  137987. export class CameraGizmo extends Gizmo {
  137988. private _cameraMesh;
  137989. private _cameraLinesMesh;
  137990. private _material;
  137991. private _pointerObserver;
  137992. /**
  137993. * Event that fires each time the gizmo is clicked
  137994. */
  137995. onClickedObservable: Observable<Camera>;
  137996. /**
  137997. * Creates a CameraGizmo
  137998. * @param gizmoLayer The utility layer the gizmo will be added to
  137999. */
  138000. constructor(gizmoLayer?: UtilityLayerRenderer);
  138001. private _camera;
  138002. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  138003. get displayFrustum(): boolean;
  138004. set displayFrustum(value: boolean);
  138005. /**
  138006. * The camera that the gizmo is attached to
  138007. */
  138008. set camera(camera: Nullable<Camera>);
  138009. get camera(): Nullable<Camera>;
  138010. /**
  138011. * Gets the material used to render the camera gizmo
  138012. */
  138013. get material(): StandardMaterial;
  138014. /**
  138015. * @hidden
  138016. * Updates the gizmo to match the attached mesh's position/rotation
  138017. */
  138018. protected _update(): void;
  138019. private static _Scale;
  138020. private _invProjection;
  138021. /**
  138022. * Disposes of the camera gizmo
  138023. */
  138024. dispose(): void;
  138025. private static _CreateCameraMesh;
  138026. private static _CreateCameraFrustum;
  138027. }
  138028. }
  138029. declare module BABYLON {
  138030. /** @hidden */
  138031. export var backgroundFragmentDeclaration: {
  138032. name: string;
  138033. shader: string;
  138034. };
  138035. }
  138036. declare module BABYLON {
  138037. /** @hidden */
  138038. export var backgroundUboDeclaration: {
  138039. name: string;
  138040. shader: string;
  138041. };
  138042. }
  138043. declare module BABYLON {
  138044. /** @hidden */
  138045. export var backgroundPixelShader: {
  138046. name: string;
  138047. shader: string;
  138048. };
  138049. }
  138050. declare module BABYLON {
  138051. /** @hidden */
  138052. export var backgroundVertexDeclaration: {
  138053. name: string;
  138054. shader: string;
  138055. };
  138056. }
  138057. declare module BABYLON {
  138058. /** @hidden */
  138059. export var backgroundVertexShader: {
  138060. name: string;
  138061. shader: string;
  138062. };
  138063. }
  138064. declare module BABYLON {
  138065. /**
  138066. * Background material used to create an efficient environement around your scene.
  138067. */
  138068. export class BackgroundMaterial extends PushMaterial {
  138069. /**
  138070. * Standard reflectance value at parallel view angle.
  138071. */
  138072. static StandardReflectance0: number;
  138073. /**
  138074. * Standard reflectance value at grazing angle.
  138075. */
  138076. static StandardReflectance90: number;
  138077. protected _primaryColor: Color3;
  138078. /**
  138079. * Key light Color (multiply against the environement texture)
  138080. */
  138081. primaryColor: Color3;
  138082. protected __perceptualColor: Nullable<Color3>;
  138083. /**
  138084. * Experimental Internal Use Only.
  138085. *
  138086. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  138087. * This acts as a helper to set the primary color to a more "human friendly" value.
  138088. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  138089. * output color as close as possible from the chosen value.
  138090. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  138091. * part of lighting setup.)
  138092. */
  138093. get _perceptualColor(): Nullable<Color3>;
  138094. set _perceptualColor(value: Nullable<Color3>);
  138095. protected _primaryColorShadowLevel: float;
  138096. /**
  138097. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  138098. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  138099. */
  138100. get primaryColorShadowLevel(): float;
  138101. set primaryColorShadowLevel(value: float);
  138102. protected _primaryColorHighlightLevel: float;
  138103. /**
  138104. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  138105. * The primary color is used at the level chosen to define what the white area would look.
  138106. */
  138107. get primaryColorHighlightLevel(): float;
  138108. set primaryColorHighlightLevel(value: float);
  138109. protected _reflectionTexture: Nullable<BaseTexture>;
  138110. /**
  138111. * Reflection Texture used in the material.
  138112. * Should be author in a specific way for the best result (refer to the documentation).
  138113. */
  138114. reflectionTexture: Nullable<BaseTexture>;
  138115. protected _reflectionBlur: float;
  138116. /**
  138117. * Reflection Texture level of blur.
  138118. *
  138119. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  138120. * texture twice.
  138121. */
  138122. reflectionBlur: float;
  138123. protected _diffuseTexture: Nullable<BaseTexture>;
  138124. /**
  138125. * Diffuse Texture used in the material.
  138126. * Should be author in a specific way for the best result (refer to the documentation).
  138127. */
  138128. diffuseTexture: Nullable<BaseTexture>;
  138129. protected _shadowLights: Nullable<IShadowLight[]>;
  138130. /**
  138131. * Specify the list of lights casting shadow on the material.
  138132. * All scene shadow lights will be included if null.
  138133. */
  138134. shadowLights: Nullable<IShadowLight[]>;
  138135. protected _shadowLevel: float;
  138136. /**
  138137. * Helps adjusting the shadow to a softer level if required.
  138138. * 0 means black shadows and 1 means no shadows.
  138139. */
  138140. shadowLevel: float;
  138141. protected _sceneCenter: Vector3;
  138142. /**
  138143. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  138144. * It is usually zero but might be interesting to modify according to your setup.
  138145. */
  138146. sceneCenter: Vector3;
  138147. protected _opacityFresnel: boolean;
  138148. /**
  138149. * This helps specifying that the material is falling off to the sky box at grazing angle.
  138150. * This helps ensuring a nice transition when the camera goes under the ground.
  138151. */
  138152. opacityFresnel: boolean;
  138153. protected _reflectionFresnel: boolean;
  138154. /**
  138155. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  138156. * This helps adding a mirror texture on the ground.
  138157. */
  138158. reflectionFresnel: boolean;
  138159. protected _reflectionFalloffDistance: number;
  138160. /**
  138161. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  138162. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  138163. */
  138164. reflectionFalloffDistance: number;
  138165. protected _reflectionAmount: number;
  138166. /**
  138167. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  138168. */
  138169. reflectionAmount: number;
  138170. protected _reflectionReflectance0: number;
  138171. /**
  138172. * This specifies the weight of the reflection at grazing angle.
  138173. */
  138174. reflectionReflectance0: number;
  138175. protected _reflectionReflectance90: number;
  138176. /**
  138177. * This specifies the weight of the reflection at a perpendicular point of view.
  138178. */
  138179. reflectionReflectance90: number;
  138180. /**
  138181. * Sets the reflection reflectance fresnel values according to the default standard
  138182. * empirically know to work well :-)
  138183. */
  138184. set reflectionStandardFresnelWeight(value: number);
  138185. protected _useRGBColor: boolean;
  138186. /**
  138187. * Helps to directly use the maps channels instead of their level.
  138188. */
  138189. useRGBColor: boolean;
  138190. protected _enableNoise: boolean;
  138191. /**
  138192. * This helps reducing the banding effect that could occur on the background.
  138193. */
  138194. enableNoise: boolean;
  138195. /**
  138196. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138197. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  138198. * Recommended to be keep at 1.0 except for special cases.
  138199. */
  138200. get fovMultiplier(): number;
  138201. set fovMultiplier(value: number);
  138202. private _fovMultiplier;
  138203. /**
  138204. * Enable the FOV adjustment feature controlled by fovMultiplier.
  138205. */
  138206. useEquirectangularFOV: boolean;
  138207. private _maxSimultaneousLights;
  138208. /**
  138209. * Number of Simultaneous lights allowed on the material.
  138210. */
  138211. maxSimultaneousLights: int;
  138212. private _shadowOnly;
  138213. /**
  138214. * Make the material only render shadows
  138215. */
  138216. shadowOnly: boolean;
  138217. /**
  138218. * Default configuration related to image processing available in the Background Material.
  138219. */
  138220. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  138221. /**
  138222. * Keep track of the image processing observer to allow dispose and replace.
  138223. */
  138224. private _imageProcessingObserver;
  138225. /**
  138226. * Attaches a new image processing configuration to the PBR Material.
  138227. * @param configuration (if null the scene configuration will be use)
  138228. */
  138229. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  138230. /**
  138231. * Gets the image processing configuration used either in this material.
  138232. */
  138233. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  138234. /**
  138235. * Sets the Default image processing configuration used either in the this material.
  138236. *
  138237. * If sets to null, the scene one is in use.
  138238. */
  138239. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  138240. /**
  138241. * Gets wether the color curves effect is enabled.
  138242. */
  138243. get cameraColorCurvesEnabled(): boolean;
  138244. /**
  138245. * Sets wether the color curves effect is enabled.
  138246. */
  138247. set cameraColorCurvesEnabled(value: boolean);
  138248. /**
  138249. * Gets wether the color grading effect is enabled.
  138250. */
  138251. get cameraColorGradingEnabled(): boolean;
  138252. /**
  138253. * Gets wether the color grading effect is enabled.
  138254. */
  138255. set cameraColorGradingEnabled(value: boolean);
  138256. /**
  138257. * Gets wether tonemapping is enabled or not.
  138258. */
  138259. get cameraToneMappingEnabled(): boolean;
  138260. /**
  138261. * Sets wether tonemapping is enabled or not
  138262. */
  138263. set cameraToneMappingEnabled(value: boolean);
  138264. /**
  138265. * The camera exposure used on this material.
  138266. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138267. * This corresponds to a photographic exposure.
  138268. */
  138269. get cameraExposure(): float;
  138270. /**
  138271. * The camera exposure used on this material.
  138272. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138273. * This corresponds to a photographic exposure.
  138274. */
  138275. set cameraExposure(value: float);
  138276. /**
  138277. * Gets The camera contrast used on this material.
  138278. */
  138279. get cameraContrast(): float;
  138280. /**
  138281. * Sets The camera contrast used on this material.
  138282. */
  138283. set cameraContrast(value: float);
  138284. /**
  138285. * Gets the Color Grading 2D Lookup Texture.
  138286. */
  138287. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  138288. /**
  138289. * Sets the Color Grading 2D Lookup Texture.
  138290. */
  138291. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  138292. /**
  138293. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138294. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138295. * 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;
  138296. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138297. */
  138298. get cameraColorCurves(): Nullable<ColorCurves>;
  138299. /**
  138300. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138301. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138302. * 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;
  138303. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138304. */
  138305. set cameraColorCurves(value: Nullable<ColorCurves>);
  138306. /**
  138307. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  138308. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  138309. */
  138310. switchToBGR: boolean;
  138311. private _renderTargets;
  138312. private _reflectionControls;
  138313. private _white;
  138314. private _primaryShadowColor;
  138315. private _primaryHighlightColor;
  138316. /**
  138317. * Instantiates a Background Material in the given scene
  138318. * @param name The friendly name of the material
  138319. * @param scene The scene to add the material to
  138320. */
  138321. constructor(name: string, scene: Scene);
  138322. /**
  138323. * Gets a boolean indicating that current material needs to register RTT
  138324. */
  138325. get hasRenderTargetTextures(): boolean;
  138326. /**
  138327. * The entire material has been created in order to prevent overdraw.
  138328. * @returns false
  138329. */
  138330. needAlphaTesting(): boolean;
  138331. /**
  138332. * The entire material has been created in order to prevent overdraw.
  138333. * @returns true if blending is enable
  138334. */
  138335. needAlphaBlending(): boolean;
  138336. /**
  138337. * Checks wether the material is ready to be rendered for a given mesh.
  138338. * @param mesh The mesh to render
  138339. * @param subMesh The submesh to check against
  138340. * @param useInstances Specify wether or not the material is used with instances
  138341. * @returns true if all the dependencies are ready (Textures, Effects...)
  138342. */
  138343. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  138344. /**
  138345. * Compute the primary color according to the chosen perceptual color.
  138346. */
  138347. private _computePrimaryColorFromPerceptualColor;
  138348. /**
  138349. * Compute the highlights and shadow colors according to their chosen levels.
  138350. */
  138351. private _computePrimaryColors;
  138352. /**
  138353. * Build the uniform buffer used in the material.
  138354. */
  138355. buildUniformLayout(): void;
  138356. /**
  138357. * Unbind the material.
  138358. */
  138359. unbind(): void;
  138360. /**
  138361. * Bind only the world matrix to the material.
  138362. * @param world The world matrix to bind.
  138363. */
  138364. bindOnlyWorldMatrix(world: Matrix): void;
  138365. /**
  138366. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  138367. * @param world The world matrix to bind.
  138368. * @param subMesh The submesh to bind for.
  138369. */
  138370. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  138371. /**
  138372. * Checks to see if a texture is used in the material.
  138373. * @param texture - Base texture to use.
  138374. * @returns - Boolean specifying if a texture is used in the material.
  138375. */
  138376. hasTexture(texture: BaseTexture): boolean;
  138377. /**
  138378. * Dispose the material.
  138379. * @param forceDisposeEffect Force disposal of the associated effect.
  138380. * @param forceDisposeTextures Force disposal of the associated textures.
  138381. */
  138382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  138383. /**
  138384. * Clones the material.
  138385. * @param name The cloned name.
  138386. * @returns The cloned material.
  138387. */
  138388. clone(name: string): BackgroundMaterial;
  138389. /**
  138390. * Serializes the current material to its JSON representation.
  138391. * @returns The JSON representation.
  138392. */
  138393. serialize(): any;
  138394. /**
  138395. * Gets the class name of the material
  138396. * @returns "BackgroundMaterial"
  138397. */
  138398. getClassName(): string;
  138399. /**
  138400. * Parse a JSON input to create back a background material.
  138401. * @param source The JSON data to parse
  138402. * @param scene The scene to create the parsed material in
  138403. * @param rootUrl The root url of the assets the material depends upon
  138404. * @returns the instantiated BackgroundMaterial.
  138405. */
  138406. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  138407. }
  138408. }
  138409. declare module BABYLON {
  138410. /**
  138411. * Represents the different options available during the creation of
  138412. * a Environment helper.
  138413. *
  138414. * This can control the default ground, skybox and image processing setup of your scene.
  138415. */
  138416. export interface IEnvironmentHelperOptions {
  138417. /**
  138418. * Specifies whether or not to create a ground.
  138419. * True by default.
  138420. */
  138421. createGround: boolean;
  138422. /**
  138423. * Specifies the ground size.
  138424. * 15 by default.
  138425. */
  138426. groundSize: number;
  138427. /**
  138428. * The texture used on the ground for the main color.
  138429. * Comes from the BabylonJS CDN by default.
  138430. *
  138431. * Remarks: Can be either a texture or a url.
  138432. */
  138433. groundTexture: string | BaseTexture;
  138434. /**
  138435. * The color mixed in the ground texture by default.
  138436. * BabylonJS clearColor by default.
  138437. */
  138438. groundColor: Color3;
  138439. /**
  138440. * Specifies the ground opacity.
  138441. * 1 by default.
  138442. */
  138443. groundOpacity: number;
  138444. /**
  138445. * Enables the ground to receive shadows.
  138446. * True by default.
  138447. */
  138448. enableGroundShadow: boolean;
  138449. /**
  138450. * Helps preventing the shadow to be fully black on the ground.
  138451. * 0.5 by default.
  138452. */
  138453. groundShadowLevel: number;
  138454. /**
  138455. * Creates a mirror texture attach to the ground.
  138456. * false by default.
  138457. */
  138458. enableGroundMirror: boolean;
  138459. /**
  138460. * Specifies the ground mirror size ratio.
  138461. * 0.3 by default as the default kernel is 64.
  138462. */
  138463. groundMirrorSizeRatio: number;
  138464. /**
  138465. * Specifies the ground mirror blur kernel size.
  138466. * 64 by default.
  138467. */
  138468. groundMirrorBlurKernel: number;
  138469. /**
  138470. * Specifies the ground mirror visibility amount.
  138471. * 1 by default
  138472. */
  138473. groundMirrorAmount: number;
  138474. /**
  138475. * Specifies the ground mirror reflectance weight.
  138476. * This uses the standard weight of the background material to setup the fresnel effect
  138477. * of the mirror.
  138478. * 1 by default.
  138479. */
  138480. groundMirrorFresnelWeight: number;
  138481. /**
  138482. * Specifies the ground mirror Falloff distance.
  138483. * This can helps reducing the size of the reflection.
  138484. * 0 by Default.
  138485. */
  138486. groundMirrorFallOffDistance: number;
  138487. /**
  138488. * Specifies the ground mirror texture type.
  138489. * Unsigned Int by Default.
  138490. */
  138491. groundMirrorTextureType: number;
  138492. /**
  138493. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  138494. * the shown objects.
  138495. */
  138496. groundYBias: number;
  138497. /**
  138498. * Specifies whether or not to create a skybox.
  138499. * True by default.
  138500. */
  138501. createSkybox: boolean;
  138502. /**
  138503. * Specifies the skybox size.
  138504. * 20 by default.
  138505. */
  138506. skyboxSize: number;
  138507. /**
  138508. * The texture used on the skybox for the main color.
  138509. * Comes from the BabylonJS CDN by default.
  138510. *
  138511. * Remarks: Can be either a texture or a url.
  138512. */
  138513. skyboxTexture: string | BaseTexture;
  138514. /**
  138515. * The color mixed in the skybox texture by default.
  138516. * BabylonJS clearColor by default.
  138517. */
  138518. skyboxColor: Color3;
  138519. /**
  138520. * The background rotation around the Y axis of the scene.
  138521. * This helps aligning the key lights of your scene with the background.
  138522. * 0 by default.
  138523. */
  138524. backgroundYRotation: number;
  138525. /**
  138526. * Compute automatically the size of the elements to best fit with the scene.
  138527. */
  138528. sizeAuto: boolean;
  138529. /**
  138530. * Default position of the rootMesh if autoSize is not true.
  138531. */
  138532. rootPosition: Vector3;
  138533. /**
  138534. * Sets up the image processing in the scene.
  138535. * true by default.
  138536. */
  138537. setupImageProcessing: boolean;
  138538. /**
  138539. * The texture used as your environment texture in the scene.
  138540. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  138541. *
  138542. * Remarks: Can be either a texture or a url.
  138543. */
  138544. environmentTexture: string | BaseTexture;
  138545. /**
  138546. * The value of the exposure to apply to the scene.
  138547. * 0.6 by default if setupImageProcessing is true.
  138548. */
  138549. cameraExposure: number;
  138550. /**
  138551. * The value of the contrast to apply to the scene.
  138552. * 1.6 by default if setupImageProcessing is true.
  138553. */
  138554. cameraContrast: number;
  138555. /**
  138556. * Specifies whether or not tonemapping should be enabled in the scene.
  138557. * true by default if setupImageProcessing is true.
  138558. */
  138559. toneMappingEnabled: boolean;
  138560. }
  138561. /**
  138562. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  138563. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  138564. * It also helps with the default setup of your imageProcessing configuration.
  138565. */
  138566. export class EnvironmentHelper {
  138567. /**
  138568. * Default ground texture URL.
  138569. */
  138570. private static _groundTextureCDNUrl;
  138571. /**
  138572. * Default skybox texture URL.
  138573. */
  138574. private static _skyboxTextureCDNUrl;
  138575. /**
  138576. * Default environment texture URL.
  138577. */
  138578. private static _environmentTextureCDNUrl;
  138579. /**
  138580. * Creates the default options for the helper.
  138581. */
  138582. private static _getDefaultOptions;
  138583. private _rootMesh;
  138584. /**
  138585. * Gets the root mesh created by the helper.
  138586. */
  138587. get rootMesh(): Mesh;
  138588. private _skybox;
  138589. /**
  138590. * Gets the skybox created by the helper.
  138591. */
  138592. get skybox(): Nullable<Mesh>;
  138593. private _skyboxTexture;
  138594. /**
  138595. * Gets the skybox texture created by the helper.
  138596. */
  138597. get skyboxTexture(): Nullable<BaseTexture>;
  138598. private _skyboxMaterial;
  138599. /**
  138600. * Gets the skybox material created by the helper.
  138601. */
  138602. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  138603. private _ground;
  138604. /**
  138605. * Gets the ground mesh created by the helper.
  138606. */
  138607. get ground(): Nullable<Mesh>;
  138608. private _groundTexture;
  138609. /**
  138610. * Gets the ground texture created by the helper.
  138611. */
  138612. get groundTexture(): Nullable<BaseTexture>;
  138613. private _groundMirror;
  138614. /**
  138615. * Gets the ground mirror created by the helper.
  138616. */
  138617. get groundMirror(): Nullable<MirrorTexture>;
  138618. /**
  138619. * Gets the ground mirror render list to helps pushing the meshes
  138620. * you wish in the ground reflection.
  138621. */
  138622. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  138623. private _groundMaterial;
  138624. /**
  138625. * Gets the ground material created by the helper.
  138626. */
  138627. get groundMaterial(): Nullable<BackgroundMaterial>;
  138628. /**
  138629. * Stores the creation options.
  138630. */
  138631. private readonly _scene;
  138632. private _options;
  138633. /**
  138634. * This observable will be notified with any error during the creation of the environment,
  138635. * mainly texture creation errors.
  138636. */
  138637. onErrorObservable: Observable<{
  138638. message?: string;
  138639. exception?: any;
  138640. }>;
  138641. /**
  138642. * constructor
  138643. * @param options Defines the options we want to customize the helper
  138644. * @param scene The scene to add the material to
  138645. */
  138646. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  138647. /**
  138648. * Updates the background according to the new options
  138649. * @param options
  138650. */
  138651. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  138652. /**
  138653. * Sets the primary color of all the available elements.
  138654. * @param color the main color to affect to the ground and the background
  138655. */
  138656. setMainColor(color: Color3): void;
  138657. /**
  138658. * Setup the image processing according to the specified options.
  138659. */
  138660. private _setupImageProcessing;
  138661. /**
  138662. * Setup the environment texture according to the specified options.
  138663. */
  138664. private _setupEnvironmentTexture;
  138665. /**
  138666. * Setup the background according to the specified options.
  138667. */
  138668. private _setupBackground;
  138669. /**
  138670. * Get the scene sizes according to the setup.
  138671. */
  138672. private _getSceneSize;
  138673. /**
  138674. * Setup the ground according to the specified options.
  138675. */
  138676. private _setupGround;
  138677. /**
  138678. * Setup the ground material according to the specified options.
  138679. */
  138680. private _setupGroundMaterial;
  138681. /**
  138682. * Setup the ground diffuse texture according to the specified options.
  138683. */
  138684. private _setupGroundDiffuseTexture;
  138685. /**
  138686. * Setup the ground mirror texture according to the specified options.
  138687. */
  138688. private _setupGroundMirrorTexture;
  138689. /**
  138690. * Setup the ground to receive the mirror texture.
  138691. */
  138692. private _setupMirrorInGroundMaterial;
  138693. /**
  138694. * Setup the skybox according to the specified options.
  138695. */
  138696. private _setupSkybox;
  138697. /**
  138698. * Setup the skybox material according to the specified options.
  138699. */
  138700. private _setupSkyboxMaterial;
  138701. /**
  138702. * Setup the skybox reflection texture according to the specified options.
  138703. */
  138704. private _setupSkyboxReflectionTexture;
  138705. private _errorHandler;
  138706. /**
  138707. * Dispose all the elements created by the Helper.
  138708. */
  138709. dispose(): void;
  138710. }
  138711. }
  138712. declare module BABYLON {
  138713. /**
  138714. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  138715. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  138716. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138717. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138718. */
  138719. export abstract class TextureDome<T extends Texture> extends TransformNode {
  138720. protected onError: Nullable<(message?: string, exception?: any) => void>;
  138721. /**
  138722. * Define the source as a Monoscopic panoramic 360/180.
  138723. */
  138724. static readonly MODE_MONOSCOPIC: number;
  138725. /**
  138726. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  138727. */
  138728. static readonly MODE_TOPBOTTOM: number;
  138729. /**
  138730. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  138731. */
  138732. static readonly MODE_SIDEBYSIDE: number;
  138733. private _halfDome;
  138734. private _crossEye;
  138735. protected _useDirectMapping: boolean;
  138736. /**
  138737. * The texture being displayed on the sphere
  138738. */
  138739. protected _texture: T;
  138740. /**
  138741. * Gets the texture being displayed on the sphere
  138742. */
  138743. get texture(): T;
  138744. /**
  138745. * Sets the texture being displayed on the sphere
  138746. */
  138747. set texture(newTexture: T);
  138748. /**
  138749. * The skybox material
  138750. */
  138751. protected _material: BackgroundMaterial;
  138752. /**
  138753. * The surface used for the dome
  138754. */
  138755. protected _mesh: Mesh;
  138756. /**
  138757. * Gets the mesh used for the dome.
  138758. */
  138759. get mesh(): Mesh;
  138760. /**
  138761. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  138762. */
  138763. private _halfDomeMask;
  138764. /**
  138765. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  138766. * Also see the options.resolution property.
  138767. */
  138768. get fovMultiplier(): number;
  138769. set fovMultiplier(value: number);
  138770. protected _textureMode: number;
  138771. /**
  138772. * Gets or set the current texture mode for the texture. It can be:
  138773. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138774. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138775. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138776. */
  138777. get textureMode(): number;
  138778. /**
  138779. * Sets the current texture mode for the texture. It can be:
  138780. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138781. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138782. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138783. */
  138784. set textureMode(value: number);
  138785. /**
  138786. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  138787. */
  138788. get halfDome(): boolean;
  138789. /**
  138790. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  138791. */
  138792. set halfDome(enabled: boolean);
  138793. /**
  138794. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  138795. */
  138796. set crossEye(enabled: boolean);
  138797. /**
  138798. * Is it a cross-eye texture?
  138799. */
  138800. get crossEye(): boolean;
  138801. /**
  138802. * Oberserver used in Stereoscopic VR Mode.
  138803. */
  138804. private _onBeforeCameraRenderObserver;
  138805. /**
  138806. * Observable raised when an error occured while loading the 360 image
  138807. */
  138808. onLoadErrorObservable: Observable<string>;
  138809. /**
  138810. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  138811. * @param name Element's name, child elements will append suffixes for their own names.
  138812. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  138813. * @param options An object containing optional or exposed sub element properties
  138814. */
  138815. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  138816. resolution?: number;
  138817. clickToPlay?: boolean;
  138818. autoPlay?: boolean;
  138819. loop?: boolean;
  138820. size?: number;
  138821. poster?: string;
  138822. faceForward?: boolean;
  138823. useDirectMapping?: boolean;
  138824. halfDomeMode?: boolean;
  138825. crossEyeMode?: boolean;
  138826. generateMipMaps?: boolean;
  138827. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  138828. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  138829. protected _changeTextureMode(value: number): void;
  138830. /**
  138831. * Releases resources associated with this node.
  138832. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  138833. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  138834. */
  138835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  138836. }
  138837. }
  138838. declare module BABYLON {
  138839. /**
  138840. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  138841. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  138842. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  138843. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138844. */
  138845. export class PhotoDome extends TextureDome<Texture> {
  138846. /**
  138847. * Define the image as a Monoscopic panoramic 360 image.
  138848. */
  138849. static readonly MODE_MONOSCOPIC: number;
  138850. /**
  138851. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  138852. */
  138853. static readonly MODE_TOPBOTTOM: number;
  138854. /**
  138855. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  138856. */
  138857. static readonly MODE_SIDEBYSIDE: number;
  138858. /**
  138859. * Gets or sets the texture being displayed on the sphere
  138860. */
  138861. get photoTexture(): Texture;
  138862. /**
  138863. * sets the texture being displayed on the sphere
  138864. */
  138865. set photoTexture(value: Texture);
  138866. /**
  138867. * Gets the current video mode for the video. It can be:
  138868. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138869. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138870. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138871. */
  138872. get imageMode(): number;
  138873. /**
  138874. * Sets the current video mode for the video. It can be:
  138875. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  138876. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  138877. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  138878. */
  138879. set imageMode(value: number);
  138880. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  138881. }
  138882. }
  138883. declare module BABYLON {
  138884. /**
  138885. * Direct draw surface info
  138886. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  138887. */
  138888. export interface DDSInfo {
  138889. /**
  138890. * Width of the texture
  138891. */
  138892. width: number;
  138893. /**
  138894. * Width of the texture
  138895. */
  138896. height: number;
  138897. /**
  138898. * Number of Mipmaps for the texture
  138899. * @see https://en.wikipedia.org/wiki/Mipmap
  138900. */
  138901. mipmapCount: number;
  138902. /**
  138903. * If the textures format is a known fourCC format
  138904. * @see https://www.fourcc.org/
  138905. */
  138906. isFourCC: boolean;
  138907. /**
  138908. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  138909. */
  138910. isRGB: boolean;
  138911. /**
  138912. * If the texture is a lumincance format
  138913. */
  138914. isLuminance: boolean;
  138915. /**
  138916. * If this is a cube texture
  138917. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  138918. */
  138919. isCube: boolean;
  138920. /**
  138921. * If the texture is a compressed format eg. FOURCC_DXT1
  138922. */
  138923. isCompressed: boolean;
  138924. /**
  138925. * The dxgiFormat of the texture
  138926. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  138927. */
  138928. dxgiFormat: number;
  138929. /**
  138930. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  138931. */
  138932. textureType: number;
  138933. /**
  138934. * Sphericle polynomial created for the dds texture
  138935. */
  138936. sphericalPolynomial?: SphericalPolynomial;
  138937. }
  138938. /**
  138939. * Class used to provide DDS decompression tools
  138940. */
  138941. export class DDSTools {
  138942. /**
  138943. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138944. */
  138945. static StoreLODInAlphaChannel: boolean;
  138946. /**
  138947. * Gets DDS information from an array buffer
  138948. * @param data defines the array buffer view to read data from
  138949. * @returns the DDS information
  138950. */
  138951. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138952. private static _FloatView;
  138953. private static _Int32View;
  138954. private static _ToHalfFloat;
  138955. private static _FromHalfFloat;
  138956. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138957. private static _GetHalfFloatRGBAArrayBuffer;
  138958. private static _GetFloatRGBAArrayBuffer;
  138959. private static _GetFloatAsUIntRGBAArrayBuffer;
  138960. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138961. private static _GetRGBAArrayBuffer;
  138962. private static _ExtractLongWordOrder;
  138963. private static _GetRGBArrayBuffer;
  138964. private static _GetLuminanceArrayBuffer;
  138965. /**
  138966. * Uploads DDS Levels to a Babylon Texture
  138967. * @hidden
  138968. */
  138969. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138970. }
  138971. interface ThinEngine {
  138972. /**
  138973. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138974. * @param rootUrl defines the url where the file to load is located
  138975. * @param scene defines the current scene
  138976. * @param lodScale defines scale to apply to the mip map selection
  138977. * @param lodOffset defines offset to apply to the mip map selection
  138978. * @param onLoad defines an optional callback raised when the texture is loaded
  138979. * @param onError defines an optional callback raised if there is an issue to load the texture
  138980. * @param format defines the format of the data
  138981. * @param forcedExtension defines the extension to use to pick the right loader
  138982. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138983. * @returns the cube texture as an InternalTexture
  138984. */
  138985. 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;
  138986. }
  138987. }
  138988. declare module BABYLON {
  138989. /**
  138990. * Implementation of the DDS Texture Loader.
  138991. * @hidden
  138992. */
  138993. export class _DDSTextureLoader implements IInternalTextureLoader {
  138994. /**
  138995. * Defines wether the loader supports cascade loading the different faces.
  138996. */
  138997. readonly supportCascades: boolean;
  138998. /**
  138999. * This returns if the loader support the current file information.
  139000. * @param extension defines the file extension of the file being loaded
  139001. * @returns true if the loader can load the specified file
  139002. */
  139003. canLoad(extension: string): boolean;
  139004. /**
  139005. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139006. * @param data contains the texture data
  139007. * @param texture defines the BabylonJS internal texture
  139008. * @param createPolynomials will be true if polynomials have been requested
  139009. * @param onLoad defines the callback to trigger once the texture is ready
  139010. * @param onError defines the callback to trigger in case of error
  139011. */
  139012. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139013. /**
  139014. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139015. * @param data contains the texture data
  139016. * @param texture defines the BabylonJS internal texture
  139017. * @param callback defines the method to call once ready to upload
  139018. */
  139019. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139020. }
  139021. }
  139022. declare module BABYLON {
  139023. /**
  139024. * Implementation of the ENV Texture Loader.
  139025. * @hidden
  139026. */
  139027. export class _ENVTextureLoader implements IInternalTextureLoader {
  139028. /**
  139029. * Defines wether the loader supports cascade loading the different faces.
  139030. */
  139031. readonly supportCascades: boolean;
  139032. /**
  139033. * This returns if the loader support the current file information.
  139034. * @param extension defines the file extension of the file being loaded
  139035. * @returns true if the loader can load the specified file
  139036. */
  139037. canLoad(extension: string): boolean;
  139038. /**
  139039. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139040. * @param data contains the texture data
  139041. * @param texture defines the BabylonJS internal texture
  139042. * @param createPolynomials will be true if polynomials have been requested
  139043. * @param onLoad defines the callback to trigger once the texture is ready
  139044. * @param onError defines the callback to trigger in case of error
  139045. */
  139046. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139047. /**
  139048. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139049. * @param data contains the texture data
  139050. * @param texture defines the BabylonJS internal texture
  139051. * @param callback defines the method to call once ready to upload
  139052. */
  139053. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139054. }
  139055. }
  139056. declare module BABYLON {
  139057. /**
  139058. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  139059. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  139060. */
  139061. export class KhronosTextureContainer {
  139062. /** contents of the KTX container file */
  139063. data: ArrayBufferView;
  139064. private static HEADER_LEN;
  139065. private static COMPRESSED_2D;
  139066. private static COMPRESSED_3D;
  139067. private static TEX_2D;
  139068. private static TEX_3D;
  139069. /**
  139070. * Gets the openGL type
  139071. */
  139072. glType: number;
  139073. /**
  139074. * Gets the openGL type size
  139075. */
  139076. glTypeSize: number;
  139077. /**
  139078. * Gets the openGL format
  139079. */
  139080. glFormat: number;
  139081. /**
  139082. * Gets the openGL internal format
  139083. */
  139084. glInternalFormat: number;
  139085. /**
  139086. * Gets the base internal format
  139087. */
  139088. glBaseInternalFormat: number;
  139089. /**
  139090. * Gets image width in pixel
  139091. */
  139092. pixelWidth: number;
  139093. /**
  139094. * Gets image height in pixel
  139095. */
  139096. pixelHeight: number;
  139097. /**
  139098. * Gets image depth in pixels
  139099. */
  139100. pixelDepth: number;
  139101. /**
  139102. * Gets the number of array elements
  139103. */
  139104. numberOfArrayElements: number;
  139105. /**
  139106. * Gets the number of faces
  139107. */
  139108. numberOfFaces: number;
  139109. /**
  139110. * Gets the number of mipmap levels
  139111. */
  139112. numberOfMipmapLevels: number;
  139113. /**
  139114. * Gets the bytes of key value data
  139115. */
  139116. bytesOfKeyValueData: number;
  139117. /**
  139118. * Gets the load type
  139119. */
  139120. loadType: number;
  139121. /**
  139122. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  139123. */
  139124. isInvalid: boolean;
  139125. /**
  139126. * Creates a new KhronosTextureContainer
  139127. * @param data contents of the KTX container file
  139128. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  139129. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  139130. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  139131. */
  139132. constructor(
  139133. /** contents of the KTX container file */
  139134. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  139135. /**
  139136. * Uploads KTX content to a Babylon Texture.
  139137. * It is assumed that the texture has already been created & is currently bound
  139138. * @hidden
  139139. */
  139140. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  139141. private _upload2DCompressedLevels;
  139142. /**
  139143. * Checks if the given data starts with a KTX file identifier.
  139144. * @param data the data to check
  139145. * @returns true if the data is a KTX file or false otherwise
  139146. */
  139147. static IsValid(data: ArrayBufferView): boolean;
  139148. }
  139149. }
  139150. declare module BABYLON {
  139151. /**
  139152. * Helper class to push actions to a pool of workers.
  139153. */
  139154. export class WorkerPool implements IDisposable {
  139155. private _workerInfos;
  139156. private _pendingActions;
  139157. /**
  139158. * Constructor
  139159. * @param workers Array of workers to use for actions
  139160. */
  139161. constructor(workers: Array<Worker>);
  139162. /**
  139163. * Terminates all workers and clears any pending actions.
  139164. */
  139165. dispose(): void;
  139166. /**
  139167. * Pushes an action to the worker pool. If all the workers are active, the action will be
  139168. * pended until a worker has completed its action.
  139169. * @param action The action to perform. Call onComplete when the action is complete.
  139170. */
  139171. push(action: (worker: Worker, onComplete: () => void) => void): void;
  139172. private _execute;
  139173. }
  139174. }
  139175. declare module BABYLON {
  139176. /**
  139177. * Class for loading KTX2 files
  139178. */
  139179. export class KhronosTextureContainer2 {
  139180. private static _WorkerPoolPromise?;
  139181. private static _Initialized;
  139182. private static _Ktx2Decoder;
  139183. /**
  139184. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  139185. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  139186. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  139187. * Urls you can change:
  139188. * URLConfig.jsDecoderModule
  139189. * URLConfig.wasmUASTCToASTC
  139190. * URLConfig.wasmUASTCToBC7
  139191. * URLConfig.jsMSCTranscoder
  139192. * URLConfig.wasmMSCTranscoder
  139193. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  139194. */
  139195. static URLConfig: {
  139196. jsDecoderModule: string;
  139197. wasmUASTCToASTC: null;
  139198. wasmUASTCToBC7: null;
  139199. jsMSCTranscoder: null;
  139200. wasmMSCTranscoder: null;
  139201. };
  139202. /**
  139203. * Default number of workers used to handle data decoding
  139204. */
  139205. static DefaultNumWorkers: number;
  139206. private static GetDefaultNumWorkers;
  139207. private _engine;
  139208. private static _CreateWorkerPool;
  139209. /**
  139210. * Constructor
  139211. * @param engine The engine to use
  139212. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  139213. */
  139214. constructor(engine: ThinEngine, numWorkers?: number);
  139215. /** @hidden */
  139216. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  139217. /**
  139218. * Stop all async operations and release resources.
  139219. */
  139220. dispose(): void;
  139221. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  139222. /**
  139223. * Checks if the given data starts with a KTX2 file identifier.
  139224. * @param data the data to check
  139225. * @returns true if the data is a KTX2 file or false otherwise
  139226. */
  139227. static IsValid(data: ArrayBufferView): boolean;
  139228. }
  139229. }
  139230. declare module BABYLON {
  139231. /**
  139232. * Implementation of the KTX Texture Loader.
  139233. * @hidden
  139234. */
  139235. export class _KTXTextureLoader implements IInternalTextureLoader {
  139236. /**
  139237. * Defines wether the loader supports cascade loading the different faces.
  139238. */
  139239. readonly supportCascades: boolean;
  139240. /**
  139241. * This returns if the loader support the current file information.
  139242. * @param extension defines the file extension of the file being loaded
  139243. * @param mimeType defines the optional mime type of the file being loaded
  139244. * @returns true if the loader can load the specified file
  139245. */
  139246. canLoad(extension: string, mimeType?: string): boolean;
  139247. /**
  139248. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139249. * @param data contains the texture data
  139250. * @param texture defines the BabylonJS internal texture
  139251. * @param createPolynomials will be true if polynomials have been requested
  139252. * @param onLoad defines the callback to trigger once the texture is ready
  139253. * @param onError defines the callback to trigger in case of error
  139254. */
  139255. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139256. /**
  139257. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139258. * @param data contains the texture data
  139259. * @param texture defines the BabylonJS internal texture
  139260. * @param callback defines the method to call once ready to upload
  139261. */
  139262. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  139263. }
  139264. }
  139265. declare module BABYLON {
  139266. /** @hidden */
  139267. export var _forceSceneHelpersToBundle: boolean;
  139268. interface Scene {
  139269. /**
  139270. * Creates a default light for the scene.
  139271. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  139272. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  139273. */
  139274. createDefaultLight(replace?: boolean): void;
  139275. /**
  139276. * Creates a default camera for the scene.
  139277. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  139278. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139279. * @param replace has default false, when true replaces the active camera in the scene
  139280. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  139281. */
  139282. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139283. /**
  139284. * Creates a default camera and a default light.
  139285. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  139286. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  139287. * @param replace has the default false, when true replaces the active camera/light in the scene
  139288. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  139289. */
  139290. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  139291. /**
  139292. * Creates a new sky box
  139293. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  139294. * @param environmentTexture defines the texture to use as environment texture
  139295. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  139296. * @param scale defines the overall scale of the skybox
  139297. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  139298. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  139299. * @returns a new mesh holding the sky box
  139300. */
  139301. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  139302. /**
  139303. * Creates a new environment
  139304. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  139305. * @param options defines the options you can use to configure the environment
  139306. * @returns the new EnvironmentHelper
  139307. */
  139308. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  139309. /**
  139310. * Creates a new VREXperienceHelper
  139311. * @see https://doc.babylonjs.com/how_to/webvr_helper
  139312. * @param webVROptions defines the options used to create the new VREXperienceHelper
  139313. * @returns a new VREXperienceHelper
  139314. */
  139315. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  139316. /**
  139317. * Creates a new WebXRDefaultExperience
  139318. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  139319. * @param options experience options
  139320. * @returns a promise for a new WebXRDefaultExperience
  139321. */
  139322. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  139323. }
  139324. }
  139325. declare module BABYLON {
  139326. /**
  139327. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  139328. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  139329. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  139330. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139331. */
  139332. export class VideoDome extends TextureDome<VideoTexture> {
  139333. /**
  139334. * Define the video source as a Monoscopic panoramic 360 video.
  139335. */
  139336. static readonly MODE_MONOSCOPIC: number;
  139337. /**
  139338. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  139339. */
  139340. static readonly MODE_TOPBOTTOM: number;
  139341. /**
  139342. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  139343. */
  139344. static readonly MODE_SIDEBYSIDE: number;
  139345. /**
  139346. * Get the video texture associated with this video dome
  139347. */
  139348. get videoTexture(): VideoTexture;
  139349. /**
  139350. * Get the video mode of this dome
  139351. */
  139352. get videoMode(): number;
  139353. /**
  139354. * Set the video mode of this dome.
  139355. * @see textureMode
  139356. */
  139357. set videoMode(value: number);
  139358. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  139359. }
  139360. }
  139361. declare module BABYLON {
  139362. /**
  139363. * This class can be used to get instrumentation data from a Babylon engine
  139364. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139365. */
  139366. export class EngineInstrumentation implements IDisposable {
  139367. /**
  139368. * Define the instrumented engine.
  139369. */
  139370. engine: Engine;
  139371. private _captureGPUFrameTime;
  139372. private _gpuFrameTimeToken;
  139373. private _gpuFrameTime;
  139374. private _captureShaderCompilationTime;
  139375. private _shaderCompilationTime;
  139376. private _onBeginFrameObserver;
  139377. private _onEndFrameObserver;
  139378. private _onBeforeShaderCompilationObserver;
  139379. private _onAfterShaderCompilationObserver;
  139380. /**
  139381. * Gets the perf counter used for GPU frame time
  139382. */
  139383. get gpuFrameTimeCounter(): PerfCounter;
  139384. /**
  139385. * Gets the GPU frame time capture status
  139386. */
  139387. get captureGPUFrameTime(): boolean;
  139388. /**
  139389. * Enable or disable the GPU frame time capture
  139390. */
  139391. set captureGPUFrameTime(value: boolean);
  139392. /**
  139393. * Gets the perf counter used for shader compilation time
  139394. */
  139395. get shaderCompilationTimeCounter(): PerfCounter;
  139396. /**
  139397. * Gets the shader compilation time capture status
  139398. */
  139399. get captureShaderCompilationTime(): boolean;
  139400. /**
  139401. * Enable or disable the shader compilation time capture
  139402. */
  139403. set captureShaderCompilationTime(value: boolean);
  139404. /**
  139405. * Instantiates a new engine instrumentation.
  139406. * This class can be used to get instrumentation data from a Babylon engine
  139407. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  139408. * @param engine Defines the engine to instrument
  139409. */
  139410. constructor(
  139411. /**
  139412. * Define the instrumented engine.
  139413. */
  139414. engine: Engine);
  139415. /**
  139416. * Dispose and release associated resources.
  139417. */
  139418. dispose(): void;
  139419. }
  139420. }
  139421. declare module BABYLON {
  139422. /**
  139423. * This class can be used to get instrumentation data from a Babylon engine
  139424. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139425. */
  139426. export class SceneInstrumentation implements IDisposable {
  139427. /**
  139428. * Defines the scene to instrument
  139429. */
  139430. scene: Scene;
  139431. private _captureActiveMeshesEvaluationTime;
  139432. private _activeMeshesEvaluationTime;
  139433. private _captureRenderTargetsRenderTime;
  139434. private _renderTargetsRenderTime;
  139435. private _captureFrameTime;
  139436. private _frameTime;
  139437. private _captureRenderTime;
  139438. private _renderTime;
  139439. private _captureInterFrameTime;
  139440. private _interFrameTime;
  139441. private _captureParticlesRenderTime;
  139442. private _particlesRenderTime;
  139443. private _captureSpritesRenderTime;
  139444. private _spritesRenderTime;
  139445. private _capturePhysicsTime;
  139446. private _physicsTime;
  139447. private _captureAnimationsTime;
  139448. private _animationsTime;
  139449. private _captureCameraRenderTime;
  139450. private _cameraRenderTime;
  139451. private _onBeforeActiveMeshesEvaluationObserver;
  139452. private _onAfterActiveMeshesEvaluationObserver;
  139453. private _onBeforeRenderTargetsRenderObserver;
  139454. private _onAfterRenderTargetsRenderObserver;
  139455. private _onAfterRenderObserver;
  139456. private _onBeforeDrawPhaseObserver;
  139457. private _onAfterDrawPhaseObserver;
  139458. private _onBeforeAnimationsObserver;
  139459. private _onBeforeParticlesRenderingObserver;
  139460. private _onAfterParticlesRenderingObserver;
  139461. private _onBeforeSpritesRenderingObserver;
  139462. private _onAfterSpritesRenderingObserver;
  139463. private _onBeforePhysicsObserver;
  139464. private _onAfterPhysicsObserver;
  139465. private _onAfterAnimationsObserver;
  139466. private _onBeforeCameraRenderObserver;
  139467. private _onAfterCameraRenderObserver;
  139468. /**
  139469. * Gets the perf counter used for active meshes evaluation time
  139470. */
  139471. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  139472. /**
  139473. * Gets the active meshes evaluation time capture status
  139474. */
  139475. get captureActiveMeshesEvaluationTime(): boolean;
  139476. /**
  139477. * Enable or disable the active meshes evaluation time capture
  139478. */
  139479. set captureActiveMeshesEvaluationTime(value: boolean);
  139480. /**
  139481. * Gets the perf counter used for render targets render time
  139482. */
  139483. get renderTargetsRenderTimeCounter(): PerfCounter;
  139484. /**
  139485. * Gets the render targets render time capture status
  139486. */
  139487. get captureRenderTargetsRenderTime(): boolean;
  139488. /**
  139489. * Enable or disable the render targets render time capture
  139490. */
  139491. set captureRenderTargetsRenderTime(value: boolean);
  139492. /**
  139493. * Gets the perf counter used for particles render time
  139494. */
  139495. get particlesRenderTimeCounter(): PerfCounter;
  139496. /**
  139497. * Gets the particles render time capture status
  139498. */
  139499. get captureParticlesRenderTime(): boolean;
  139500. /**
  139501. * Enable or disable the particles render time capture
  139502. */
  139503. set captureParticlesRenderTime(value: boolean);
  139504. /**
  139505. * Gets the perf counter used for sprites render time
  139506. */
  139507. get spritesRenderTimeCounter(): PerfCounter;
  139508. /**
  139509. * Gets the sprites render time capture status
  139510. */
  139511. get captureSpritesRenderTime(): boolean;
  139512. /**
  139513. * Enable or disable the sprites render time capture
  139514. */
  139515. set captureSpritesRenderTime(value: boolean);
  139516. /**
  139517. * Gets the perf counter used for physics time
  139518. */
  139519. get physicsTimeCounter(): PerfCounter;
  139520. /**
  139521. * Gets the physics time capture status
  139522. */
  139523. get capturePhysicsTime(): boolean;
  139524. /**
  139525. * Enable or disable the physics time capture
  139526. */
  139527. set capturePhysicsTime(value: boolean);
  139528. /**
  139529. * Gets the perf counter used for animations time
  139530. */
  139531. get animationsTimeCounter(): PerfCounter;
  139532. /**
  139533. * Gets the animations time capture status
  139534. */
  139535. get captureAnimationsTime(): boolean;
  139536. /**
  139537. * Enable or disable the animations time capture
  139538. */
  139539. set captureAnimationsTime(value: boolean);
  139540. /**
  139541. * Gets the perf counter used for frame time capture
  139542. */
  139543. get frameTimeCounter(): PerfCounter;
  139544. /**
  139545. * Gets the frame time capture status
  139546. */
  139547. get captureFrameTime(): boolean;
  139548. /**
  139549. * Enable or disable the frame time capture
  139550. */
  139551. set captureFrameTime(value: boolean);
  139552. /**
  139553. * Gets the perf counter used for inter-frames time capture
  139554. */
  139555. get interFrameTimeCounter(): PerfCounter;
  139556. /**
  139557. * Gets the inter-frames time capture status
  139558. */
  139559. get captureInterFrameTime(): boolean;
  139560. /**
  139561. * Enable or disable the inter-frames time capture
  139562. */
  139563. set captureInterFrameTime(value: boolean);
  139564. /**
  139565. * Gets the perf counter used for render time capture
  139566. */
  139567. get renderTimeCounter(): PerfCounter;
  139568. /**
  139569. * Gets the render time capture status
  139570. */
  139571. get captureRenderTime(): boolean;
  139572. /**
  139573. * Enable or disable the render time capture
  139574. */
  139575. set captureRenderTime(value: boolean);
  139576. /**
  139577. * Gets the perf counter used for camera render time capture
  139578. */
  139579. get cameraRenderTimeCounter(): PerfCounter;
  139580. /**
  139581. * Gets the camera render time capture status
  139582. */
  139583. get captureCameraRenderTime(): boolean;
  139584. /**
  139585. * Enable or disable the camera render time capture
  139586. */
  139587. set captureCameraRenderTime(value: boolean);
  139588. /**
  139589. * Gets the perf counter used for draw calls
  139590. */
  139591. get drawCallsCounter(): PerfCounter;
  139592. /**
  139593. * Instantiates a new scene instrumentation.
  139594. * This class can be used to get instrumentation data from a Babylon engine
  139595. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139596. * @param scene Defines the scene to instrument
  139597. */
  139598. constructor(
  139599. /**
  139600. * Defines the scene to instrument
  139601. */
  139602. scene: Scene);
  139603. /**
  139604. * Dispose and release associated resources.
  139605. */
  139606. dispose(): void;
  139607. }
  139608. }
  139609. declare module BABYLON {
  139610. /** @hidden */
  139611. export var glowMapGenerationPixelShader: {
  139612. name: string;
  139613. shader: string;
  139614. };
  139615. }
  139616. declare module BABYLON {
  139617. /** @hidden */
  139618. export var glowMapGenerationVertexShader: {
  139619. name: string;
  139620. shader: string;
  139621. };
  139622. }
  139623. declare module BABYLON {
  139624. /**
  139625. * Effect layer options. This helps customizing the behaviour
  139626. * of the effect layer.
  139627. */
  139628. export interface IEffectLayerOptions {
  139629. /**
  139630. * Multiplication factor apply to the canvas size to compute the render target size
  139631. * used to generated the objects (the smaller the faster).
  139632. */
  139633. mainTextureRatio: number;
  139634. /**
  139635. * Enforces a fixed size texture to ensure effect stability across devices.
  139636. */
  139637. mainTextureFixedSize?: number;
  139638. /**
  139639. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  139640. */
  139641. alphaBlendingMode: number;
  139642. /**
  139643. * The camera attached to the layer.
  139644. */
  139645. camera: Nullable<Camera>;
  139646. /**
  139647. * The rendering group to draw the layer in.
  139648. */
  139649. renderingGroupId: number;
  139650. }
  139651. /**
  139652. * The effect layer Helps adding post process effect blended with the main pass.
  139653. *
  139654. * This can be for instance use to generate glow or higlight effects on the scene.
  139655. *
  139656. * The effect layer class can not be used directly and is intented to inherited from to be
  139657. * customized per effects.
  139658. */
  139659. export abstract class EffectLayer {
  139660. private _vertexBuffers;
  139661. private _indexBuffer;
  139662. private _cachedDefines;
  139663. private _effectLayerMapGenerationEffect;
  139664. private _effectLayerOptions;
  139665. private _mergeEffect;
  139666. protected _scene: Scene;
  139667. protected _engine: Engine;
  139668. protected _maxSize: number;
  139669. protected _mainTextureDesiredSize: ISize;
  139670. protected _mainTexture: RenderTargetTexture;
  139671. protected _shouldRender: boolean;
  139672. protected _postProcesses: PostProcess[];
  139673. protected _textures: BaseTexture[];
  139674. protected _emissiveTextureAndColor: {
  139675. texture: Nullable<BaseTexture>;
  139676. color: Color4;
  139677. };
  139678. /**
  139679. * The name of the layer
  139680. */
  139681. name: string;
  139682. /**
  139683. * The clear color of the texture used to generate the glow map.
  139684. */
  139685. neutralColor: Color4;
  139686. /**
  139687. * Specifies whether the highlight layer is enabled or not.
  139688. */
  139689. isEnabled: boolean;
  139690. /**
  139691. * Gets the camera attached to the layer.
  139692. */
  139693. get camera(): Nullable<Camera>;
  139694. /**
  139695. * Gets the rendering group id the layer should render in.
  139696. */
  139697. get renderingGroupId(): number;
  139698. set renderingGroupId(renderingGroupId: number);
  139699. /**
  139700. * An event triggered when the effect layer has been disposed.
  139701. */
  139702. onDisposeObservable: Observable<EffectLayer>;
  139703. /**
  139704. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  139705. */
  139706. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  139707. /**
  139708. * An event triggered when the generated texture is being merged in the scene.
  139709. */
  139710. onBeforeComposeObservable: Observable<EffectLayer>;
  139711. /**
  139712. * An event triggered when the mesh is rendered into the effect render target.
  139713. */
  139714. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  139715. /**
  139716. * An event triggered after the mesh has been rendered into the effect render target.
  139717. */
  139718. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  139719. /**
  139720. * An event triggered when the generated texture has been merged in the scene.
  139721. */
  139722. onAfterComposeObservable: Observable<EffectLayer>;
  139723. /**
  139724. * An event triggered when the efffect layer changes its size.
  139725. */
  139726. onSizeChangedObservable: Observable<EffectLayer>;
  139727. /** @hidden */
  139728. static _SceneComponentInitialization: (scene: Scene) => void;
  139729. /**
  139730. * Instantiates a new effect Layer and references it in the scene.
  139731. * @param name The name of the layer
  139732. * @param scene The scene to use the layer in
  139733. */
  139734. constructor(
  139735. /** The Friendly of the effect in the scene */
  139736. name: string, scene: Scene);
  139737. /**
  139738. * Get the effect name of the layer.
  139739. * @return The effect name
  139740. */
  139741. abstract getEffectName(): string;
  139742. /**
  139743. * Checks for the readiness of the element composing the layer.
  139744. * @param subMesh the mesh to check for
  139745. * @param useInstances specify whether or not to use instances to render the mesh
  139746. * @return true if ready otherwise, false
  139747. */
  139748. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139749. /**
  139750. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139751. * @returns true if the effect requires stencil during the main canvas render pass.
  139752. */
  139753. abstract needStencil(): boolean;
  139754. /**
  139755. * Create the merge effect. This is the shader use to blit the information back
  139756. * to the main canvas at the end of the scene rendering.
  139757. * @returns The effect containing the shader used to merge the effect on the main canvas
  139758. */
  139759. protected abstract _createMergeEffect(): Effect;
  139760. /**
  139761. * Creates the render target textures and post processes used in the effect layer.
  139762. */
  139763. protected abstract _createTextureAndPostProcesses(): void;
  139764. /**
  139765. * Implementation specific of rendering the generating effect on the main canvas.
  139766. * @param effect The effect used to render through
  139767. */
  139768. protected abstract _internalRender(effect: Effect): void;
  139769. /**
  139770. * Sets the required values for both the emissive texture and and the main color.
  139771. */
  139772. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139773. /**
  139774. * Free any resources and references associated to a mesh.
  139775. * Internal use
  139776. * @param mesh The mesh to free.
  139777. */
  139778. abstract _disposeMesh(mesh: Mesh): void;
  139779. /**
  139780. * Serializes this layer (Glow or Highlight for example)
  139781. * @returns a serialized layer object
  139782. */
  139783. abstract serialize?(): any;
  139784. /**
  139785. * Initializes the effect layer with the required options.
  139786. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  139787. */
  139788. protected _init(options: Partial<IEffectLayerOptions>): void;
  139789. /**
  139790. * Generates the index buffer of the full screen quad blending to the main canvas.
  139791. */
  139792. private _generateIndexBuffer;
  139793. /**
  139794. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  139795. */
  139796. private _generateVertexBuffer;
  139797. /**
  139798. * Sets the main texture desired size which is the closest power of two
  139799. * of the engine canvas size.
  139800. */
  139801. private _setMainTextureSize;
  139802. /**
  139803. * Creates the main texture for the effect layer.
  139804. */
  139805. protected _createMainTexture(): void;
  139806. /**
  139807. * Adds specific effects defines.
  139808. * @param defines The defines to add specifics to.
  139809. */
  139810. protected _addCustomEffectDefines(defines: string[]): void;
  139811. /**
  139812. * Checks for the readiness of the element composing the layer.
  139813. * @param subMesh the mesh to check for
  139814. * @param useInstances specify whether or not to use instances to render the mesh
  139815. * @param emissiveTexture the associated emissive texture used to generate the glow
  139816. * @return true if ready otherwise, false
  139817. */
  139818. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  139819. /**
  139820. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  139821. */
  139822. render(): void;
  139823. /**
  139824. * Determine if a given mesh will be used in the current effect.
  139825. * @param mesh mesh to test
  139826. * @returns true if the mesh will be used
  139827. */
  139828. hasMesh(mesh: AbstractMesh): boolean;
  139829. /**
  139830. * Returns true if the layer contains information to display, otherwise false.
  139831. * @returns true if the glow layer should be rendered
  139832. */
  139833. shouldRender(): boolean;
  139834. /**
  139835. * Returns true if the mesh should render, otherwise false.
  139836. * @param mesh The mesh to render
  139837. * @returns true if it should render otherwise false
  139838. */
  139839. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  139840. /**
  139841. * Returns true if the mesh can be rendered, otherwise false.
  139842. * @param mesh The mesh to render
  139843. * @param material The material used on the mesh
  139844. * @returns true if it can be rendered otherwise false
  139845. */
  139846. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139847. /**
  139848. * Returns true if the mesh should render, otherwise false.
  139849. * @param mesh The mesh to render
  139850. * @returns true if it should render otherwise false
  139851. */
  139852. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  139853. /**
  139854. * Renders the submesh passed in parameter to the generation map.
  139855. */
  139856. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  139857. /**
  139858. * Defines whether the current material of the mesh should be use to render the effect.
  139859. * @param mesh defines the current mesh to render
  139860. */
  139861. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139862. /**
  139863. * Rebuild the required buffers.
  139864. * @hidden Internal use only.
  139865. */
  139866. _rebuild(): void;
  139867. /**
  139868. * Dispose only the render target textures and post process.
  139869. */
  139870. private _disposeTextureAndPostProcesses;
  139871. /**
  139872. * Dispose the highlight layer and free resources.
  139873. */
  139874. dispose(): void;
  139875. /**
  139876. * Gets the class name of the effect layer
  139877. * @returns the string with the class name of the effect layer
  139878. */
  139879. getClassName(): string;
  139880. /**
  139881. * Creates an effect layer from parsed effect layer data
  139882. * @param parsedEffectLayer defines effect layer data
  139883. * @param scene defines the current scene
  139884. * @param rootUrl defines the root URL containing the effect layer information
  139885. * @returns a parsed effect Layer
  139886. */
  139887. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  139888. }
  139889. }
  139890. declare module BABYLON {
  139891. interface AbstractScene {
  139892. /**
  139893. * The list of effect layers (highlights/glow) added to the scene
  139894. * @see https://doc.babylonjs.com/how_to/highlight_layer
  139895. * @see https://doc.babylonjs.com/how_to/glow_layer
  139896. */
  139897. effectLayers: Array<EffectLayer>;
  139898. /**
  139899. * Removes the given effect layer from this scene.
  139900. * @param toRemove defines the effect layer to remove
  139901. * @returns the index of the removed effect layer
  139902. */
  139903. removeEffectLayer(toRemove: EffectLayer): number;
  139904. /**
  139905. * Adds the given effect layer to this scene
  139906. * @param newEffectLayer defines the effect layer to add
  139907. */
  139908. addEffectLayer(newEffectLayer: EffectLayer): void;
  139909. }
  139910. /**
  139911. * Defines the layer scene component responsible to manage any effect layers
  139912. * in a given scene.
  139913. */
  139914. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  139915. /**
  139916. * The component name helpfull to identify the component in the list of scene components.
  139917. */
  139918. readonly name: string;
  139919. /**
  139920. * The scene the component belongs to.
  139921. */
  139922. scene: Scene;
  139923. private _engine;
  139924. private _renderEffects;
  139925. private _needStencil;
  139926. private _previousStencilState;
  139927. /**
  139928. * Creates a new instance of the component for the given scene
  139929. * @param scene Defines the scene to register the component in
  139930. */
  139931. constructor(scene: Scene);
  139932. /**
  139933. * Registers the component in a given scene
  139934. */
  139935. register(): void;
  139936. /**
  139937. * Rebuilds the elements related to this component in case of
  139938. * context lost for instance.
  139939. */
  139940. rebuild(): void;
  139941. /**
  139942. * Serializes the component data to the specified json object
  139943. * @param serializationObject The object to serialize to
  139944. */
  139945. serialize(serializationObject: any): void;
  139946. /**
  139947. * Adds all the elements from the container to the scene
  139948. * @param container the container holding the elements
  139949. */
  139950. addFromContainer(container: AbstractScene): void;
  139951. /**
  139952. * Removes all the elements in the container from the scene
  139953. * @param container contains the elements to remove
  139954. * @param dispose if the removed element should be disposed (default: false)
  139955. */
  139956. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139957. /**
  139958. * Disposes the component and the associated ressources.
  139959. */
  139960. dispose(): void;
  139961. private _isReadyForMesh;
  139962. private _renderMainTexture;
  139963. private _setStencil;
  139964. private _setStencilBack;
  139965. private _draw;
  139966. private _drawCamera;
  139967. private _drawRenderingGroup;
  139968. }
  139969. }
  139970. declare module BABYLON {
  139971. /** @hidden */
  139972. export var glowMapMergePixelShader: {
  139973. name: string;
  139974. shader: string;
  139975. };
  139976. }
  139977. declare module BABYLON {
  139978. /** @hidden */
  139979. export var glowMapMergeVertexShader: {
  139980. name: string;
  139981. shader: string;
  139982. };
  139983. }
  139984. declare module BABYLON {
  139985. interface AbstractScene {
  139986. /**
  139987. * Return a the first highlight layer of the scene with a given name.
  139988. * @param name The name of the highlight layer to look for.
  139989. * @return The highlight layer if found otherwise null.
  139990. */
  139991. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139992. }
  139993. /**
  139994. * Glow layer options. This helps customizing the behaviour
  139995. * of the glow layer.
  139996. */
  139997. export interface IGlowLayerOptions {
  139998. /**
  139999. * Multiplication factor apply to the canvas size to compute the render target size
  140000. * used to generated the glowing objects (the smaller the faster).
  140001. */
  140002. mainTextureRatio: number;
  140003. /**
  140004. * Enforces a fixed size texture to ensure resize independant blur.
  140005. */
  140006. mainTextureFixedSize?: number;
  140007. /**
  140008. * How big is the kernel of the blur texture.
  140009. */
  140010. blurKernelSize: number;
  140011. /**
  140012. * The camera attached to the layer.
  140013. */
  140014. camera: Nullable<Camera>;
  140015. /**
  140016. * Enable MSAA by chosing the number of samples.
  140017. */
  140018. mainTextureSamples?: number;
  140019. /**
  140020. * The rendering group to draw the layer in.
  140021. */
  140022. renderingGroupId: number;
  140023. }
  140024. /**
  140025. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  140026. *
  140027. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  140028. *
  140029. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  140030. */
  140031. export class GlowLayer extends EffectLayer {
  140032. /**
  140033. * Effect Name of the layer.
  140034. */
  140035. static readonly EffectName: string;
  140036. /**
  140037. * The default blur kernel size used for the glow.
  140038. */
  140039. static DefaultBlurKernelSize: number;
  140040. /**
  140041. * The default texture size ratio used for the glow.
  140042. */
  140043. static DefaultTextureRatio: number;
  140044. /**
  140045. * Sets the kernel size of the blur.
  140046. */
  140047. set blurKernelSize(value: number);
  140048. /**
  140049. * Gets the kernel size of the blur.
  140050. */
  140051. get blurKernelSize(): number;
  140052. /**
  140053. * Sets the glow intensity.
  140054. */
  140055. set intensity(value: number);
  140056. /**
  140057. * Gets the glow intensity.
  140058. */
  140059. get intensity(): number;
  140060. private _options;
  140061. private _intensity;
  140062. private _horizontalBlurPostprocess1;
  140063. private _verticalBlurPostprocess1;
  140064. private _horizontalBlurPostprocess2;
  140065. private _verticalBlurPostprocess2;
  140066. private _blurTexture1;
  140067. private _blurTexture2;
  140068. private _postProcesses1;
  140069. private _postProcesses2;
  140070. private _includedOnlyMeshes;
  140071. private _excludedMeshes;
  140072. private _meshesUsingTheirOwnMaterials;
  140073. /**
  140074. * Callback used to let the user override the color selection on a per mesh basis
  140075. */
  140076. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  140077. /**
  140078. * Callback used to let the user override the texture selection on a per mesh basis
  140079. */
  140080. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  140081. /**
  140082. * Instantiates a new glow Layer and references it to the scene.
  140083. * @param name The name of the layer
  140084. * @param scene The scene to use the layer in
  140085. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  140086. */
  140087. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  140088. /**
  140089. * Get the effect name of the layer.
  140090. * @return The effect name
  140091. */
  140092. getEffectName(): string;
  140093. /**
  140094. * Create the merge effect. This is the shader use to blit the information back
  140095. * to the main canvas at the end of the scene rendering.
  140096. */
  140097. protected _createMergeEffect(): Effect;
  140098. /**
  140099. * Creates the render target textures and post processes used in the glow layer.
  140100. */
  140101. protected _createTextureAndPostProcesses(): void;
  140102. /**
  140103. * Checks for the readiness of the element composing the layer.
  140104. * @param subMesh the mesh to check for
  140105. * @param useInstances specify wether or not to use instances to render the mesh
  140106. * @param emissiveTexture the associated emissive texture used to generate the glow
  140107. * @return true if ready otherwise, false
  140108. */
  140109. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140110. /**
  140111. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140112. */
  140113. needStencil(): boolean;
  140114. /**
  140115. * Returns true if the mesh can be rendered, otherwise false.
  140116. * @param mesh The mesh to render
  140117. * @param material The material used on the mesh
  140118. * @returns true if it can be rendered otherwise false
  140119. */
  140120. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140121. /**
  140122. * Implementation specific of rendering the generating effect on the main canvas.
  140123. * @param effect The effect used to render through
  140124. */
  140125. protected _internalRender(effect: Effect): void;
  140126. /**
  140127. * Sets the required values for both the emissive texture and and the main color.
  140128. */
  140129. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140130. /**
  140131. * Returns true if the mesh should render, otherwise false.
  140132. * @param mesh The mesh to render
  140133. * @returns true if it should render otherwise false
  140134. */
  140135. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140136. /**
  140137. * Adds specific effects defines.
  140138. * @param defines The defines to add specifics to.
  140139. */
  140140. protected _addCustomEffectDefines(defines: string[]): void;
  140141. /**
  140142. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  140143. * @param mesh The mesh to exclude from the glow layer
  140144. */
  140145. addExcludedMesh(mesh: Mesh): void;
  140146. /**
  140147. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  140148. * @param mesh The mesh to remove
  140149. */
  140150. removeExcludedMesh(mesh: Mesh): void;
  140151. /**
  140152. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  140153. * @param mesh The mesh to include in the glow layer
  140154. */
  140155. addIncludedOnlyMesh(mesh: Mesh): void;
  140156. /**
  140157. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  140158. * @param mesh The mesh to remove
  140159. */
  140160. removeIncludedOnlyMesh(mesh: Mesh): void;
  140161. /**
  140162. * Determine if a given mesh will be used in the glow layer
  140163. * @param mesh The mesh to test
  140164. * @returns true if the mesh will be highlighted by the current glow layer
  140165. */
  140166. hasMesh(mesh: AbstractMesh): boolean;
  140167. /**
  140168. * Defines whether the current material of the mesh should be use to render the effect.
  140169. * @param mesh defines the current mesh to render
  140170. */
  140171. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140172. /**
  140173. * Add a mesh to be rendered through its own material and not with emissive only.
  140174. * @param mesh The mesh for which we need to use its material
  140175. */
  140176. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  140177. /**
  140178. * Remove a mesh from being rendered through its own material and not with emissive only.
  140179. * @param mesh The mesh for which we need to not use its material
  140180. */
  140181. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  140182. /**
  140183. * Free any resources and references associated to a mesh.
  140184. * Internal use
  140185. * @param mesh The mesh to free.
  140186. * @hidden
  140187. */
  140188. _disposeMesh(mesh: Mesh): void;
  140189. /**
  140190. * Gets the class name of the effect layer
  140191. * @returns the string with the class name of the effect layer
  140192. */
  140193. getClassName(): string;
  140194. /**
  140195. * Serializes this glow layer
  140196. * @returns a serialized glow layer object
  140197. */
  140198. serialize(): any;
  140199. /**
  140200. * Creates a Glow Layer from parsed glow layer data
  140201. * @param parsedGlowLayer defines glow layer data
  140202. * @param scene defines the current scene
  140203. * @param rootUrl defines the root URL containing the glow layer information
  140204. * @returns a parsed Glow Layer
  140205. */
  140206. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  140207. }
  140208. }
  140209. declare module BABYLON {
  140210. /** @hidden */
  140211. export var glowBlurPostProcessPixelShader: {
  140212. name: string;
  140213. shader: string;
  140214. };
  140215. }
  140216. declare module BABYLON {
  140217. interface AbstractScene {
  140218. /**
  140219. * Return a the first highlight layer of the scene with a given name.
  140220. * @param name The name of the highlight layer to look for.
  140221. * @return The highlight layer if found otherwise null.
  140222. */
  140223. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  140224. }
  140225. /**
  140226. * Highlight layer options. This helps customizing the behaviour
  140227. * of the highlight layer.
  140228. */
  140229. export interface IHighlightLayerOptions {
  140230. /**
  140231. * Multiplication factor apply to the canvas size to compute the render target size
  140232. * used to generated the glowing objects (the smaller the faster).
  140233. */
  140234. mainTextureRatio: number;
  140235. /**
  140236. * Enforces a fixed size texture to ensure resize independant blur.
  140237. */
  140238. mainTextureFixedSize?: number;
  140239. /**
  140240. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  140241. * of the picture to blur (the smaller the faster).
  140242. */
  140243. blurTextureSizeRatio: number;
  140244. /**
  140245. * How big in texel of the blur texture is the vertical blur.
  140246. */
  140247. blurVerticalSize: number;
  140248. /**
  140249. * How big in texel of the blur texture is the horizontal blur.
  140250. */
  140251. blurHorizontalSize: number;
  140252. /**
  140253. * Alpha blending mode used to apply the blur. Default is combine.
  140254. */
  140255. alphaBlendingMode: number;
  140256. /**
  140257. * The camera attached to the layer.
  140258. */
  140259. camera: Nullable<Camera>;
  140260. /**
  140261. * Should we display highlight as a solid stroke?
  140262. */
  140263. isStroke?: boolean;
  140264. /**
  140265. * The rendering group to draw the layer in.
  140266. */
  140267. renderingGroupId: number;
  140268. }
  140269. /**
  140270. * The highlight layer Helps adding a glow effect around a mesh.
  140271. *
  140272. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  140273. * glowy meshes to your scene.
  140274. *
  140275. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  140276. */
  140277. export class HighlightLayer extends EffectLayer {
  140278. name: string;
  140279. /**
  140280. * Effect Name of the highlight layer.
  140281. */
  140282. static readonly EffectName: string;
  140283. /**
  140284. * The neutral color used during the preparation of the glow effect.
  140285. * This is black by default as the blend operation is a blend operation.
  140286. */
  140287. static NeutralColor: Color4;
  140288. /**
  140289. * Stencil value used for glowing meshes.
  140290. */
  140291. static GlowingMeshStencilReference: number;
  140292. /**
  140293. * Stencil value used for the other meshes in the scene.
  140294. */
  140295. static NormalMeshStencilReference: number;
  140296. /**
  140297. * Specifies whether or not the inner glow is ACTIVE in the layer.
  140298. */
  140299. innerGlow: boolean;
  140300. /**
  140301. * Specifies whether or not the outer glow is ACTIVE in the layer.
  140302. */
  140303. outerGlow: boolean;
  140304. /**
  140305. * Specifies the horizontal size of the blur.
  140306. */
  140307. set blurHorizontalSize(value: number);
  140308. /**
  140309. * Specifies the vertical size of the blur.
  140310. */
  140311. set blurVerticalSize(value: number);
  140312. /**
  140313. * Gets the horizontal size of the blur.
  140314. */
  140315. get blurHorizontalSize(): number;
  140316. /**
  140317. * Gets the vertical size of the blur.
  140318. */
  140319. get blurVerticalSize(): number;
  140320. /**
  140321. * An event triggered when the highlight layer is being blurred.
  140322. */
  140323. onBeforeBlurObservable: Observable<HighlightLayer>;
  140324. /**
  140325. * An event triggered when the highlight layer has been blurred.
  140326. */
  140327. onAfterBlurObservable: Observable<HighlightLayer>;
  140328. private _instanceGlowingMeshStencilReference;
  140329. private _options;
  140330. private _downSamplePostprocess;
  140331. private _horizontalBlurPostprocess;
  140332. private _verticalBlurPostprocess;
  140333. private _blurTexture;
  140334. private _meshes;
  140335. private _excludedMeshes;
  140336. /**
  140337. * Instantiates a new highlight Layer and references it to the scene..
  140338. * @param name The name of the layer
  140339. * @param scene The scene to use the layer in
  140340. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  140341. */
  140342. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  140343. /**
  140344. * Get the effect name of the layer.
  140345. * @return The effect name
  140346. */
  140347. getEffectName(): string;
  140348. /**
  140349. * Create the merge effect. This is the shader use to blit the information back
  140350. * to the main canvas at the end of the scene rendering.
  140351. */
  140352. protected _createMergeEffect(): Effect;
  140353. /**
  140354. * Creates the render target textures and post processes used in the highlight layer.
  140355. */
  140356. protected _createTextureAndPostProcesses(): void;
  140357. /**
  140358. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  140359. */
  140360. needStencil(): boolean;
  140361. /**
  140362. * Checks for the readiness of the element composing the layer.
  140363. * @param subMesh the mesh to check for
  140364. * @param useInstances specify wether or not to use instances to render the mesh
  140365. * @param emissiveTexture the associated emissive texture used to generate the glow
  140366. * @return true if ready otherwise, false
  140367. */
  140368. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140369. /**
  140370. * Implementation specific of rendering the generating effect on the main canvas.
  140371. * @param effect The effect used to render through
  140372. */
  140373. protected _internalRender(effect: Effect): void;
  140374. /**
  140375. * Returns true if the layer contains information to display, otherwise false.
  140376. */
  140377. shouldRender(): boolean;
  140378. /**
  140379. * Returns true if the mesh should render, otherwise false.
  140380. * @param mesh The mesh to render
  140381. * @returns true if it should render otherwise false
  140382. */
  140383. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140384. /**
  140385. * Returns true if the mesh can be rendered, otherwise false.
  140386. * @param mesh The mesh to render
  140387. * @param material The material used on the mesh
  140388. * @returns true if it can be rendered otherwise false
  140389. */
  140390. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140391. /**
  140392. * Adds specific effects defines.
  140393. * @param defines The defines to add specifics to.
  140394. */
  140395. protected _addCustomEffectDefines(defines: string[]): void;
  140396. /**
  140397. * Sets the required values for both the emissive texture and and the main color.
  140398. */
  140399. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140400. /**
  140401. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  140402. * @param mesh The mesh to exclude from the highlight layer
  140403. */
  140404. addExcludedMesh(mesh: Mesh): void;
  140405. /**
  140406. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  140407. * @param mesh The mesh to highlight
  140408. */
  140409. removeExcludedMesh(mesh: Mesh): void;
  140410. /**
  140411. * Determine if a given mesh will be highlighted by the current HighlightLayer
  140412. * @param mesh mesh to test
  140413. * @returns true if the mesh will be highlighted by the current HighlightLayer
  140414. */
  140415. hasMesh(mesh: AbstractMesh): boolean;
  140416. /**
  140417. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  140418. * @param mesh The mesh to highlight
  140419. * @param color The color of the highlight
  140420. * @param glowEmissiveOnly Extract the glow from the emissive texture
  140421. */
  140422. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  140423. /**
  140424. * Remove a mesh from the highlight layer in order to make it stop glowing.
  140425. * @param mesh The mesh to highlight
  140426. */
  140427. removeMesh(mesh: Mesh): void;
  140428. /**
  140429. * Remove all the meshes currently referenced in the highlight layer
  140430. */
  140431. removeAllMeshes(): void;
  140432. /**
  140433. * Force the stencil to the normal expected value for none glowing parts
  140434. */
  140435. private _defaultStencilReference;
  140436. /**
  140437. * Free any resources and references associated to a mesh.
  140438. * Internal use
  140439. * @param mesh The mesh to free.
  140440. * @hidden
  140441. */
  140442. _disposeMesh(mesh: Mesh): void;
  140443. /**
  140444. * Dispose the highlight layer and free resources.
  140445. */
  140446. dispose(): void;
  140447. /**
  140448. * Gets the class name of the effect layer
  140449. * @returns the string with the class name of the effect layer
  140450. */
  140451. getClassName(): string;
  140452. /**
  140453. * Serializes this Highlight layer
  140454. * @returns a serialized Highlight layer object
  140455. */
  140456. serialize(): any;
  140457. /**
  140458. * Creates a Highlight layer from parsed Highlight layer data
  140459. * @param parsedHightlightLayer defines the Highlight layer data
  140460. * @param scene defines the current scene
  140461. * @param rootUrl defines the root URL containing the Highlight layer information
  140462. * @returns a parsed Highlight layer
  140463. */
  140464. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  140465. }
  140466. }
  140467. declare module BABYLON {
  140468. interface AbstractScene {
  140469. /**
  140470. * The list of layers (background and foreground) of the scene
  140471. */
  140472. layers: Array<Layer>;
  140473. }
  140474. /**
  140475. * Defines the layer scene component responsible to manage any layers
  140476. * in a given scene.
  140477. */
  140478. export class LayerSceneComponent implements ISceneComponent {
  140479. /**
  140480. * The component name helpfull to identify the component in the list of scene components.
  140481. */
  140482. readonly name: string;
  140483. /**
  140484. * The scene the component belongs to.
  140485. */
  140486. scene: Scene;
  140487. private _engine;
  140488. /**
  140489. * Creates a new instance of the component for the given scene
  140490. * @param scene Defines the scene to register the component in
  140491. */
  140492. constructor(scene: Scene);
  140493. /**
  140494. * Registers the component in a given scene
  140495. */
  140496. register(): void;
  140497. /**
  140498. * Rebuilds the elements related to this component in case of
  140499. * context lost for instance.
  140500. */
  140501. rebuild(): void;
  140502. /**
  140503. * Disposes the component and the associated ressources.
  140504. */
  140505. dispose(): void;
  140506. private _draw;
  140507. private _drawCameraPredicate;
  140508. private _drawCameraBackground;
  140509. private _drawCameraForeground;
  140510. private _drawRenderTargetPredicate;
  140511. private _drawRenderTargetBackground;
  140512. private _drawRenderTargetForeground;
  140513. /**
  140514. * Adds all the elements from the container to the scene
  140515. * @param container the container holding the elements
  140516. */
  140517. addFromContainer(container: AbstractScene): void;
  140518. /**
  140519. * Removes all the elements in the container from the scene
  140520. * @param container contains the elements to remove
  140521. * @param dispose if the removed element should be disposed (default: false)
  140522. */
  140523. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140524. }
  140525. }
  140526. declare module BABYLON {
  140527. /** @hidden */
  140528. export var layerPixelShader: {
  140529. name: string;
  140530. shader: string;
  140531. };
  140532. }
  140533. declare module BABYLON {
  140534. /** @hidden */
  140535. export var layerVertexShader: {
  140536. name: string;
  140537. shader: string;
  140538. };
  140539. }
  140540. declare module BABYLON {
  140541. /**
  140542. * This represents a full screen 2d layer.
  140543. * This can be useful to display a picture in the background of your scene for instance.
  140544. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140545. */
  140546. export class Layer {
  140547. /**
  140548. * Define the name of the layer.
  140549. */
  140550. name: string;
  140551. /**
  140552. * Define the texture the layer should display.
  140553. */
  140554. texture: Nullable<Texture>;
  140555. /**
  140556. * Is the layer in background or foreground.
  140557. */
  140558. isBackground: boolean;
  140559. /**
  140560. * Define the color of the layer (instead of texture).
  140561. */
  140562. color: Color4;
  140563. /**
  140564. * Define the scale of the layer in order to zoom in out of the texture.
  140565. */
  140566. scale: Vector2;
  140567. /**
  140568. * Define an offset for the layer in order to shift the texture.
  140569. */
  140570. offset: Vector2;
  140571. /**
  140572. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  140573. */
  140574. alphaBlendingMode: number;
  140575. /**
  140576. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  140577. * Alpha test will not mix with the background color in case of transparency.
  140578. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  140579. */
  140580. alphaTest: boolean;
  140581. /**
  140582. * Define a mask to restrict the layer to only some of the scene cameras.
  140583. */
  140584. layerMask: number;
  140585. /**
  140586. * Define the list of render target the layer is visible into.
  140587. */
  140588. renderTargetTextures: RenderTargetTexture[];
  140589. /**
  140590. * Define if the layer is only used in renderTarget or if it also
  140591. * renders in the main frame buffer of the canvas.
  140592. */
  140593. renderOnlyInRenderTargetTextures: boolean;
  140594. private _scene;
  140595. private _vertexBuffers;
  140596. private _indexBuffer;
  140597. private _effect;
  140598. private _previousDefines;
  140599. /**
  140600. * An event triggered when the layer is disposed.
  140601. */
  140602. onDisposeObservable: Observable<Layer>;
  140603. private _onDisposeObserver;
  140604. /**
  140605. * Back compatibility with callback before the onDisposeObservable existed.
  140606. * The set callback will be triggered when the layer has been disposed.
  140607. */
  140608. set onDispose(callback: () => void);
  140609. /**
  140610. * An event triggered before rendering the scene
  140611. */
  140612. onBeforeRenderObservable: Observable<Layer>;
  140613. private _onBeforeRenderObserver;
  140614. /**
  140615. * Back compatibility with callback before the onBeforeRenderObservable existed.
  140616. * The set callback will be triggered just before rendering the layer.
  140617. */
  140618. set onBeforeRender(callback: () => void);
  140619. /**
  140620. * An event triggered after rendering the scene
  140621. */
  140622. onAfterRenderObservable: Observable<Layer>;
  140623. private _onAfterRenderObserver;
  140624. /**
  140625. * Back compatibility with callback before the onAfterRenderObservable existed.
  140626. * The set callback will be triggered just after rendering the layer.
  140627. */
  140628. set onAfterRender(callback: () => void);
  140629. /**
  140630. * Instantiates a new layer.
  140631. * This represents a full screen 2d layer.
  140632. * This can be useful to display a picture in the background of your scene for instance.
  140633. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140634. * @param name Define the name of the layer in the scene
  140635. * @param imgUrl Define the url of the texture to display in the layer
  140636. * @param scene Define the scene the layer belongs to
  140637. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  140638. * @param color Defines a color for the layer
  140639. */
  140640. constructor(
  140641. /**
  140642. * Define the name of the layer.
  140643. */
  140644. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  140645. private _createIndexBuffer;
  140646. /** @hidden */
  140647. _rebuild(): void;
  140648. /**
  140649. * Renders the layer in the scene.
  140650. */
  140651. render(): void;
  140652. /**
  140653. * Disposes and releases the associated ressources.
  140654. */
  140655. dispose(): void;
  140656. }
  140657. }
  140658. declare module BABYLON {
  140659. /** @hidden */
  140660. export var lensFlarePixelShader: {
  140661. name: string;
  140662. shader: string;
  140663. };
  140664. }
  140665. declare module BABYLON {
  140666. /** @hidden */
  140667. export var lensFlareVertexShader: {
  140668. name: string;
  140669. shader: string;
  140670. };
  140671. }
  140672. declare module BABYLON {
  140673. /**
  140674. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140675. * It is usually composed of several `lensFlare`.
  140676. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140677. */
  140678. export class LensFlareSystem {
  140679. /**
  140680. * Define the name of the lens flare system
  140681. */
  140682. name: string;
  140683. /**
  140684. * List of lens flares used in this system.
  140685. */
  140686. lensFlares: LensFlare[];
  140687. /**
  140688. * Define a limit from the border the lens flare can be visible.
  140689. */
  140690. borderLimit: number;
  140691. /**
  140692. * Define a viewport border we do not want to see the lens flare in.
  140693. */
  140694. viewportBorder: number;
  140695. /**
  140696. * Define a predicate which could limit the list of meshes able to occlude the effect.
  140697. */
  140698. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140699. /**
  140700. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  140701. */
  140702. layerMask: number;
  140703. /**
  140704. * Define the id of the lens flare system in the scene.
  140705. * (equal to name by default)
  140706. */
  140707. id: string;
  140708. private _scene;
  140709. private _emitter;
  140710. private _vertexBuffers;
  140711. private _indexBuffer;
  140712. private _effect;
  140713. private _positionX;
  140714. private _positionY;
  140715. private _isEnabled;
  140716. /** @hidden */
  140717. static _SceneComponentInitialization: (scene: Scene) => void;
  140718. /**
  140719. * Instantiates a lens flare system.
  140720. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140721. * It is usually composed of several `lensFlare`.
  140722. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140723. * @param name Define the name of the lens flare system in the scene
  140724. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  140725. * @param scene Define the scene the lens flare system belongs to
  140726. */
  140727. constructor(
  140728. /**
  140729. * Define the name of the lens flare system
  140730. */
  140731. name: string, emitter: any, scene: Scene);
  140732. /**
  140733. * Define if the lens flare system is enabled.
  140734. */
  140735. get isEnabled(): boolean;
  140736. set isEnabled(value: boolean);
  140737. /**
  140738. * Get the scene the effects belongs to.
  140739. * @returns the scene holding the lens flare system
  140740. */
  140741. getScene(): Scene;
  140742. /**
  140743. * Get the emitter of the lens flare system.
  140744. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140745. * @returns the emitter of the lens flare system
  140746. */
  140747. getEmitter(): any;
  140748. /**
  140749. * Set the emitter of the lens flare system.
  140750. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140751. * @param newEmitter Define the new emitter of the system
  140752. */
  140753. setEmitter(newEmitter: any): void;
  140754. /**
  140755. * Get the lens flare system emitter position.
  140756. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  140757. * @returns the position
  140758. */
  140759. getEmitterPosition(): Vector3;
  140760. /**
  140761. * @hidden
  140762. */
  140763. computeEffectivePosition(globalViewport: Viewport): boolean;
  140764. /** @hidden */
  140765. _isVisible(): boolean;
  140766. /**
  140767. * @hidden
  140768. */
  140769. render(): boolean;
  140770. /**
  140771. * Dispose and release the lens flare with its associated resources.
  140772. */
  140773. dispose(): void;
  140774. /**
  140775. * Parse a lens flare system from a JSON repressentation
  140776. * @param parsedLensFlareSystem Define the JSON to parse
  140777. * @param scene Define the scene the parsed system should be instantiated in
  140778. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  140779. * @returns the parsed system
  140780. */
  140781. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  140782. /**
  140783. * Serialize the current Lens Flare System into a JSON representation.
  140784. * @returns the serialized JSON
  140785. */
  140786. serialize(): any;
  140787. }
  140788. }
  140789. declare module BABYLON {
  140790. /**
  140791. * This represents one of the lens effect in a `lensFlareSystem`.
  140792. * It controls one of the indiviual texture used in the effect.
  140793. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140794. */
  140795. export class LensFlare {
  140796. /**
  140797. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140798. */
  140799. size: number;
  140800. /**
  140801. * 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.
  140802. */
  140803. position: number;
  140804. /**
  140805. * Define the lens color.
  140806. */
  140807. color: Color3;
  140808. /**
  140809. * Define the lens texture.
  140810. */
  140811. texture: Nullable<Texture>;
  140812. /**
  140813. * Define the alpha mode to render this particular lens.
  140814. */
  140815. alphaMode: number;
  140816. private _system;
  140817. /**
  140818. * Creates a new Lens Flare.
  140819. * This represents one of the lens effect in a `lensFlareSystem`.
  140820. * It controls one of the indiviual texture used in the effect.
  140821. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140822. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  140823. * @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.
  140824. * @param color Define the lens color
  140825. * @param imgUrl Define the lens texture url
  140826. * @param system Define the `lensFlareSystem` this flare is part of
  140827. * @returns The newly created Lens Flare
  140828. */
  140829. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  140830. /**
  140831. * Instantiates a new Lens Flare.
  140832. * This represents one of the lens effect in a `lensFlareSystem`.
  140833. * It controls one of the indiviual texture used in the effect.
  140834. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140835. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  140836. * @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.
  140837. * @param color Define the lens color
  140838. * @param imgUrl Define the lens texture url
  140839. * @param system Define the `lensFlareSystem` this flare is part of
  140840. */
  140841. constructor(
  140842. /**
  140843. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140844. */
  140845. size: number,
  140846. /**
  140847. * 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.
  140848. */
  140849. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  140850. /**
  140851. * Dispose and release the lens flare with its associated resources.
  140852. */
  140853. dispose(): void;
  140854. }
  140855. }
  140856. declare module BABYLON {
  140857. interface AbstractScene {
  140858. /**
  140859. * The list of lens flare system added to the scene
  140860. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140861. */
  140862. lensFlareSystems: Array<LensFlareSystem>;
  140863. /**
  140864. * Removes the given lens flare system from this scene.
  140865. * @param toRemove The lens flare system to remove
  140866. * @returns The index of the removed lens flare system
  140867. */
  140868. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  140869. /**
  140870. * Adds the given lens flare system to this scene
  140871. * @param newLensFlareSystem The lens flare system to add
  140872. */
  140873. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  140874. /**
  140875. * Gets a lens flare system using its name
  140876. * @param name defines the name to look for
  140877. * @returns the lens flare system or null if not found
  140878. */
  140879. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  140880. /**
  140881. * Gets a lens flare system using its id
  140882. * @param id defines the id to look for
  140883. * @returns the lens flare system or null if not found
  140884. */
  140885. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  140886. }
  140887. /**
  140888. * Defines the lens flare scene component responsible to manage any lens flares
  140889. * in a given scene.
  140890. */
  140891. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  140892. /**
  140893. * The component name helpfull to identify the component in the list of scene components.
  140894. */
  140895. readonly name: string;
  140896. /**
  140897. * The scene the component belongs to.
  140898. */
  140899. scene: Scene;
  140900. /**
  140901. * Creates a new instance of the component for the given scene
  140902. * @param scene Defines the scene to register the component in
  140903. */
  140904. constructor(scene: Scene);
  140905. /**
  140906. * Registers the component in a given scene
  140907. */
  140908. register(): void;
  140909. /**
  140910. * Rebuilds the elements related to this component in case of
  140911. * context lost for instance.
  140912. */
  140913. rebuild(): void;
  140914. /**
  140915. * Adds all the elements from the container to the scene
  140916. * @param container the container holding the elements
  140917. */
  140918. addFromContainer(container: AbstractScene): void;
  140919. /**
  140920. * Removes all the elements in the container from the scene
  140921. * @param container contains the elements to remove
  140922. * @param dispose if the removed element should be disposed (default: false)
  140923. */
  140924. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140925. /**
  140926. * Serializes the component data to the specified json object
  140927. * @param serializationObject The object to serialize to
  140928. */
  140929. serialize(serializationObject: any): void;
  140930. /**
  140931. * Disposes the component and the associated ressources.
  140932. */
  140933. dispose(): void;
  140934. private _draw;
  140935. }
  140936. }
  140937. declare module BABYLON {
  140938. /** @hidden */
  140939. export var depthPixelShader: {
  140940. name: string;
  140941. shader: string;
  140942. };
  140943. }
  140944. declare module BABYLON {
  140945. /** @hidden */
  140946. export var depthVertexShader: {
  140947. name: string;
  140948. shader: string;
  140949. };
  140950. }
  140951. declare module BABYLON {
  140952. /**
  140953. * This represents a depth renderer in Babylon.
  140954. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140955. */
  140956. export class DepthRenderer {
  140957. private _scene;
  140958. private _depthMap;
  140959. private _effect;
  140960. private readonly _storeNonLinearDepth;
  140961. private readonly _clearColor;
  140962. /** Get if the depth renderer is using packed depth or not */
  140963. readonly isPacked: boolean;
  140964. private _cachedDefines;
  140965. private _camera;
  140966. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140967. enabled: boolean;
  140968. /**
  140969. * Specifiess that the depth renderer will only be used within
  140970. * the camera it is created for.
  140971. * This can help forcing its rendering during the camera processing.
  140972. */
  140973. useOnlyInActiveCamera: boolean;
  140974. /** @hidden */
  140975. static _SceneComponentInitialization: (scene: Scene) => void;
  140976. /**
  140977. * Instantiates a depth renderer
  140978. * @param scene The scene the renderer belongs to
  140979. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140980. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140981. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140982. */
  140983. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140984. /**
  140985. * Creates the depth rendering effect and checks if the effect is ready.
  140986. * @param subMesh The submesh to be used to render the depth map of
  140987. * @param useInstances If multiple world instances should be used
  140988. * @returns if the depth renderer is ready to render the depth map
  140989. */
  140990. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140991. /**
  140992. * Gets the texture which the depth map will be written to.
  140993. * @returns The depth map texture
  140994. */
  140995. getDepthMap(): RenderTargetTexture;
  140996. /**
  140997. * Disposes of the depth renderer.
  140998. */
  140999. dispose(): void;
  141000. }
  141001. }
  141002. declare module BABYLON {
  141003. /** @hidden */
  141004. export var minmaxReduxPixelShader: {
  141005. name: string;
  141006. shader: string;
  141007. };
  141008. }
  141009. declare module BABYLON {
  141010. /**
  141011. * This class computes a min/max reduction from a texture: it means it computes the minimum
  141012. * and maximum values from all values of the texture.
  141013. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  141014. * The source values are read from the red channel of the texture.
  141015. */
  141016. export class MinMaxReducer {
  141017. /**
  141018. * Observable triggered when the computation has been performed
  141019. */
  141020. onAfterReductionPerformed: Observable<{
  141021. min: number;
  141022. max: number;
  141023. }>;
  141024. protected _camera: Camera;
  141025. protected _sourceTexture: Nullable<RenderTargetTexture>;
  141026. protected _reductionSteps: Nullable<Array<PostProcess>>;
  141027. protected _postProcessManager: PostProcessManager;
  141028. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  141029. protected _forceFullscreenViewport: boolean;
  141030. /**
  141031. * Creates a min/max reducer
  141032. * @param camera The camera to use for the post processes
  141033. */
  141034. constructor(camera: Camera);
  141035. /**
  141036. * Gets the texture used to read the values from.
  141037. */
  141038. get sourceTexture(): Nullable<RenderTargetTexture>;
  141039. /**
  141040. * Sets the source texture to read the values from.
  141041. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  141042. * because in such textures '1' value must not be taken into account to compute the maximum
  141043. * as this value is used to clear the texture.
  141044. * Note that the computation is not activated by calling this function, you must call activate() for that!
  141045. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  141046. * @param depthRedux Indicates if the texture is a depth texture or not
  141047. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  141048. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141049. */
  141050. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141051. /**
  141052. * Defines the refresh rate of the computation.
  141053. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141054. */
  141055. get refreshRate(): number;
  141056. set refreshRate(value: number);
  141057. protected _activated: boolean;
  141058. /**
  141059. * Gets the activation status of the reducer
  141060. */
  141061. get activated(): boolean;
  141062. /**
  141063. * Activates the reduction computation.
  141064. * When activated, the observers registered in onAfterReductionPerformed are
  141065. * called after the compuation is performed
  141066. */
  141067. activate(): void;
  141068. /**
  141069. * Deactivates the reduction computation.
  141070. */
  141071. deactivate(): void;
  141072. /**
  141073. * Disposes the min/max reducer
  141074. * @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.
  141075. */
  141076. dispose(disposeAll?: boolean): void;
  141077. }
  141078. }
  141079. declare module BABYLON {
  141080. /**
  141081. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  141082. */
  141083. export class DepthReducer extends MinMaxReducer {
  141084. private _depthRenderer;
  141085. private _depthRendererId;
  141086. /**
  141087. * Gets the depth renderer used for the computation.
  141088. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  141089. */
  141090. get depthRenderer(): Nullable<DepthRenderer>;
  141091. /**
  141092. * Creates a depth reducer
  141093. * @param camera The camera used to render the depth texture
  141094. */
  141095. constructor(camera: Camera);
  141096. /**
  141097. * Sets the depth renderer to use to generate the depth map
  141098. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  141099. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  141100. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141101. */
  141102. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  141103. /** @hidden */
  141104. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141105. /**
  141106. * Activates the reduction computation.
  141107. * When activated, the observers registered in onAfterReductionPerformed are
  141108. * called after the compuation is performed
  141109. */
  141110. activate(): void;
  141111. /**
  141112. * Deactivates the reduction computation.
  141113. */
  141114. deactivate(): void;
  141115. /**
  141116. * Disposes the depth reducer
  141117. * @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.
  141118. */
  141119. dispose(disposeAll?: boolean): void;
  141120. }
  141121. }
  141122. declare module BABYLON {
  141123. /**
  141124. * A CSM implementation allowing casting shadows on large scenes.
  141125. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141126. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  141127. */
  141128. export class CascadedShadowGenerator extends ShadowGenerator {
  141129. private static readonly frustumCornersNDCSpace;
  141130. /**
  141131. * Name of the CSM class
  141132. */
  141133. static CLASSNAME: string;
  141134. /**
  141135. * Defines the default number of cascades used by the CSM.
  141136. */
  141137. static readonly DEFAULT_CASCADES_COUNT: number;
  141138. /**
  141139. * Defines the minimum number of cascades used by the CSM.
  141140. */
  141141. static readonly MIN_CASCADES_COUNT: number;
  141142. /**
  141143. * Defines the maximum number of cascades used by the CSM.
  141144. */
  141145. static readonly MAX_CASCADES_COUNT: number;
  141146. protected _validateFilter(filter: number): number;
  141147. /**
  141148. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  141149. */
  141150. penumbraDarkness: number;
  141151. private _numCascades;
  141152. /**
  141153. * Gets or set the number of cascades used by the CSM.
  141154. */
  141155. get numCascades(): number;
  141156. set numCascades(value: number);
  141157. /**
  141158. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  141159. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  141160. */
  141161. stabilizeCascades: boolean;
  141162. private _freezeShadowCastersBoundingInfo;
  141163. private _freezeShadowCastersBoundingInfoObservable;
  141164. /**
  141165. * Enables or disables the shadow casters bounding info computation.
  141166. * If your shadow casters don't move, you can disable this feature.
  141167. * If it is enabled, the bounding box computation is done every frame.
  141168. */
  141169. get freezeShadowCastersBoundingInfo(): boolean;
  141170. set freezeShadowCastersBoundingInfo(freeze: boolean);
  141171. private _scbiMin;
  141172. private _scbiMax;
  141173. protected _computeShadowCastersBoundingInfo(): void;
  141174. protected _shadowCastersBoundingInfo: BoundingInfo;
  141175. /**
  141176. * Gets or sets the shadow casters bounding info.
  141177. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  141178. * so that the system won't overwrite the bounds you provide
  141179. */
  141180. get shadowCastersBoundingInfo(): BoundingInfo;
  141181. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  141182. protected _breaksAreDirty: boolean;
  141183. protected _minDistance: number;
  141184. protected _maxDistance: number;
  141185. /**
  141186. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  141187. *
  141188. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  141189. * If you don't know these values, simply leave them to their defaults and don't call this function.
  141190. * @param min minimal distance for the breaks (default to 0.)
  141191. * @param max maximal distance for the breaks (default to 1.)
  141192. */
  141193. setMinMaxDistance(min: number, max: number): void;
  141194. /** Gets the minimal distance used in the cascade break computation */
  141195. get minDistance(): number;
  141196. /** Gets the maximal distance used in the cascade break computation */
  141197. get maxDistance(): number;
  141198. /**
  141199. * Gets the class name of that object
  141200. * @returns "CascadedShadowGenerator"
  141201. */
  141202. getClassName(): string;
  141203. private _cascadeMinExtents;
  141204. private _cascadeMaxExtents;
  141205. /**
  141206. * Gets a cascade minimum extents
  141207. * @param cascadeIndex index of the cascade
  141208. * @returns the minimum cascade extents
  141209. */
  141210. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  141211. /**
  141212. * Gets a cascade maximum extents
  141213. * @param cascadeIndex index of the cascade
  141214. * @returns the maximum cascade extents
  141215. */
  141216. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  141217. private _cascades;
  141218. private _currentLayer;
  141219. private _viewSpaceFrustumsZ;
  141220. private _viewMatrices;
  141221. private _projectionMatrices;
  141222. private _transformMatrices;
  141223. private _transformMatricesAsArray;
  141224. private _frustumLengths;
  141225. private _lightSizeUVCorrection;
  141226. private _depthCorrection;
  141227. private _frustumCornersWorldSpace;
  141228. private _frustumCenter;
  141229. private _shadowCameraPos;
  141230. private _shadowMaxZ;
  141231. /**
  141232. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  141233. * It defaults to camera.maxZ
  141234. */
  141235. get shadowMaxZ(): number;
  141236. /**
  141237. * Sets the shadow max z distance.
  141238. */
  141239. set shadowMaxZ(value: number);
  141240. protected _debug: boolean;
  141241. /**
  141242. * Gets or sets the debug flag.
  141243. * When enabled, the cascades are materialized by different colors on the screen.
  141244. */
  141245. get debug(): boolean;
  141246. set debug(dbg: boolean);
  141247. private _depthClamp;
  141248. /**
  141249. * Gets or sets the depth clamping value.
  141250. *
  141251. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  141252. * to account for the shadow casters far away.
  141253. *
  141254. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  141255. */
  141256. get depthClamp(): boolean;
  141257. set depthClamp(value: boolean);
  141258. private _cascadeBlendPercentage;
  141259. /**
  141260. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  141261. * It defaults to 0.1 (10% blending).
  141262. */
  141263. get cascadeBlendPercentage(): number;
  141264. set cascadeBlendPercentage(value: number);
  141265. private _lambda;
  141266. /**
  141267. * Gets or set the lambda parameter.
  141268. * This parameter is used to split the camera frustum and create the cascades.
  141269. * 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.
  141270. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  141271. */
  141272. get lambda(): number;
  141273. set lambda(value: number);
  141274. /**
  141275. * Gets the view matrix corresponding to a given cascade
  141276. * @param cascadeNum cascade to retrieve the view matrix from
  141277. * @returns the cascade view matrix
  141278. */
  141279. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  141280. /**
  141281. * Gets the projection matrix corresponding to a given cascade
  141282. * @param cascadeNum cascade to retrieve the projection matrix from
  141283. * @returns the cascade projection matrix
  141284. */
  141285. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  141286. /**
  141287. * Gets the transformation matrix corresponding to a given cascade
  141288. * @param cascadeNum cascade to retrieve the transformation matrix from
  141289. * @returns the cascade transformation matrix
  141290. */
  141291. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  141292. private _depthRenderer;
  141293. /**
  141294. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  141295. *
  141296. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  141297. *
  141298. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  141299. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  141300. * @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
  141301. */
  141302. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  141303. private _depthReducer;
  141304. private _autoCalcDepthBounds;
  141305. /**
  141306. * Gets or sets the autoCalcDepthBounds property.
  141307. *
  141308. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  141309. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  141310. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  141311. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  141312. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  141313. */
  141314. get autoCalcDepthBounds(): boolean;
  141315. set autoCalcDepthBounds(value: boolean);
  141316. /**
  141317. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  141318. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141319. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  141320. * for setting the refresh rate on the renderer yourself!
  141321. */
  141322. get autoCalcDepthBoundsRefreshRate(): number;
  141323. set autoCalcDepthBoundsRefreshRate(value: number);
  141324. /**
  141325. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  141326. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  141327. * you change the camera near/far planes!
  141328. */
  141329. splitFrustum(): void;
  141330. private _splitFrustum;
  141331. private _computeMatrices;
  141332. private _computeFrustumInWorldSpace;
  141333. private _computeCascadeFrustum;
  141334. /**
  141335. * Support test.
  141336. */
  141337. static get IsSupported(): boolean;
  141338. /** @hidden */
  141339. static _SceneComponentInitialization: (scene: Scene) => void;
  141340. /**
  141341. * Creates a Cascaded Shadow Generator object.
  141342. * A ShadowGenerator is the required tool to use the shadows.
  141343. * Each directional light casting shadows needs to use its own ShadowGenerator.
  141344. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141345. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  141346. * @param light The directional light object generating the shadows.
  141347. * @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.
  141348. */
  141349. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  141350. protected _initializeGenerator(): void;
  141351. protected _createTargetRenderTexture(): void;
  141352. protected _initializeShadowMap(): void;
  141353. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  141354. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  141355. /**
  141356. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  141357. * @param defines Defines of the material we want to update
  141358. * @param lightIndex Index of the light in the enabled light list of the material
  141359. */
  141360. prepareDefines(defines: any, lightIndex: number): void;
  141361. /**
  141362. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  141363. * defined in the generator but impacting the effect).
  141364. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  141365. * @param effect The effect we are binfing the information for
  141366. */
  141367. bindShadowLight(lightIndex: string, effect: Effect): void;
  141368. /**
  141369. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  141370. * (eq to view projection * shadow projection matrices)
  141371. * @returns The transform matrix used to create the shadow map
  141372. */
  141373. getTransformMatrix(): Matrix;
  141374. /**
  141375. * Disposes the ShadowGenerator.
  141376. * Returns nothing.
  141377. */
  141378. dispose(): void;
  141379. /**
  141380. * Serializes the shadow generator setup to a json object.
  141381. * @returns The serialized JSON object
  141382. */
  141383. serialize(): any;
  141384. /**
  141385. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  141386. * @param parsedShadowGenerator The JSON object to parse
  141387. * @param scene The scene to create the shadow map for
  141388. * @returns The parsed shadow generator
  141389. */
  141390. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  141391. }
  141392. }
  141393. declare module BABYLON {
  141394. /**
  141395. * Defines the shadow generator component responsible to manage any shadow generators
  141396. * in a given scene.
  141397. */
  141398. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  141399. /**
  141400. * The component name helpfull to identify the component in the list of scene components.
  141401. */
  141402. readonly name: string;
  141403. /**
  141404. * The scene the component belongs to.
  141405. */
  141406. scene: Scene;
  141407. /**
  141408. * Creates a new instance of the component for the given scene
  141409. * @param scene Defines the scene to register the component in
  141410. */
  141411. constructor(scene: Scene);
  141412. /**
  141413. * Registers the component in a given scene
  141414. */
  141415. register(): void;
  141416. /**
  141417. * Rebuilds the elements related to this component in case of
  141418. * context lost for instance.
  141419. */
  141420. rebuild(): void;
  141421. /**
  141422. * Serializes the component data to the specified json object
  141423. * @param serializationObject The object to serialize to
  141424. */
  141425. serialize(serializationObject: any): void;
  141426. /**
  141427. * Adds all the elements from the container to the scene
  141428. * @param container the container holding the elements
  141429. */
  141430. addFromContainer(container: AbstractScene): void;
  141431. /**
  141432. * Removes all the elements in the container from the scene
  141433. * @param container contains the elements to remove
  141434. * @param dispose if the removed element should be disposed (default: false)
  141435. */
  141436. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141437. /**
  141438. * Rebuilds the elements related to this component in case of
  141439. * context lost for instance.
  141440. */
  141441. dispose(): void;
  141442. private _gatherRenderTargets;
  141443. }
  141444. }
  141445. declare module BABYLON {
  141446. /**
  141447. * A point light is a light defined by an unique point in world space.
  141448. * The light is emitted in every direction from this point.
  141449. * A good example of a point light is a standard light bulb.
  141450. * Documentation: https://doc.babylonjs.com/babylon101/lights
  141451. */
  141452. export class PointLight extends ShadowLight {
  141453. private _shadowAngle;
  141454. /**
  141455. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141456. * This specifies what angle the shadow will use to be created.
  141457. *
  141458. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141459. */
  141460. get shadowAngle(): number;
  141461. /**
  141462. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141463. * This specifies what angle the shadow will use to be created.
  141464. *
  141465. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  141466. */
  141467. set shadowAngle(value: number);
  141468. /**
  141469. * Gets the direction if it has been set.
  141470. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141471. */
  141472. get direction(): Vector3;
  141473. /**
  141474. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  141475. */
  141476. set direction(value: Vector3);
  141477. /**
  141478. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  141479. * A PointLight emits the light in every direction.
  141480. * It can cast shadows.
  141481. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  141482. * ```javascript
  141483. * var pointLight = new PointLight("pl", camera.position, scene);
  141484. * ```
  141485. * Documentation : https://doc.babylonjs.com/babylon101/lights
  141486. * @param name The light friendly name
  141487. * @param position The position of the point light in the scene
  141488. * @param scene The scene the lights belongs to
  141489. */
  141490. constructor(name: string, position: Vector3, scene: Scene);
  141491. /**
  141492. * Returns the string "PointLight"
  141493. * @returns the class name
  141494. */
  141495. getClassName(): string;
  141496. /**
  141497. * Returns the integer 0.
  141498. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  141499. */
  141500. getTypeID(): number;
  141501. /**
  141502. * Specifies wether or not the shadowmap should be a cube texture.
  141503. * @returns true if the shadowmap needs to be a cube texture.
  141504. */
  141505. needCube(): boolean;
  141506. /**
  141507. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  141508. * @param faceIndex The index of the face we are computed the direction to generate shadow
  141509. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  141510. */
  141511. getShadowDirection(faceIndex?: number): Vector3;
  141512. /**
  141513. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  141514. * - fov = PI / 2
  141515. * - aspect ratio : 1.0
  141516. * - z-near and far equal to the active camera minZ and maxZ.
  141517. * Returns the PointLight.
  141518. */
  141519. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  141520. protected _buildUniformLayout(): void;
  141521. /**
  141522. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  141523. * @param effect The effect to update
  141524. * @param lightIndex The index of the light in the effect to update
  141525. * @returns The point light
  141526. */
  141527. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  141528. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  141529. /**
  141530. * Prepares the list of defines specific to the light type.
  141531. * @param defines the list of defines
  141532. * @param lightIndex defines the index of the light for the effect
  141533. */
  141534. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  141535. }
  141536. }
  141537. declare module BABYLON {
  141538. /**
  141539. * Header information of HDR texture files.
  141540. */
  141541. export interface HDRInfo {
  141542. /**
  141543. * The height of the texture in pixels.
  141544. */
  141545. height: number;
  141546. /**
  141547. * The width of the texture in pixels.
  141548. */
  141549. width: number;
  141550. /**
  141551. * The index of the beginning of the data in the binary file.
  141552. */
  141553. dataPosition: number;
  141554. }
  141555. /**
  141556. * This groups tools to convert HDR texture to native colors array.
  141557. */
  141558. export class HDRTools {
  141559. private static Ldexp;
  141560. private static Rgbe2float;
  141561. private static readStringLine;
  141562. /**
  141563. * Reads header information from an RGBE texture stored in a native array.
  141564. * More information on this format are available here:
  141565. * https://en.wikipedia.org/wiki/RGBE_image_format
  141566. *
  141567. * @param uint8array The binary file stored in native array.
  141568. * @return The header information.
  141569. */
  141570. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  141571. /**
  141572. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  141573. * This RGBE texture needs to store the information as a panorama.
  141574. *
  141575. * More information on this format are available here:
  141576. * https://en.wikipedia.org/wiki/RGBE_image_format
  141577. *
  141578. * @param buffer The binary file stored in an array buffer.
  141579. * @param size The expected size of the extracted cubemap.
  141580. * @return The Cube Map information.
  141581. */
  141582. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  141583. /**
  141584. * Returns the pixels data extracted from an RGBE texture.
  141585. * This pixels will be stored left to right up to down in the R G B order in one array.
  141586. *
  141587. * More information on this format are available here:
  141588. * https://en.wikipedia.org/wiki/RGBE_image_format
  141589. *
  141590. * @param uint8array The binary file stored in an array buffer.
  141591. * @param hdrInfo The header information of the file.
  141592. * @return The pixels data in RGB right to left up to down order.
  141593. */
  141594. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  141595. private static RGBE_ReadPixels_RLE;
  141596. private static RGBE_ReadPixels_NOT_RLE;
  141597. }
  141598. }
  141599. declare module BABYLON {
  141600. /**
  141601. * Effect Render Options
  141602. */
  141603. export interface IEffectRendererOptions {
  141604. /**
  141605. * Defines the vertices positions.
  141606. */
  141607. positions?: number[];
  141608. /**
  141609. * Defines the indices.
  141610. */
  141611. indices?: number[];
  141612. }
  141613. /**
  141614. * Helper class to render one or more effects.
  141615. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  141616. */
  141617. export class EffectRenderer {
  141618. private engine;
  141619. private static _DefaultOptions;
  141620. private _vertexBuffers;
  141621. private _indexBuffer;
  141622. private _fullscreenViewport;
  141623. /**
  141624. * Creates an effect renderer
  141625. * @param engine the engine to use for rendering
  141626. * @param options defines the options of the effect renderer
  141627. */
  141628. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  141629. /**
  141630. * Sets the current viewport in normalized coordinates 0-1
  141631. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  141632. */
  141633. setViewport(viewport?: Viewport): void;
  141634. /**
  141635. * Binds the embedded attributes buffer to the effect.
  141636. * @param effect Defines the effect to bind the attributes for
  141637. */
  141638. bindBuffers(effect: Effect): void;
  141639. /**
  141640. * Sets the current effect wrapper to use during draw.
  141641. * The effect needs to be ready before calling this api.
  141642. * This also sets the default full screen position attribute.
  141643. * @param effectWrapper Defines the effect to draw with
  141644. */
  141645. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  141646. /**
  141647. * Restores engine states
  141648. */
  141649. restoreStates(): void;
  141650. /**
  141651. * Draws a full screen quad.
  141652. */
  141653. draw(): void;
  141654. private isRenderTargetTexture;
  141655. /**
  141656. * renders one or more effects to a specified texture
  141657. * @param effectWrapper the effect to renderer
  141658. * @param outputTexture texture to draw to, if null it will render to the screen.
  141659. */
  141660. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  141661. /**
  141662. * Disposes of the effect renderer
  141663. */
  141664. dispose(): void;
  141665. }
  141666. /**
  141667. * Options to create an EffectWrapper
  141668. */
  141669. interface EffectWrapperCreationOptions {
  141670. /**
  141671. * Engine to use to create the effect
  141672. */
  141673. engine: ThinEngine;
  141674. /**
  141675. * Fragment shader for the effect
  141676. */
  141677. fragmentShader: string;
  141678. /**
  141679. * Use the shader store instead of direct source code
  141680. */
  141681. useShaderStore?: boolean;
  141682. /**
  141683. * Vertex shader for the effect
  141684. */
  141685. vertexShader?: string;
  141686. /**
  141687. * Attributes to use in the shader
  141688. */
  141689. attributeNames?: Array<string>;
  141690. /**
  141691. * Uniforms to use in the shader
  141692. */
  141693. uniformNames?: Array<string>;
  141694. /**
  141695. * Texture sampler names to use in the shader
  141696. */
  141697. samplerNames?: Array<string>;
  141698. /**
  141699. * Defines to use in the shader
  141700. */
  141701. defines?: Array<string>;
  141702. /**
  141703. * Callback when effect is compiled
  141704. */
  141705. onCompiled?: Nullable<(effect: Effect) => void>;
  141706. /**
  141707. * The friendly name of the effect displayed in Spector.
  141708. */
  141709. name?: string;
  141710. }
  141711. /**
  141712. * Wraps an effect to be used for rendering
  141713. */
  141714. export class EffectWrapper {
  141715. /**
  141716. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  141717. */
  141718. onApplyObservable: Observable<{}>;
  141719. /**
  141720. * The underlying effect
  141721. */
  141722. effect: Effect;
  141723. /**
  141724. * Creates an effect to be renderer
  141725. * @param creationOptions options to create the effect
  141726. */
  141727. constructor(creationOptions: EffectWrapperCreationOptions);
  141728. /**
  141729. * Disposes of the effect wrapper
  141730. */
  141731. dispose(): void;
  141732. }
  141733. }
  141734. declare module BABYLON {
  141735. /** @hidden */
  141736. export var hdrFilteringVertexShader: {
  141737. name: string;
  141738. shader: string;
  141739. };
  141740. }
  141741. declare module BABYLON {
  141742. /** @hidden */
  141743. export var hdrFilteringPixelShader: {
  141744. name: string;
  141745. shader: string;
  141746. };
  141747. }
  141748. declare module BABYLON {
  141749. /**
  141750. * Options for texture filtering
  141751. */
  141752. interface IHDRFilteringOptions {
  141753. /**
  141754. * Scales pixel intensity for the input HDR map.
  141755. */
  141756. hdrScale?: number;
  141757. /**
  141758. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  141759. */
  141760. quality?: number;
  141761. }
  141762. /**
  141763. * Filters HDR maps to get correct renderings of PBR reflections
  141764. */
  141765. export class HDRFiltering {
  141766. private _engine;
  141767. private _effectRenderer;
  141768. private _effectWrapper;
  141769. private _lodGenerationOffset;
  141770. private _lodGenerationScale;
  141771. /**
  141772. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  141773. * you care about baking speed.
  141774. */
  141775. quality: number;
  141776. /**
  141777. * Scales pixel intensity for the input HDR map.
  141778. */
  141779. hdrScale: number;
  141780. /**
  141781. * Instantiates HDR filter for reflection maps
  141782. *
  141783. * @param engine Thin engine
  141784. * @param options Options
  141785. */
  141786. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  141787. private _createRenderTarget;
  141788. private _prefilterInternal;
  141789. private _createEffect;
  141790. /**
  141791. * Get a value indicating if the filter is ready to be used
  141792. * @param texture Texture to filter
  141793. * @returns true if the filter is ready
  141794. */
  141795. isReady(texture: BaseTexture): boolean;
  141796. /**
  141797. * Prefilters a cube texture to have mipmap levels representing roughness values.
  141798. * Prefiltering will be invoked at the end of next rendering pass.
  141799. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  141800. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  141801. * @param texture Texture to filter
  141802. * @param onFinished Callback when filtering is done
  141803. * @return Promise called when prefiltering is done
  141804. */
  141805. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  141806. }
  141807. }
  141808. declare module BABYLON {
  141809. /**
  141810. * This represents a texture coming from an HDR input.
  141811. *
  141812. * The only supported format is currently panorama picture stored in RGBE format.
  141813. * Example of such files can be found on HDRLib: http://hdrlib.com/
  141814. */
  141815. export class HDRCubeTexture extends BaseTexture {
  141816. private static _facesMapping;
  141817. private _generateHarmonics;
  141818. private _noMipmap;
  141819. private _prefilterOnLoad;
  141820. private _textureMatrix;
  141821. private _size;
  141822. private _onLoad;
  141823. private _onError;
  141824. /**
  141825. * The texture URL.
  141826. */
  141827. url: string;
  141828. protected _isBlocking: boolean;
  141829. /**
  141830. * Sets wether or not the texture is blocking during loading.
  141831. */
  141832. set isBlocking(value: boolean);
  141833. /**
  141834. * Gets wether or not the texture is blocking during loading.
  141835. */
  141836. get isBlocking(): boolean;
  141837. protected _rotationY: number;
  141838. /**
  141839. * Sets texture matrix rotation angle around Y axis in radians.
  141840. */
  141841. set rotationY(value: number);
  141842. /**
  141843. * Gets texture matrix rotation angle around Y axis radians.
  141844. */
  141845. get rotationY(): number;
  141846. /**
  141847. * Gets or sets the center of the bounding box associated with the cube texture
  141848. * It must define where the camera used to render the texture was set
  141849. */
  141850. boundingBoxPosition: Vector3;
  141851. private _boundingBoxSize;
  141852. /**
  141853. * Gets or sets the size of the bounding box associated with the cube texture
  141854. * When defined, the cubemap will switch to local mode
  141855. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  141856. * @example https://www.babylonjs-playground.com/#RNASML
  141857. */
  141858. set boundingBoxSize(value: Vector3);
  141859. get boundingBoxSize(): Vector3;
  141860. /**
  141861. * Instantiates an HDRTexture from the following parameters.
  141862. *
  141863. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  141864. * @param sceneOrEngine The scene or engine the texture will be used in
  141865. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141866. * @param noMipmap Forces to not generate the mipmap if true
  141867. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  141868. * @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)
  141869. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  141870. */
  141871. 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>);
  141872. /**
  141873. * Get the current class name of the texture useful for serialization or dynamic coding.
  141874. * @returns "HDRCubeTexture"
  141875. */
  141876. getClassName(): string;
  141877. /**
  141878. * Occurs when the file is raw .hdr file.
  141879. */
  141880. private loadTexture;
  141881. clone(): HDRCubeTexture;
  141882. delayLoad(): void;
  141883. /**
  141884. * Get the texture reflection matrix used to rotate/transform the reflection.
  141885. * @returns the reflection matrix
  141886. */
  141887. getReflectionTextureMatrix(): Matrix;
  141888. /**
  141889. * Set the texture reflection matrix used to rotate/transform the reflection.
  141890. * @param value Define the reflection matrix to set
  141891. */
  141892. setReflectionTextureMatrix(value: Matrix): void;
  141893. /**
  141894. * Parses a JSON representation of an HDR Texture in order to create the texture
  141895. * @param parsedTexture Define the JSON representation
  141896. * @param scene Define the scene the texture should be created in
  141897. * @param rootUrl Define the root url in case we need to load relative dependencies
  141898. * @returns the newly created texture after parsing
  141899. */
  141900. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  141901. serialize(): any;
  141902. }
  141903. }
  141904. declare module BABYLON {
  141905. /**
  141906. * Class used to control physics engine
  141907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141908. */
  141909. export class PhysicsEngine implements IPhysicsEngine {
  141910. private _physicsPlugin;
  141911. /**
  141912. * Global value used to control the smallest number supported by the simulation
  141913. */
  141914. static Epsilon: number;
  141915. private _impostors;
  141916. private _joints;
  141917. private _subTimeStep;
  141918. /**
  141919. * Gets the gravity vector used by the simulation
  141920. */
  141921. gravity: Vector3;
  141922. /**
  141923. * Factory used to create the default physics plugin.
  141924. * @returns The default physics plugin
  141925. */
  141926. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  141927. /**
  141928. * Creates a new Physics Engine
  141929. * @param gravity defines the gravity vector used by the simulation
  141930. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  141931. */
  141932. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  141933. /**
  141934. * Sets the gravity vector used by the simulation
  141935. * @param gravity defines the gravity vector to use
  141936. */
  141937. setGravity(gravity: Vector3): void;
  141938. /**
  141939. * Set the time step of the physics engine.
  141940. * Default is 1/60.
  141941. * To slow it down, enter 1/600 for example.
  141942. * To speed it up, 1/30
  141943. * @param newTimeStep defines the new timestep to apply to this world.
  141944. */
  141945. setTimeStep(newTimeStep?: number): void;
  141946. /**
  141947. * Get the time step of the physics engine.
  141948. * @returns the current time step
  141949. */
  141950. getTimeStep(): number;
  141951. /**
  141952. * Set the sub time step of the physics engine.
  141953. * Default is 0 meaning there is no sub steps
  141954. * To increase physics resolution precision, set a small value (like 1 ms)
  141955. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141956. */
  141957. setSubTimeStep(subTimeStep?: number): void;
  141958. /**
  141959. * Get the sub time step of the physics engine.
  141960. * @returns the current sub time step
  141961. */
  141962. getSubTimeStep(): number;
  141963. /**
  141964. * Release all resources
  141965. */
  141966. dispose(): void;
  141967. /**
  141968. * Gets the name of the current physics plugin
  141969. * @returns the name of the plugin
  141970. */
  141971. getPhysicsPluginName(): string;
  141972. /**
  141973. * Adding a new impostor for the impostor tracking.
  141974. * This will be done by the impostor itself.
  141975. * @param impostor the impostor to add
  141976. */
  141977. addImpostor(impostor: PhysicsImpostor): void;
  141978. /**
  141979. * Remove an impostor from the engine.
  141980. * This impostor and its mesh will not longer be updated by the physics engine.
  141981. * @param impostor the impostor to remove
  141982. */
  141983. removeImpostor(impostor: PhysicsImpostor): void;
  141984. /**
  141985. * Add a joint to the physics engine
  141986. * @param mainImpostor defines the main impostor to which the joint is added.
  141987. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141988. * @param joint defines the joint that will connect both impostors.
  141989. */
  141990. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141991. /**
  141992. * Removes a joint from the simulation
  141993. * @param mainImpostor defines the impostor used with the joint
  141994. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141995. * @param joint defines the joint to remove
  141996. */
  141997. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141998. /**
  141999. * Called by the scene. No need to call it.
  142000. * @param delta defines the timespam between frames
  142001. */
  142002. _step(delta: number): void;
  142003. /**
  142004. * Gets the current plugin used to run the simulation
  142005. * @returns current plugin
  142006. */
  142007. getPhysicsPlugin(): IPhysicsEnginePlugin;
  142008. /**
  142009. * Gets the list of physic impostors
  142010. * @returns an array of PhysicsImpostor
  142011. */
  142012. getImpostors(): Array<PhysicsImpostor>;
  142013. /**
  142014. * Gets the impostor for a physics enabled object
  142015. * @param object defines the object impersonated by the impostor
  142016. * @returns the PhysicsImpostor or null if not found
  142017. */
  142018. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  142019. /**
  142020. * Gets the impostor for a physics body object
  142021. * @param body defines physics body used by the impostor
  142022. * @returns the PhysicsImpostor or null if not found
  142023. */
  142024. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  142025. /**
  142026. * Does a raycast in the physics world
  142027. * @param from when should the ray start?
  142028. * @param to when should the ray end?
  142029. * @returns PhysicsRaycastResult
  142030. */
  142031. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142032. }
  142033. }
  142034. declare module BABYLON {
  142035. /** @hidden */
  142036. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  142037. private _useDeltaForWorldStep;
  142038. world: any;
  142039. name: string;
  142040. private _physicsMaterials;
  142041. private _fixedTimeStep;
  142042. private _cannonRaycastResult;
  142043. private _raycastResult;
  142044. private _physicsBodysToRemoveAfterStep;
  142045. private _firstFrame;
  142046. BJSCANNON: any;
  142047. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  142048. setGravity(gravity: Vector3): void;
  142049. setTimeStep(timeStep: number): void;
  142050. getTimeStep(): number;
  142051. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142052. private _removeMarkedPhysicsBodiesFromWorld;
  142053. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142054. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142055. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142056. private _processChildMeshes;
  142057. removePhysicsBody(impostor: PhysicsImpostor): void;
  142058. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142059. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142060. private _addMaterial;
  142061. private _checkWithEpsilon;
  142062. private _createShape;
  142063. private _createHeightmap;
  142064. private _minus90X;
  142065. private _plus90X;
  142066. private _tmpPosition;
  142067. private _tmpDeltaPosition;
  142068. private _tmpUnityRotation;
  142069. private _updatePhysicsBodyTransformation;
  142070. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142071. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142072. isSupported(): boolean;
  142073. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142074. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142075. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142076. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142077. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142078. getBodyMass(impostor: PhysicsImpostor): number;
  142079. getBodyFriction(impostor: PhysicsImpostor): number;
  142080. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142081. getBodyRestitution(impostor: PhysicsImpostor): number;
  142082. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142083. sleepBody(impostor: PhysicsImpostor): void;
  142084. wakeUpBody(impostor: PhysicsImpostor): void;
  142085. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  142086. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142087. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142088. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142089. getRadius(impostor: PhysicsImpostor): number;
  142090. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142091. dispose(): void;
  142092. private _extendNamespace;
  142093. /**
  142094. * Does a raycast in the physics world
  142095. * @param from when should the ray start?
  142096. * @param to when should the ray end?
  142097. * @returns PhysicsRaycastResult
  142098. */
  142099. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142100. }
  142101. }
  142102. declare module BABYLON {
  142103. /** @hidden */
  142104. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  142105. private _useDeltaForWorldStep;
  142106. world: any;
  142107. name: string;
  142108. BJSOIMO: any;
  142109. private _raycastResult;
  142110. private _fixedTimeStep;
  142111. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  142112. setGravity(gravity: Vector3): void;
  142113. setTimeStep(timeStep: number): void;
  142114. getTimeStep(): number;
  142115. private _tmpImpostorsArray;
  142116. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142117. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142118. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142119. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142120. private _tmpPositionVector;
  142121. removePhysicsBody(impostor: PhysicsImpostor): void;
  142122. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142123. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142124. isSupported(): boolean;
  142125. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142126. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142127. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142128. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142129. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142130. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142131. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142132. getBodyMass(impostor: PhysicsImpostor): number;
  142133. getBodyFriction(impostor: PhysicsImpostor): number;
  142134. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142135. getBodyRestitution(impostor: PhysicsImpostor): number;
  142136. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142137. sleepBody(impostor: PhysicsImpostor): void;
  142138. wakeUpBody(impostor: PhysicsImpostor): void;
  142139. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142140. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  142141. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  142142. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142143. getRadius(impostor: PhysicsImpostor): number;
  142144. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142145. dispose(): void;
  142146. /**
  142147. * Does a raycast in the physics world
  142148. * @param from when should the ray start?
  142149. * @param to when should the ray end?
  142150. * @returns PhysicsRaycastResult
  142151. */
  142152. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142153. }
  142154. }
  142155. declare module BABYLON {
  142156. /**
  142157. * AmmoJS Physics plugin
  142158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142159. * @see https://github.com/kripken/ammo.js/
  142160. */
  142161. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  142162. private _useDeltaForWorldStep;
  142163. /**
  142164. * Reference to the Ammo library
  142165. */
  142166. bjsAMMO: any;
  142167. /**
  142168. * Created ammoJS world which physics bodies are added to
  142169. */
  142170. world: any;
  142171. /**
  142172. * Name of the plugin
  142173. */
  142174. name: string;
  142175. private _timeStep;
  142176. private _fixedTimeStep;
  142177. private _maxSteps;
  142178. private _tmpQuaternion;
  142179. private _tmpAmmoTransform;
  142180. private _tmpAmmoQuaternion;
  142181. private _tmpAmmoConcreteContactResultCallback;
  142182. private _collisionConfiguration;
  142183. private _dispatcher;
  142184. private _overlappingPairCache;
  142185. private _solver;
  142186. private _softBodySolver;
  142187. private _tmpAmmoVectorA;
  142188. private _tmpAmmoVectorB;
  142189. private _tmpAmmoVectorC;
  142190. private _tmpAmmoVectorD;
  142191. private _tmpContactCallbackResult;
  142192. private _tmpAmmoVectorRCA;
  142193. private _tmpAmmoVectorRCB;
  142194. private _raycastResult;
  142195. private static readonly DISABLE_COLLISION_FLAG;
  142196. private static readonly KINEMATIC_FLAG;
  142197. private static readonly DISABLE_DEACTIVATION_FLAG;
  142198. /**
  142199. * Initializes the ammoJS plugin
  142200. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  142201. * @param ammoInjection can be used to inject your own ammo reference
  142202. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  142203. */
  142204. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  142205. /**
  142206. * Sets the gravity of the physics world (m/(s^2))
  142207. * @param gravity Gravity to set
  142208. */
  142209. setGravity(gravity: Vector3): void;
  142210. /**
  142211. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  142212. * @param timeStep timestep to use in seconds
  142213. */
  142214. setTimeStep(timeStep: number): void;
  142215. /**
  142216. * 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)
  142217. * @param fixedTimeStep fixedTimeStep to use in seconds
  142218. */
  142219. setFixedTimeStep(fixedTimeStep: number): void;
  142220. /**
  142221. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  142222. * @param maxSteps the maximum number of steps by the physics engine per frame
  142223. */
  142224. setMaxSteps(maxSteps: number): void;
  142225. /**
  142226. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  142227. * @returns the current timestep in seconds
  142228. */
  142229. getTimeStep(): number;
  142230. /**
  142231. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  142232. */
  142233. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  142234. private _isImpostorInContact;
  142235. private _isImpostorPairInContact;
  142236. private _stepSimulation;
  142237. /**
  142238. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  142239. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  142240. * After the step the babylon meshes are set to the position of the physics imposters
  142241. * @param delta amount of time to step forward
  142242. * @param impostors array of imposters to update before/after the step
  142243. */
  142244. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142245. /**
  142246. * Update babylon mesh to match physics world object
  142247. * @param impostor imposter to match
  142248. */
  142249. private _afterSoftStep;
  142250. /**
  142251. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142252. * @param impostor imposter to match
  142253. */
  142254. private _ropeStep;
  142255. /**
  142256. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  142257. * @param impostor imposter to match
  142258. */
  142259. private _softbodyOrClothStep;
  142260. private _tmpMatrix;
  142261. /**
  142262. * Applies an impulse on the imposter
  142263. * @param impostor imposter to apply impulse to
  142264. * @param force amount of force to be applied to the imposter
  142265. * @param contactPoint the location to apply the impulse on the imposter
  142266. */
  142267. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142268. /**
  142269. * Applies a force on the imposter
  142270. * @param impostor imposter to apply force
  142271. * @param force amount of force to be applied to the imposter
  142272. * @param contactPoint the location to apply the force on the imposter
  142273. */
  142274. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142275. /**
  142276. * Creates a physics body using the plugin
  142277. * @param impostor the imposter to create the physics body on
  142278. */
  142279. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142280. /**
  142281. * Removes the physics body from the imposter and disposes of the body's memory
  142282. * @param impostor imposter to remove the physics body from
  142283. */
  142284. removePhysicsBody(impostor: PhysicsImpostor): void;
  142285. /**
  142286. * Generates a joint
  142287. * @param impostorJoint the imposter joint to create the joint with
  142288. */
  142289. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142290. /**
  142291. * Removes a joint
  142292. * @param impostorJoint the imposter joint to remove the joint from
  142293. */
  142294. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142295. private _addMeshVerts;
  142296. /**
  142297. * Initialise the soft body vertices to match its object's (mesh) vertices
  142298. * Softbody vertices (nodes) are in world space and to match this
  142299. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  142300. * @param impostor to create the softbody for
  142301. */
  142302. private _softVertexData;
  142303. /**
  142304. * Create an impostor's soft body
  142305. * @param impostor to create the softbody for
  142306. */
  142307. private _createSoftbody;
  142308. /**
  142309. * Create cloth for an impostor
  142310. * @param impostor to create the softbody for
  142311. */
  142312. private _createCloth;
  142313. /**
  142314. * Create rope for an impostor
  142315. * @param impostor to create the softbody for
  142316. */
  142317. private _createRope;
  142318. /**
  142319. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  142320. * @param impostor to create the custom physics shape for
  142321. */
  142322. private _createCustom;
  142323. private _addHullVerts;
  142324. private _createShape;
  142325. /**
  142326. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  142327. * @param impostor imposter containing the physics body and babylon object
  142328. */
  142329. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142330. /**
  142331. * Sets the babylon object's position/rotation from the physics body's position/rotation
  142332. * @param impostor imposter containing the physics body and babylon object
  142333. * @param newPosition new position
  142334. * @param newRotation new rotation
  142335. */
  142336. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142337. /**
  142338. * If this plugin is supported
  142339. * @returns true if its supported
  142340. */
  142341. isSupported(): boolean;
  142342. /**
  142343. * Sets the linear velocity of the physics body
  142344. * @param impostor imposter to set the velocity on
  142345. * @param velocity velocity to set
  142346. */
  142347. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142348. /**
  142349. * Sets the angular velocity of the physics body
  142350. * @param impostor imposter to set the velocity on
  142351. * @param velocity velocity to set
  142352. */
  142353. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142354. /**
  142355. * gets the linear velocity
  142356. * @param impostor imposter to get linear velocity from
  142357. * @returns linear velocity
  142358. */
  142359. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142360. /**
  142361. * gets the angular velocity
  142362. * @param impostor imposter to get angular velocity from
  142363. * @returns angular velocity
  142364. */
  142365. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142366. /**
  142367. * Sets the mass of physics body
  142368. * @param impostor imposter to set the mass on
  142369. * @param mass mass to set
  142370. */
  142371. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142372. /**
  142373. * Gets the mass of the physics body
  142374. * @param impostor imposter to get the mass from
  142375. * @returns mass
  142376. */
  142377. getBodyMass(impostor: PhysicsImpostor): number;
  142378. /**
  142379. * Gets friction of the impostor
  142380. * @param impostor impostor to get friction from
  142381. * @returns friction value
  142382. */
  142383. getBodyFriction(impostor: PhysicsImpostor): number;
  142384. /**
  142385. * Sets friction of the impostor
  142386. * @param impostor impostor to set friction on
  142387. * @param friction friction value
  142388. */
  142389. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142390. /**
  142391. * Gets restitution of the impostor
  142392. * @param impostor impostor to get restitution from
  142393. * @returns restitution value
  142394. */
  142395. getBodyRestitution(impostor: PhysicsImpostor): number;
  142396. /**
  142397. * Sets resitution of the impostor
  142398. * @param impostor impostor to set resitution on
  142399. * @param restitution resitution value
  142400. */
  142401. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142402. /**
  142403. * Gets pressure inside the impostor
  142404. * @param impostor impostor to get pressure from
  142405. * @returns pressure value
  142406. */
  142407. getBodyPressure(impostor: PhysicsImpostor): number;
  142408. /**
  142409. * Sets pressure inside a soft body impostor
  142410. * Cloth and rope must remain 0 pressure
  142411. * @param impostor impostor to set pressure on
  142412. * @param pressure pressure value
  142413. */
  142414. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  142415. /**
  142416. * Gets stiffness of the impostor
  142417. * @param impostor impostor to get stiffness from
  142418. * @returns pressure value
  142419. */
  142420. getBodyStiffness(impostor: PhysicsImpostor): number;
  142421. /**
  142422. * Sets stiffness of the impostor
  142423. * @param impostor impostor to set stiffness on
  142424. * @param stiffness stiffness value from 0 to 1
  142425. */
  142426. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  142427. /**
  142428. * Gets velocityIterations of the impostor
  142429. * @param impostor impostor to get velocity iterations from
  142430. * @returns velocityIterations value
  142431. */
  142432. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  142433. /**
  142434. * Sets velocityIterations of the impostor
  142435. * @param impostor impostor to set velocity iterations on
  142436. * @param velocityIterations velocityIterations value
  142437. */
  142438. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  142439. /**
  142440. * Gets positionIterations of the impostor
  142441. * @param impostor impostor to get position iterations from
  142442. * @returns positionIterations value
  142443. */
  142444. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  142445. /**
  142446. * Sets positionIterations of the impostor
  142447. * @param impostor impostor to set position on
  142448. * @param positionIterations positionIterations value
  142449. */
  142450. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  142451. /**
  142452. * Append an anchor to a cloth object
  142453. * @param impostor is the cloth impostor to add anchor to
  142454. * @param otherImpostor is the rigid impostor to anchor to
  142455. * @param width ratio across width from 0 to 1
  142456. * @param height ratio up height from 0 to 1
  142457. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  142458. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142459. */
  142460. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142461. /**
  142462. * Append an hook to a rope object
  142463. * @param impostor is the rope impostor to add hook to
  142464. * @param otherImpostor is the rigid impostor to hook to
  142465. * @param length ratio along the rope from 0 to 1
  142466. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  142467. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  142468. */
  142469. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  142470. /**
  142471. * Sleeps the physics body and stops it from being active
  142472. * @param impostor impostor to sleep
  142473. */
  142474. sleepBody(impostor: PhysicsImpostor): void;
  142475. /**
  142476. * Activates the physics body
  142477. * @param impostor impostor to activate
  142478. */
  142479. wakeUpBody(impostor: PhysicsImpostor): void;
  142480. /**
  142481. * Updates the distance parameters of the joint
  142482. * @param joint joint to update
  142483. * @param maxDistance maximum distance of the joint
  142484. * @param minDistance minimum distance of the joint
  142485. */
  142486. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142487. /**
  142488. * Sets a motor on the joint
  142489. * @param joint joint to set motor on
  142490. * @param speed speed of the motor
  142491. * @param maxForce maximum force of the motor
  142492. * @param motorIndex index of the motor
  142493. */
  142494. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142495. /**
  142496. * Sets the motors limit
  142497. * @param joint joint to set limit on
  142498. * @param upperLimit upper limit
  142499. * @param lowerLimit lower limit
  142500. */
  142501. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142502. /**
  142503. * Syncs the position and rotation of a mesh with the impostor
  142504. * @param mesh mesh to sync
  142505. * @param impostor impostor to update the mesh with
  142506. */
  142507. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142508. /**
  142509. * Gets the radius of the impostor
  142510. * @param impostor impostor to get radius from
  142511. * @returns the radius
  142512. */
  142513. getRadius(impostor: PhysicsImpostor): number;
  142514. /**
  142515. * Gets the box size of the impostor
  142516. * @param impostor impostor to get box size from
  142517. * @param result the resulting box size
  142518. */
  142519. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142520. /**
  142521. * Disposes of the impostor
  142522. */
  142523. dispose(): void;
  142524. /**
  142525. * Does a raycast in the physics world
  142526. * @param from when should the ray start?
  142527. * @param to when should the ray end?
  142528. * @returns PhysicsRaycastResult
  142529. */
  142530. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142531. }
  142532. }
  142533. declare module BABYLON {
  142534. interface AbstractScene {
  142535. /**
  142536. * The list of reflection probes added to the scene
  142537. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142538. */
  142539. reflectionProbes: Array<ReflectionProbe>;
  142540. /**
  142541. * Removes the given reflection probe from this scene.
  142542. * @param toRemove The reflection probe to remove
  142543. * @returns The index of the removed reflection probe
  142544. */
  142545. removeReflectionProbe(toRemove: ReflectionProbe): number;
  142546. /**
  142547. * Adds the given reflection probe to this scene.
  142548. * @param newReflectionProbe The reflection probe to add
  142549. */
  142550. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  142551. }
  142552. /**
  142553. * Class used to generate realtime reflection / refraction cube textures
  142554. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  142555. */
  142556. export class ReflectionProbe {
  142557. /** defines the name of the probe */
  142558. name: string;
  142559. private _scene;
  142560. private _renderTargetTexture;
  142561. private _projectionMatrix;
  142562. private _viewMatrix;
  142563. private _target;
  142564. private _add;
  142565. private _attachedMesh;
  142566. private _invertYAxis;
  142567. /** Gets or sets probe position (center of the cube map) */
  142568. position: Vector3;
  142569. /**
  142570. * Creates a new reflection probe
  142571. * @param name defines the name of the probe
  142572. * @param size defines the texture resolution (for each face)
  142573. * @param scene defines the hosting scene
  142574. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  142575. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  142576. */
  142577. constructor(
  142578. /** defines the name of the probe */
  142579. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  142580. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  142581. get samples(): number;
  142582. set samples(value: number);
  142583. /** Gets or sets the refresh rate to use (on every frame by default) */
  142584. get refreshRate(): number;
  142585. set refreshRate(value: number);
  142586. /**
  142587. * Gets the hosting scene
  142588. * @returns a Scene
  142589. */
  142590. getScene(): Scene;
  142591. /** Gets the internal CubeTexture used to render to */
  142592. get cubeTexture(): RenderTargetTexture;
  142593. /** Gets the list of meshes to render */
  142594. get renderList(): Nullable<AbstractMesh[]>;
  142595. /**
  142596. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  142597. * @param mesh defines the mesh to attach to
  142598. */
  142599. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142600. /**
  142601. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  142602. * @param renderingGroupId The rendering group id corresponding to its index
  142603. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  142604. */
  142605. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  142606. /**
  142607. * Clean all associated resources
  142608. */
  142609. dispose(): void;
  142610. /**
  142611. * Converts the reflection probe information to a readable string for debug purpose.
  142612. * @param fullDetails Supports for multiple levels of logging within scene loading
  142613. * @returns the human readable reflection probe info
  142614. */
  142615. toString(fullDetails?: boolean): string;
  142616. /**
  142617. * Get the class name of the relfection probe.
  142618. * @returns "ReflectionProbe"
  142619. */
  142620. getClassName(): string;
  142621. /**
  142622. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  142623. * @returns The JSON representation of the texture
  142624. */
  142625. serialize(): any;
  142626. /**
  142627. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  142628. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  142629. * @param scene Define the scene the parsed reflection probe should be instantiated in
  142630. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  142631. * @returns The parsed reflection probe if successful
  142632. */
  142633. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  142634. }
  142635. }
  142636. declare module BABYLON {
  142637. /** @hidden */
  142638. export var _BabylonLoaderRegistered: boolean;
  142639. /**
  142640. * Helps setting up some configuration for the babylon file loader.
  142641. */
  142642. export class BabylonFileLoaderConfiguration {
  142643. /**
  142644. * The loader does not allow injecting custom physix engine into the plugins.
  142645. * Unfortunately in ES6, we need to manually inject them into the plugin.
  142646. * So you could set this variable to your engine import to make it work.
  142647. */
  142648. static LoaderInjectedPhysicsEngine: any;
  142649. }
  142650. }
  142651. declare module BABYLON {
  142652. /**
  142653. * The Physically based simple base material of BJS.
  142654. *
  142655. * This enables better naming and convention enforcements on top of the pbrMaterial.
  142656. * It is used as the base class for both the specGloss and metalRough conventions.
  142657. */
  142658. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  142659. /**
  142660. * Number of Simultaneous lights allowed on the material.
  142661. */
  142662. maxSimultaneousLights: number;
  142663. /**
  142664. * If sets to true, disables all the lights affecting the material.
  142665. */
  142666. disableLighting: boolean;
  142667. /**
  142668. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  142669. */
  142670. environmentTexture: BaseTexture;
  142671. /**
  142672. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  142673. */
  142674. invertNormalMapX: boolean;
  142675. /**
  142676. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  142677. */
  142678. invertNormalMapY: boolean;
  142679. /**
  142680. * Normal map used in the model.
  142681. */
  142682. normalTexture: BaseTexture;
  142683. /**
  142684. * Emissivie color used to self-illuminate the model.
  142685. */
  142686. emissiveColor: Color3;
  142687. /**
  142688. * Emissivie texture used to self-illuminate the model.
  142689. */
  142690. emissiveTexture: BaseTexture;
  142691. /**
  142692. * Occlusion Channel Strenght.
  142693. */
  142694. occlusionStrength: number;
  142695. /**
  142696. * Occlusion Texture of the material (adding extra occlusion effects).
  142697. */
  142698. occlusionTexture: BaseTexture;
  142699. /**
  142700. * Defines the alpha limits in alpha test mode.
  142701. */
  142702. alphaCutOff: number;
  142703. /**
  142704. * Gets the current double sided mode.
  142705. */
  142706. get doubleSided(): boolean;
  142707. /**
  142708. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  142709. */
  142710. set doubleSided(value: boolean);
  142711. /**
  142712. * Stores the pre-calculated light information of a mesh in a texture.
  142713. */
  142714. lightmapTexture: BaseTexture;
  142715. /**
  142716. * If true, the light map contains occlusion information instead of lighting info.
  142717. */
  142718. useLightmapAsShadowmap: boolean;
  142719. /**
  142720. * Instantiates a new PBRMaterial instance.
  142721. *
  142722. * @param name The material name
  142723. * @param scene The scene the material will be use in.
  142724. */
  142725. constructor(name: string, scene: Scene);
  142726. getClassName(): string;
  142727. }
  142728. }
  142729. declare module BABYLON {
  142730. /**
  142731. * The PBR material of BJS following the metal roughness convention.
  142732. *
  142733. * This fits to the PBR convention in the GLTF definition:
  142734. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  142735. */
  142736. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  142737. /**
  142738. * The base color has two different interpretations depending on the value of metalness.
  142739. * When the material is a metal, the base color is the specific measured reflectance value
  142740. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  142741. * of the material.
  142742. */
  142743. baseColor: Color3;
  142744. /**
  142745. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  142746. * well as opacity information in the alpha channel.
  142747. */
  142748. baseTexture: BaseTexture;
  142749. /**
  142750. * Specifies the metallic scalar value of the material.
  142751. * Can also be used to scale the metalness values of the metallic texture.
  142752. */
  142753. metallic: number;
  142754. /**
  142755. * Specifies the roughness scalar value of the material.
  142756. * Can also be used to scale the roughness values of the metallic texture.
  142757. */
  142758. roughness: number;
  142759. /**
  142760. * Texture containing both the metallic value in the B channel and the
  142761. * roughness value in the G channel to keep better precision.
  142762. */
  142763. metallicRoughnessTexture: BaseTexture;
  142764. /**
  142765. * Instantiates a new PBRMetalRoughnessMaterial instance.
  142766. *
  142767. * @param name The material name
  142768. * @param scene The scene the material will be use in.
  142769. */
  142770. constructor(name: string, scene: Scene);
  142771. /**
  142772. * Return the currrent class name of the material.
  142773. */
  142774. getClassName(): string;
  142775. /**
  142776. * Makes a duplicate of the current material.
  142777. * @param name - name to use for the new material.
  142778. */
  142779. clone(name: string): PBRMetallicRoughnessMaterial;
  142780. /**
  142781. * Serialize the material to a parsable JSON object.
  142782. */
  142783. serialize(): any;
  142784. /**
  142785. * Parses a JSON object correponding to the serialize function.
  142786. */
  142787. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  142788. }
  142789. }
  142790. declare module BABYLON {
  142791. /**
  142792. * The PBR material of BJS following the specular glossiness convention.
  142793. *
  142794. * This fits to the PBR convention in the GLTF definition:
  142795. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  142796. */
  142797. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  142798. /**
  142799. * Specifies the diffuse color of the material.
  142800. */
  142801. diffuseColor: Color3;
  142802. /**
  142803. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  142804. * channel.
  142805. */
  142806. diffuseTexture: BaseTexture;
  142807. /**
  142808. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  142809. */
  142810. specularColor: Color3;
  142811. /**
  142812. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  142813. */
  142814. glossiness: number;
  142815. /**
  142816. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  142817. */
  142818. specularGlossinessTexture: BaseTexture;
  142819. /**
  142820. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  142821. *
  142822. * @param name The material name
  142823. * @param scene The scene the material will be use in.
  142824. */
  142825. constructor(name: string, scene: Scene);
  142826. /**
  142827. * Return the currrent class name of the material.
  142828. */
  142829. getClassName(): string;
  142830. /**
  142831. * Makes a duplicate of the current material.
  142832. * @param name - name to use for the new material.
  142833. */
  142834. clone(name: string): PBRSpecularGlossinessMaterial;
  142835. /**
  142836. * Serialize the material to a parsable JSON object.
  142837. */
  142838. serialize(): any;
  142839. /**
  142840. * Parses a JSON object correponding to the serialize function.
  142841. */
  142842. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  142843. }
  142844. }
  142845. declare module BABYLON {
  142846. /**
  142847. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  142848. * It can help converting any input color in a desired output one. This can then be used to create effects
  142849. * from sepia, black and white to sixties or futuristic rendering...
  142850. *
  142851. * The only supported format is currently 3dl.
  142852. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  142853. */
  142854. export class ColorGradingTexture extends BaseTexture {
  142855. /**
  142856. * The texture URL.
  142857. */
  142858. url: string;
  142859. /**
  142860. * Empty line regex stored for GC.
  142861. */
  142862. private static _noneEmptyLineRegex;
  142863. private _textureMatrix;
  142864. private _onLoad;
  142865. /**
  142866. * Instantiates a ColorGradingTexture from the following parameters.
  142867. *
  142868. * @param url The location of the color gradind data (currently only supporting 3dl)
  142869. * @param sceneOrEngine The scene or engine the texture will be used in
  142870. * @param onLoad defines a callback triggered when the texture has been loaded
  142871. */
  142872. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  142873. /**
  142874. * Fires the onload event from the constructor if requested.
  142875. */
  142876. private _triggerOnLoad;
  142877. /**
  142878. * Returns the texture matrix used in most of the material.
  142879. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  142880. */
  142881. getTextureMatrix(): Matrix;
  142882. /**
  142883. * Occurs when the file being loaded is a .3dl LUT file.
  142884. */
  142885. private load3dlTexture;
  142886. /**
  142887. * Starts the loading process of the texture.
  142888. */
  142889. private loadTexture;
  142890. /**
  142891. * Clones the color gradind texture.
  142892. */
  142893. clone(): ColorGradingTexture;
  142894. /**
  142895. * Called during delayed load for textures.
  142896. */
  142897. delayLoad(): void;
  142898. /**
  142899. * Parses a color grading texture serialized by Babylon.
  142900. * @param parsedTexture The texture information being parsedTexture
  142901. * @param scene The scene to load the texture in
  142902. * @param rootUrl The root url of the data assets to load
  142903. * @return A color gradind texture
  142904. */
  142905. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  142906. /**
  142907. * Serializes the LUT texture to json format.
  142908. */
  142909. serialize(): any;
  142910. }
  142911. }
  142912. declare module BABYLON {
  142913. /**
  142914. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  142915. */
  142916. export class EquiRectangularCubeTexture extends BaseTexture {
  142917. /** The six faces of the cube. */
  142918. private static _FacesMapping;
  142919. private _noMipmap;
  142920. private _onLoad;
  142921. private _onError;
  142922. /** The size of the cubemap. */
  142923. private _size;
  142924. /** The buffer of the image. */
  142925. private _buffer;
  142926. /** The width of the input image. */
  142927. private _width;
  142928. /** The height of the input image. */
  142929. private _height;
  142930. /** The URL to the image. */
  142931. url: string;
  142932. /**
  142933. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  142934. * @param url The location of the image
  142935. * @param scene The scene the texture will be used in
  142936. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142937. * @param noMipmap Forces to not generate the mipmap if true
  142938. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142939. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142940. * @param onLoad — defines a callback called when texture is loaded
  142941. * @param onError — defines a callback called if there is an error
  142942. */
  142943. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  142944. /**
  142945. * Load the image data, by putting the image on a canvas and extracting its buffer.
  142946. */
  142947. private loadImage;
  142948. /**
  142949. * Convert the image buffer into a cubemap and create a CubeTexture.
  142950. */
  142951. private loadTexture;
  142952. /**
  142953. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142954. * @param buffer The ArrayBuffer that should be converted.
  142955. * @returns The buffer as Float32Array.
  142956. */
  142957. private getFloat32ArrayFromArrayBuffer;
  142958. /**
  142959. * Get the current class name of the texture useful for serialization or dynamic coding.
  142960. * @returns "EquiRectangularCubeTexture"
  142961. */
  142962. getClassName(): string;
  142963. /**
  142964. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142965. * @returns A clone of the current EquiRectangularCubeTexture.
  142966. */
  142967. clone(): EquiRectangularCubeTexture;
  142968. }
  142969. }
  142970. declare module BABYLON {
  142971. /**
  142972. * Defines the options related to the creation of an HtmlElementTexture
  142973. */
  142974. export interface IHtmlElementTextureOptions {
  142975. /**
  142976. * Defines wether mip maps should be created or not.
  142977. */
  142978. generateMipMaps?: boolean;
  142979. /**
  142980. * Defines the sampling mode of the texture.
  142981. */
  142982. samplingMode?: number;
  142983. /**
  142984. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142985. */
  142986. engine: Nullable<ThinEngine>;
  142987. /**
  142988. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142989. */
  142990. scene: Nullable<Scene>;
  142991. }
  142992. /**
  142993. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142994. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142995. * is automatically managed.
  142996. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142997. * in your application.
  142998. *
  142999. * As the update is not automatic, you need to call them manually.
  143000. */
  143001. export class HtmlElementTexture extends BaseTexture {
  143002. /**
  143003. * The texture URL.
  143004. */
  143005. element: HTMLVideoElement | HTMLCanvasElement;
  143006. private static readonly DefaultOptions;
  143007. private _textureMatrix;
  143008. private _isVideo;
  143009. private _generateMipMaps;
  143010. private _samplingMode;
  143011. /**
  143012. * Instantiates a HtmlElementTexture from the following parameters.
  143013. *
  143014. * @param name Defines the name of the texture
  143015. * @param element Defines the video or canvas the texture is filled with
  143016. * @param options Defines the other none mandatory texture creation options
  143017. */
  143018. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  143019. private _createInternalTexture;
  143020. /**
  143021. * Returns the texture matrix used in most of the material.
  143022. */
  143023. getTextureMatrix(): Matrix;
  143024. /**
  143025. * Updates the content of the texture.
  143026. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  143027. */
  143028. update(invertY?: Nullable<boolean>): void;
  143029. }
  143030. }
  143031. declare module BABYLON {
  143032. /**
  143033. * Based on jsTGALoader - Javascript loader for TGA file
  143034. * By Vincent Thibault
  143035. * @see http://blog.robrowser.com/javascript-tga-loader.html
  143036. */
  143037. export class TGATools {
  143038. private static _TYPE_INDEXED;
  143039. private static _TYPE_RGB;
  143040. private static _TYPE_GREY;
  143041. private static _TYPE_RLE_INDEXED;
  143042. private static _TYPE_RLE_RGB;
  143043. private static _TYPE_RLE_GREY;
  143044. private static _ORIGIN_MASK;
  143045. private static _ORIGIN_SHIFT;
  143046. private static _ORIGIN_BL;
  143047. private static _ORIGIN_BR;
  143048. private static _ORIGIN_UL;
  143049. private static _ORIGIN_UR;
  143050. /**
  143051. * Gets the header of a TGA file
  143052. * @param data defines the TGA data
  143053. * @returns the header
  143054. */
  143055. static GetTGAHeader(data: Uint8Array): any;
  143056. /**
  143057. * Uploads TGA content to a Babylon Texture
  143058. * @hidden
  143059. */
  143060. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  143061. /** @hidden */
  143062. 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;
  143063. /** @hidden */
  143064. 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;
  143065. /** @hidden */
  143066. 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;
  143067. /** @hidden */
  143068. 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;
  143069. /** @hidden */
  143070. 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;
  143071. /** @hidden */
  143072. 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;
  143073. }
  143074. }
  143075. declare module BABYLON {
  143076. /**
  143077. * Implementation of the TGA Texture Loader.
  143078. * @hidden
  143079. */
  143080. export class _TGATextureLoader implements IInternalTextureLoader {
  143081. /**
  143082. * Defines wether the loader supports cascade loading the different faces.
  143083. */
  143084. readonly supportCascades: boolean;
  143085. /**
  143086. * This returns if the loader support the current file information.
  143087. * @param extension defines the file extension of the file being loaded
  143088. * @returns true if the loader can load the specified file
  143089. */
  143090. canLoad(extension: string): boolean;
  143091. /**
  143092. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143093. * @param data contains the texture data
  143094. * @param texture defines the BabylonJS internal texture
  143095. * @param createPolynomials will be true if polynomials have been requested
  143096. * @param onLoad defines the callback to trigger once the texture is ready
  143097. * @param onError defines the callback to trigger in case of error
  143098. */
  143099. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143100. /**
  143101. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143102. * @param data contains the texture data
  143103. * @param texture defines the BabylonJS internal texture
  143104. * @param callback defines the method to call once ready to upload
  143105. */
  143106. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143107. }
  143108. }
  143109. declare module BABYLON {
  143110. /**
  143111. * Info about the .basis files
  143112. */
  143113. class BasisFileInfo {
  143114. /**
  143115. * If the file has alpha
  143116. */
  143117. hasAlpha: boolean;
  143118. /**
  143119. * Info about each image of the basis file
  143120. */
  143121. images: Array<{
  143122. levels: Array<{
  143123. width: number;
  143124. height: number;
  143125. transcodedPixels: ArrayBufferView;
  143126. }>;
  143127. }>;
  143128. }
  143129. /**
  143130. * Result of transcoding a basis file
  143131. */
  143132. class TranscodeResult {
  143133. /**
  143134. * Info about the .basis file
  143135. */
  143136. fileInfo: BasisFileInfo;
  143137. /**
  143138. * Format to use when loading the file
  143139. */
  143140. format: number;
  143141. }
  143142. /**
  143143. * Configuration options for the Basis transcoder
  143144. */
  143145. export class BasisTranscodeConfiguration {
  143146. /**
  143147. * Supported compression formats used to determine the supported output format of the transcoder
  143148. */
  143149. supportedCompressionFormats?: {
  143150. /**
  143151. * etc1 compression format
  143152. */
  143153. etc1?: boolean;
  143154. /**
  143155. * s3tc compression format
  143156. */
  143157. s3tc?: boolean;
  143158. /**
  143159. * pvrtc compression format
  143160. */
  143161. pvrtc?: boolean;
  143162. /**
  143163. * etc2 compression format
  143164. */
  143165. etc2?: boolean;
  143166. };
  143167. /**
  143168. * If mipmap levels should be loaded for transcoded images (Default: true)
  143169. */
  143170. loadMipmapLevels?: boolean;
  143171. /**
  143172. * Index of a single image to load (Default: all images)
  143173. */
  143174. loadSingleImage?: number;
  143175. }
  143176. /**
  143177. * Used to load .Basis files
  143178. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  143179. */
  143180. export class BasisTools {
  143181. private static _IgnoreSupportedFormats;
  143182. /**
  143183. * URL to use when loading the basis transcoder
  143184. */
  143185. static JSModuleURL: string;
  143186. /**
  143187. * URL to use when loading the wasm module for the transcoder
  143188. */
  143189. static WasmModuleURL: string;
  143190. /**
  143191. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  143192. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  143193. * @returns internal format corresponding to the Basis format
  143194. */
  143195. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  143196. private static _WorkerPromise;
  143197. private static _Worker;
  143198. private static _actionId;
  143199. private static _CreateWorkerAsync;
  143200. /**
  143201. * Transcodes a loaded image file to compressed pixel data
  143202. * @param data image data to transcode
  143203. * @param config configuration options for the transcoding
  143204. * @returns a promise resulting in the transcoded image
  143205. */
  143206. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  143207. /**
  143208. * Loads a texture from the transcode result
  143209. * @param texture texture load to
  143210. * @param transcodeResult the result of transcoding the basis file to load from
  143211. */
  143212. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  143213. }
  143214. }
  143215. declare module BABYLON {
  143216. /**
  143217. * Loader for .basis file format
  143218. */
  143219. export class _BasisTextureLoader implements IInternalTextureLoader {
  143220. /**
  143221. * Defines whether the loader supports cascade loading the different faces.
  143222. */
  143223. readonly supportCascades: boolean;
  143224. /**
  143225. * This returns if the loader support the current file information.
  143226. * @param extension defines the file extension of the file being loaded
  143227. * @returns true if the loader can load the specified file
  143228. */
  143229. canLoad(extension: string): boolean;
  143230. /**
  143231. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143232. * @param data contains the texture data
  143233. * @param texture defines the BabylonJS internal texture
  143234. * @param createPolynomials will be true if polynomials have been requested
  143235. * @param onLoad defines the callback to trigger once the texture is ready
  143236. * @param onError defines the callback to trigger in case of error
  143237. */
  143238. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143239. /**
  143240. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143241. * @param data contains the texture data
  143242. * @param texture defines the BabylonJS internal texture
  143243. * @param callback defines the method to call once ready to upload
  143244. */
  143245. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143246. }
  143247. }
  143248. declare module BABYLON {
  143249. /**
  143250. * Defines the basic options interface of a TexturePacker Frame
  143251. */
  143252. export interface ITexturePackerFrame {
  143253. /**
  143254. * The frame ID
  143255. */
  143256. id: number;
  143257. /**
  143258. * The frames Scale
  143259. */
  143260. scale: Vector2;
  143261. /**
  143262. * The Frames offset
  143263. */
  143264. offset: Vector2;
  143265. }
  143266. /**
  143267. * This is a support class for frame Data on texture packer sets.
  143268. */
  143269. export class TexturePackerFrame implements ITexturePackerFrame {
  143270. /**
  143271. * The frame ID
  143272. */
  143273. id: number;
  143274. /**
  143275. * The frames Scale
  143276. */
  143277. scale: Vector2;
  143278. /**
  143279. * The Frames offset
  143280. */
  143281. offset: Vector2;
  143282. /**
  143283. * Initializes a texture package frame.
  143284. * @param id The numerical frame identifier
  143285. * @param scale Scalar Vector2 for UV frame
  143286. * @param offset Vector2 for the frame position in UV units.
  143287. * @returns TexturePackerFrame
  143288. */
  143289. constructor(id: number, scale: Vector2, offset: Vector2);
  143290. }
  143291. }
  143292. declare module BABYLON {
  143293. /**
  143294. * Defines the basic options interface of a TexturePacker
  143295. */
  143296. export interface ITexturePackerOptions {
  143297. /**
  143298. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  143299. */
  143300. map?: string[];
  143301. /**
  143302. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143303. */
  143304. uvsIn?: string;
  143305. /**
  143306. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  143307. */
  143308. uvsOut?: string;
  143309. /**
  143310. * number representing the layout style. Defaults to LAYOUT_STRIP
  143311. */
  143312. layout?: number;
  143313. /**
  143314. * number of columns if using custom column count layout(2). This defaults to 4.
  143315. */
  143316. colnum?: number;
  143317. /**
  143318. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  143319. */
  143320. updateInputMeshes?: boolean;
  143321. /**
  143322. * boolean flag to dispose all the source textures. Defaults to true.
  143323. */
  143324. disposeSources?: boolean;
  143325. /**
  143326. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  143327. */
  143328. fillBlanks?: boolean;
  143329. /**
  143330. * string value representing the context fill style color. Defaults to 'black'.
  143331. */
  143332. customFillColor?: string;
  143333. /**
  143334. * Width and Height Value of each Frame in the TexturePacker Sets
  143335. */
  143336. frameSize?: number;
  143337. /**
  143338. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  143339. */
  143340. paddingRatio?: number;
  143341. /**
  143342. * Number that declares the fill method for the padding gutter.
  143343. */
  143344. paddingMode?: number;
  143345. /**
  143346. * If in SUBUV_COLOR padding mode what color to use.
  143347. */
  143348. paddingColor?: Color3 | Color4;
  143349. }
  143350. /**
  143351. * Defines the basic interface of a TexturePacker JSON File
  143352. */
  143353. export interface ITexturePackerJSON {
  143354. /**
  143355. * The frame ID
  143356. */
  143357. name: string;
  143358. /**
  143359. * The base64 channel data
  143360. */
  143361. sets: any;
  143362. /**
  143363. * The options of the Packer
  143364. */
  143365. options: ITexturePackerOptions;
  143366. /**
  143367. * The frame data of the Packer
  143368. */
  143369. frames: Array<number>;
  143370. }
  143371. /**
  143372. * This is a support class that generates a series of packed texture sets.
  143373. * @see https://doc.babylonjs.com/babylon101/materials
  143374. */
  143375. export class TexturePacker {
  143376. /** Packer Layout Constant 0 */
  143377. static readonly LAYOUT_STRIP: number;
  143378. /** Packer Layout Constant 1 */
  143379. static readonly LAYOUT_POWER2: number;
  143380. /** Packer Layout Constant 2 */
  143381. static readonly LAYOUT_COLNUM: number;
  143382. /** Packer Layout Constant 0 */
  143383. static readonly SUBUV_WRAP: number;
  143384. /** Packer Layout Constant 1 */
  143385. static readonly SUBUV_EXTEND: number;
  143386. /** Packer Layout Constant 2 */
  143387. static readonly SUBUV_COLOR: number;
  143388. /** The Name of the Texture Package */
  143389. name: string;
  143390. /** The scene scope of the TexturePacker */
  143391. scene: Scene;
  143392. /** The Meshes to target */
  143393. meshes: AbstractMesh[];
  143394. /** Arguments passed with the Constructor */
  143395. options: ITexturePackerOptions;
  143396. /** The promise that is started upon initialization */
  143397. promise: Nullable<Promise<TexturePacker | string>>;
  143398. /** The Container object for the channel sets that are generated */
  143399. sets: object;
  143400. /** The Container array for the frames that are generated */
  143401. frames: TexturePackerFrame[];
  143402. /** The expected number of textures the system is parsing. */
  143403. private _expecting;
  143404. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  143405. private _paddingValue;
  143406. /**
  143407. * Initializes a texture package series from an array of meshes or a single mesh.
  143408. * @param name The name of the package
  143409. * @param meshes The target meshes to compose the package from
  143410. * @param options The arguments that texture packer should follow while building.
  143411. * @param scene The scene which the textures are scoped to.
  143412. * @returns TexturePacker
  143413. */
  143414. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  143415. /**
  143416. * Starts the package process
  143417. * @param resolve The promises resolution function
  143418. * @returns TexturePacker
  143419. */
  143420. private _createFrames;
  143421. /**
  143422. * Calculates the Size of the Channel Sets
  143423. * @returns Vector2
  143424. */
  143425. private _calculateSize;
  143426. /**
  143427. * Calculates the UV data for the frames.
  143428. * @param baseSize the base frameSize
  143429. * @param padding the base frame padding
  143430. * @param dtSize size of the Dynamic Texture for that channel
  143431. * @param dtUnits is 1/dtSize
  143432. * @param update flag to update the input meshes
  143433. */
  143434. private _calculateMeshUVFrames;
  143435. /**
  143436. * Calculates the frames Offset.
  143437. * @param index of the frame
  143438. * @returns Vector2
  143439. */
  143440. private _getFrameOffset;
  143441. /**
  143442. * Updates a Mesh to the frame data
  143443. * @param mesh that is the target
  143444. * @param frameID or the frame index
  143445. */
  143446. private _updateMeshUV;
  143447. /**
  143448. * Updates a Meshes materials to use the texture packer channels
  143449. * @param m is the mesh to target
  143450. * @param force all channels on the packer to be set.
  143451. */
  143452. private _updateTextureReferences;
  143453. /**
  143454. * Public method to set a Mesh to a frame
  143455. * @param m that is the target
  143456. * @param frameID or the frame index
  143457. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  143458. */
  143459. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  143460. /**
  143461. * Starts the async promise to compile the texture packer.
  143462. * @returns Promise<void>
  143463. */
  143464. processAsync(): Promise<void>;
  143465. /**
  143466. * Disposes all textures associated with this packer
  143467. */
  143468. dispose(): void;
  143469. /**
  143470. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  143471. * @param imageType is the image type to use.
  143472. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  143473. */
  143474. download(imageType?: string, quality?: number): void;
  143475. /**
  143476. * Public method to load a texturePacker JSON file.
  143477. * @param data of the JSON file in string format.
  143478. */
  143479. updateFromJSON(data: string): void;
  143480. }
  143481. }
  143482. declare module BABYLON {
  143483. /**
  143484. * 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.
  143485. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143486. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143487. */
  143488. export class CustomProceduralTexture extends ProceduralTexture {
  143489. private _animate;
  143490. private _time;
  143491. private _config;
  143492. private _texturePath;
  143493. /**
  143494. * Instantiates a new Custom Procedural Texture.
  143495. * 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.
  143496. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  143497. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  143498. * @param name Define the name of the texture
  143499. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  143500. * @param size Define the size of the texture to create
  143501. * @param scene Define the scene the texture belongs to
  143502. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  143503. * @param generateMipMaps Define if the texture should creates mip maps or not
  143504. */
  143505. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143506. private _loadJson;
  143507. /**
  143508. * Is the texture ready to be used ? (rendered at least once)
  143509. * @returns true if ready, otherwise, false.
  143510. */
  143511. isReady(): boolean;
  143512. /**
  143513. * Render the texture to its associated render target.
  143514. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  143515. */
  143516. render(useCameraPostProcess?: boolean): void;
  143517. /**
  143518. * Update the list of dependant textures samplers in the shader.
  143519. */
  143520. updateTextures(): void;
  143521. /**
  143522. * Update the uniform values of the procedural texture in the shader.
  143523. */
  143524. updateShaderUniforms(): void;
  143525. /**
  143526. * Define if the texture animates or not.
  143527. */
  143528. get animate(): boolean;
  143529. set animate(value: boolean);
  143530. }
  143531. }
  143532. declare module BABYLON {
  143533. /** @hidden */
  143534. export var noisePixelShader: {
  143535. name: string;
  143536. shader: string;
  143537. };
  143538. }
  143539. declare module BABYLON {
  143540. /**
  143541. * Class used to generate noise procedural textures
  143542. */
  143543. export class NoiseProceduralTexture extends ProceduralTexture {
  143544. /** Gets or sets the start time (default is 0) */
  143545. time: number;
  143546. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  143547. brightness: number;
  143548. /** Defines the number of octaves to process */
  143549. octaves: number;
  143550. /** Defines the level of persistence (0.8 by default) */
  143551. persistence: number;
  143552. /** Gets or sets animation speed factor (default is 1) */
  143553. animationSpeedFactor: number;
  143554. /**
  143555. * Creates a new NoiseProceduralTexture
  143556. * @param name defines the name fo the texture
  143557. * @param size defines the size of the texture (default is 256)
  143558. * @param scene defines the hosting scene
  143559. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  143560. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  143561. */
  143562. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  143563. private _updateShaderUniforms;
  143564. protected _getDefines(): string;
  143565. /** Generate the current state of the procedural texture */
  143566. render(useCameraPostProcess?: boolean): void;
  143567. /**
  143568. * Serializes this noise procedural texture
  143569. * @returns a serialized noise procedural texture object
  143570. */
  143571. serialize(): any;
  143572. /**
  143573. * Clone the texture.
  143574. * @returns the cloned texture
  143575. */
  143576. clone(): NoiseProceduralTexture;
  143577. /**
  143578. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  143579. * @param parsedTexture defines parsed texture data
  143580. * @param scene defines the current scene
  143581. * @param rootUrl defines the root URL containing noise procedural texture information
  143582. * @returns a parsed NoiseProceduralTexture
  143583. */
  143584. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  143585. }
  143586. }
  143587. declare module BABYLON {
  143588. /**
  143589. * Raw cube texture where the raw buffers are passed in
  143590. */
  143591. export class RawCubeTexture extends CubeTexture {
  143592. /**
  143593. * Creates a cube texture where the raw buffers are passed in.
  143594. * @param scene defines the scene the texture is attached to
  143595. * @param data defines the array of data to use to create each face
  143596. * @param size defines the size of the textures
  143597. * @param format defines the format of the data
  143598. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  143599. * @param generateMipMaps defines if the engine should generate the mip levels
  143600. * @param invertY defines if data must be stored with Y axis inverted
  143601. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  143602. * @param compression defines the compression used (null by default)
  143603. */
  143604. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  143605. /**
  143606. * Updates the raw cube texture.
  143607. * @param data defines the data to store
  143608. * @param format defines the data format
  143609. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143610. * @param invertY defines if data must be stored with Y axis inverted
  143611. * @param compression defines the compression used (null by default)
  143612. * @param level defines which level of the texture to update
  143613. */
  143614. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  143615. /**
  143616. * Updates a raw cube texture with RGBD encoded data.
  143617. * @param data defines the array of data [mipmap][face] to use to create each face
  143618. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  143619. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  143620. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  143621. * @returns a promsie that resolves when the operation is complete
  143622. */
  143623. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  143624. /**
  143625. * Clones the raw cube texture.
  143626. * @return a new cube texture
  143627. */
  143628. clone(): CubeTexture;
  143629. /** @hidden */
  143630. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  143631. }
  143632. }
  143633. declare module BABYLON {
  143634. /**
  143635. * Class used to store 2D array textures containing user data
  143636. */
  143637. export class RawTexture2DArray extends Texture {
  143638. /** Gets or sets the texture format to use */
  143639. format: number;
  143640. /**
  143641. * Create a new RawTexture2DArray
  143642. * @param data defines the data of the texture
  143643. * @param width defines the width of the texture
  143644. * @param height defines the height of the texture
  143645. * @param depth defines the number of layers of the texture
  143646. * @param format defines the texture format to use
  143647. * @param scene defines the hosting scene
  143648. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143649. * @param invertY defines if texture must be stored with Y axis inverted
  143650. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143651. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143652. */
  143653. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143654. /** Gets or sets the texture format to use */
  143655. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143656. /**
  143657. * Update the texture with new data
  143658. * @param data defines the data to store in the texture
  143659. */
  143660. update(data: ArrayBufferView): void;
  143661. }
  143662. }
  143663. declare module BABYLON {
  143664. /**
  143665. * Class used to store 3D textures containing user data
  143666. */
  143667. export class RawTexture3D extends Texture {
  143668. /** Gets or sets the texture format to use */
  143669. format: number;
  143670. /**
  143671. * Create a new RawTexture3D
  143672. * @param data defines the data of the texture
  143673. * @param width defines the width of the texture
  143674. * @param height defines the height of the texture
  143675. * @param depth defines the depth of the texture
  143676. * @param format defines the texture format to use
  143677. * @param scene defines the hosting scene
  143678. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143679. * @param invertY defines if texture must be stored with Y axis inverted
  143680. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143681. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143682. */
  143683. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143684. /** Gets or sets the texture format to use */
  143685. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143686. /**
  143687. * Update the texture with new data
  143688. * @param data defines the data to store in the texture
  143689. */
  143690. update(data: ArrayBufferView): void;
  143691. }
  143692. }
  143693. declare module BABYLON {
  143694. /**
  143695. * Creates a refraction texture used by refraction channel of the standard material.
  143696. * It is like a mirror but to see through a material.
  143697. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143698. */
  143699. export class RefractionTexture extends RenderTargetTexture {
  143700. /**
  143701. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  143702. * 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.
  143703. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143704. */
  143705. refractionPlane: Plane;
  143706. /**
  143707. * Define how deep under the surface we should see.
  143708. */
  143709. depth: number;
  143710. /**
  143711. * Creates a refraction texture used by refraction channel of the standard material.
  143712. * It is like a mirror but to see through a material.
  143713. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143714. * @param name Define the texture name
  143715. * @param size Define the size of the underlying texture
  143716. * @param scene Define the scene the refraction belongs to
  143717. * @param generateMipMaps Define if we need to generate mips level for the refraction
  143718. */
  143719. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  143720. /**
  143721. * Clone the refraction texture.
  143722. * @returns the cloned texture
  143723. */
  143724. clone(): RefractionTexture;
  143725. /**
  143726. * Serialize the texture to a JSON representation you could use in Parse later on
  143727. * @returns the serialized JSON representation
  143728. */
  143729. serialize(): any;
  143730. }
  143731. }
  143732. declare module BABYLON {
  143733. /**
  143734. * Block used to add support for vertex skinning (bones)
  143735. */
  143736. export class BonesBlock extends NodeMaterialBlock {
  143737. /**
  143738. * Creates a new BonesBlock
  143739. * @param name defines the block name
  143740. */
  143741. constructor(name: string);
  143742. /**
  143743. * Initialize the block and prepare the context for build
  143744. * @param state defines the state that will be used for the build
  143745. */
  143746. initialize(state: NodeMaterialBuildState): void;
  143747. /**
  143748. * Gets the current class name
  143749. * @returns the class name
  143750. */
  143751. getClassName(): string;
  143752. /**
  143753. * Gets the matrix indices input component
  143754. */
  143755. get matricesIndices(): NodeMaterialConnectionPoint;
  143756. /**
  143757. * Gets the matrix weights input component
  143758. */
  143759. get matricesWeights(): NodeMaterialConnectionPoint;
  143760. /**
  143761. * Gets the extra matrix indices input component
  143762. */
  143763. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  143764. /**
  143765. * Gets the extra matrix weights input component
  143766. */
  143767. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  143768. /**
  143769. * Gets the world input component
  143770. */
  143771. get world(): NodeMaterialConnectionPoint;
  143772. /**
  143773. * Gets the output component
  143774. */
  143775. get output(): NodeMaterialConnectionPoint;
  143776. autoConfigure(material: NodeMaterial): void;
  143777. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  143778. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143779. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143780. protected _buildBlock(state: NodeMaterialBuildState): this;
  143781. }
  143782. }
  143783. declare module BABYLON {
  143784. /**
  143785. * Block used to add support for instances
  143786. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  143787. */
  143788. export class InstancesBlock extends NodeMaterialBlock {
  143789. /**
  143790. * Creates a new InstancesBlock
  143791. * @param name defines the block name
  143792. */
  143793. constructor(name: string);
  143794. /**
  143795. * Gets the current class name
  143796. * @returns the class name
  143797. */
  143798. getClassName(): string;
  143799. /**
  143800. * Gets the first world row input component
  143801. */
  143802. get world0(): NodeMaterialConnectionPoint;
  143803. /**
  143804. * Gets the second world row input component
  143805. */
  143806. get world1(): NodeMaterialConnectionPoint;
  143807. /**
  143808. * Gets the third world row input component
  143809. */
  143810. get world2(): NodeMaterialConnectionPoint;
  143811. /**
  143812. * Gets the forth world row input component
  143813. */
  143814. get world3(): NodeMaterialConnectionPoint;
  143815. /**
  143816. * Gets the world input component
  143817. */
  143818. get world(): NodeMaterialConnectionPoint;
  143819. /**
  143820. * Gets the output component
  143821. */
  143822. get output(): NodeMaterialConnectionPoint;
  143823. /**
  143824. * Gets the isntanceID component
  143825. */
  143826. get instanceID(): NodeMaterialConnectionPoint;
  143827. autoConfigure(material: NodeMaterial): void;
  143828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  143829. protected _buildBlock(state: NodeMaterialBuildState): this;
  143830. }
  143831. }
  143832. declare module BABYLON {
  143833. /**
  143834. * Block used to add morph targets support to vertex shader
  143835. */
  143836. export class MorphTargetsBlock extends NodeMaterialBlock {
  143837. private _repeatableContentAnchor;
  143838. /**
  143839. * Create a new MorphTargetsBlock
  143840. * @param name defines the block name
  143841. */
  143842. constructor(name: string);
  143843. /**
  143844. * Gets the current class name
  143845. * @returns the class name
  143846. */
  143847. getClassName(): string;
  143848. /**
  143849. * Gets the position input component
  143850. */
  143851. get position(): NodeMaterialConnectionPoint;
  143852. /**
  143853. * Gets the normal input component
  143854. */
  143855. get normal(): NodeMaterialConnectionPoint;
  143856. /**
  143857. * Gets the tangent input component
  143858. */
  143859. get tangent(): NodeMaterialConnectionPoint;
  143860. /**
  143861. * Gets the tangent input component
  143862. */
  143863. get uv(): NodeMaterialConnectionPoint;
  143864. /**
  143865. * Gets the position output component
  143866. */
  143867. get positionOutput(): NodeMaterialConnectionPoint;
  143868. /**
  143869. * Gets the normal output component
  143870. */
  143871. get normalOutput(): NodeMaterialConnectionPoint;
  143872. /**
  143873. * Gets the tangent output component
  143874. */
  143875. get tangentOutput(): NodeMaterialConnectionPoint;
  143876. /**
  143877. * Gets the tangent output component
  143878. */
  143879. get uvOutput(): NodeMaterialConnectionPoint;
  143880. initialize(state: NodeMaterialBuildState): void;
  143881. autoConfigure(material: NodeMaterial): void;
  143882. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143883. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143884. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  143885. protected _buildBlock(state: NodeMaterialBuildState): this;
  143886. }
  143887. }
  143888. declare module BABYLON {
  143889. /**
  143890. * Block used to get data information from a light
  143891. */
  143892. export class LightInformationBlock extends NodeMaterialBlock {
  143893. private _lightDataUniformName;
  143894. private _lightColorUniformName;
  143895. private _lightTypeDefineName;
  143896. /**
  143897. * Gets or sets the light associated with this block
  143898. */
  143899. light: Nullable<Light>;
  143900. /**
  143901. * Creates a new LightInformationBlock
  143902. * @param name defines the block name
  143903. */
  143904. constructor(name: string);
  143905. /**
  143906. * Gets the current class name
  143907. * @returns the class name
  143908. */
  143909. getClassName(): string;
  143910. /**
  143911. * Gets the world position input component
  143912. */
  143913. get worldPosition(): NodeMaterialConnectionPoint;
  143914. /**
  143915. * Gets the direction output component
  143916. */
  143917. get direction(): NodeMaterialConnectionPoint;
  143918. /**
  143919. * Gets the direction output component
  143920. */
  143921. get color(): NodeMaterialConnectionPoint;
  143922. /**
  143923. * Gets the direction output component
  143924. */
  143925. get intensity(): NodeMaterialConnectionPoint;
  143926. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143927. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143928. protected _buildBlock(state: NodeMaterialBuildState): this;
  143929. serialize(): any;
  143930. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143931. }
  143932. }
  143933. declare module BABYLON {
  143934. /**
  143935. * Block used to add image processing support to fragment shader
  143936. */
  143937. export class ImageProcessingBlock extends NodeMaterialBlock {
  143938. /**
  143939. * Create a new ImageProcessingBlock
  143940. * @param name defines the block name
  143941. */
  143942. constructor(name: string);
  143943. /**
  143944. * Gets the current class name
  143945. * @returns the class name
  143946. */
  143947. getClassName(): string;
  143948. /**
  143949. * Gets the color input component
  143950. */
  143951. get color(): NodeMaterialConnectionPoint;
  143952. /**
  143953. * Gets the output component
  143954. */
  143955. get output(): NodeMaterialConnectionPoint;
  143956. /**
  143957. * Initialize the block and prepare the context for build
  143958. * @param state defines the state that will be used for the build
  143959. */
  143960. initialize(state: NodeMaterialBuildState): void;
  143961. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143962. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143963. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143964. protected _buildBlock(state: NodeMaterialBuildState): this;
  143965. }
  143966. }
  143967. declare module BABYLON {
  143968. /**
  143969. * Block used to pertub normals based on a normal map
  143970. */
  143971. export class PerturbNormalBlock extends NodeMaterialBlock {
  143972. private _tangentSpaceParameterName;
  143973. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143974. invertX: boolean;
  143975. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143976. invertY: boolean;
  143977. /**
  143978. * Create a new PerturbNormalBlock
  143979. * @param name defines the block name
  143980. */
  143981. constructor(name: string);
  143982. /**
  143983. * Gets the current class name
  143984. * @returns the class name
  143985. */
  143986. getClassName(): string;
  143987. /**
  143988. * Gets the world position input component
  143989. */
  143990. get worldPosition(): NodeMaterialConnectionPoint;
  143991. /**
  143992. * Gets the world normal input component
  143993. */
  143994. get worldNormal(): NodeMaterialConnectionPoint;
  143995. /**
  143996. * Gets the world tangent input component
  143997. */
  143998. get worldTangent(): NodeMaterialConnectionPoint;
  143999. /**
  144000. * Gets the uv input component
  144001. */
  144002. get uv(): NodeMaterialConnectionPoint;
  144003. /**
  144004. * Gets the normal map color input component
  144005. */
  144006. get normalMapColor(): NodeMaterialConnectionPoint;
  144007. /**
  144008. * Gets the strength input component
  144009. */
  144010. get strength(): NodeMaterialConnectionPoint;
  144011. /**
  144012. * Gets the output component
  144013. */
  144014. get output(): NodeMaterialConnectionPoint;
  144015. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144016. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144017. autoConfigure(material: NodeMaterial): void;
  144018. protected _buildBlock(state: NodeMaterialBuildState): this;
  144019. protected _dumpPropertiesCode(): string;
  144020. serialize(): any;
  144021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144022. }
  144023. }
  144024. declare module BABYLON {
  144025. /**
  144026. * Block used to discard a pixel if a value is smaller than a cutoff
  144027. */
  144028. export class DiscardBlock extends NodeMaterialBlock {
  144029. /**
  144030. * Create a new DiscardBlock
  144031. * @param name defines the block name
  144032. */
  144033. constructor(name: string);
  144034. /**
  144035. * Gets the current class name
  144036. * @returns the class name
  144037. */
  144038. getClassName(): string;
  144039. /**
  144040. * Gets the color input component
  144041. */
  144042. get value(): NodeMaterialConnectionPoint;
  144043. /**
  144044. * Gets the cutoff input component
  144045. */
  144046. get cutoff(): NodeMaterialConnectionPoint;
  144047. protected _buildBlock(state: NodeMaterialBuildState): this;
  144048. }
  144049. }
  144050. declare module BABYLON {
  144051. /**
  144052. * Block used to test if the fragment shader is front facing
  144053. */
  144054. export class FrontFacingBlock extends NodeMaterialBlock {
  144055. /**
  144056. * Creates a new FrontFacingBlock
  144057. * @param name defines the block name
  144058. */
  144059. constructor(name: string);
  144060. /**
  144061. * Gets the current class name
  144062. * @returns the class name
  144063. */
  144064. getClassName(): string;
  144065. /**
  144066. * Gets the output component
  144067. */
  144068. get output(): NodeMaterialConnectionPoint;
  144069. protected _buildBlock(state: NodeMaterialBuildState): this;
  144070. }
  144071. }
  144072. declare module BABYLON {
  144073. /**
  144074. * Block used to get the derivative value on x and y of a given input
  144075. */
  144076. export class DerivativeBlock extends NodeMaterialBlock {
  144077. /**
  144078. * Create a new DerivativeBlock
  144079. * @param name defines the block name
  144080. */
  144081. constructor(name: string);
  144082. /**
  144083. * Gets the current class name
  144084. * @returns the class name
  144085. */
  144086. getClassName(): string;
  144087. /**
  144088. * Gets the input component
  144089. */
  144090. get input(): NodeMaterialConnectionPoint;
  144091. /**
  144092. * Gets the derivative output on x
  144093. */
  144094. get dx(): NodeMaterialConnectionPoint;
  144095. /**
  144096. * Gets the derivative output on y
  144097. */
  144098. get dy(): NodeMaterialConnectionPoint;
  144099. protected _buildBlock(state: NodeMaterialBuildState): this;
  144100. }
  144101. }
  144102. declare module BABYLON {
  144103. /**
  144104. * Block used to make gl_FragCoord available
  144105. */
  144106. export class FragCoordBlock extends NodeMaterialBlock {
  144107. /**
  144108. * Creates a new FragCoordBlock
  144109. * @param name defines the block name
  144110. */
  144111. constructor(name: string);
  144112. /**
  144113. * Gets the current class name
  144114. * @returns the class name
  144115. */
  144116. getClassName(): string;
  144117. /**
  144118. * Gets the xy component
  144119. */
  144120. get xy(): NodeMaterialConnectionPoint;
  144121. /**
  144122. * Gets the xyz component
  144123. */
  144124. get xyz(): NodeMaterialConnectionPoint;
  144125. /**
  144126. * Gets the xyzw component
  144127. */
  144128. get xyzw(): NodeMaterialConnectionPoint;
  144129. /**
  144130. * Gets the x component
  144131. */
  144132. get x(): NodeMaterialConnectionPoint;
  144133. /**
  144134. * Gets the y component
  144135. */
  144136. get y(): NodeMaterialConnectionPoint;
  144137. /**
  144138. * Gets the z component
  144139. */
  144140. get z(): NodeMaterialConnectionPoint;
  144141. /**
  144142. * Gets the w component
  144143. */
  144144. get output(): NodeMaterialConnectionPoint;
  144145. protected writeOutputs(state: NodeMaterialBuildState): string;
  144146. protected _buildBlock(state: NodeMaterialBuildState): this;
  144147. }
  144148. }
  144149. declare module BABYLON {
  144150. /**
  144151. * Block used to get the screen sizes
  144152. */
  144153. export class ScreenSizeBlock extends NodeMaterialBlock {
  144154. private _varName;
  144155. private _scene;
  144156. /**
  144157. * Creates a new ScreenSizeBlock
  144158. * @param name defines the block name
  144159. */
  144160. constructor(name: string);
  144161. /**
  144162. * Gets the current class name
  144163. * @returns the class name
  144164. */
  144165. getClassName(): string;
  144166. /**
  144167. * Gets the xy component
  144168. */
  144169. get xy(): NodeMaterialConnectionPoint;
  144170. /**
  144171. * Gets the x component
  144172. */
  144173. get x(): NodeMaterialConnectionPoint;
  144174. /**
  144175. * Gets the y component
  144176. */
  144177. get y(): NodeMaterialConnectionPoint;
  144178. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144179. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  144180. protected _buildBlock(state: NodeMaterialBuildState): this;
  144181. }
  144182. }
  144183. declare module BABYLON {
  144184. /**
  144185. * Block used to add support for scene fog
  144186. */
  144187. export class FogBlock extends NodeMaterialBlock {
  144188. private _fogDistanceName;
  144189. private _fogParameters;
  144190. /**
  144191. * Create a new FogBlock
  144192. * @param name defines the block name
  144193. */
  144194. constructor(name: string);
  144195. /**
  144196. * Gets the current class name
  144197. * @returns the class name
  144198. */
  144199. getClassName(): string;
  144200. /**
  144201. * Gets the world position input component
  144202. */
  144203. get worldPosition(): NodeMaterialConnectionPoint;
  144204. /**
  144205. * Gets the view input component
  144206. */
  144207. get view(): NodeMaterialConnectionPoint;
  144208. /**
  144209. * Gets the color input component
  144210. */
  144211. get input(): NodeMaterialConnectionPoint;
  144212. /**
  144213. * Gets the fog color input component
  144214. */
  144215. get fogColor(): NodeMaterialConnectionPoint;
  144216. /**
  144217. * Gets the output component
  144218. */
  144219. get output(): NodeMaterialConnectionPoint;
  144220. autoConfigure(material: NodeMaterial): void;
  144221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144222. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144223. protected _buildBlock(state: NodeMaterialBuildState): this;
  144224. }
  144225. }
  144226. declare module BABYLON {
  144227. /**
  144228. * Block used to add light in the fragment shader
  144229. */
  144230. export class LightBlock extends NodeMaterialBlock {
  144231. private _lightId;
  144232. /**
  144233. * Gets or sets the light associated with this block
  144234. */
  144235. light: Nullable<Light>;
  144236. /**
  144237. * Create a new LightBlock
  144238. * @param name defines the block name
  144239. */
  144240. constructor(name: string);
  144241. /**
  144242. * Gets the current class name
  144243. * @returns the class name
  144244. */
  144245. getClassName(): string;
  144246. /**
  144247. * Gets the world position input component
  144248. */
  144249. get worldPosition(): NodeMaterialConnectionPoint;
  144250. /**
  144251. * Gets the world normal input component
  144252. */
  144253. get worldNormal(): NodeMaterialConnectionPoint;
  144254. /**
  144255. * Gets the camera (or eye) position component
  144256. */
  144257. get cameraPosition(): NodeMaterialConnectionPoint;
  144258. /**
  144259. * Gets the glossiness component
  144260. */
  144261. get glossiness(): NodeMaterialConnectionPoint;
  144262. /**
  144263. * Gets the glossinness power component
  144264. */
  144265. get glossPower(): NodeMaterialConnectionPoint;
  144266. /**
  144267. * Gets the diffuse color component
  144268. */
  144269. get diffuseColor(): NodeMaterialConnectionPoint;
  144270. /**
  144271. * Gets the specular color component
  144272. */
  144273. get specularColor(): NodeMaterialConnectionPoint;
  144274. /**
  144275. * Gets the diffuse output component
  144276. */
  144277. get diffuseOutput(): NodeMaterialConnectionPoint;
  144278. /**
  144279. * Gets the specular output component
  144280. */
  144281. get specularOutput(): NodeMaterialConnectionPoint;
  144282. /**
  144283. * Gets the shadow output component
  144284. */
  144285. get shadow(): NodeMaterialConnectionPoint;
  144286. autoConfigure(material: NodeMaterial): void;
  144287. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144288. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144289. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144290. private _injectVertexCode;
  144291. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144292. serialize(): any;
  144293. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144294. }
  144295. }
  144296. declare module BABYLON {
  144297. /**
  144298. * Block used to read a reflection texture from a sampler
  144299. */
  144300. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  144301. /**
  144302. * Create a new ReflectionTextureBlock
  144303. * @param name defines the block name
  144304. */
  144305. constructor(name: string);
  144306. /**
  144307. * Gets the current class name
  144308. * @returns the class name
  144309. */
  144310. getClassName(): string;
  144311. /**
  144312. * Gets the world position input component
  144313. */
  144314. get position(): NodeMaterialConnectionPoint;
  144315. /**
  144316. * Gets the world position input component
  144317. */
  144318. get worldPosition(): NodeMaterialConnectionPoint;
  144319. /**
  144320. * Gets the world normal input component
  144321. */
  144322. get worldNormal(): NodeMaterialConnectionPoint;
  144323. /**
  144324. * Gets the world input component
  144325. */
  144326. get world(): NodeMaterialConnectionPoint;
  144327. /**
  144328. * Gets the camera (or eye) position component
  144329. */
  144330. get cameraPosition(): NodeMaterialConnectionPoint;
  144331. /**
  144332. * Gets the view input component
  144333. */
  144334. get view(): NodeMaterialConnectionPoint;
  144335. /**
  144336. * Gets the rgb output component
  144337. */
  144338. get rgb(): NodeMaterialConnectionPoint;
  144339. /**
  144340. * Gets the rgba output component
  144341. */
  144342. get rgba(): NodeMaterialConnectionPoint;
  144343. /**
  144344. * Gets the r output component
  144345. */
  144346. get r(): NodeMaterialConnectionPoint;
  144347. /**
  144348. * Gets the g output component
  144349. */
  144350. get g(): NodeMaterialConnectionPoint;
  144351. /**
  144352. * Gets the b output component
  144353. */
  144354. get b(): NodeMaterialConnectionPoint;
  144355. /**
  144356. * Gets the a output component
  144357. */
  144358. get a(): NodeMaterialConnectionPoint;
  144359. autoConfigure(material: NodeMaterial): void;
  144360. protected _buildBlock(state: NodeMaterialBuildState): this;
  144361. }
  144362. }
  144363. declare module BABYLON {
  144364. /**
  144365. * Block used to add 2 vectors
  144366. */
  144367. export class AddBlock extends NodeMaterialBlock {
  144368. /**
  144369. * Creates a new AddBlock
  144370. * @param name defines the block name
  144371. */
  144372. constructor(name: string);
  144373. /**
  144374. * Gets the current class name
  144375. * @returns the class name
  144376. */
  144377. getClassName(): string;
  144378. /**
  144379. * Gets the left operand input component
  144380. */
  144381. get left(): NodeMaterialConnectionPoint;
  144382. /**
  144383. * Gets the right operand input component
  144384. */
  144385. get right(): NodeMaterialConnectionPoint;
  144386. /**
  144387. * Gets the output component
  144388. */
  144389. get output(): NodeMaterialConnectionPoint;
  144390. protected _buildBlock(state: NodeMaterialBuildState): this;
  144391. }
  144392. }
  144393. declare module BABYLON {
  144394. /**
  144395. * Block used to scale a vector by a float
  144396. */
  144397. export class ScaleBlock extends NodeMaterialBlock {
  144398. /**
  144399. * Creates a new ScaleBlock
  144400. * @param name defines the block name
  144401. */
  144402. constructor(name: string);
  144403. /**
  144404. * Gets the current class name
  144405. * @returns the class name
  144406. */
  144407. getClassName(): string;
  144408. /**
  144409. * Gets the input component
  144410. */
  144411. get input(): NodeMaterialConnectionPoint;
  144412. /**
  144413. * Gets the factor input component
  144414. */
  144415. get factor(): NodeMaterialConnectionPoint;
  144416. /**
  144417. * Gets the output component
  144418. */
  144419. get output(): NodeMaterialConnectionPoint;
  144420. protected _buildBlock(state: NodeMaterialBuildState): this;
  144421. }
  144422. }
  144423. declare module BABYLON {
  144424. /**
  144425. * Block used to clamp a float
  144426. */
  144427. export class ClampBlock extends NodeMaterialBlock {
  144428. /** Gets or sets the minimum range */
  144429. minimum: number;
  144430. /** Gets or sets the maximum range */
  144431. maximum: number;
  144432. /**
  144433. * Creates a new ClampBlock
  144434. * @param name defines the block name
  144435. */
  144436. constructor(name: string);
  144437. /**
  144438. * Gets the current class name
  144439. * @returns the class name
  144440. */
  144441. getClassName(): string;
  144442. /**
  144443. * Gets the value input component
  144444. */
  144445. get value(): NodeMaterialConnectionPoint;
  144446. /**
  144447. * Gets the output component
  144448. */
  144449. get output(): NodeMaterialConnectionPoint;
  144450. protected _buildBlock(state: NodeMaterialBuildState): this;
  144451. protected _dumpPropertiesCode(): string;
  144452. serialize(): any;
  144453. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144454. }
  144455. }
  144456. declare module BABYLON {
  144457. /**
  144458. * Block used to apply a cross product between 2 vectors
  144459. */
  144460. export class CrossBlock extends NodeMaterialBlock {
  144461. /**
  144462. * Creates a new CrossBlock
  144463. * @param name defines the block name
  144464. */
  144465. constructor(name: string);
  144466. /**
  144467. * Gets the current class name
  144468. * @returns the class name
  144469. */
  144470. getClassName(): string;
  144471. /**
  144472. * Gets the left operand input component
  144473. */
  144474. get left(): NodeMaterialConnectionPoint;
  144475. /**
  144476. * Gets the right operand input component
  144477. */
  144478. get right(): NodeMaterialConnectionPoint;
  144479. /**
  144480. * Gets the output component
  144481. */
  144482. get output(): NodeMaterialConnectionPoint;
  144483. protected _buildBlock(state: NodeMaterialBuildState): this;
  144484. }
  144485. }
  144486. declare module BABYLON {
  144487. /**
  144488. * Block used to apply a dot product between 2 vectors
  144489. */
  144490. export class DotBlock extends NodeMaterialBlock {
  144491. /**
  144492. * Creates a new DotBlock
  144493. * @param name defines the block name
  144494. */
  144495. constructor(name: string);
  144496. /**
  144497. * Gets the current class name
  144498. * @returns the class name
  144499. */
  144500. getClassName(): string;
  144501. /**
  144502. * Gets the left operand input component
  144503. */
  144504. get left(): NodeMaterialConnectionPoint;
  144505. /**
  144506. * Gets the right operand input component
  144507. */
  144508. get right(): NodeMaterialConnectionPoint;
  144509. /**
  144510. * Gets the output component
  144511. */
  144512. get output(): NodeMaterialConnectionPoint;
  144513. protected _buildBlock(state: NodeMaterialBuildState): this;
  144514. }
  144515. }
  144516. declare module BABYLON {
  144517. /**
  144518. * Block used to normalize a vector
  144519. */
  144520. export class NormalizeBlock extends NodeMaterialBlock {
  144521. /**
  144522. * Creates a new NormalizeBlock
  144523. * @param name defines the block name
  144524. */
  144525. constructor(name: string);
  144526. /**
  144527. * Gets the current class name
  144528. * @returns the class name
  144529. */
  144530. getClassName(): string;
  144531. /**
  144532. * Gets the input component
  144533. */
  144534. get input(): NodeMaterialConnectionPoint;
  144535. /**
  144536. * Gets the output component
  144537. */
  144538. get output(): NodeMaterialConnectionPoint;
  144539. protected _buildBlock(state: NodeMaterialBuildState): this;
  144540. }
  144541. }
  144542. declare module BABYLON {
  144543. /**
  144544. * Block used to create a Color3/4 out of individual inputs (one for each component)
  144545. */
  144546. export class ColorMergerBlock extends NodeMaterialBlock {
  144547. /**
  144548. * Create a new ColorMergerBlock
  144549. * @param name defines the block name
  144550. */
  144551. constructor(name: string);
  144552. /**
  144553. * Gets the current class name
  144554. * @returns the class name
  144555. */
  144556. getClassName(): string;
  144557. /**
  144558. * Gets the rgb component (input)
  144559. */
  144560. get rgbIn(): NodeMaterialConnectionPoint;
  144561. /**
  144562. * Gets the r component (input)
  144563. */
  144564. get r(): NodeMaterialConnectionPoint;
  144565. /**
  144566. * Gets the g component (input)
  144567. */
  144568. get g(): NodeMaterialConnectionPoint;
  144569. /**
  144570. * Gets the b component (input)
  144571. */
  144572. get b(): NodeMaterialConnectionPoint;
  144573. /**
  144574. * Gets the a component (input)
  144575. */
  144576. get a(): NodeMaterialConnectionPoint;
  144577. /**
  144578. * Gets the rgba component (output)
  144579. */
  144580. get rgba(): NodeMaterialConnectionPoint;
  144581. /**
  144582. * Gets the rgb component (output)
  144583. */
  144584. get rgbOut(): NodeMaterialConnectionPoint;
  144585. /**
  144586. * Gets the rgb component (output)
  144587. * @deprecated Please use rgbOut instead.
  144588. */
  144589. get rgb(): NodeMaterialConnectionPoint;
  144590. protected _buildBlock(state: NodeMaterialBuildState): this;
  144591. }
  144592. }
  144593. declare module BABYLON {
  144594. /**
  144595. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  144596. */
  144597. export class VectorSplitterBlock extends NodeMaterialBlock {
  144598. /**
  144599. * Create a new VectorSplitterBlock
  144600. * @param name defines the block name
  144601. */
  144602. constructor(name: string);
  144603. /**
  144604. * Gets the current class name
  144605. * @returns the class name
  144606. */
  144607. getClassName(): string;
  144608. /**
  144609. * Gets the xyzw component (input)
  144610. */
  144611. get xyzw(): NodeMaterialConnectionPoint;
  144612. /**
  144613. * Gets the xyz component (input)
  144614. */
  144615. get xyzIn(): NodeMaterialConnectionPoint;
  144616. /**
  144617. * Gets the xy component (input)
  144618. */
  144619. get xyIn(): NodeMaterialConnectionPoint;
  144620. /**
  144621. * Gets the xyz component (output)
  144622. */
  144623. get xyzOut(): NodeMaterialConnectionPoint;
  144624. /**
  144625. * Gets the xy component (output)
  144626. */
  144627. get xyOut(): NodeMaterialConnectionPoint;
  144628. /**
  144629. * Gets the x component (output)
  144630. */
  144631. get x(): NodeMaterialConnectionPoint;
  144632. /**
  144633. * Gets the y component (output)
  144634. */
  144635. get y(): NodeMaterialConnectionPoint;
  144636. /**
  144637. * Gets the z component (output)
  144638. */
  144639. get z(): NodeMaterialConnectionPoint;
  144640. /**
  144641. * Gets the w component (output)
  144642. */
  144643. get w(): NodeMaterialConnectionPoint;
  144644. protected _inputRename(name: string): string;
  144645. protected _outputRename(name: string): string;
  144646. protected _buildBlock(state: NodeMaterialBuildState): this;
  144647. }
  144648. }
  144649. declare module BABYLON {
  144650. /**
  144651. * Block used to lerp between 2 values
  144652. */
  144653. export class LerpBlock extends NodeMaterialBlock {
  144654. /**
  144655. * Creates a new LerpBlock
  144656. * @param name defines the block name
  144657. */
  144658. constructor(name: string);
  144659. /**
  144660. * Gets the current class name
  144661. * @returns the class name
  144662. */
  144663. getClassName(): string;
  144664. /**
  144665. * Gets the left operand input component
  144666. */
  144667. get left(): NodeMaterialConnectionPoint;
  144668. /**
  144669. * Gets the right operand input component
  144670. */
  144671. get right(): NodeMaterialConnectionPoint;
  144672. /**
  144673. * Gets the gradient operand input component
  144674. */
  144675. get gradient(): NodeMaterialConnectionPoint;
  144676. /**
  144677. * Gets the output component
  144678. */
  144679. get output(): NodeMaterialConnectionPoint;
  144680. protected _buildBlock(state: NodeMaterialBuildState): this;
  144681. }
  144682. }
  144683. declare module BABYLON {
  144684. /**
  144685. * Block used to divide 2 vectors
  144686. */
  144687. export class DivideBlock extends NodeMaterialBlock {
  144688. /**
  144689. * Creates a new DivideBlock
  144690. * @param name defines the block name
  144691. */
  144692. constructor(name: string);
  144693. /**
  144694. * Gets the current class name
  144695. * @returns the class name
  144696. */
  144697. getClassName(): string;
  144698. /**
  144699. * Gets the left operand input component
  144700. */
  144701. get left(): NodeMaterialConnectionPoint;
  144702. /**
  144703. * Gets the right operand input component
  144704. */
  144705. get right(): NodeMaterialConnectionPoint;
  144706. /**
  144707. * Gets the output component
  144708. */
  144709. get output(): NodeMaterialConnectionPoint;
  144710. protected _buildBlock(state: NodeMaterialBuildState): this;
  144711. }
  144712. }
  144713. declare module BABYLON {
  144714. /**
  144715. * Block used to subtract 2 vectors
  144716. */
  144717. export class SubtractBlock extends NodeMaterialBlock {
  144718. /**
  144719. * Creates a new SubtractBlock
  144720. * @param name defines the block name
  144721. */
  144722. constructor(name: string);
  144723. /**
  144724. * Gets the current class name
  144725. * @returns the class name
  144726. */
  144727. getClassName(): string;
  144728. /**
  144729. * Gets the left operand input component
  144730. */
  144731. get left(): NodeMaterialConnectionPoint;
  144732. /**
  144733. * Gets the right operand input component
  144734. */
  144735. get right(): NodeMaterialConnectionPoint;
  144736. /**
  144737. * Gets the output component
  144738. */
  144739. get output(): NodeMaterialConnectionPoint;
  144740. protected _buildBlock(state: NodeMaterialBuildState): this;
  144741. }
  144742. }
  144743. declare module BABYLON {
  144744. /**
  144745. * Block used to step a value
  144746. */
  144747. export class StepBlock extends NodeMaterialBlock {
  144748. /**
  144749. * Creates a new StepBlock
  144750. * @param name defines the block name
  144751. */
  144752. constructor(name: string);
  144753. /**
  144754. * Gets the current class name
  144755. * @returns the class name
  144756. */
  144757. getClassName(): string;
  144758. /**
  144759. * Gets the value operand input component
  144760. */
  144761. get value(): NodeMaterialConnectionPoint;
  144762. /**
  144763. * Gets the edge operand input component
  144764. */
  144765. get edge(): NodeMaterialConnectionPoint;
  144766. /**
  144767. * Gets the output component
  144768. */
  144769. get output(): NodeMaterialConnectionPoint;
  144770. protected _buildBlock(state: NodeMaterialBuildState): this;
  144771. }
  144772. }
  144773. declare module BABYLON {
  144774. /**
  144775. * Block used to get the opposite (1 - x) of a value
  144776. */
  144777. export class OneMinusBlock extends NodeMaterialBlock {
  144778. /**
  144779. * Creates a new OneMinusBlock
  144780. * @param name defines the block name
  144781. */
  144782. constructor(name: string);
  144783. /**
  144784. * Gets the current class name
  144785. * @returns the class name
  144786. */
  144787. getClassName(): string;
  144788. /**
  144789. * Gets the input component
  144790. */
  144791. get input(): NodeMaterialConnectionPoint;
  144792. /**
  144793. * Gets the output component
  144794. */
  144795. get output(): NodeMaterialConnectionPoint;
  144796. protected _buildBlock(state: NodeMaterialBuildState): this;
  144797. }
  144798. }
  144799. declare module BABYLON {
  144800. /**
  144801. * Block used to get the view direction
  144802. */
  144803. export class ViewDirectionBlock extends NodeMaterialBlock {
  144804. /**
  144805. * Creates a new ViewDirectionBlock
  144806. * @param name defines the block name
  144807. */
  144808. constructor(name: string);
  144809. /**
  144810. * Gets the current class name
  144811. * @returns the class name
  144812. */
  144813. getClassName(): string;
  144814. /**
  144815. * Gets the world position component
  144816. */
  144817. get worldPosition(): NodeMaterialConnectionPoint;
  144818. /**
  144819. * Gets the camera position component
  144820. */
  144821. get cameraPosition(): NodeMaterialConnectionPoint;
  144822. /**
  144823. * Gets the output component
  144824. */
  144825. get output(): NodeMaterialConnectionPoint;
  144826. autoConfigure(material: NodeMaterial): void;
  144827. protected _buildBlock(state: NodeMaterialBuildState): this;
  144828. }
  144829. }
  144830. declare module BABYLON {
  144831. /**
  144832. * Block used to compute fresnel value
  144833. */
  144834. export class FresnelBlock extends NodeMaterialBlock {
  144835. /**
  144836. * Create a new FresnelBlock
  144837. * @param name defines the block name
  144838. */
  144839. constructor(name: string);
  144840. /**
  144841. * Gets the current class name
  144842. * @returns the class name
  144843. */
  144844. getClassName(): string;
  144845. /**
  144846. * Gets the world normal input component
  144847. */
  144848. get worldNormal(): NodeMaterialConnectionPoint;
  144849. /**
  144850. * Gets the view direction input component
  144851. */
  144852. get viewDirection(): NodeMaterialConnectionPoint;
  144853. /**
  144854. * Gets the bias input component
  144855. */
  144856. get bias(): NodeMaterialConnectionPoint;
  144857. /**
  144858. * Gets the camera (or eye) position component
  144859. */
  144860. get power(): NodeMaterialConnectionPoint;
  144861. /**
  144862. * Gets the fresnel output component
  144863. */
  144864. get fresnel(): NodeMaterialConnectionPoint;
  144865. autoConfigure(material: NodeMaterial): void;
  144866. protected _buildBlock(state: NodeMaterialBuildState): this;
  144867. }
  144868. }
  144869. declare module BABYLON {
  144870. /**
  144871. * Block used to get the max of 2 values
  144872. */
  144873. export class MaxBlock extends NodeMaterialBlock {
  144874. /**
  144875. * Creates a new MaxBlock
  144876. * @param name defines the block name
  144877. */
  144878. constructor(name: string);
  144879. /**
  144880. * Gets the current class name
  144881. * @returns the class name
  144882. */
  144883. getClassName(): string;
  144884. /**
  144885. * Gets the left operand input component
  144886. */
  144887. get left(): NodeMaterialConnectionPoint;
  144888. /**
  144889. * Gets the right operand input component
  144890. */
  144891. get right(): NodeMaterialConnectionPoint;
  144892. /**
  144893. * Gets the output component
  144894. */
  144895. get output(): NodeMaterialConnectionPoint;
  144896. protected _buildBlock(state: NodeMaterialBuildState): this;
  144897. }
  144898. }
  144899. declare module BABYLON {
  144900. /**
  144901. * Block used to get the min of 2 values
  144902. */
  144903. export class MinBlock extends NodeMaterialBlock {
  144904. /**
  144905. * Creates a new MinBlock
  144906. * @param name defines the block name
  144907. */
  144908. constructor(name: string);
  144909. /**
  144910. * Gets the current class name
  144911. * @returns the class name
  144912. */
  144913. getClassName(): string;
  144914. /**
  144915. * Gets the left operand input component
  144916. */
  144917. get left(): NodeMaterialConnectionPoint;
  144918. /**
  144919. * Gets the right operand input component
  144920. */
  144921. get right(): NodeMaterialConnectionPoint;
  144922. /**
  144923. * Gets the output component
  144924. */
  144925. get output(): NodeMaterialConnectionPoint;
  144926. protected _buildBlock(state: NodeMaterialBuildState): this;
  144927. }
  144928. }
  144929. declare module BABYLON {
  144930. /**
  144931. * Block used to get the distance between 2 values
  144932. */
  144933. export class DistanceBlock extends NodeMaterialBlock {
  144934. /**
  144935. * Creates a new DistanceBlock
  144936. * @param name defines the block name
  144937. */
  144938. constructor(name: string);
  144939. /**
  144940. * Gets the current class name
  144941. * @returns the class name
  144942. */
  144943. getClassName(): string;
  144944. /**
  144945. * Gets the left operand input component
  144946. */
  144947. get left(): NodeMaterialConnectionPoint;
  144948. /**
  144949. * Gets the right operand input component
  144950. */
  144951. get right(): NodeMaterialConnectionPoint;
  144952. /**
  144953. * Gets the output component
  144954. */
  144955. get output(): NodeMaterialConnectionPoint;
  144956. protected _buildBlock(state: NodeMaterialBuildState): this;
  144957. }
  144958. }
  144959. declare module BABYLON {
  144960. /**
  144961. * Block used to get the length of a vector
  144962. */
  144963. export class LengthBlock extends NodeMaterialBlock {
  144964. /**
  144965. * Creates a new LengthBlock
  144966. * @param name defines the block name
  144967. */
  144968. constructor(name: string);
  144969. /**
  144970. * Gets the current class name
  144971. * @returns the class name
  144972. */
  144973. getClassName(): string;
  144974. /**
  144975. * Gets the value input component
  144976. */
  144977. get value(): NodeMaterialConnectionPoint;
  144978. /**
  144979. * Gets the output component
  144980. */
  144981. get output(): NodeMaterialConnectionPoint;
  144982. protected _buildBlock(state: NodeMaterialBuildState): this;
  144983. }
  144984. }
  144985. declare module BABYLON {
  144986. /**
  144987. * Block used to get negative version of a value (i.e. x * -1)
  144988. */
  144989. export class NegateBlock extends NodeMaterialBlock {
  144990. /**
  144991. * Creates a new NegateBlock
  144992. * @param name defines the block name
  144993. */
  144994. constructor(name: string);
  144995. /**
  144996. * Gets the current class name
  144997. * @returns the class name
  144998. */
  144999. getClassName(): string;
  145000. /**
  145001. * Gets the value input component
  145002. */
  145003. get value(): NodeMaterialConnectionPoint;
  145004. /**
  145005. * Gets the output component
  145006. */
  145007. get output(): NodeMaterialConnectionPoint;
  145008. protected _buildBlock(state: NodeMaterialBuildState): this;
  145009. }
  145010. }
  145011. declare module BABYLON {
  145012. /**
  145013. * Block used to get the value of the first parameter raised to the power of the second
  145014. */
  145015. export class PowBlock extends NodeMaterialBlock {
  145016. /**
  145017. * Creates a new PowBlock
  145018. * @param name defines the block name
  145019. */
  145020. constructor(name: string);
  145021. /**
  145022. * Gets the current class name
  145023. * @returns the class name
  145024. */
  145025. getClassName(): string;
  145026. /**
  145027. * Gets the value operand input component
  145028. */
  145029. get value(): NodeMaterialConnectionPoint;
  145030. /**
  145031. * Gets the power operand input component
  145032. */
  145033. get power(): NodeMaterialConnectionPoint;
  145034. /**
  145035. * Gets the output component
  145036. */
  145037. get output(): NodeMaterialConnectionPoint;
  145038. protected _buildBlock(state: NodeMaterialBuildState): this;
  145039. }
  145040. }
  145041. declare module BABYLON {
  145042. /**
  145043. * Block used to get a random number
  145044. */
  145045. export class RandomNumberBlock extends NodeMaterialBlock {
  145046. /**
  145047. * Creates a new RandomNumberBlock
  145048. * @param name defines the block name
  145049. */
  145050. constructor(name: string);
  145051. /**
  145052. * Gets the current class name
  145053. * @returns the class name
  145054. */
  145055. getClassName(): string;
  145056. /**
  145057. * Gets the seed input component
  145058. */
  145059. get seed(): NodeMaterialConnectionPoint;
  145060. /**
  145061. * Gets the output component
  145062. */
  145063. get output(): NodeMaterialConnectionPoint;
  145064. protected _buildBlock(state: NodeMaterialBuildState): this;
  145065. }
  145066. }
  145067. declare module BABYLON {
  145068. /**
  145069. * Block used to compute arc tangent of 2 values
  145070. */
  145071. export class ArcTan2Block extends NodeMaterialBlock {
  145072. /**
  145073. * Creates a new ArcTan2Block
  145074. * @param name defines the block name
  145075. */
  145076. constructor(name: string);
  145077. /**
  145078. * Gets the current class name
  145079. * @returns the class name
  145080. */
  145081. getClassName(): string;
  145082. /**
  145083. * Gets the x operand input component
  145084. */
  145085. get x(): NodeMaterialConnectionPoint;
  145086. /**
  145087. * Gets the y operand input component
  145088. */
  145089. get y(): NodeMaterialConnectionPoint;
  145090. /**
  145091. * Gets the output component
  145092. */
  145093. get output(): NodeMaterialConnectionPoint;
  145094. protected _buildBlock(state: NodeMaterialBuildState): this;
  145095. }
  145096. }
  145097. declare module BABYLON {
  145098. /**
  145099. * Block used to smooth step a value
  145100. */
  145101. export class SmoothStepBlock extends NodeMaterialBlock {
  145102. /**
  145103. * Creates a new SmoothStepBlock
  145104. * @param name defines the block name
  145105. */
  145106. constructor(name: string);
  145107. /**
  145108. * Gets the current class name
  145109. * @returns the class name
  145110. */
  145111. getClassName(): string;
  145112. /**
  145113. * Gets the value operand input component
  145114. */
  145115. get value(): NodeMaterialConnectionPoint;
  145116. /**
  145117. * Gets the first edge operand input component
  145118. */
  145119. get edge0(): NodeMaterialConnectionPoint;
  145120. /**
  145121. * Gets the second edge operand input component
  145122. */
  145123. get edge1(): NodeMaterialConnectionPoint;
  145124. /**
  145125. * Gets the output component
  145126. */
  145127. get output(): NodeMaterialConnectionPoint;
  145128. protected _buildBlock(state: NodeMaterialBuildState): this;
  145129. }
  145130. }
  145131. declare module BABYLON {
  145132. /**
  145133. * Block used to get the reciprocal (1 / x) of a value
  145134. */
  145135. export class ReciprocalBlock extends NodeMaterialBlock {
  145136. /**
  145137. * Creates a new ReciprocalBlock
  145138. * @param name defines the block name
  145139. */
  145140. constructor(name: string);
  145141. /**
  145142. * Gets the current class name
  145143. * @returns the class name
  145144. */
  145145. getClassName(): string;
  145146. /**
  145147. * Gets the input component
  145148. */
  145149. get input(): NodeMaterialConnectionPoint;
  145150. /**
  145151. * Gets the output component
  145152. */
  145153. get output(): NodeMaterialConnectionPoint;
  145154. protected _buildBlock(state: NodeMaterialBuildState): this;
  145155. }
  145156. }
  145157. declare module BABYLON {
  145158. /**
  145159. * Block used to replace a color by another one
  145160. */
  145161. export class ReplaceColorBlock extends NodeMaterialBlock {
  145162. /**
  145163. * Creates a new ReplaceColorBlock
  145164. * @param name defines the block name
  145165. */
  145166. constructor(name: string);
  145167. /**
  145168. * Gets the current class name
  145169. * @returns the class name
  145170. */
  145171. getClassName(): string;
  145172. /**
  145173. * Gets the value input component
  145174. */
  145175. get value(): NodeMaterialConnectionPoint;
  145176. /**
  145177. * Gets the reference input component
  145178. */
  145179. get reference(): NodeMaterialConnectionPoint;
  145180. /**
  145181. * Gets the distance input component
  145182. */
  145183. get distance(): NodeMaterialConnectionPoint;
  145184. /**
  145185. * Gets the replacement input component
  145186. */
  145187. get replacement(): NodeMaterialConnectionPoint;
  145188. /**
  145189. * Gets the output component
  145190. */
  145191. get output(): NodeMaterialConnectionPoint;
  145192. protected _buildBlock(state: NodeMaterialBuildState): this;
  145193. }
  145194. }
  145195. declare module BABYLON {
  145196. /**
  145197. * Block used to posterize a value
  145198. * @see https://en.wikipedia.org/wiki/Posterization
  145199. */
  145200. export class PosterizeBlock extends NodeMaterialBlock {
  145201. /**
  145202. * Creates a new PosterizeBlock
  145203. * @param name defines the block name
  145204. */
  145205. constructor(name: string);
  145206. /**
  145207. * Gets the current class name
  145208. * @returns the class name
  145209. */
  145210. getClassName(): string;
  145211. /**
  145212. * Gets the value input component
  145213. */
  145214. get value(): NodeMaterialConnectionPoint;
  145215. /**
  145216. * Gets the steps input component
  145217. */
  145218. get steps(): NodeMaterialConnectionPoint;
  145219. /**
  145220. * Gets the output component
  145221. */
  145222. get output(): NodeMaterialConnectionPoint;
  145223. protected _buildBlock(state: NodeMaterialBuildState): this;
  145224. }
  145225. }
  145226. declare module BABYLON {
  145227. /**
  145228. * Operations supported by the Wave block
  145229. */
  145230. export enum WaveBlockKind {
  145231. /** SawTooth */
  145232. SawTooth = 0,
  145233. /** Square */
  145234. Square = 1,
  145235. /** Triangle */
  145236. Triangle = 2
  145237. }
  145238. /**
  145239. * Block used to apply wave operation to floats
  145240. */
  145241. export class WaveBlock extends NodeMaterialBlock {
  145242. /**
  145243. * Gets or sets the kibnd of wave to be applied by the block
  145244. */
  145245. kind: WaveBlockKind;
  145246. /**
  145247. * Creates a new WaveBlock
  145248. * @param name defines the block name
  145249. */
  145250. constructor(name: string);
  145251. /**
  145252. * Gets the current class name
  145253. * @returns the class name
  145254. */
  145255. getClassName(): string;
  145256. /**
  145257. * Gets the input component
  145258. */
  145259. get input(): NodeMaterialConnectionPoint;
  145260. /**
  145261. * Gets the output component
  145262. */
  145263. get output(): NodeMaterialConnectionPoint;
  145264. protected _buildBlock(state: NodeMaterialBuildState): this;
  145265. serialize(): any;
  145266. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145267. }
  145268. }
  145269. declare module BABYLON {
  145270. /**
  145271. * Class used to store a color step for the GradientBlock
  145272. */
  145273. export class GradientBlockColorStep {
  145274. private _step;
  145275. /**
  145276. * Gets value indicating which step this color is associated with (between 0 and 1)
  145277. */
  145278. get step(): number;
  145279. /**
  145280. * Sets a value indicating which step this color is associated with (between 0 and 1)
  145281. */
  145282. set step(val: number);
  145283. private _color;
  145284. /**
  145285. * Gets the color associated with this step
  145286. */
  145287. get color(): Color3;
  145288. /**
  145289. * Sets the color associated with this step
  145290. */
  145291. set color(val: Color3);
  145292. /**
  145293. * Creates a new GradientBlockColorStep
  145294. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  145295. * @param color defines the color associated with this step
  145296. */
  145297. constructor(step: number, color: Color3);
  145298. }
  145299. /**
  145300. * Block used to return a color from a gradient based on an input value between 0 and 1
  145301. */
  145302. export class GradientBlock extends NodeMaterialBlock {
  145303. /**
  145304. * Gets or sets the list of color steps
  145305. */
  145306. colorSteps: GradientBlockColorStep[];
  145307. /** Gets an observable raised when the value is changed */
  145308. onValueChangedObservable: Observable<GradientBlock>;
  145309. /** calls observable when the value is changed*/
  145310. colorStepsUpdated(): void;
  145311. /**
  145312. * Creates a new GradientBlock
  145313. * @param name defines the block name
  145314. */
  145315. constructor(name: string);
  145316. /**
  145317. * Gets the current class name
  145318. * @returns the class name
  145319. */
  145320. getClassName(): string;
  145321. /**
  145322. * Gets the gradient input component
  145323. */
  145324. get gradient(): NodeMaterialConnectionPoint;
  145325. /**
  145326. * Gets the output component
  145327. */
  145328. get output(): NodeMaterialConnectionPoint;
  145329. private _writeColorConstant;
  145330. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145331. serialize(): any;
  145332. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145333. protected _dumpPropertiesCode(): string;
  145334. }
  145335. }
  145336. declare module BABYLON {
  145337. /**
  145338. * Block used to normalize lerp between 2 values
  145339. */
  145340. export class NLerpBlock extends NodeMaterialBlock {
  145341. /**
  145342. * Creates a new NLerpBlock
  145343. * @param name defines the block name
  145344. */
  145345. constructor(name: string);
  145346. /**
  145347. * Gets the current class name
  145348. * @returns the class name
  145349. */
  145350. getClassName(): string;
  145351. /**
  145352. * Gets the left operand input component
  145353. */
  145354. get left(): NodeMaterialConnectionPoint;
  145355. /**
  145356. * Gets the right operand input component
  145357. */
  145358. get right(): NodeMaterialConnectionPoint;
  145359. /**
  145360. * Gets the gradient operand input component
  145361. */
  145362. get gradient(): NodeMaterialConnectionPoint;
  145363. /**
  145364. * Gets the output component
  145365. */
  145366. get output(): NodeMaterialConnectionPoint;
  145367. protected _buildBlock(state: NodeMaterialBuildState): this;
  145368. }
  145369. }
  145370. declare module BABYLON {
  145371. /**
  145372. * block used to Generate a Worley Noise 3D Noise Pattern
  145373. */
  145374. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  145375. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145376. manhattanDistance: boolean;
  145377. /**
  145378. * Creates a new WorleyNoise3DBlock
  145379. * @param name defines the block name
  145380. */
  145381. constructor(name: string);
  145382. /**
  145383. * Gets the current class name
  145384. * @returns the class name
  145385. */
  145386. getClassName(): string;
  145387. /**
  145388. * Gets the seed input component
  145389. */
  145390. get seed(): NodeMaterialConnectionPoint;
  145391. /**
  145392. * Gets the jitter input component
  145393. */
  145394. get jitter(): NodeMaterialConnectionPoint;
  145395. /**
  145396. * Gets the output component
  145397. */
  145398. get output(): NodeMaterialConnectionPoint;
  145399. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145400. /**
  145401. * Exposes the properties to the UI?
  145402. */
  145403. protected _dumpPropertiesCode(): string;
  145404. /**
  145405. * Exposes the properties to the Seralize?
  145406. */
  145407. serialize(): any;
  145408. /**
  145409. * Exposes the properties to the deseralize?
  145410. */
  145411. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145412. }
  145413. }
  145414. declare module BABYLON {
  145415. /**
  145416. * block used to Generate a Simplex Perlin 3d Noise Pattern
  145417. */
  145418. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  145419. /**
  145420. * Creates a new SimplexPerlin3DBlock
  145421. * @param name defines the block name
  145422. */
  145423. constructor(name: string);
  145424. /**
  145425. * Gets the current class name
  145426. * @returns the class name
  145427. */
  145428. getClassName(): string;
  145429. /**
  145430. * Gets the seed operand input component
  145431. */
  145432. get seed(): NodeMaterialConnectionPoint;
  145433. /**
  145434. * Gets the output component
  145435. */
  145436. get output(): NodeMaterialConnectionPoint;
  145437. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145438. }
  145439. }
  145440. declare module BABYLON {
  145441. /**
  145442. * Block used to blend normals
  145443. */
  145444. export class NormalBlendBlock extends NodeMaterialBlock {
  145445. /**
  145446. * Creates a new NormalBlendBlock
  145447. * @param name defines the block name
  145448. */
  145449. constructor(name: string);
  145450. /**
  145451. * Gets the current class name
  145452. * @returns the class name
  145453. */
  145454. getClassName(): string;
  145455. /**
  145456. * Gets the first input component
  145457. */
  145458. get normalMap0(): NodeMaterialConnectionPoint;
  145459. /**
  145460. * Gets the second input component
  145461. */
  145462. get normalMap1(): NodeMaterialConnectionPoint;
  145463. /**
  145464. * Gets the output component
  145465. */
  145466. get output(): NodeMaterialConnectionPoint;
  145467. protected _buildBlock(state: NodeMaterialBuildState): this;
  145468. }
  145469. }
  145470. declare module BABYLON {
  145471. /**
  145472. * Block used to rotate a 2d vector by a given angle
  145473. */
  145474. export class Rotate2dBlock extends NodeMaterialBlock {
  145475. /**
  145476. * Creates a new Rotate2dBlock
  145477. * @param name defines the block name
  145478. */
  145479. constructor(name: string);
  145480. /**
  145481. * Gets the current class name
  145482. * @returns the class name
  145483. */
  145484. getClassName(): string;
  145485. /**
  145486. * Gets the input vector
  145487. */
  145488. get input(): NodeMaterialConnectionPoint;
  145489. /**
  145490. * Gets the input angle
  145491. */
  145492. get angle(): NodeMaterialConnectionPoint;
  145493. /**
  145494. * Gets the output component
  145495. */
  145496. get output(): NodeMaterialConnectionPoint;
  145497. autoConfigure(material: NodeMaterial): void;
  145498. protected _buildBlock(state: NodeMaterialBuildState): this;
  145499. }
  145500. }
  145501. declare module BABYLON {
  145502. /**
  145503. * Block used to get the reflected vector from a direction and a normal
  145504. */
  145505. export class ReflectBlock extends NodeMaterialBlock {
  145506. /**
  145507. * Creates a new ReflectBlock
  145508. * @param name defines the block name
  145509. */
  145510. constructor(name: string);
  145511. /**
  145512. * Gets the current class name
  145513. * @returns the class name
  145514. */
  145515. getClassName(): string;
  145516. /**
  145517. * Gets the incident component
  145518. */
  145519. get incident(): NodeMaterialConnectionPoint;
  145520. /**
  145521. * Gets the normal component
  145522. */
  145523. get normal(): NodeMaterialConnectionPoint;
  145524. /**
  145525. * Gets the output component
  145526. */
  145527. get output(): NodeMaterialConnectionPoint;
  145528. protected _buildBlock(state: NodeMaterialBuildState): this;
  145529. }
  145530. }
  145531. declare module BABYLON {
  145532. /**
  145533. * Block used to get the refracted vector from a direction and a normal
  145534. */
  145535. export class RefractBlock extends NodeMaterialBlock {
  145536. /**
  145537. * Creates a new RefractBlock
  145538. * @param name defines the block name
  145539. */
  145540. constructor(name: string);
  145541. /**
  145542. * Gets the current class name
  145543. * @returns the class name
  145544. */
  145545. getClassName(): string;
  145546. /**
  145547. * Gets the incident component
  145548. */
  145549. get incident(): NodeMaterialConnectionPoint;
  145550. /**
  145551. * Gets the normal component
  145552. */
  145553. get normal(): NodeMaterialConnectionPoint;
  145554. /**
  145555. * Gets the index of refraction component
  145556. */
  145557. get ior(): NodeMaterialConnectionPoint;
  145558. /**
  145559. * Gets the output component
  145560. */
  145561. get output(): NodeMaterialConnectionPoint;
  145562. protected _buildBlock(state: NodeMaterialBuildState): this;
  145563. }
  145564. }
  145565. declare module BABYLON {
  145566. /**
  145567. * Block used to desaturate a color
  145568. */
  145569. export class DesaturateBlock extends NodeMaterialBlock {
  145570. /**
  145571. * Creates a new DesaturateBlock
  145572. * @param name defines the block name
  145573. */
  145574. constructor(name: string);
  145575. /**
  145576. * Gets the current class name
  145577. * @returns the class name
  145578. */
  145579. getClassName(): string;
  145580. /**
  145581. * Gets the color operand input component
  145582. */
  145583. get color(): NodeMaterialConnectionPoint;
  145584. /**
  145585. * Gets the level operand input component
  145586. */
  145587. get level(): NodeMaterialConnectionPoint;
  145588. /**
  145589. * Gets the output component
  145590. */
  145591. get output(): NodeMaterialConnectionPoint;
  145592. protected _buildBlock(state: NodeMaterialBuildState): this;
  145593. }
  145594. }
  145595. declare module BABYLON {
  145596. /**
  145597. * Block used to implement the ambient occlusion module of the PBR material
  145598. */
  145599. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  145600. /**
  145601. * Create a new AmbientOcclusionBlock
  145602. * @param name defines the block name
  145603. */
  145604. constructor(name: string);
  145605. /**
  145606. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  145607. */
  145608. useAmbientInGrayScale: boolean;
  145609. /**
  145610. * Initialize the block and prepare the context for build
  145611. * @param state defines the state that will be used for the build
  145612. */
  145613. initialize(state: NodeMaterialBuildState): void;
  145614. /**
  145615. * Gets the current class name
  145616. * @returns the class name
  145617. */
  145618. getClassName(): string;
  145619. /**
  145620. * Gets the texture input component
  145621. */
  145622. get texture(): NodeMaterialConnectionPoint;
  145623. /**
  145624. * Gets the texture intensity component
  145625. */
  145626. get intensity(): NodeMaterialConnectionPoint;
  145627. /**
  145628. * Gets the direct light intensity input component
  145629. */
  145630. get directLightIntensity(): NodeMaterialConnectionPoint;
  145631. /**
  145632. * Gets the ambient occlusion object output component
  145633. */
  145634. get ambientOcc(): NodeMaterialConnectionPoint;
  145635. /**
  145636. * Gets the main code of the block (fragment side)
  145637. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  145638. * @returns the shader code
  145639. */
  145640. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  145641. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145642. protected _buildBlock(state: NodeMaterialBuildState): this;
  145643. protected _dumpPropertiesCode(): string;
  145644. serialize(): any;
  145645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145646. }
  145647. }
  145648. declare module BABYLON {
  145649. /**
  145650. * Block used to implement the reflection module of the PBR material
  145651. */
  145652. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  145653. /** @hidden */
  145654. _defineLODReflectionAlpha: string;
  145655. /** @hidden */
  145656. _defineLinearSpecularReflection: string;
  145657. private _vEnvironmentIrradianceName;
  145658. /** @hidden */
  145659. _vReflectionMicrosurfaceInfosName: string;
  145660. /** @hidden */
  145661. _vReflectionInfosName: string;
  145662. /** @hidden */
  145663. _vReflectionFilteringInfoName: string;
  145664. private _scene;
  145665. /**
  145666. * The three properties below are set by the main PBR block prior to calling methods of this class.
  145667. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145668. * It's less burden on the user side in the editor part.
  145669. */
  145670. /** @hidden */
  145671. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145672. /** @hidden */
  145673. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145674. /** @hidden */
  145675. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  145676. /**
  145677. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  145678. * diffuse part of the IBL.
  145679. */
  145680. useSphericalHarmonics: boolean;
  145681. /**
  145682. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  145683. */
  145684. forceIrradianceInFragment: boolean;
  145685. /**
  145686. * Create a new ReflectionBlock
  145687. * @param name defines the block name
  145688. */
  145689. constructor(name: string);
  145690. /**
  145691. * Gets the current class name
  145692. * @returns the class name
  145693. */
  145694. getClassName(): string;
  145695. /**
  145696. * Gets the position input component
  145697. */
  145698. get position(): NodeMaterialConnectionPoint;
  145699. /**
  145700. * Gets the world position input component
  145701. */
  145702. get worldPosition(): NodeMaterialConnectionPoint;
  145703. /**
  145704. * Gets the world normal input component
  145705. */
  145706. get worldNormal(): NodeMaterialConnectionPoint;
  145707. /**
  145708. * Gets the world input component
  145709. */
  145710. get world(): NodeMaterialConnectionPoint;
  145711. /**
  145712. * Gets the camera (or eye) position component
  145713. */
  145714. get cameraPosition(): NodeMaterialConnectionPoint;
  145715. /**
  145716. * Gets the view input component
  145717. */
  145718. get view(): NodeMaterialConnectionPoint;
  145719. /**
  145720. * Gets the color input component
  145721. */
  145722. get color(): NodeMaterialConnectionPoint;
  145723. /**
  145724. * Gets the reflection object output component
  145725. */
  145726. get reflection(): NodeMaterialConnectionPoint;
  145727. /**
  145728. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  145729. */
  145730. get hasTexture(): boolean;
  145731. /**
  145732. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  145733. */
  145734. get reflectionColor(): string;
  145735. protected _getTexture(): Nullable<BaseTexture>;
  145736. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145738. /**
  145739. * Gets the code to inject in the vertex shader
  145740. * @param state current state of the node material building
  145741. * @returns the shader code
  145742. */
  145743. handleVertexSide(state: NodeMaterialBuildState): string;
  145744. /**
  145745. * Gets the main code of the block (fragment side)
  145746. * @param state current state of the node material building
  145747. * @param normalVarName name of the existing variable corresponding to the normal
  145748. * @returns the shader code
  145749. */
  145750. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  145751. protected _buildBlock(state: NodeMaterialBuildState): this;
  145752. protected _dumpPropertiesCode(): string;
  145753. serialize(): any;
  145754. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145755. }
  145756. }
  145757. declare module BABYLON {
  145758. /**
  145759. * Block used to implement the sheen module of the PBR material
  145760. */
  145761. export class SheenBlock extends NodeMaterialBlock {
  145762. /**
  145763. * Create a new SheenBlock
  145764. * @param name defines the block name
  145765. */
  145766. constructor(name: string);
  145767. /**
  145768. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  145769. * It allows the strength of the sheen effect to not depend on the base color of the material,
  145770. * making it easier to setup and tweak the effect
  145771. */
  145772. albedoScaling: boolean;
  145773. /**
  145774. * Defines if the sheen is linked to the sheen color.
  145775. */
  145776. linkSheenWithAlbedo: boolean;
  145777. /**
  145778. * Initialize the block and prepare the context for build
  145779. * @param state defines the state that will be used for the build
  145780. */
  145781. initialize(state: NodeMaterialBuildState): void;
  145782. /**
  145783. * Gets the current class name
  145784. * @returns the class name
  145785. */
  145786. getClassName(): string;
  145787. /**
  145788. * Gets the intensity input component
  145789. */
  145790. get intensity(): NodeMaterialConnectionPoint;
  145791. /**
  145792. * Gets the color input component
  145793. */
  145794. get color(): NodeMaterialConnectionPoint;
  145795. /**
  145796. * Gets the roughness input component
  145797. */
  145798. get roughness(): NodeMaterialConnectionPoint;
  145799. /**
  145800. * Gets the sheen object output component
  145801. */
  145802. get sheen(): NodeMaterialConnectionPoint;
  145803. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145804. /**
  145805. * Gets the main code of the block (fragment side)
  145806. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145807. * @returns the shader code
  145808. */
  145809. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  145810. protected _buildBlock(state: NodeMaterialBuildState): this;
  145811. protected _dumpPropertiesCode(): string;
  145812. serialize(): any;
  145813. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145814. }
  145815. }
  145816. declare module BABYLON {
  145817. /**
  145818. * Block used to implement the reflectivity module of the PBR material
  145819. */
  145820. export class ReflectivityBlock extends NodeMaterialBlock {
  145821. private _metallicReflectanceColor;
  145822. private _metallicF0Factor;
  145823. /** @hidden */
  145824. _vMetallicReflectanceFactorsName: string;
  145825. /**
  145826. * The property below is set by the main PBR block prior to calling methods of this class.
  145827. */
  145828. /** @hidden */
  145829. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  145830. /**
  145831. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  145832. */
  145833. useAmbientOcclusionFromMetallicTextureRed: boolean;
  145834. /**
  145835. * Specifies if the metallic texture contains the metallness information in its blue channel.
  145836. */
  145837. useMetallnessFromMetallicTextureBlue: boolean;
  145838. /**
  145839. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  145840. */
  145841. useRoughnessFromMetallicTextureAlpha: boolean;
  145842. /**
  145843. * Specifies if the metallic texture contains the roughness information in its green channel.
  145844. */
  145845. useRoughnessFromMetallicTextureGreen: boolean;
  145846. /**
  145847. * Create a new ReflectivityBlock
  145848. * @param name defines the block name
  145849. */
  145850. constructor(name: string);
  145851. /**
  145852. * Initialize the block and prepare the context for build
  145853. * @param state defines the state that will be used for the build
  145854. */
  145855. initialize(state: NodeMaterialBuildState): void;
  145856. /**
  145857. * Gets the current class name
  145858. * @returns the class name
  145859. */
  145860. getClassName(): string;
  145861. /**
  145862. * Gets the metallic input component
  145863. */
  145864. get metallic(): NodeMaterialConnectionPoint;
  145865. /**
  145866. * Gets the roughness input component
  145867. */
  145868. get roughness(): NodeMaterialConnectionPoint;
  145869. /**
  145870. * Gets the texture input component
  145871. */
  145872. get texture(): NodeMaterialConnectionPoint;
  145873. /**
  145874. * Gets the reflectivity object output component
  145875. */
  145876. get reflectivity(): NodeMaterialConnectionPoint;
  145877. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145878. /**
  145879. * Gets the main code of the block (fragment side)
  145880. * @param state current state of the node material building
  145881. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  145882. * @returns the shader code
  145883. */
  145884. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  145885. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145886. protected _buildBlock(state: NodeMaterialBuildState): this;
  145887. protected _dumpPropertiesCode(): string;
  145888. serialize(): any;
  145889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145890. }
  145891. }
  145892. declare module BABYLON {
  145893. /**
  145894. * Block used to implement the anisotropy module of the PBR material
  145895. */
  145896. export class AnisotropyBlock extends NodeMaterialBlock {
  145897. /**
  145898. * The two properties below are set by the main PBR block prior to calling methods of this class.
  145899. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145900. * It's less burden on the user side in the editor part.
  145901. */
  145902. /** @hidden */
  145903. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145904. /** @hidden */
  145905. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145906. /**
  145907. * Create a new AnisotropyBlock
  145908. * @param name defines the block name
  145909. */
  145910. constructor(name: string);
  145911. /**
  145912. * Initialize the block and prepare the context for build
  145913. * @param state defines the state that will be used for the build
  145914. */
  145915. initialize(state: NodeMaterialBuildState): void;
  145916. /**
  145917. * Gets the current class name
  145918. * @returns the class name
  145919. */
  145920. getClassName(): string;
  145921. /**
  145922. * Gets the intensity input component
  145923. */
  145924. get intensity(): NodeMaterialConnectionPoint;
  145925. /**
  145926. * Gets the direction input component
  145927. */
  145928. get direction(): NodeMaterialConnectionPoint;
  145929. /**
  145930. * Gets the texture input component
  145931. */
  145932. get texture(): NodeMaterialConnectionPoint;
  145933. /**
  145934. * Gets the uv input component
  145935. */
  145936. get uv(): NodeMaterialConnectionPoint;
  145937. /**
  145938. * Gets the worldTangent input component
  145939. */
  145940. get worldTangent(): NodeMaterialConnectionPoint;
  145941. /**
  145942. * Gets the anisotropy object output component
  145943. */
  145944. get anisotropy(): NodeMaterialConnectionPoint;
  145945. private _generateTBNSpace;
  145946. /**
  145947. * Gets the main code of the block (fragment side)
  145948. * @param state current state of the node material building
  145949. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145950. * @returns the shader code
  145951. */
  145952. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145953. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145954. protected _buildBlock(state: NodeMaterialBuildState): this;
  145955. }
  145956. }
  145957. declare module BABYLON {
  145958. /**
  145959. * Block used to implement the clear coat module of the PBR material
  145960. */
  145961. export class ClearCoatBlock extends NodeMaterialBlock {
  145962. private _scene;
  145963. /**
  145964. * Create a new ClearCoatBlock
  145965. * @param name defines the block name
  145966. */
  145967. constructor(name: string);
  145968. /**
  145969. * Initialize the block and prepare the context for build
  145970. * @param state defines the state that will be used for the build
  145971. */
  145972. initialize(state: NodeMaterialBuildState): void;
  145973. /**
  145974. * Gets the current class name
  145975. * @returns the class name
  145976. */
  145977. getClassName(): string;
  145978. /**
  145979. * Gets the intensity input component
  145980. */
  145981. get intensity(): NodeMaterialConnectionPoint;
  145982. /**
  145983. * Gets the roughness input component
  145984. */
  145985. get roughness(): NodeMaterialConnectionPoint;
  145986. /**
  145987. * Gets the ior input component
  145988. */
  145989. get ior(): NodeMaterialConnectionPoint;
  145990. /**
  145991. * Gets the texture input component
  145992. */
  145993. get texture(): NodeMaterialConnectionPoint;
  145994. /**
  145995. * Gets the bump texture input component
  145996. */
  145997. get bumpTexture(): NodeMaterialConnectionPoint;
  145998. /**
  145999. * Gets the uv input component
  146000. */
  146001. get uv(): NodeMaterialConnectionPoint;
  146002. /**
  146003. * Gets the tint color input component
  146004. */
  146005. get tintColor(): NodeMaterialConnectionPoint;
  146006. /**
  146007. * Gets the tint "at distance" input component
  146008. */
  146009. get tintAtDistance(): NodeMaterialConnectionPoint;
  146010. /**
  146011. * Gets the tint thickness input component
  146012. */
  146013. get tintThickness(): NodeMaterialConnectionPoint;
  146014. /**
  146015. * Gets the world tangent input component
  146016. */
  146017. get worldTangent(): NodeMaterialConnectionPoint;
  146018. /**
  146019. * Gets the clear coat object output component
  146020. */
  146021. get clearcoat(): NodeMaterialConnectionPoint;
  146022. autoConfigure(material: NodeMaterial): void;
  146023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146024. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146025. private _generateTBNSpace;
  146026. /**
  146027. * Gets the main code of the block (fragment side)
  146028. * @param state current state of the node material building
  146029. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  146030. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146031. * @param worldPosVarName name of the variable holding the world position
  146032. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146033. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  146034. * @param worldNormalVarName name of the variable holding the world normal
  146035. * @returns the shader code
  146036. */
  146037. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  146038. protected _buildBlock(state: NodeMaterialBuildState): this;
  146039. }
  146040. }
  146041. declare module BABYLON {
  146042. /**
  146043. * Block used to implement the sub surface module of the PBR material
  146044. */
  146045. export class SubSurfaceBlock extends NodeMaterialBlock {
  146046. /**
  146047. * Create a new SubSurfaceBlock
  146048. * @param name defines the block name
  146049. */
  146050. constructor(name: string);
  146051. /**
  146052. * Stores the intensity of the different subsurface effects in the thickness texture.
  146053. * * the green channel is the translucency intensity.
  146054. * * the blue channel is the scattering intensity.
  146055. * * the alpha channel is the refraction intensity.
  146056. */
  146057. useMaskFromThicknessTexture: boolean;
  146058. /**
  146059. * Initialize the block and prepare the context for build
  146060. * @param state defines the state that will be used for the build
  146061. */
  146062. initialize(state: NodeMaterialBuildState): void;
  146063. /**
  146064. * Gets the current class name
  146065. * @returns the class name
  146066. */
  146067. getClassName(): string;
  146068. /**
  146069. * Gets the min thickness input component
  146070. */
  146071. get minThickness(): NodeMaterialConnectionPoint;
  146072. /**
  146073. * Gets the max thickness input component
  146074. */
  146075. get maxThickness(): NodeMaterialConnectionPoint;
  146076. /**
  146077. * Gets the thickness texture component
  146078. */
  146079. get thicknessTexture(): NodeMaterialConnectionPoint;
  146080. /**
  146081. * Gets the tint color input component
  146082. */
  146083. get tintColor(): NodeMaterialConnectionPoint;
  146084. /**
  146085. * Gets the translucency intensity input component
  146086. */
  146087. get translucencyIntensity(): NodeMaterialConnectionPoint;
  146088. /**
  146089. * Gets the translucency diffusion distance input component
  146090. */
  146091. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  146092. /**
  146093. * Gets the refraction object parameters
  146094. */
  146095. get refraction(): NodeMaterialConnectionPoint;
  146096. /**
  146097. * Gets the sub surface object output component
  146098. */
  146099. get subsurface(): NodeMaterialConnectionPoint;
  146100. autoConfigure(material: NodeMaterial): void;
  146101. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146102. /**
  146103. * Gets the main code of the block (fragment side)
  146104. * @param state current state of the node material building
  146105. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  146106. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146107. * @param worldPosVarName name of the variable holding the world position
  146108. * @returns the shader code
  146109. */
  146110. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  146111. protected _buildBlock(state: NodeMaterialBuildState): this;
  146112. }
  146113. }
  146114. declare module BABYLON {
  146115. /**
  146116. * Block used to implement the PBR metallic/roughness model
  146117. */
  146118. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  146119. /**
  146120. * Gets or sets the light associated with this block
  146121. */
  146122. light: Nullable<Light>;
  146123. private _lightId;
  146124. private _scene;
  146125. private _environmentBRDFTexture;
  146126. private _environmentBrdfSamplerName;
  146127. private _vNormalWName;
  146128. private _invertNormalName;
  146129. /**
  146130. * Create a new ReflectionBlock
  146131. * @param name defines the block name
  146132. */
  146133. constructor(name: string);
  146134. /**
  146135. * Intensity of the direct lights e.g. the four lights available in your scene.
  146136. * This impacts both the direct diffuse and specular highlights.
  146137. */
  146138. directIntensity: number;
  146139. /**
  146140. * Intensity of the environment e.g. how much the environment will light the object
  146141. * either through harmonics for rough material or through the refelction for shiny ones.
  146142. */
  146143. environmentIntensity: number;
  146144. /**
  146145. * This is a special control allowing the reduction of the specular highlights coming from the
  146146. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  146147. */
  146148. specularIntensity: number;
  146149. /**
  146150. * Defines the falloff type used in this material.
  146151. * It by default is Physical.
  146152. */
  146153. lightFalloff: number;
  146154. /**
  146155. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  146156. */
  146157. useAlphaFromAlbedoTexture: boolean;
  146158. /**
  146159. * Specifies that alpha test should be used
  146160. */
  146161. useAlphaTest: boolean;
  146162. /**
  146163. * Defines the alpha limits in alpha test mode.
  146164. */
  146165. alphaTestCutoff: number;
  146166. /**
  146167. * Specifies that alpha blending should be used
  146168. */
  146169. useAlphaBlending: boolean;
  146170. /**
  146171. * Defines if the alpha value should be determined via the rgb values.
  146172. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  146173. */
  146174. opacityRGB: boolean;
  146175. /**
  146176. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  146177. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  146178. */
  146179. useRadianceOverAlpha: boolean;
  146180. /**
  146181. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  146182. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  146183. */
  146184. useSpecularOverAlpha: boolean;
  146185. /**
  146186. * Enables specular anti aliasing in the PBR shader.
  146187. * It will both interacts on the Geometry for analytical and IBL lighting.
  146188. * It also prefilter the roughness map based on the bump values.
  146189. */
  146190. enableSpecularAntiAliasing: boolean;
  146191. /**
  146192. * Enables realtime filtering on the texture.
  146193. */
  146194. realTimeFiltering: boolean;
  146195. /**
  146196. * Quality switch for realtime filtering
  146197. */
  146198. realTimeFilteringQuality: number;
  146199. /**
  146200. * Defines if the material uses energy conservation.
  146201. */
  146202. useEnergyConservation: boolean;
  146203. /**
  146204. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  146205. * too much the area relying on ambient texture to define their ambient occlusion.
  146206. */
  146207. useRadianceOcclusion: boolean;
  146208. /**
  146209. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  146210. * makes the reflect vector face the model (under horizon).
  146211. */
  146212. useHorizonOcclusion: boolean;
  146213. /**
  146214. * If set to true, no lighting calculations will be applied.
  146215. */
  146216. unlit: boolean;
  146217. /**
  146218. * Force normal to face away from face.
  146219. */
  146220. forceNormalForward: boolean;
  146221. /**
  146222. * Defines the material debug mode.
  146223. * It helps seeing only some components of the material while troubleshooting.
  146224. */
  146225. debugMode: number;
  146226. /**
  146227. * Specify from where on screen the debug mode should start.
  146228. * The value goes from -1 (full screen) to 1 (not visible)
  146229. * It helps with side by side comparison against the final render
  146230. * This defaults to 0
  146231. */
  146232. debugLimit: number;
  146233. /**
  146234. * As the default viewing range might not be enough (if the ambient is really small for instance)
  146235. * You can use the factor to better multiply the final value.
  146236. */
  146237. debugFactor: number;
  146238. /**
  146239. * Initialize the block and prepare the context for build
  146240. * @param state defines the state that will be used for the build
  146241. */
  146242. initialize(state: NodeMaterialBuildState): void;
  146243. /**
  146244. * Gets the current class name
  146245. * @returns the class name
  146246. */
  146247. getClassName(): string;
  146248. /**
  146249. * Gets the world position input component
  146250. */
  146251. get worldPosition(): NodeMaterialConnectionPoint;
  146252. /**
  146253. * Gets the world normal input component
  146254. */
  146255. get worldNormal(): NodeMaterialConnectionPoint;
  146256. /**
  146257. * Gets the perturbed normal input component
  146258. */
  146259. get perturbedNormal(): NodeMaterialConnectionPoint;
  146260. /**
  146261. * Gets the camera position input component
  146262. */
  146263. get cameraPosition(): NodeMaterialConnectionPoint;
  146264. /**
  146265. * Gets the base color input component
  146266. */
  146267. get baseColor(): NodeMaterialConnectionPoint;
  146268. /**
  146269. * Gets the opacity texture input component
  146270. */
  146271. get opacityTexture(): NodeMaterialConnectionPoint;
  146272. /**
  146273. * Gets the ambient color input component
  146274. */
  146275. get ambientColor(): NodeMaterialConnectionPoint;
  146276. /**
  146277. * Gets the reflectivity object parameters
  146278. */
  146279. get reflectivity(): NodeMaterialConnectionPoint;
  146280. /**
  146281. * Gets the ambient occlusion object parameters
  146282. */
  146283. get ambientOcc(): NodeMaterialConnectionPoint;
  146284. /**
  146285. * Gets the reflection object parameters
  146286. */
  146287. get reflection(): NodeMaterialConnectionPoint;
  146288. /**
  146289. * Gets the sheen object parameters
  146290. */
  146291. get sheen(): NodeMaterialConnectionPoint;
  146292. /**
  146293. * Gets the clear coat object parameters
  146294. */
  146295. get clearcoat(): NodeMaterialConnectionPoint;
  146296. /**
  146297. * Gets the sub surface object parameters
  146298. */
  146299. get subsurface(): NodeMaterialConnectionPoint;
  146300. /**
  146301. * Gets the anisotropy object parameters
  146302. */
  146303. get anisotropy(): NodeMaterialConnectionPoint;
  146304. /**
  146305. * Gets the ambient output component
  146306. */
  146307. get ambient(): NodeMaterialConnectionPoint;
  146308. /**
  146309. * Gets the diffuse output component
  146310. */
  146311. get diffuse(): NodeMaterialConnectionPoint;
  146312. /**
  146313. * Gets the specular output component
  146314. */
  146315. get specular(): NodeMaterialConnectionPoint;
  146316. /**
  146317. * Gets the sheen output component
  146318. */
  146319. get sheenDir(): NodeMaterialConnectionPoint;
  146320. /**
  146321. * Gets the clear coat output component
  146322. */
  146323. get clearcoatDir(): NodeMaterialConnectionPoint;
  146324. /**
  146325. * Gets the indirect diffuse output component
  146326. */
  146327. get diffuseIndirect(): NodeMaterialConnectionPoint;
  146328. /**
  146329. * Gets the indirect specular output component
  146330. */
  146331. get specularIndirect(): NodeMaterialConnectionPoint;
  146332. /**
  146333. * Gets the indirect sheen output component
  146334. */
  146335. get sheenIndirect(): NodeMaterialConnectionPoint;
  146336. /**
  146337. * Gets the indirect clear coat output component
  146338. */
  146339. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  146340. /**
  146341. * Gets the refraction output component
  146342. */
  146343. get refraction(): NodeMaterialConnectionPoint;
  146344. /**
  146345. * Gets the global lighting output component
  146346. */
  146347. get lighting(): NodeMaterialConnectionPoint;
  146348. /**
  146349. * Gets the shadow output component
  146350. */
  146351. get shadow(): NodeMaterialConnectionPoint;
  146352. /**
  146353. * Gets the alpha output component
  146354. */
  146355. get alpha(): NodeMaterialConnectionPoint;
  146356. autoConfigure(material: NodeMaterial): void;
  146357. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146358. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  146359. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146360. private _injectVertexCode;
  146361. /**
  146362. * Gets the code corresponding to the albedo/opacity module
  146363. * @returns the shader code
  146364. */
  146365. getAlbedoOpacityCode(): string;
  146366. protected _buildBlock(state: NodeMaterialBuildState): this;
  146367. protected _dumpPropertiesCode(): string;
  146368. serialize(): any;
  146369. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146370. }
  146371. }
  146372. declare module BABYLON {
  146373. /**
  146374. * Block used to compute value of one parameter modulo another
  146375. */
  146376. export class ModBlock extends NodeMaterialBlock {
  146377. /**
  146378. * Creates a new ModBlock
  146379. * @param name defines the block name
  146380. */
  146381. constructor(name: string);
  146382. /**
  146383. * Gets the current class name
  146384. * @returns the class name
  146385. */
  146386. getClassName(): string;
  146387. /**
  146388. * Gets the left operand input component
  146389. */
  146390. get left(): NodeMaterialConnectionPoint;
  146391. /**
  146392. * Gets the right operand input component
  146393. */
  146394. get right(): NodeMaterialConnectionPoint;
  146395. /**
  146396. * Gets the output component
  146397. */
  146398. get output(): NodeMaterialConnectionPoint;
  146399. protected _buildBlock(state: NodeMaterialBuildState): this;
  146400. }
  146401. }
  146402. declare module BABYLON {
  146403. /**
  146404. * Configuration for Draco compression
  146405. */
  146406. export interface IDracoCompressionConfiguration {
  146407. /**
  146408. * Configuration for the decoder.
  146409. */
  146410. decoder: {
  146411. /**
  146412. * The url to the WebAssembly module.
  146413. */
  146414. wasmUrl?: string;
  146415. /**
  146416. * The url to the WebAssembly binary.
  146417. */
  146418. wasmBinaryUrl?: string;
  146419. /**
  146420. * The url to the fallback JavaScript module.
  146421. */
  146422. fallbackUrl?: string;
  146423. };
  146424. }
  146425. /**
  146426. * Draco compression (https://google.github.io/draco/)
  146427. *
  146428. * This class wraps the Draco module.
  146429. *
  146430. * **Encoder**
  146431. *
  146432. * The encoder is not currently implemented.
  146433. *
  146434. * **Decoder**
  146435. *
  146436. * 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.
  146437. *
  146438. * To update the configuration, use the following code:
  146439. * ```javascript
  146440. * DracoCompression.Configuration = {
  146441. * decoder: {
  146442. * wasmUrl: "<url to the WebAssembly library>",
  146443. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  146444. * fallbackUrl: "<url to the fallback JavaScript library>",
  146445. * }
  146446. * };
  146447. * ```
  146448. *
  146449. * 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.
  146450. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  146451. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  146452. *
  146453. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  146454. * ```javascript
  146455. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  146456. * ```
  146457. *
  146458. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  146459. */
  146460. export class DracoCompression implements IDisposable {
  146461. private _workerPoolPromise?;
  146462. private _decoderModulePromise?;
  146463. /**
  146464. * The configuration. Defaults to the following urls:
  146465. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  146466. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  146467. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  146468. */
  146469. static Configuration: IDracoCompressionConfiguration;
  146470. /**
  146471. * Returns true if the decoder configuration is available.
  146472. */
  146473. static get DecoderAvailable(): boolean;
  146474. /**
  146475. * Default number of workers to create when creating the draco compression object.
  146476. */
  146477. static DefaultNumWorkers: number;
  146478. private static GetDefaultNumWorkers;
  146479. private static _Default;
  146480. /**
  146481. * Default instance for the draco compression object.
  146482. */
  146483. static get Default(): DracoCompression;
  146484. /**
  146485. * Constructor
  146486. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  146487. */
  146488. constructor(numWorkers?: number);
  146489. /**
  146490. * Stop all async operations and release resources.
  146491. */
  146492. dispose(): void;
  146493. /**
  146494. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  146495. * @returns a promise that resolves when ready
  146496. */
  146497. whenReadyAsync(): Promise<void>;
  146498. /**
  146499. * Decode Draco compressed mesh data to vertex data.
  146500. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  146501. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  146502. * @returns A promise that resolves with the decoded vertex data
  146503. */
  146504. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  146505. [kind: string]: number;
  146506. }): Promise<VertexData>;
  146507. }
  146508. }
  146509. declare module BABYLON {
  146510. /**
  146511. * Class for building Constructive Solid Geometry
  146512. */
  146513. export class CSG {
  146514. private polygons;
  146515. /**
  146516. * The world matrix
  146517. */
  146518. matrix: Matrix;
  146519. /**
  146520. * Stores the position
  146521. */
  146522. position: Vector3;
  146523. /**
  146524. * Stores the rotation
  146525. */
  146526. rotation: Vector3;
  146527. /**
  146528. * Stores the rotation quaternion
  146529. */
  146530. rotationQuaternion: Nullable<Quaternion>;
  146531. /**
  146532. * Stores the scaling vector
  146533. */
  146534. scaling: Vector3;
  146535. /**
  146536. * Convert the Mesh to CSG
  146537. * @param mesh The Mesh to convert to CSG
  146538. * @returns A new CSG from the Mesh
  146539. */
  146540. static FromMesh(mesh: Mesh): CSG;
  146541. /**
  146542. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  146543. * @param polygons Polygons used to construct a CSG solid
  146544. */
  146545. private static FromPolygons;
  146546. /**
  146547. * Clones, or makes a deep copy, of the CSG
  146548. * @returns A new CSG
  146549. */
  146550. clone(): CSG;
  146551. /**
  146552. * Unions this CSG with another CSG
  146553. * @param csg The CSG to union against this CSG
  146554. * @returns The unioned CSG
  146555. */
  146556. union(csg: CSG): CSG;
  146557. /**
  146558. * Unions this CSG with another CSG in place
  146559. * @param csg The CSG to union against this CSG
  146560. */
  146561. unionInPlace(csg: CSG): void;
  146562. /**
  146563. * Subtracts this CSG with another CSG
  146564. * @param csg The CSG to subtract against this CSG
  146565. * @returns A new CSG
  146566. */
  146567. subtract(csg: CSG): CSG;
  146568. /**
  146569. * Subtracts this CSG with another CSG in place
  146570. * @param csg The CSG to subtact against this CSG
  146571. */
  146572. subtractInPlace(csg: CSG): void;
  146573. /**
  146574. * Intersect this CSG with another CSG
  146575. * @param csg The CSG to intersect against this CSG
  146576. * @returns A new CSG
  146577. */
  146578. intersect(csg: CSG): CSG;
  146579. /**
  146580. * Intersects this CSG with another CSG in place
  146581. * @param csg The CSG to intersect against this CSG
  146582. */
  146583. intersectInPlace(csg: CSG): void;
  146584. /**
  146585. * Return a new CSG solid with solid and empty space switched. This solid is
  146586. * not modified.
  146587. * @returns A new CSG solid with solid and empty space switched
  146588. */
  146589. inverse(): CSG;
  146590. /**
  146591. * Inverses the CSG in place
  146592. */
  146593. inverseInPlace(): void;
  146594. /**
  146595. * This is used to keep meshes transformations so they can be restored
  146596. * when we build back a Babylon Mesh
  146597. * NB : All CSG operations are performed in world coordinates
  146598. * @param csg The CSG to copy the transform attributes from
  146599. * @returns This CSG
  146600. */
  146601. copyTransformAttributes(csg: CSG): CSG;
  146602. /**
  146603. * Build Raw mesh from CSG
  146604. * Coordinates here are in world space
  146605. * @param name The name of the mesh geometry
  146606. * @param scene The Scene
  146607. * @param keepSubMeshes Specifies if the submeshes should be kept
  146608. * @returns A new Mesh
  146609. */
  146610. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146611. /**
  146612. * Build Mesh from CSG taking material and transforms into account
  146613. * @param name The name of the Mesh
  146614. * @param material The material of the Mesh
  146615. * @param scene The Scene
  146616. * @param keepSubMeshes Specifies if submeshes should be kept
  146617. * @returns The new Mesh
  146618. */
  146619. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146620. }
  146621. }
  146622. declare module BABYLON {
  146623. /**
  146624. * Class used to create a trail following a mesh
  146625. */
  146626. export class TrailMesh extends Mesh {
  146627. private _generator;
  146628. private _autoStart;
  146629. private _running;
  146630. private _diameter;
  146631. private _length;
  146632. private _sectionPolygonPointsCount;
  146633. private _sectionVectors;
  146634. private _sectionNormalVectors;
  146635. private _beforeRenderObserver;
  146636. /**
  146637. * @constructor
  146638. * @param name The value used by scene.getMeshByName() to do a lookup.
  146639. * @param generator The mesh or transform node to generate a trail.
  146640. * @param scene The scene to add this mesh to.
  146641. * @param diameter Diameter of trailing mesh. Default is 1.
  146642. * @param length Length of trailing mesh. Default is 60.
  146643. * @param autoStart Automatically start trailing mesh. Default true.
  146644. */
  146645. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  146646. /**
  146647. * "TrailMesh"
  146648. * @returns "TrailMesh"
  146649. */
  146650. getClassName(): string;
  146651. private _createMesh;
  146652. /**
  146653. * Start trailing mesh.
  146654. */
  146655. start(): void;
  146656. /**
  146657. * Stop trailing mesh.
  146658. */
  146659. stop(): void;
  146660. /**
  146661. * Update trailing mesh geometry.
  146662. */
  146663. update(): void;
  146664. /**
  146665. * Returns a new TrailMesh object.
  146666. * @param name is a string, the name given to the new mesh
  146667. * @param newGenerator use new generator object for cloned trail mesh
  146668. * @returns a new mesh
  146669. */
  146670. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  146671. /**
  146672. * Serializes this trail mesh
  146673. * @param serializationObject object to write serialization to
  146674. */
  146675. serialize(serializationObject: any): void;
  146676. /**
  146677. * Parses a serialized trail mesh
  146678. * @param parsedMesh the serialized mesh
  146679. * @param scene the scene to create the trail mesh in
  146680. * @returns the created trail mesh
  146681. */
  146682. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  146683. }
  146684. }
  146685. declare module BABYLON {
  146686. /**
  146687. * Class containing static functions to help procedurally build meshes
  146688. */
  146689. export class TiledBoxBuilder {
  146690. /**
  146691. * Creates a box mesh
  146692. * 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)
  146693. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146695. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146697. * @param name defines the name of the mesh
  146698. * @param options defines the options used to create the mesh
  146699. * @param scene defines the hosting scene
  146700. * @returns the box mesh
  146701. */
  146702. static CreateTiledBox(name: string, options: {
  146703. pattern?: number;
  146704. width?: number;
  146705. height?: number;
  146706. depth?: number;
  146707. tileSize?: number;
  146708. tileWidth?: number;
  146709. tileHeight?: number;
  146710. alignHorizontal?: number;
  146711. alignVertical?: number;
  146712. faceUV?: Vector4[];
  146713. faceColors?: Color4[];
  146714. sideOrientation?: number;
  146715. updatable?: boolean;
  146716. }, scene?: Nullable<Scene>): Mesh;
  146717. }
  146718. }
  146719. declare module BABYLON {
  146720. /**
  146721. * Class containing static functions to help procedurally build meshes
  146722. */
  146723. export class TorusKnotBuilder {
  146724. /**
  146725. * Creates a torus knot mesh
  146726. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146727. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146728. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146729. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  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). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  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. * @returns the torus knot mesh
  146737. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146738. */
  146739. static CreateTorusKnot(name: string, options: {
  146740. radius?: number;
  146741. tube?: number;
  146742. radialSegments?: number;
  146743. tubularSegments?: number;
  146744. p?: number;
  146745. q?: number;
  146746. updatable?: boolean;
  146747. sideOrientation?: number;
  146748. frontUVs?: Vector4;
  146749. backUVs?: Vector4;
  146750. }, scene: any): Mesh;
  146751. }
  146752. }
  146753. declare module BABYLON {
  146754. /**
  146755. * Polygon
  146756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  146757. */
  146758. export class Polygon {
  146759. /**
  146760. * Creates a rectangle
  146761. * @param xmin bottom X coord
  146762. * @param ymin bottom Y coord
  146763. * @param xmax top X coord
  146764. * @param ymax top Y coord
  146765. * @returns points that make the resulting rectation
  146766. */
  146767. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  146768. /**
  146769. * Creates a circle
  146770. * @param radius radius of circle
  146771. * @param cx scale in x
  146772. * @param cy scale in y
  146773. * @param numberOfSides number of sides that make up the circle
  146774. * @returns points that make the resulting circle
  146775. */
  146776. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  146777. /**
  146778. * Creates a polygon from input string
  146779. * @param input Input polygon data
  146780. * @returns the parsed points
  146781. */
  146782. static Parse(input: string): Vector2[];
  146783. /**
  146784. * Starts building a polygon from x and y coordinates
  146785. * @param x x coordinate
  146786. * @param y y coordinate
  146787. * @returns the started path2
  146788. */
  146789. static StartingAt(x: number, y: number): Path2;
  146790. }
  146791. /**
  146792. * Builds a polygon
  146793. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  146794. */
  146795. export class PolygonMeshBuilder {
  146796. private _points;
  146797. private _outlinepoints;
  146798. private _holes;
  146799. private _name;
  146800. private _scene;
  146801. private _epoints;
  146802. private _eholes;
  146803. private _addToepoint;
  146804. /**
  146805. * Babylon reference to the earcut plugin.
  146806. */
  146807. bjsEarcut: any;
  146808. /**
  146809. * Creates a PolygonMeshBuilder
  146810. * @param name name of the builder
  146811. * @param contours Path of the polygon
  146812. * @param scene scene to add to when creating the mesh
  146813. * @param earcutInjection can be used to inject your own earcut reference
  146814. */
  146815. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  146816. /**
  146817. * Adds a whole within the polygon
  146818. * @param hole Array of points defining the hole
  146819. * @returns this
  146820. */
  146821. addHole(hole: Vector2[]): PolygonMeshBuilder;
  146822. /**
  146823. * Creates the polygon
  146824. * @param updatable If the mesh should be updatable
  146825. * @param depth The depth of the mesh created
  146826. * @returns the created mesh
  146827. */
  146828. build(updatable?: boolean, depth?: number): Mesh;
  146829. /**
  146830. * Creates the polygon
  146831. * @param depth The depth of the mesh created
  146832. * @returns the created VertexData
  146833. */
  146834. buildVertexData(depth?: number): VertexData;
  146835. /**
  146836. * Adds a side to the polygon
  146837. * @param positions points that make the polygon
  146838. * @param normals normals of the polygon
  146839. * @param uvs uvs of the polygon
  146840. * @param indices indices of the polygon
  146841. * @param bounds bounds of the polygon
  146842. * @param points points of the polygon
  146843. * @param depth depth of the polygon
  146844. * @param flip flip of the polygon
  146845. */
  146846. private addSide;
  146847. }
  146848. }
  146849. declare module BABYLON {
  146850. /**
  146851. * Class containing static functions to help procedurally build meshes
  146852. */
  146853. export class PolygonBuilder {
  146854. /**
  146855. * Creates a polygon mesh
  146856. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146857. * * 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
  146858. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146861. * * Remember you can only change the shape positions, not their number when updating a polygon
  146862. * @param name defines the name of the mesh
  146863. * @param options defines the options used to create the mesh
  146864. * @param scene defines the hosting scene
  146865. * @param earcutInjection can be used to inject your own earcut reference
  146866. * @returns the polygon mesh
  146867. */
  146868. static CreatePolygon(name: string, options: {
  146869. shape: Vector3[];
  146870. holes?: Vector3[][];
  146871. depth?: number;
  146872. faceUV?: Vector4[];
  146873. faceColors?: Color4[];
  146874. updatable?: boolean;
  146875. sideOrientation?: number;
  146876. frontUVs?: Vector4;
  146877. backUVs?: Vector4;
  146878. wrap?: boolean;
  146879. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146880. /**
  146881. * Creates an extruded polygon mesh, with depth in the Y direction.
  146882. * * 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)
  146883. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146884. * @param name defines the name of the mesh
  146885. * @param options defines the options used to create the mesh
  146886. * @param scene defines the hosting scene
  146887. * @param earcutInjection can be used to inject your own earcut reference
  146888. * @returns the polygon mesh
  146889. */
  146890. static ExtrudePolygon(name: string, options: {
  146891. shape: Vector3[];
  146892. holes?: Vector3[][];
  146893. depth?: number;
  146894. faceUV?: Vector4[];
  146895. faceColors?: Color4[];
  146896. updatable?: boolean;
  146897. sideOrientation?: number;
  146898. frontUVs?: Vector4;
  146899. backUVs?: Vector4;
  146900. wrap?: boolean;
  146901. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146902. }
  146903. }
  146904. declare module BABYLON {
  146905. /**
  146906. * Class containing static functions to help procedurally build meshes
  146907. */
  146908. export class LatheBuilder {
  146909. /**
  146910. * Creates lathe mesh.
  146911. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146912. * * 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
  146913. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146914. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146915. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146916. * * 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
  146917. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146918. * * 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
  146919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146921. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146923. * @param name defines the name of the mesh
  146924. * @param options defines the options used to create the mesh
  146925. * @param scene defines the hosting scene
  146926. * @returns the lathe mesh
  146927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146928. */
  146929. static CreateLathe(name: string, options: {
  146930. shape: Vector3[];
  146931. radius?: number;
  146932. tessellation?: number;
  146933. clip?: number;
  146934. arc?: number;
  146935. closed?: boolean;
  146936. updatable?: boolean;
  146937. sideOrientation?: number;
  146938. frontUVs?: Vector4;
  146939. backUVs?: Vector4;
  146940. cap?: number;
  146941. invertUV?: boolean;
  146942. }, scene?: Nullable<Scene>): Mesh;
  146943. }
  146944. }
  146945. declare module BABYLON {
  146946. /**
  146947. * Class containing static functions to help procedurally build meshes
  146948. */
  146949. export class TiledPlaneBuilder {
  146950. /**
  146951. * Creates a tiled plane mesh
  146952. * * The parameter `pattern` will, depending on value, do nothing or
  146953. * * * flip (reflect about central vertical) alternate tiles across and up
  146954. * * * flip every tile on alternate rows
  146955. * * * rotate (180 degs) alternate tiles across and up
  146956. * * * rotate every tile on alternate rows
  146957. * * * flip and rotate alternate tiles across and up
  146958. * * * flip and rotate every tile on alternate rows
  146959. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146960. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146962. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146963. * * 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)
  146964. * * 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)
  146965. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146966. * @param name defines the name of the mesh
  146967. * @param options defines the options used to create the mesh
  146968. * @param scene defines the hosting scene
  146969. * @returns the box mesh
  146970. */
  146971. static CreateTiledPlane(name: string, options: {
  146972. pattern?: number;
  146973. tileSize?: number;
  146974. tileWidth?: number;
  146975. tileHeight?: number;
  146976. size?: number;
  146977. width?: number;
  146978. height?: number;
  146979. alignHorizontal?: number;
  146980. alignVertical?: number;
  146981. sideOrientation?: number;
  146982. frontUVs?: Vector4;
  146983. backUVs?: Vector4;
  146984. updatable?: boolean;
  146985. }, scene?: Nullable<Scene>): Mesh;
  146986. }
  146987. }
  146988. declare module BABYLON {
  146989. /**
  146990. * Class containing static functions to help procedurally build meshes
  146991. */
  146992. export class TubeBuilder {
  146993. /**
  146994. * Creates a tube mesh.
  146995. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146996. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146997. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146998. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146999. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147000. * * 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)
  147001. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147002. * * 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
  147003. * * 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
  147004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147008. * @param name defines the name of the mesh
  147009. * @param options defines the options used to create the mesh
  147010. * @param scene defines the hosting scene
  147011. * @returns the tube mesh
  147012. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147013. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147014. */
  147015. static CreateTube(name: string, options: {
  147016. path: Vector3[];
  147017. radius?: number;
  147018. tessellation?: number;
  147019. radiusFunction?: {
  147020. (i: number, distance: number): number;
  147021. };
  147022. cap?: number;
  147023. arc?: number;
  147024. updatable?: boolean;
  147025. sideOrientation?: number;
  147026. frontUVs?: Vector4;
  147027. backUVs?: Vector4;
  147028. instance?: Mesh;
  147029. invertUV?: boolean;
  147030. }, scene?: Nullable<Scene>): Mesh;
  147031. }
  147032. }
  147033. declare module BABYLON {
  147034. /**
  147035. * Class containing static functions to help procedurally build meshes
  147036. */
  147037. export class IcoSphereBuilder {
  147038. /**
  147039. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147040. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147041. * * 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`)
  147042. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147043. * * 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
  147044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147047. * @param name defines the name of the mesh
  147048. * @param options defines the options used to create the mesh
  147049. * @param scene defines the hosting scene
  147050. * @returns the icosahedron mesh
  147051. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147052. */
  147053. static CreateIcoSphere(name: string, options: {
  147054. radius?: number;
  147055. radiusX?: number;
  147056. radiusY?: number;
  147057. radiusZ?: number;
  147058. flat?: boolean;
  147059. subdivisions?: number;
  147060. sideOrientation?: number;
  147061. frontUVs?: Vector4;
  147062. backUVs?: Vector4;
  147063. updatable?: boolean;
  147064. }, scene?: Nullable<Scene>): Mesh;
  147065. }
  147066. }
  147067. declare module BABYLON {
  147068. /**
  147069. * Class containing static functions to help procedurally build meshes
  147070. */
  147071. export class DecalBuilder {
  147072. /**
  147073. * Creates a decal mesh.
  147074. * 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
  147075. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147076. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147077. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147078. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147079. * @param name defines the name of the mesh
  147080. * @param sourceMesh defines the mesh where the decal must be applied
  147081. * @param options defines the options used to create the mesh
  147082. * @param scene defines the hosting scene
  147083. * @returns the decal mesh
  147084. * @see https://doc.babylonjs.com/how_to/decals
  147085. */
  147086. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147087. position?: Vector3;
  147088. normal?: Vector3;
  147089. size?: Vector3;
  147090. angle?: number;
  147091. }): Mesh;
  147092. }
  147093. }
  147094. declare module BABYLON {
  147095. /**
  147096. * Class containing static functions to help procedurally build meshes
  147097. */
  147098. export class MeshBuilder {
  147099. /**
  147100. * Creates a box mesh
  147101. * * The parameter `size` sets the size (float) of each box side (default 1)
  147102. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  147103. * * 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)
  147104. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147108. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147109. * @param name defines the name of the mesh
  147110. * @param options defines the options used to create the mesh
  147111. * @param scene defines the hosting scene
  147112. * @returns the box mesh
  147113. */
  147114. static CreateBox(name: string, options: {
  147115. size?: number;
  147116. width?: number;
  147117. height?: number;
  147118. depth?: number;
  147119. faceUV?: Vector4[];
  147120. faceColors?: Color4[];
  147121. sideOrientation?: number;
  147122. frontUVs?: Vector4;
  147123. backUVs?: Vector4;
  147124. wrap?: boolean;
  147125. topBaseAt?: number;
  147126. bottomBaseAt?: number;
  147127. updatable?: boolean;
  147128. }, scene?: Nullable<Scene>): Mesh;
  147129. /**
  147130. * Creates a tiled box mesh
  147131. * * faceTiles sets the pattern, tile size and number of tiles for a face
  147132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147133. * @param name defines the name of the mesh
  147134. * @param options defines the options used to create the mesh
  147135. * @param scene defines the hosting scene
  147136. * @returns the tiled box mesh
  147137. */
  147138. static CreateTiledBox(name: string, options: {
  147139. pattern?: number;
  147140. size?: number;
  147141. width?: number;
  147142. height?: number;
  147143. depth: number;
  147144. tileSize?: number;
  147145. tileWidth?: number;
  147146. tileHeight?: number;
  147147. faceUV?: Vector4[];
  147148. faceColors?: Color4[];
  147149. alignHorizontal?: number;
  147150. alignVertical?: number;
  147151. sideOrientation?: number;
  147152. updatable?: boolean;
  147153. }, scene?: Nullable<Scene>): Mesh;
  147154. /**
  147155. * Creates a sphere mesh
  147156. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  147157. * * 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`)
  147158. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  147159. * * 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
  147160. * * 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)
  147161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147164. * @param name defines the name of the mesh
  147165. * @param options defines the options used to create the mesh
  147166. * @param scene defines the hosting scene
  147167. * @returns the sphere mesh
  147168. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  147169. */
  147170. static CreateSphere(name: string, options: {
  147171. segments?: number;
  147172. diameter?: number;
  147173. diameterX?: number;
  147174. diameterY?: number;
  147175. diameterZ?: number;
  147176. arc?: number;
  147177. slice?: number;
  147178. sideOrientation?: number;
  147179. frontUVs?: Vector4;
  147180. backUVs?: Vector4;
  147181. updatable?: boolean;
  147182. }, scene?: Nullable<Scene>): Mesh;
  147183. /**
  147184. * Creates a plane polygonal mesh. By default, this is a disc
  147185. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  147186. * * 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
  147187. * * 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
  147188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147191. * @param name defines the name of the mesh
  147192. * @param options defines the options used to create the mesh
  147193. * @param scene defines the hosting scene
  147194. * @returns the plane polygonal mesh
  147195. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  147196. */
  147197. static CreateDisc(name: string, options: {
  147198. radius?: number;
  147199. tessellation?: number;
  147200. arc?: number;
  147201. updatable?: boolean;
  147202. sideOrientation?: number;
  147203. frontUVs?: Vector4;
  147204. backUVs?: Vector4;
  147205. }, scene?: Nullable<Scene>): Mesh;
  147206. /**
  147207. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147208. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147209. * * 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`)
  147210. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147211. * * 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
  147212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147215. * @param name defines the name of the mesh
  147216. * @param options defines the options used to create the mesh
  147217. * @param scene defines the hosting scene
  147218. * @returns the icosahedron mesh
  147219. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147220. */
  147221. static CreateIcoSphere(name: string, options: {
  147222. radius?: number;
  147223. radiusX?: number;
  147224. radiusY?: number;
  147225. radiusZ?: number;
  147226. flat?: boolean;
  147227. subdivisions?: number;
  147228. sideOrientation?: number;
  147229. frontUVs?: Vector4;
  147230. backUVs?: Vector4;
  147231. updatable?: boolean;
  147232. }, scene?: Nullable<Scene>): Mesh;
  147233. /**
  147234. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147235. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  147236. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  147237. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  147238. * * 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
  147239. * * 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
  147240. * * 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
  147241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147243. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147244. * * 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
  147245. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  147246. * * 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
  147247. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  147248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147249. * @param name defines the name of the mesh
  147250. * @param options defines the options used to create the mesh
  147251. * @param scene defines the hosting scene
  147252. * @returns the ribbon mesh
  147253. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  147254. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147255. */
  147256. static CreateRibbon(name: string, options: {
  147257. pathArray: Vector3[][];
  147258. closeArray?: boolean;
  147259. closePath?: boolean;
  147260. offset?: number;
  147261. updatable?: boolean;
  147262. sideOrientation?: number;
  147263. frontUVs?: Vector4;
  147264. backUVs?: Vector4;
  147265. instance?: Mesh;
  147266. invertUV?: boolean;
  147267. uvs?: Vector2[];
  147268. colors?: Color4[];
  147269. }, scene?: Nullable<Scene>): Mesh;
  147270. /**
  147271. * Creates a cylinder or a cone mesh
  147272. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  147273. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  147274. * * 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.
  147275. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  147276. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  147277. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  147278. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  147279. * * 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).
  147280. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  147281. * * 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).
  147282. * * 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
  147283. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  147284. * * 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
  147285. * * 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.
  147286. * * If `enclose` is false, a ring surface is one element.
  147287. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  147288. * * 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
  147289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147292. * @param name defines the name of the mesh
  147293. * @param options defines the options used to create the mesh
  147294. * @param scene defines the hosting scene
  147295. * @returns the cylinder mesh
  147296. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  147297. */
  147298. static CreateCylinder(name: string, options: {
  147299. height?: number;
  147300. diameterTop?: number;
  147301. diameterBottom?: number;
  147302. diameter?: number;
  147303. tessellation?: number;
  147304. subdivisions?: number;
  147305. arc?: number;
  147306. faceColors?: Color4[];
  147307. faceUV?: Vector4[];
  147308. updatable?: boolean;
  147309. hasRings?: boolean;
  147310. enclose?: boolean;
  147311. cap?: number;
  147312. sideOrientation?: number;
  147313. frontUVs?: Vector4;
  147314. backUVs?: Vector4;
  147315. }, scene?: Nullable<Scene>): Mesh;
  147316. /**
  147317. * Creates a torus mesh
  147318. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  147319. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  147320. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  147321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147324. * @param name defines the name of the mesh
  147325. * @param options defines the options used to create the mesh
  147326. * @param scene defines the hosting scene
  147327. * @returns the torus mesh
  147328. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  147329. */
  147330. static CreateTorus(name: string, options: {
  147331. diameter?: number;
  147332. thickness?: number;
  147333. tessellation?: number;
  147334. updatable?: boolean;
  147335. sideOrientation?: number;
  147336. frontUVs?: Vector4;
  147337. backUVs?: Vector4;
  147338. }, scene?: Nullable<Scene>): Mesh;
  147339. /**
  147340. * Creates a torus knot mesh
  147341. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147342. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147343. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147344. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147348. * @param name defines the name of the mesh
  147349. * @param options defines the options used to create the mesh
  147350. * @param scene defines the hosting scene
  147351. * @returns the torus knot mesh
  147352. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147353. */
  147354. static CreateTorusKnot(name: string, options: {
  147355. radius?: number;
  147356. tube?: number;
  147357. radialSegments?: number;
  147358. tubularSegments?: number;
  147359. p?: number;
  147360. q?: number;
  147361. updatable?: boolean;
  147362. sideOrientation?: number;
  147363. frontUVs?: Vector4;
  147364. backUVs?: Vector4;
  147365. }, scene?: Nullable<Scene>): Mesh;
  147366. /**
  147367. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  147368. * * 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
  147369. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  147370. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  147371. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  147372. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  147373. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  147374. * * 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
  147375. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  147376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147377. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  147378. * @param name defines the name of the new line system
  147379. * @param options defines the options used to create the line system
  147380. * @param scene defines the hosting scene
  147381. * @returns a new line system mesh
  147382. */
  147383. static CreateLineSystem(name: string, options: {
  147384. lines: Vector3[][];
  147385. updatable?: boolean;
  147386. instance?: Nullable<LinesMesh>;
  147387. colors?: Nullable<Color4[][]>;
  147388. useVertexAlpha?: boolean;
  147389. }, scene: Nullable<Scene>): LinesMesh;
  147390. /**
  147391. * Creates a line mesh
  147392. * 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
  147393. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147394. * * The parameter `points` is an array successive Vector3
  147395. * * 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
  147396. * * The optional parameter `colors` is an array of successive Color4, one per line point
  147397. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  147398. * * When updating an instance, remember that only point positions can change, not the number of points
  147399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  147401. * @param name defines the name of the new line system
  147402. * @param options defines the options used to create the line system
  147403. * @param scene defines the hosting scene
  147404. * @returns a new line mesh
  147405. */
  147406. static CreateLines(name: string, options: {
  147407. points: Vector3[];
  147408. updatable?: boolean;
  147409. instance?: Nullable<LinesMesh>;
  147410. colors?: Color4[];
  147411. useVertexAlpha?: boolean;
  147412. }, scene?: Nullable<Scene>): LinesMesh;
  147413. /**
  147414. * Creates a dashed line mesh
  147415. * * 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
  147416. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  147417. * * The parameter `points` is an array successive Vector3
  147418. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  147419. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  147420. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  147421. * * 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
  147422. * * When updating an instance, remember that only point positions can change, not the number of points
  147423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147424. * @param name defines the name of the mesh
  147425. * @param options defines the options used to create the mesh
  147426. * @param scene defines the hosting scene
  147427. * @returns the dashed line mesh
  147428. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  147429. */
  147430. static CreateDashedLines(name: string, options: {
  147431. points: Vector3[];
  147432. dashSize?: number;
  147433. gapSize?: number;
  147434. dashNb?: number;
  147435. updatable?: boolean;
  147436. instance?: LinesMesh;
  147437. }, scene?: Nullable<Scene>): LinesMesh;
  147438. /**
  147439. * 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.
  147440. * * 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.
  147441. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147442. * * 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.
  147443. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  147444. * * 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
  147445. * * 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
  147446. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  147447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147449. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  147450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147451. * @param name defines the name of the mesh
  147452. * @param options defines the options used to create the mesh
  147453. * @param scene defines the hosting scene
  147454. * @returns the extruded shape mesh
  147455. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147457. */
  147458. static ExtrudeShape(name: string, options: {
  147459. shape: Vector3[];
  147460. path: Vector3[];
  147461. scale?: number;
  147462. rotation?: number;
  147463. cap?: number;
  147464. updatable?: boolean;
  147465. sideOrientation?: number;
  147466. frontUVs?: Vector4;
  147467. backUVs?: Vector4;
  147468. instance?: Mesh;
  147469. invertUV?: boolean;
  147470. }, scene?: Nullable<Scene>): Mesh;
  147471. /**
  147472. * Creates an custom extruded shape mesh.
  147473. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  147474. * * 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.
  147475. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  147476. * * 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
  147477. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  147478. * * 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
  147479. * * It must returns a float value that will be the scale value applied to the shape on each path point
  147480. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  147481. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  147482. * * 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
  147483. * * 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
  147484. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  147485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147487. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147489. * @param name defines the name of the mesh
  147490. * @param options defines the options used to create the mesh
  147491. * @param scene defines the hosting scene
  147492. * @returns the custom extruded shape mesh
  147493. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  147494. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  147496. */
  147497. static ExtrudeShapeCustom(name: string, options: {
  147498. shape: Vector3[];
  147499. path: Vector3[];
  147500. scaleFunction?: any;
  147501. rotationFunction?: any;
  147502. ribbonCloseArray?: boolean;
  147503. ribbonClosePath?: boolean;
  147504. cap?: number;
  147505. updatable?: boolean;
  147506. sideOrientation?: number;
  147507. frontUVs?: Vector4;
  147508. backUVs?: Vector4;
  147509. instance?: Mesh;
  147510. invertUV?: boolean;
  147511. }, scene?: Nullable<Scene>): Mesh;
  147512. /**
  147513. * Creates lathe mesh.
  147514. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147515. * * 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
  147516. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147517. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147518. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147519. * * 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
  147520. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147521. * * 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
  147522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147524. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147526. * @param name defines the name of the mesh
  147527. * @param options defines the options used to create the mesh
  147528. * @param scene defines the hosting scene
  147529. * @returns the lathe mesh
  147530. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147531. */
  147532. static CreateLathe(name: string, options: {
  147533. shape: Vector3[];
  147534. radius?: number;
  147535. tessellation?: number;
  147536. clip?: number;
  147537. arc?: number;
  147538. closed?: boolean;
  147539. updatable?: boolean;
  147540. sideOrientation?: number;
  147541. frontUVs?: Vector4;
  147542. backUVs?: Vector4;
  147543. cap?: number;
  147544. invertUV?: boolean;
  147545. }, scene?: Nullable<Scene>): Mesh;
  147546. /**
  147547. * Creates a tiled plane mesh
  147548. * * You can set a limited pattern arrangement with the tiles
  147549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147552. * @param name defines the name of the mesh
  147553. * @param options defines the options used to create the mesh
  147554. * @param scene defines the hosting scene
  147555. * @returns the plane mesh
  147556. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147557. */
  147558. static CreateTiledPlane(name: string, options: {
  147559. pattern?: number;
  147560. tileSize?: number;
  147561. tileWidth?: number;
  147562. tileHeight?: number;
  147563. size?: number;
  147564. width?: number;
  147565. height?: number;
  147566. alignHorizontal?: number;
  147567. alignVertical?: number;
  147568. sideOrientation?: number;
  147569. frontUVs?: Vector4;
  147570. backUVs?: Vector4;
  147571. updatable?: boolean;
  147572. }, scene?: Nullable<Scene>): Mesh;
  147573. /**
  147574. * Creates a plane mesh
  147575. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  147576. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  147577. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  147578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147581. * @param name defines the name of the mesh
  147582. * @param options defines the options used to create the mesh
  147583. * @param scene defines the hosting scene
  147584. * @returns the plane mesh
  147585. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147586. */
  147587. static CreatePlane(name: string, options: {
  147588. size?: number;
  147589. width?: number;
  147590. height?: number;
  147591. sideOrientation?: number;
  147592. frontUVs?: Vector4;
  147593. backUVs?: Vector4;
  147594. updatable?: boolean;
  147595. sourcePlane?: Plane;
  147596. }, scene?: Nullable<Scene>): Mesh;
  147597. /**
  147598. * Creates a ground mesh
  147599. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  147600. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  147601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147602. * @param name defines the name of the mesh
  147603. * @param options defines the options used to create the mesh
  147604. * @param scene defines the hosting scene
  147605. * @returns the ground mesh
  147606. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  147607. */
  147608. static CreateGround(name: string, options: {
  147609. width?: number;
  147610. height?: number;
  147611. subdivisions?: number;
  147612. subdivisionsX?: number;
  147613. subdivisionsY?: number;
  147614. updatable?: boolean;
  147615. }, scene?: Nullable<Scene>): Mesh;
  147616. /**
  147617. * Creates a tiled ground mesh
  147618. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  147619. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  147620. * * 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
  147621. * * 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
  147622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147623. * @param name defines the name of the mesh
  147624. * @param options defines the options used to create the mesh
  147625. * @param scene defines the hosting scene
  147626. * @returns the tiled ground mesh
  147627. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  147628. */
  147629. static CreateTiledGround(name: string, options: {
  147630. xmin: number;
  147631. zmin: number;
  147632. xmax: number;
  147633. zmax: number;
  147634. subdivisions?: {
  147635. w: number;
  147636. h: number;
  147637. };
  147638. precision?: {
  147639. w: number;
  147640. h: number;
  147641. };
  147642. updatable?: boolean;
  147643. }, scene?: Nullable<Scene>): Mesh;
  147644. /**
  147645. * Creates a ground mesh from a height map
  147646. * * The parameter `url` sets the URL of the height map image resource.
  147647. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  147648. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  147649. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  147650. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  147651. * * 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.
  147652. * * 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).
  147653. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  147654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147655. * @param name defines the name of the mesh
  147656. * @param url defines the url to the height map
  147657. * @param options defines the options used to create the mesh
  147658. * @param scene defines the hosting scene
  147659. * @returns the ground mesh
  147660. * @see https://doc.babylonjs.com/babylon101/height_map
  147661. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  147662. */
  147663. static CreateGroundFromHeightMap(name: string, url: string, options: {
  147664. width?: number;
  147665. height?: number;
  147666. subdivisions?: number;
  147667. minHeight?: number;
  147668. maxHeight?: number;
  147669. colorFilter?: Color3;
  147670. alphaFilter?: number;
  147671. updatable?: boolean;
  147672. onReady?: (mesh: GroundMesh) => void;
  147673. }, scene?: Nullable<Scene>): GroundMesh;
  147674. /**
  147675. * Creates a polygon mesh
  147676. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147677. * * 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
  147678. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147681. * * Remember you can only change the shape positions, not their number when updating a polygon
  147682. * @param name defines the name of the mesh
  147683. * @param options defines the options used to create the mesh
  147684. * @param scene defines the hosting scene
  147685. * @param earcutInjection can be used to inject your own earcut reference
  147686. * @returns the polygon mesh
  147687. */
  147688. static CreatePolygon(name: string, options: {
  147689. shape: Vector3[];
  147690. holes?: Vector3[][];
  147691. depth?: number;
  147692. faceUV?: Vector4[];
  147693. faceColors?: Color4[];
  147694. updatable?: boolean;
  147695. sideOrientation?: number;
  147696. frontUVs?: Vector4;
  147697. backUVs?: Vector4;
  147698. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147699. /**
  147700. * Creates an extruded polygon mesh, with depth in the Y direction.
  147701. * * 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)
  147702. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147703. * @param name defines the name of the mesh
  147704. * @param options defines the options used to create the mesh
  147705. * @param scene defines the hosting scene
  147706. * @param earcutInjection can be used to inject your own earcut reference
  147707. * @returns the polygon mesh
  147708. */
  147709. static ExtrudePolygon(name: string, options: {
  147710. shape: Vector3[];
  147711. holes?: Vector3[][];
  147712. depth?: number;
  147713. faceUV?: Vector4[];
  147714. faceColors?: Color4[];
  147715. updatable?: boolean;
  147716. sideOrientation?: number;
  147717. frontUVs?: Vector4;
  147718. backUVs?: Vector4;
  147719. wrap?: boolean;
  147720. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147721. /**
  147722. * Creates a tube mesh.
  147723. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147724. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147725. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147726. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147727. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147728. * * 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)
  147729. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147730. * * 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
  147731. * * 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
  147732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147734. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147736. * @param name defines the name of the mesh
  147737. * @param options defines the options used to create the mesh
  147738. * @param scene defines the hosting scene
  147739. * @returns the tube mesh
  147740. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147741. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147742. */
  147743. static CreateTube(name: string, options: {
  147744. path: Vector3[];
  147745. radius?: number;
  147746. tessellation?: number;
  147747. radiusFunction?: {
  147748. (i: number, distance: number): number;
  147749. };
  147750. cap?: number;
  147751. arc?: number;
  147752. updatable?: boolean;
  147753. sideOrientation?: number;
  147754. frontUVs?: Vector4;
  147755. backUVs?: Vector4;
  147756. instance?: Mesh;
  147757. invertUV?: boolean;
  147758. }, scene?: Nullable<Scene>): Mesh;
  147759. /**
  147760. * Creates a polyhedron mesh
  147761. * * 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
  147762. * * The parameter `size` (positive float, default 1) sets the polygon size
  147763. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  147764. * * 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`
  147765. * * 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
  147766. * * 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)`)
  147767. * * 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
  147768. * * 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
  147769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147772. * @param name defines the name of the mesh
  147773. * @param options defines the options used to create the mesh
  147774. * @param scene defines the hosting scene
  147775. * @returns the polyhedron mesh
  147776. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  147777. */
  147778. static CreatePolyhedron(name: string, options: {
  147779. type?: number;
  147780. size?: number;
  147781. sizeX?: number;
  147782. sizeY?: number;
  147783. sizeZ?: number;
  147784. custom?: any;
  147785. faceUV?: Vector4[];
  147786. faceColors?: Color4[];
  147787. flat?: boolean;
  147788. updatable?: boolean;
  147789. sideOrientation?: number;
  147790. frontUVs?: Vector4;
  147791. backUVs?: Vector4;
  147792. }, scene?: Nullable<Scene>): Mesh;
  147793. /**
  147794. * Creates a decal mesh.
  147795. * 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
  147796. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147797. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147798. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147799. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147800. * @param name defines the name of the mesh
  147801. * @param sourceMesh defines the mesh where the decal must be applied
  147802. * @param options defines the options used to create the mesh
  147803. * @param scene defines the hosting scene
  147804. * @returns the decal mesh
  147805. * @see https://doc.babylonjs.com/how_to/decals
  147806. */
  147807. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147808. position?: Vector3;
  147809. normal?: Vector3;
  147810. size?: Vector3;
  147811. angle?: number;
  147812. }): Mesh;
  147813. /**
  147814. * Creates a Capsule Mesh
  147815. * @param name defines the name of the mesh.
  147816. * @param options the constructors options used to shape the mesh.
  147817. * @param scene defines the scene the mesh is scoped to.
  147818. * @returns the capsule mesh
  147819. * @see https://doc.babylonjs.com/how_to/capsule_shape
  147820. */
  147821. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  147822. }
  147823. }
  147824. declare module BABYLON {
  147825. /**
  147826. * A simplifier interface for future simplification implementations
  147827. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147828. */
  147829. export interface ISimplifier {
  147830. /**
  147831. * Simplification of a given mesh according to the given settings.
  147832. * Since this requires computation, it is assumed that the function runs async.
  147833. * @param settings The settings of the simplification, including quality and distance
  147834. * @param successCallback A callback that will be called after the mesh was simplified.
  147835. * @param errorCallback in case of an error, this callback will be called. optional.
  147836. */
  147837. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  147838. }
  147839. /**
  147840. * Expected simplification settings.
  147841. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  147842. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147843. */
  147844. export interface ISimplificationSettings {
  147845. /**
  147846. * Gets or sets the expected quality
  147847. */
  147848. quality: number;
  147849. /**
  147850. * Gets or sets the distance when this optimized version should be used
  147851. */
  147852. distance: number;
  147853. /**
  147854. * Gets an already optimized mesh
  147855. */
  147856. optimizeMesh?: boolean;
  147857. }
  147858. /**
  147859. * Class used to specify simplification options
  147860. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147861. */
  147862. export class SimplificationSettings implements ISimplificationSettings {
  147863. /** expected quality */
  147864. quality: number;
  147865. /** distance when this optimized version should be used */
  147866. distance: number;
  147867. /** already optimized mesh */
  147868. optimizeMesh?: boolean | undefined;
  147869. /**
  147870. * Creates a SimplificationSettings
  147871. * @param quality expected quality
  147872. * @param distance distance when this optimized version should be used
  147873. * @param optimizeMesh already optimized mesh
  147874. */
  147875. constructor(
  147876. /** expected quality */
  147877. quality: number,
  147878. /** distance when this optimized version should be used */
  147879. distance: number,
  147880. /** already optimized mesh */
  147881. optimizeMesh?: boolean | undefined);
  147882. }
  147883. /**
  147884. * Interface used to define a simplification task
  147885. */
  147886. export interface ISimplificationTask {
  147887. /**
  147888. * Array of settings
  147889. */
  147890. settings: Array<ISimplificationSettings>;
  147891. /**
  147892. * Simplification type
  147893. */
  147894. simplificationType: SimplificationType;
  147895. /**
  147896. * Mesh to simplify
  147897. */
  147898. mesh: Mesh;
  147899. /**
  147900. * Callback called on success
  147901. */
  147902. successCallback?: () => void;
  147903. /**
  147904. * Defines if parallel processing can be used
  147905. */
  147906. parallelProcessing: boolean;
  147907. }
  147908. /**
  147909. * Queue used to order the simplification tasks
  147910. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147911. */
  147912. export class SimplificationQueue {
  147913. private _simplificationArray;
  147914. /**
  147915. * Gets a boolean indicating that the process is still running
  147916. */
  147917. running: boolean;
  147918. /**
  147919. * Creates a new queue
  147920. */
  147921. constructor();
  147922. /**
  147923. * Adds a new simplification task
  147924. * @param task defines a task to add
  147925. */
  147926. addTask(task: ISimplificationTask): void;
  147927. /**
  147928. * Execute next task
  147929. */
  147930. executeNext(): void;
  147931. /**
  147932. * Execute a simplification task
  147933. * @param task defines the task to run
  147934. */
  147935. runSimplification(task: ISimplificationTask): void;
  147936. private getSimplifier;
  147937. }
  147938. /**
  147939. * The implemented types of simplification
  147940. * At the moment only Quadratic Error Decimation is implemented
  147941. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147942. */
  147943. export enum SimplificationType {
  147944. /** Quadratic error decimation */
  147945. QUADRATIC = 0
  147946. }
  147947. /**
  147948. * An implementation of the Quadratic Error simplification algorithm.
  147949. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147950. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147951. * @author RaananW
  147952. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147953. */
  147954. export class QuadraticErrorSimplification implements ISimplifier {
  147955. private _mesh;
  147956. private triangles;
  147957. private vertices;
  147958. private references;
  147959. private _reconstructedMesh;
  147960. /** Gets or sets the number pf sync interations */
  147961. syncIterations: number;
  147962. /** Gets or sets the aggressiveness of the simplifier */
  147963. aggressiveness: number;
  147964. /** Gets or sets the number of allowed iterations for decimation */
  147965. decimationIterations: number;
  147966. /** Gets or sets the espilon to use for bounding box computation */
  147967. boundingBoxEpsilon: number;
  147968. /**
  147969. * Creates a new QuadraticErrorSimplification
  147970. * @param _mesh defines the target mesh
  147971. */
  147972. constructor(_mesh: Mesh);
  147973. /**
  147974. * Simplification of a given mesh according to the given settings.
  147975. * Since this requires computation, it is assumed that the function runs async.
  147976. * @param settings The settings of the simplification, including quality and distance
  147977. * @param successCallback A callback that will be called after the mesh was simplified.
  147978. */
  147979. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147980. private runDecimation;
  147981. private initWithMesh;
  147982. private init;
  147983. private reconstructMesh;
  147984. private initDecimatedMesh;
  147985. private isFlipped;
  147986. private updateTriangles;
  147987. private identifyBorder;
  147988. private updateMesh;
  147989. private vertexError;
  147990. private calculateError;
  147991. }
  147992. }
  147993. declare module BABYLON {
  147994. interface Scene {
  147995. /** @hidden (Backing field) */
  147996. _simplificationQueue: SimplificationQueue;
  147997. /**
  147998. * Gets or sets the simplification queue attached to the scene
  147999. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148000. */
  148001. simplificationQueue: SimplificationQueue;
  148002. }
  148003. interface Mesh {
  148004. /**
  148005. * Simplify the mesh according to the given array of settings.
  148006. * Function will return immediately and will simplify async
  148007. * @param settings a collection of simplification settings
  148008. * @param parallelProcessing should all levels calculate parallel or one after the other
  148009. * @param simplificationType the type of simplification to run
  148010. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  148011. * @returns the current mesh
  148012. */
  148013. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  148014. }
  148015. /**
  148016. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  148017. * created in a scene
  148018. */
  148019. export class SimplicationQueueSceneComponent implements ISceneComponent {
  148020. /**
  148021. * The component name helpfull to identify the component in the list of scene components.
  148022. */
  148023. readonly name: string;
  148024. /**
  148025. * The scene the component belongs to.
  148026. */
  148027. scene: Scene;
  148028. /**
  148029. * Creates a new instance of the component for the given scene
  148030. * @param scene Defines the scene to register the component in
  148031. */
  148032. constructor(scene: Scene);
  148033. /**
  148034. * Registers the component in a given scene
  148035. */
  148036. register(): void;
  148037. /**
  148038. * Rebuilds the elements related to this component in case of
  148039. * context lost for instance.
  148040. */
  148041. rebuild(): void;
  148042. /**
  148043. * Disposes the component and the associated ressources
  148044. */
  148045. dispose(): void;
  148046. private _beforeCameraUpdate;
  148047. }
  148048. }
  148049. declare module BABYLON {
  148050. interface Mesh {
  148051. /**
  148052. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  148053. */
  148054. thinInstanceEnablePicking: boolean;
  148055. /**
  148056. * Creates a new thin instance
  148057. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  148058. * @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
  148059. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  148060. */
  148061. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  148062. /**
  148063. * Adds the transformation (matrix) of the current mesh as a thin instance
  148064. * @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
  148065. * @returns the thin instance index number
  148066. */
  148067. thinInstanceAddSelf(refresh: boolean): number;
  148068. /**
  148069. * Registers a custom attribute to be used with thin instances
  148070. * @param kind name of the attribute
  148071. * @param stride size in floats of the attribute
  148072. */
  148073. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  148074. /**
  148075. * Sets the matrix of a thin instance
  148076. * @param index index of the thin instance
  148077. * @param matrix matrix to set
  148078. * @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
  148079. */
  148080. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  148081. /**
  148082. * Sets the value of a custom attribute for a thin instance
  148083. * @param kind name of the attribute
  148084. * @param index index of the thin instance
  148085. * @param value value to set
  148086. * @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
  148087. */
  148088. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  148089. /**
  148090. * 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.
  148091. */
  148092. thinInstanceCount: number;
  148093. /**
  148094. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  148095. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  148096. * @param buffer buffer to set
  148097. * @param stride size in floats of each value of the buffer
  148098. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  148099. */
  148100. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  148101. /**
  148102. * Gets the list of world matrices
  148103. * @return an array containing all the world matrices from the thin instances
  148104. */
  148105. thinInstanceGetWorldMatrices(): Matrix[];
  148106. /**
  148107. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  148108. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148109. */
  148110. thinInstanceBufferUpdated(kind: string): void;
  148111. /**
  148112. * Applies a partial update to a buffer directly on the GPU
  148113. * 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
  148114. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148115. * @param data the data to set in the GPU buffer
  148116. * @param offset the offset in the GPU buffer where to update the data
  148117. */
  148118. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  148119. /**
  148120. * Refreshes the bounding info, taking into account all the thin instances defined
  148121. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  148122. */
  148123. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  148124. /** @hidden */
  148125. _thinInstanceInitializeUserStorage(): void;
  148126. /** @hidden */
  148127. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  148128. /** @hidden */
  148129. _userThinInstanceBuffersStorage: {
  148130. data: {
  148131. [key: string]: Float32Array;
  148132. };
  148133. sizes: {
  148134. [key: string]: number;
  148135. };
  148136. vertexBuffers: {
  148137. [key: string]: Nullable<VertexBuffer>;
  148138. };
  148139. strides: {
  148140. [key: string]: number;
  148141. };
  148142. };
  148143. }
  148144. }
  148145. declare module BABYLON {
  148146. /**
  148147. * Navigation plugin interface to add navigation constrained by a navigation mesh
  148148. */
  148149. export interface INavigationEnginePlugin {
  148150. /**
  148151. * plugin name
  148152. */
  148153. name: string;
  148154. /**
  148155. * Creates a navigation mesh
  148156. * @param meshes array of all the geometry used to compute the navigatio mesh
  148157. * @param parameters bunch of parameters used to filter geometry
  148158. */
  148159. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148160. /**
  148161. * Create a navigation mesh debug mesh
  148162. * @param scene is where the mesh will be added
  148163. * @returns debug display mesh
  148164. */
  148165. createDebugNavMesh(scene: Scene): Mesh;
  148166. /**
  148167. * Get a navigation mesh constrained position, closest to the parameter position
  148168. * @param position world position
  148169. * @returns the closest point to position constrained by the navigation mesh
  148170. */
  148171. getClosestPoint(position: Vector3): Vector3;
  148172. /**
  148173. * Get a navigation mesh constrained position, closest to the parameter position
  148174. * @param position world position
  148175. * @param result output the closest point to position constrained by the navigation mesh
  148176. */
  148177. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148178. /**
  148179. * Get a navigation mesh constrained position, within a particular radius
  148180. * @param position world position
  148181. * @param maxRadius the maximum distance to the constrained world position
  148182. * @returns the closest point to position constrained by the navigation mesh
  148183. */
  148184. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148185. /**
  148186. * Get a navigation mesh constrained position, within a particular radius
  148187. * @param position world position
  148188. * @param maxRadius the maximum distance to the constrained world position
  148189. * @param result output the closest point to position constrained by the navigation mesh
  148190. */
  148191. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148192. /**
  148193. * Compute the final position from a segment made of destination-position
  148194. * @param position world position
  148195. * @param destination world position
  148196. * @returns the resulting point along the navmesh
  148197. */
  148198. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148199. /**
  148200. * Compute the final position from a segment made of destination-position
  148201. * @param position world position
  148202. * @param destination world position
  148203. * @param result output the resulting point along the navmesh
  148204. */
  148205. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148206. /**
  148207. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148208. * @param start world position
  148209. * @param end world position
  148210. * @returns array containing world position composing the path
  148211. */
  148212. computePath(start: Vector3, end: Vector3): Vector3[];
  148213. /**
  148214. * If this plugin is supported
  148215. * @returns true if plugin is supported
  148216. */
  148217. isSupported(): boolean;
  148218. /**
  148219. * Create a new Crowd so you can add agents
  148220. * @param maxAgents the maximum agent count in the crowd
  148221. * @param maxAgentRadius the maximum radius an agent can have
  148222. * @param scene to attach the crowd to
  148223. * @returns the crowd you can add agents to
  148224. */
  148225. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148226. /**
  148227. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148228. * The queries will try to find a solution within those bounds
  148229. * default is (1,1,1)
  148230. * @param extent x,y,z value that define the extent around the queries point of reference
  148231. */
  148232. setDefaultQueryExtent(extent: Vector3): void;
  148233. /**
  148234. * Get the Bounding box extent specified by setDefaultQueryExtent
  148235. * @returns the box extent values
  148236. */
  148237. getDefaultQueryExtent(): Vector3;
  148238. /**
  148239. * build the navmesh from a previously saved state using getNavmeshData
  148240. * @param data the Uint8Array returned by getNavmeshData
  148241. */
  148242. buildFromNavmeshData(data: Uint8Array): void;
  148243. /**
  148244. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148245. * @returns data the Uint8Array that can be saved and reused
  148246. */
  148247. getNavmeshData(): Uint8Array;
  148248. /**
  148249. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148250. * @param result output the box extent values
  148251. */
  148252. getDefaultQueryExtentToRef(result: Vector3): void;
  148253. /**
  148254. * Release all resources
  148255. */
  148256. dispose(): void;
  148257. }
  148258. /**
  148259. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  148260. */
  148261. export interface ICrowd {
  148262. /**
  148263. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148264. * You can attach anything to that node. The node position is updated in the scene update tick.
  148265. * @param pos world position that will be constrained by the navigation mesh
  148266. * @param parameters agent parameters
  148267. * @param transform hooked to the agent that will be update by the scene
  148268. * @returns agent index
  148269. */
  148270. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148271. /**
  148272. * Returns the agent position in world space
  148273. * @param index agent index returned by addAgent
  148274. * @returns world space position
  148275. */
  148276. getAgentPosition(index: number): Vector3;
  148277. /**
  148278. * Gets the agent position result in world space
  148279. * @param index agent index returned by addAgent
  148280. * @param result output world space position
  148281. */
  148282. getAgentPositionToRef(index: number, result: Vector3): void;
  148283. /**
  148284. * Gets the agent velocity in world space
  148285. * @param index agent index returned by addAgent
  148286. * @returns world space velocity
  148287. */
  148288. getAgentVelocity(index: number): Vector3;
  148289. /**
  148290. * Gets the agent velocity result in world space
  148291. * @param index agent index returned by addAgent
  148292. * @param result output world space velocity
  148293. */
  148294. getAgentVelocityToRef(index: number, result: Vector3): void;
  148295. /**
  148296. * remove a particular agent previously created
  148297. * @param index agent index returned by addAgent
  148298. */
  148299. removeAgent(index: number): void;
  148300. /**
  148301. * get the list of all agents attached to this crowd
  148302. * @returns list of agent indices
  148303. */
  148304. getAgents(): number[];
  148305. /**
  148306. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148307. * @param deltaTime in seconds
  148308. */
  148309. update(deltaTime: number): void;
  148310. /**
  148311. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148312. * @param index agent index returned by addAgent
  148313. * @param destination targeted world position
  148314. */
  148315. agentGoto(index: number, destination: Vector3): void;
  148316. /**
  148317. * Teleport the agent to a new position
  148318. * @param index agent index returned by addAgent
  148319. * @param destination targeted world position
  148320. */
  148321. agentTeleport(index: number, destination: Vector3): void;
  148322. /**
  148323. * Update agent parameters
  148324. * @param index agent index returned by addAgent
  148325. * @param parameters agent parameters
  148326. */
  148327. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148328. /**
  148329. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148330. * The queries will try to find a solution within those bounds
  148331. * default is (1,1,1)
  148332. * @param extent x,y,z value that define the extent around the queries point of reference
  148333. */
  148334. setDefaultQueryExtent(extent: Vector3): void;
  148335. /**
  148336. * Get the Bounding box extent specified by setDefaultQueryExtent
  148337. * @returns the box extent values
  148338. */
  148339. getDefaultQueryExtent(): Vector3;
  148340. /**
  148341. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148342. * @param result output the box extent values
  148343. */
  148344. getDefaultQueryExtentToRef(result: Vector3): void;
  148345. /**
  148346. * Release all resources
  148347. */
  148348. dispose(): void;
  148349. }
  148350. /**
  148351. * Configures an agent
  148352. */
  148353. export interface IAgentParameters {
  148354. /**
  148355. * Agent radius. [Limit: >= 0]
  148356. */
  148357. radius: number;
  148358. /**
  148359. * Agent height. [Limit: > 0]
  148360. */
  148361. height: number;
  148362. /**
  148363. * Maximum allowed acceleration. [Limit: >= 0]
  148364. */
  148365. maxAcceleration: number;
  148366. /**
  148367. * Maximum allowed speed. [Limit: >= 0]
  148368. */
  148369. maxSpeed: number;
  148370. /**
  148371. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  148372. */
  148373. collisionQueryRange: number;
  148374. /**
  148375. * The path visibility optimization range. [Limit: > 0]
  148376. */
  148377. pathOptimizationRange: number;
  148378. /**
  148379. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  148380. */
  148381. separationWeight: number;
  148382. }
  148383. /**
  148384. * Configures the navigation mesh creation
  148385. */
  148386. export interface INavMeshParameters {
  148387. /**
  148388. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  148389. */
  148390. cs: number;
  148391. /**
  148392. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  148393. */
  148394. ch: number;
  148395. /**
  148396. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  148397. */
  148398. walkableSlopeAngle: number;
  148399. /**
  148400. * Minimum floor to 'ceiling' height that will still allow the floor area to
  148401. * be considered walkable. [Limit: >= 3] [Units: vx]
  148402. */
  148403. walkableHeight: number;
  148404. /**
  148405. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  148406. */
  148407. walkableClimb: number;
  148408. /**
  148409. * The distance to erode/shrink the walkable area of the heightfield away from
  148410. * obstructions. [Limit: >=0] [Units: vx]
  148411. */
  148412. walkableRadius: number;
  148413. /**
  148414. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  148415. */
  148416. maxEdgeLen: number;
  148417. /**
  148418. * The maximum distance a simplfied contour's border edges should deviate
  148419. * the original raw contour. [Limit: >=0] [Units: vx]
  148420. */
  148421. maxSimplificationError: number;
  148422. /**
  148423. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  148424. */
  148425. minRegionArea: number;
  148426. /**
  148427. * Any regions with a span count smaller than this value will, if possible,
  148428. * be merged with larger regions. [Limit: >=0] [Units: vx]
  148429. */
  148430. mergeRegionArea: number;
  148431. /**
  148432. * The maximum number of vertices allowed for polygons generated during the
  148433. * contour to polygon conversion process. [Limit: >= 3]
  148434. */
  148435. maxVertsPerPoly: number;
  148436. /**
  148437. * Sets the sampling distance to use when generating the detail mesh.
  148438. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  148439. */
  148440. detailSampleDist: number;
  148441. /**
  148442. * The maximum distance the detail mesh surface should deviate from heightfield
  148443. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  148444. */
  148445. detailSampleMaxError: number;
  148446. }
  148447. }
  148448. declare module BABYLON {
  148449. /**
  148450. * RecastJS navigation plugin
  148451. */
  148452. export class RecastJSPlugin implements INavigationEnginePlugin {
  148453. /**
  148454. * Reference to the Recast library
  148455. */
  148456. bjsRECAST: any;
  148457. /**
  148458. * plugin name
  148459. */
  148460. name: string;
  148461. /**
  148462. * the first navmesh created. We might extend this to support multiple navmeshes
  148463. */
  148464. navMesh: any;
  148465. /**
  148466. * Initializes the recastJS plugin
  148467. * @param recastInjection can be used to inject your own recast reference
  148468. */
  148469. constructor(recastInjection?: any);
  148470. /**
  148471. * Creates a navigation mesh
  148472. * @param meshes array of all the geometry used to compute the navigatio mesh
  148473. * @param parameters bunch of parameters used to filter geometry
  148474. */
  148475. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148476. /**
  148477. * Create a navigation mesh debug mesh
  148478. * @param scene is where the mesh will be added
  148479. * @returns debug display mesh
  148480. */
  148481. createDebugNavMesh(scene: Scene): Mesh;
  148482. /**
  148483. * Get a navigation mesh constrained position, closest to the parameter position
  148484. * @param position world position
  148485. * @returns the closest point to position constrained by the navigation mesh
  148486. */
  148487. getClosestPoint(position: Vector3): Vector3;
  148488. /**
  148489. * Get a navigation mesh constrained position, closest to the parameter position
  148490. * @param position world position
  148491. * @param result output the closest point to position constrained by the navigation mesh
  148492. */
  148493. getClosestPointToRef(position: Vector3, result: Vector3): void;
  148494. /**
  148495. * Get a navigation mesh constrained position, within a particular radius
  148496. * @param position world position
  148497. * @param maxRadius the maximum distance to the constrained world position
  148498. * @returns the closest point to position constrained by the navigation mesh
  148499. */
  148500. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  148501. /**
  148502. * Get a navigation mesh constrained position, within a particular radius
  148503. * @param position world position
  148504. * @param maxRadius the maximum distance to the constrained world position
  148505. * @param result output the closest point to position constrained by the navigation mesh
  148506. */
  148507. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  148508. /**
  148509. * Compute the final position from a segment made of destination-position
  148510. * @param position world position
  148511. * @param destination world position
  148512. * @returns the resulting point along the navmesh
  148513. */
  148514. moveAlong(position: Vector3, destination: Vector3): Vector3;
  148515. /**
  148516. * Compute the final position from a segment made of destination-position
  148517. * @param position world position
  148518. * @param destination world position
  148519. * @param result output the resulting point along the navmesh
  148520. */
  148521. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  148522. /**
  148523. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  148524. * @param start world position
  148525. * @param end world position
  148526. * @returns array containing world position composing the path
  148527. */
  148528. computePath(start: Vector3, end: Vector3): Vector3[];
  148529. /**
  148530. * Create a new Crowd so you can add agents
  148531. * @param maxAgents the maximum agent count in the crowd
  148532. * @param maxAgentRadius the maximum radius an agent can have
  148533. * @param scene to attach the crowd to
  148534. * @returns the crowd you can add agents to
  148535. */
  148536. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  148537. /**
  148538. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148539. * The queries will try to find a solution within those bounds
  148540. * default is (1,1,1)
  148541. * @param extent x,y,z value that define the extent around the queries point of reference
  148542. */
  148543. setDefaultQueryExtent(extent: Vector3): void;
  148544. /**
  148545. * Get the Bounding box extent specified by setDefaultQueryExtent
  148546. * @returns the box extent values
  148547. */
  148548. getDefaultQueryExtent(): Vector3;
  148549. /**
  148550. * build the navmesh from a previously saved state using getNavmeshData
  148551. * @param data the Uint8Array returned by getNavmeshData
  148552. */
  148553. buildFromNavmeshData(data: Uint8Array): void;
  148554. /**
  148555. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  148556. * @returns data the Uint8Array that can be saved and reused
  148557. */
  148558. getNavmeshData(): Uint8Array;
  148559. /**
  148560. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148561. * @param result output the box extent values
  148562. */
  148563. getDefaultQueryExtentToRef(result: Vector3): void;
  148564. /**
  148565. * Disposes
  148566. */
  148567. dispose(): void;
  148568. /**
  148569. * If this plugin is supported
  148570. * @returns true if plugin is supported
  148571. */
  148572. isSupported(): boolean;
  148573. }
  148574. /**
  148575. * Recast detour crowd implementation
  148576. */
  148577. export class RecastJSCrowd implements ICrowd {
  148578. /**
  148579. * Recast/detour plugin
  148580. */
  148581. bjsRECASTPlugin: RecastJSPlugin;
  148582. /**
  148583. * Link to the detour crowd
  148584. */
  148585. recastCrowd: any;
  148586. /**
  148587. * One transform per agent
  148588. */
  148589. transforms: TransformNode[];
  148590. /**
  148591. * All agents created
  148592. */
  148593. agents: number[];
  148594. /**
  148595. * Link to the scene is kept to unregister the crowd from the scene
  148596. */
  148597. private _scene;
  148598. /**
  148599. * Observer for crowd updates
  148600. */
  148601. private _onBeforeAnimationsObserver;
  148602. /**
  148603. * Constructor
  148604. * @param plugin recastJS plugin
  148605. * @param maxAgents the maximum agent count in the crowd
  148606. * @param maxAgentRadius the maximum radius an agent can have
  148607. * @param scene to attach the crowd to
  148608. * @returns the crowd you can add agents to
  148609. */
  148610. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  148611. /**
  148612. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148613. * You can attach anything to that node. The node position is updated in the scene update tick.
  148614. * @param pos world position that will be constrained by the navigation mesh
  148615. * @param parameters agent parameters
  148616. * @param transform hooked to the agent that will be update by the scene
  148617. * @returns agent index
  148618. */
  148619. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148620. /**
  148621. * Returns the agent position in world space
  148622. * @param index agent index returned by addAgent
  148623. * @returns world space position
  148624. */
  148625. getAgentPosition(index: number): Vector3;
  148626. /**
  148627. * Returns the agent position result in world space
  148628. * @param index agent index returned by addAgent
  148629. * @param result output world space position
  148630. */
  148631. getAgentPositionToRef(index: number, result: Vector3): void;
  148632. /**
  148633. * Returns the agent velocity in world space
  148634. * @param index agent index returned by addAgent
  148635. * @returns world space velocity
  148636. */
  148637. getAgentVelocity(index: number): Vector3;
  148638. /**
  148639. * Returns the agent velocity result in world space
  148640. * @param index agent index returned by addAgent
  148641. * @param result output world space velocity
  148642. */
  148643. getAgentVelocityToRef(index: number, result: Vector3): void;
  148644. /**
  148645. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148646. * @param index agent index returned by addAgent
  148647. * @param destination targeted world position
  148648. */
  148649. agentGoto(index: number, destination: Vector3): void;
  148650. /**
  148651. * Teleport the agent to a new position
  148652. * @param index agent index returned by addAgent
  148653. * @param destination targeted world position
  148654. */
  148655. agentTeleport(index: number, destination: Vector3): void;
  148656. /**
  148657. * Update agent parameters
  148658. * @param index agent index returned by addAgent
  148659. * @param parameters agent parameters
  148660. */
  148661. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148662. /**
  148663. * remove a particular agent previously created
  148664. * @param index agent index returned by addAgent
  148665. */
  148666. removeAgent(index: number): void;
  148667. /**
  148668. * get the list of all agents attached to this crowd
  148669. * @returns list of agent indices
  148670. */
  148671. getAgents(): number[];
  148672. /**
  148673. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148674. * @param deltaTime in seconds
  148675. */
  148676. update(deltaTime: number): void;
  148677. /**
  148678. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148679. * The queries will try to find a solution within those bounds
  148680. * default is (1,1,1)
  148681. * @param extent x,y,z value that define the extent around the queries point of reference
  148682. */
  148683. setDefaultQueryExtent(extent: Vector3): void;
  148684. /**
  148685. * Get the Bounding box extent specified by setDefaultQueryExtent
  148686. * @returns the box extent values
  148687. */
  148688. getDefaultQueryExtent(): Vector3;
  148689. /**
  148690. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148691. * @param result output the box extent values
  148692. */
  148693. getDefaultQueryExtentToRef(result: Vector3): void;
  148694. /**
  148695. * Release all resources
  148696. */
  148697. dispose(): void;
  148698. }
  148699. }
  148700. declare module BABYLON {
  148701. /**
  148702. * Class used to enable access to IndexedDB
  148703. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  148704. */
  148705. export class Database implements IOfflineProvider {
  148706. private _callbackManifestChecked;
  148707. private _currentSceneUrl;
  148708. private _db;
  148709. private _enableSceneOffline;
  148710. private _enableTexturesOffline;
  148711. private _manifestVersionFound;
  148712. private _mustUpdateRessources;
  148713. private _hasReachedQuota;
  148714. private _isSupported;
  148715. private _idbFactory;
  148716. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  148717. private static IsUASupportingBlobStorage;
  148718. /**
  148719. * Gets a boolean indicating if Database storate is enabled (off by default)
  148720. */
  148721. static IDBStorageEnabled: boolean;
  148722. /**
  148723. * Gets a boolean indicating if scene must be saved in the database
  148724. */
  148725. get enableSceneOffline(): boolean;
  148726. /**
  148727. * Gets a boolean indicating if textures must be saved in the database
  148728. */
  148729. get enableTexturesOffline(): boolean;
  148730. /**
  148731. * Creates a new Database
  148732. * @param urlToScene defines the url to load the scene
  148733. * @param callbackManifestChecked defines the callback to use when manifest is checked
  148734. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  148735. */
  148736. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  148737. private static _ParseURL;
  148738. private static _ReturnFullUrlLocation;
  148739. private _checkManifestFile;
  148740. /**
  148741. * Open the database and make it available
  148742. * @param successCallback defines the callback to call on success
  148743. * @param errorCallback defines the callback to call on error
  148744. */
  148745. open(successCallback: () => void, errorCallback: () => void): void;
  148746. /**
  148747. * Loads an image from the database
  148748. * @param url defines the url to load from
  148749. * @param image defines the target DOM image
  148750. */
  148751. loadImage(url: string, image: HTMLImageElement): void;
  148752. private _loadImageFromDBAsync;
  148753. private _saveImageIntoDBAsync;
  148754. private _checkVersionFromDB;
  148755. private _loadVersionFromDBAsync;
  148756. private _saveVersionIntoDBAsync;
  148757. /**
  148758. * Loads a file from database
  148759. * @param url defines the URL to load from
  148760. * @param sceneLoaded defines a callback to call on success
  148761. * @param progressCallBack defines a callback to call when progress changed
  148762. * @param errorCallback defines a callback to call on error
  148763. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  148764. */
  148765. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  148766. private _loadFileAsync;
  148767. private _saveFileAsync;
  148768. /**
  148769. * Validates if xhr data is correct
  148770. * @param xhr defines the request to validate
  148771. * @param dataType defines the expected data type
  148772. * @returns true if data is correct
  148773. */
  148774. private static _ValidateXHRData;
  148775. }
  148776. }
  148777. declare module BABYLON {
  148778. /** @hidden */
  148779. export var gpuUpdateParticlesPixelShader: {
  148780. name: string;
  148781. shader: string;
  148782. };
  148783. }
  148784. declare module BABYLON {
  148785. /** @hidden */
  148786. export var gpuUpdateParticlesVertexShader: {
  148787. name: string;
  148788. shader: string;
  148789. };
  148790. }
  148791. declare module BABYLON {
  148792. /** @hidden */
  148793. export var clipPlaneFragmentDeclaration2: {
  148794. name: string;
  148795. shader: string;
  148796. };
  148797. }
  148798. declare module BABYLON {
  148799. /** @hidden */
  148800. export var gpuRenderParticlesPixelShader: {
  148801. name: string;
  148802. shader: string;
  148803. };
  148804. }
  148805. declare module BABYLON {
  148806. /** @hidden */
  148807. export var clipPlaneVertexDeclaration2: {
  148808. name: string;
  148809. shader: string;
  148810. };
  148811. }
  148812. declare module BABYLON {
  148813. /** @hidden */
  148814. export var gpuRenderParticlesVertexShader: {
  148815. name: string;
  148816. shader: string;
  148817. };
  148818. }
  148819. declare module BABYLON {
  148820. /**
  148821. * This represents a GPU particle system in Babylon
  148822. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  148823. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  148824. */
  148825. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  148826. /**
  148827. * The layer mask we are rendering the particles through.
  148828. */
  148829. layerMask: number;
  148830. private _capacity;
  148831. private _activeCount;
  148832. private _currentActiveCount;
  148833. private _accumulatedCount;
  148834. private _renderEffect;
  148835. private _updateEffect;
  148836. private _buffer0;
  148837. private _buffer1;
  148838. private _spriteBuffer;
  148839. private _updateVAO;
  148840. private _renderVAO;
  148841. private _targetIndex;
  148842. private _sourceBuffer;
  148843. private _targetBuffer;
  148844. private _currentRenderId;
  148845. private _started;
  148846. private _stopped;
  148847. private _timeDelta;
  148848. private _randomTexture;
  148849. private _randomTexture2;
  148850. private _attributesStrideSize;
  148851. private _updateEffectOptions;
  148852. private _randomTextureSize;
  148853. private _actualFrame;
  148854. private _customEffect;
  148855. private readonly _rawTextureWidth;
  148856. /**
  148857. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  148858. */
  148859. static get IsSupported(): boolean;
  148860. /**
  148861. * An event triggered when the system is disposed.
  148862. */
  148863. onDisposeObservable: Observable<IParticleSystem>;
  148864. /**
  148865. * An event triggered when the system is stopped
  148866. */
  148867. onStoppedObservable: Observable<IParticleSystem>;
  148868. /**
  148869. * Gets the maximum number of particles active at the same time.
  148870. * @returns The max number of active particles.
  148871. */
  148872. getCapacity(): number;
  148873. /**
  148874. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  148875. * to override the particles.
  148876. */
  148877. forceDepthWrite: boolean;
  148878. /**
  148879. * Gets or set the number of active particles
  148880. */
  148881. get activeParticleCount(): number;
  148882. set activeParticleCount(value: number);
  148883. private _preWarmDone;
  148884. /**
  148885. * Specifies if the particles are updated in emitter local space or world space.
  148886. */
  148887. isLocal: boolean;
  148888. /** Gets or sets a matrix to use to compute projection */
  148889. defaultProjectionMatrix: Matrix;
  148890. /**
  148891. * Is this system ready to be used/rendered
  148892. * @return true if the system is ready
  148893. */
  148894. isReady(): boolean;
  148895. /**
  148896. * Gets if the system has been started. (Note: this will still be true after stop is called)
  148897. * @returns True if it has been started, otherwise false.
  148898. */
  148899. isStarted(): boolean;
  148900. /**
  148901. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  148902. * @returns True if it has been stopped, otherwise false.
  148903. */
  148904. isStopped(): boolean;
  148905. /**
  148906. * Gets a boolean indicating that the system is stopping
  148907. * @returns true if the system is currently stopping
  148908. */
  148909. isStopping(): boolean;
  148910. /**
  148911. * Gets the number of particles active at the same time.
  148912. * @returns The number of active particles.
  148913. */
  148914. getActiveCount(): number;
  148915. /**
  148916. * Starts the particle system and begins to emit
  148917. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  148918. */
  148919. start(delay?: number): void;
  148920. /**
  148921. * Stops the particle system.
  148922. */
  148923. stop(): void;
  148924. /**
  148925. * Remove all active particles
  148926. */
  148927. reset(): void;
  148928. /**
  148929. * Returns the string "GPUParticleSystem"
  148930. * @returns a string containing the class name
  148931. */
  148932. getClassName(): string;
  148933. /**
  148934. * Gets the custom effect used to render the particles
  148935. * @param blendMode Blend mode for which the effect should be retrieved
  148936. * @returns The effect
  148937. */
  148938. getCustomEffect(blendMode?: number): Nullable<Effect>;
  148939. /**
  148940. * Sets the custom effect used to render the particles
  148941. * @param effect The effect to set
  148942. * @param blendMode Blend mode for which the effect should be set
  148943. */
  148944. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  148945. /** @hidden */
  148946. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  148947. /**
  148948. * Observable that will be called just before the particles are drawn
  148949. */
  148950. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  148951. /**
  148952. * Gets the name of the particle vertex shader
  148953. */
  148954. get vertexShaderName(): string;
  148955. private _colorGradientsTexture;
  148956. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148957. /**
  148958. * Adds a new color gradient
  148959. * @param gradient defines the gradient to use (between 0 and 1)
  148960. * @param color1 defines the color to affect to the specified gradient
  148961. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148962. * @returns the current particle system
  148963. */
  148964. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148965. private _refreshColorGradient;
  148966. /** Force the system to rebuild all gradients that need to be resync */
  148967. forceRefreshGradients(): void;
  148968. /**
  148969. * Remove a specific color gradient
  148970. * @param gradient defines the gradient to remove
  148971. * @returns the current particle system
  148972. */
  148973. removeColorGradient(gradient: number): GPUParticleSystem;
  148974. private _angularSpeedGradientsTexture;
  148975. private _sizeGradientsTexture;
  148976. private _velocityGradientsTexture;
  148977. private _limitVelocityGradientsTexture;
  148978. private _dragGradientsTexture;
  148979. private _addFactorGradient;
  148980. /**
  148981. * Adds a new size gradient
  148982. * @param gradient defines the gradient to use (between 0 and 1)
  148983. * @param factor defines the size factor to affect to the specified gradient
  148984. * @returns the current particle system
  148985. */
  148986. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148987. /**
  148988. * Remove a specific size gradient
  148989. * @param gradient defines the gradient to remove
  148990. * @returns the current particle system
  148991. */
  148992. removeSizeGradient(gradient: number): GPUParticleSystem;
  148993. private _refreshFactorGradient;
  148994. /**
  148995. * Adds a new angular speed gradient
  148996. * @param gradient defines the gradient to use (between 0 and 1)
  148997. * @param factor defines the angular speed to affect to the specified gradient
  148998. * @returns the current particle system
  148999. */
  149000. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  149001. /**
  149002. * Remove a specific angular speed gradient
  149003. * @param gradient defines the gradient to remove
  149004. * @returns the current particle system
  149005. */
  149006. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  149007. /**
  149008. * Adds a new velocity gradient
  149009. * @param gradient defines the gradient to use (between 0 and 1)
  149010. * @param factor defines the velocity to affect to the specified gradient
  149011. * @returns the current particle system
  149012. */
  149013. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149014. /**
  149015. * Remove a specific velocity gradient
  149016. * @param gradient defines the gradient to remove
  149017. * @returns the current particle system
  149018. */
  149019. removeVelocityGradient(gradient: number): GPUParticleSystem;
  149020. /**
  149021. * Adds a new limit velocity gradient
  149022. * @param gradient defines the gradient to use (between 0 and 1)
  149023. * @param factor defines the limit velocity value to affect to the specified gradient
  149024. * @returns the current particle system
  149025. */
  149026. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149027. /**
  149028. * Remove a specific limit velocity gradient
  149029. * @param gradient defines the gradient to remove
  149030. * @returns the current particle system
  149031. */
  149032. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  149033. /**
  149034. * Adds a new drag gradient
  149035. * @param gradient defines the gradient to use (between 0 and 1)
  149036. * @param factor defines the drag value to affect to the specified gradient
  149037. * @returns the current particle system
  149038. */
  149039. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  149040. /**
  149041. * Remove a specific drag gradient
  149042. * @param gradient defines the gradient to remove
  149043. * @returns the current particle system
  149044. */
  149045. removeDragGradient(gradient: number): GPUParticleSystem;
  149046. /**
  149047. * Not supported by GPUParticleSystem
  149048. * @param gradient defines the gradient to use (between 0 and 1)
  149049. * @param factor defines the emit rate value to affect to the specified gradient
  149050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149051. * @returns the current particle system
  149052. */
  149053. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149054. /**
  149055. * Not supported by GPUParticleSystem
  149056. * @param gradient defines the gradient to remove
  149057. * @returns the current particle system
  149058. */
  149059. removeEmitRateGradient(gradient: number): IParticleSystem;
  149060. /**
  149061. * Not supported by GPUParticleSystem
  149062. * @param gradient defines the gradient to use (between 0 and 1)
  149063. * @param factor defines the start size value to affect to the specified gradient
  149064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149065. * @returns the current particle system
  149066. */
  149067. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149068. /**
  149069. * Not supported by GPUParticleSystem
  149070. * @param gradient defines the gradient to remove
  149071. * @returns the current particle system
  149072. */
  149073. removeStartSizeGradient(gradient: number): IParticleSystem;
  149074. /**
  149075. * Not supported by GPUParticleSystem
  149076. * @param gradient defines the gradient to use (between 0 and 1)
  149077. * @param min defines the color remap minimal range
  149078. * @param max defines the color remap maximal range
  149079. * @returns the current particle system
  149080. */
  149081. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149082. /**
  149083. * Not supported by GPUParticleSystem
  149084. * @param gradient defines the gradient to remove
  149085. * @returns the current particle system
  149086. */
  149087. removeColorRemapGradient(): IParticleSystem;
  149088. /**
  149089. * Not supported by GPUParticleSystem
  149090. * @param gradient defines the gradient to use (between 0 and 1)
  149091. * @param min defines the alpha remap minimal range
  149092. * @param max defines the alpha remap maximal range
  149093. * @returns the current particle system
  149094. */
  149095. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149096. /**
  149097. * Not supported by GPUParticleSystem
  149098. * @param gradient defines the gradient to remove
  149099. * @returns the current particle system
  149100. */
  149101. removeAlphaRemapGradient(): IParticleSystem;
  149102. /**
  149103. * Not supported by GPUParticleSystem
  149104. * @param gradient defines the gradient to use (between 0 and 1)
  149105. * @param color defines the color to affect to the specified gradient
  149106. * @returns the current particle system
  149107. */
  149108. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  149109. /**
  149110. * Not supported by GPUParticleSystem
  149111. * @param gradient defines the gradient to remove
  149112. * @returns the current particle system
  149113. */
  149114. removeRampGradient(): IParticleSystem;
  149115. /**
  149116. * Not supported by GPUParticleSystem
  149117. * @returns the list of ramp gradients
  149118. */
  149119. getRampGradients(): Nullable<Array<Color3Gradient>>;
  149120. /**
  149121. * Not supported by GPUParticleSystem
  149122. * Gets or sets a boolean indicating that ramp gradients must be used
  149123. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  149124. */
  149125. get useRampGradients(): boolean;
  149126. set useRampGradients(value: boolean);
  149127. /**
  149128. * Not supported by GPUParticleSystem
  149129. * @param gradient defines the gradient to use (between 0 and 1)
  149130. * @param factor defines the life time factor to affect to the specified gradient
  149131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149132. * @returns the current particle system
  149133. */
  149134. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149135. /**
  149136. * Not supported by GPUParticleSystem
  149137. * @param gradient defines the gradient to remove
  149138. * @returns the current particle system
  149139. */
  149140. removeLifeTimeGradient(gradient: number): IParticleSystem;
  149141. /**
  149142. * Instantiates a GPU particle system.
  149143. * 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.
  149144. * @param name The name of the particle system
  149145. * @param options The options used to create the system
  149146. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  149147. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  149148. * @param customEffect a custom effect used to change the way particles are rendered by default
  149149. */
  149150. constructor(name: string, options: Partial<{
  149151. capacity: number;
  149152. randomTextureSize: number;
  149153. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  149154. protected _reset(): void;
  149155. private _createUpdateVAO;
  149156. private _createRenderVAO;
  149157. private _initialize;
  149158. /** @hidden */
  149159. _recreateUpdateEffect(): void;
  149160. private _getEffect;
  149161. /**
  149162. * Fill the defines array according to the current settings of the particle system
  149163. * @param defines Array to be updated
  149164. * @param blendMode blend mode to take into account when updating the array
  149165. */
  149166. fillDefines(defines: Array<string>, blendMode?: number): void;
  149167. /**
  149168. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  149169. * @param uniforms Uniforms array to fill
  149170. * @param attributes Attributes array to fill
  149171. * @param samplers Samplers array to fill
  149172. */
  149173. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  149174. /** @hidden */
  149175. _recreateRenderEffect(): Effect;
  149176. /**
  149177. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  149178. * @param preWarm defines if we are in the pre-warmimg phase
  149179. */
  149180. animate(preWarm?: boolean): void;
  149181. private _createFactorGradientTexture;
  149182. private _createSizeGradientTexture;
  149183. private _createAngularSpeedGradientTexture;
  149184. private _createVelocityGradientTexture;
  149185. private _createLimitVelocityGradientTexture;
  149186. private _createDragGradientTexture;
  149187. private _createColorGradientTexture;
  149188. /**
  149189. * Renders the particle system in its current state
  149190. * @param preWarm defines if the system should only update the particles but not render them
  149191. * @returns the current number of particles
  149192. */
  149193. render(preWarm?: boolean): number;
  149194. /**
  149195. * Rebuilds the particle system
  149196. */
  149197. rebuild(): void;
  149198. private _releaseBuffers;
  149199. private _releaseVAOs;
  149200. /**
  149201. * Disposes the particle system and free the associated resources
  149202. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  149203. */
  149204. dispose(disposeTexture?: boolean): void;
  149205. /**
  149206. * Clones the particle system.
  149207. * @param name The name of the cloned object
  149208. * @param newEmitter The new emitter to use
  149209. * @returns the cloned particle system
  149210. */
  149211. clone(name: string, newEmitter: any): GPUParticleSystem;
  149212. /**
  149213. * Serializes the particle system to a JSON object
  149214. * @param serializeTexture defines if the texture must be serialized as well
  149215. * @returns the JSON object
  149216. */
  149217. serialize(serializeTexture?: boolean): any;
  149218. /**
  149219. * Parses a JSON object to create a GPU particle system.
  149220. * @param parsedParticleSystem The JSON object to parse
  149221. * @param sceneOrEngine The scene or the engine to create the particle system in
  149222. * @param rootUrl The root url to use to load external dependencies like texture
  149223. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  149224. * @returns the parsed GPU particle system
  149225. */
  149226. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  149227. }
  149228. }
  149229. declare module BABYLON {
  149230. /**
  149231. * Represents a set of particle systems working together to create a specific effect
  149232. */
  149233. export class ParticleSystemSet implements IDisposable {
  149234. /**
  149235. * Gets or sets base Assets URL
  149236. */
  149237. static BaseAssetsUrl: string;
  149238. private _emitterCreationOptions;
  149239. private _emitterNode;
  149240. /**
  149241. * Gets the particle system list
  149242. */
  149243. systems: IParticleSystem[];
  149244. /**
  149245. * Gets the emitter node used with this set
  149246. */
  149247. get emitterNode(): Nullable<TransformNode>;
  149248. /**
  149249. * Creates a new emitter mesh as a sphere
  149250. * @param options defines the options used to create the sphere
  149251. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  149252. * @param scene defines the hosting scene
  149253. */
  149254. setEmitterAsSphere(options: {
  149255. diameter: number;
  149256. segments: number;
  149257. color: Color3;
  149258. }, renderingGroupId: number, scene: Scene): void;
  149259. /**
  149260. * Starts all particle systems of the set
  149261. * @param emitter defines an optional mesh to use as emitter for the particle systems
  149262. */
  149263. start(emitter?: AbstractMesh): void;
  149264. /**
  149265. * Release all associated resources
  149266. */
  149267. dispose(): void;
  149268. /**
  149269. * Serialize the set into a JSON compatible object
  149270. * @param serializeTexture defines if the texture must be serialized as well
  149271. * @returns a JSON compatible representation of the set
  149272. */
  149273. serialize(serializeTexture?: boolean): any;
  149274. /**
  149275. * Parse a new ParticleSystemSet from a serialized source
  149276. * @param data defines a JSON compatible representation of the set
  149277. * @param scene defines the hosting scene
  149278. * @param gpu defines if we want GPU particles or CPU particles
  149279. * @returns a new ParticleSystemSet
  149280. */
  149281. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  149282. }
  149283. }
  149284. declare module BABYLON {
  149285. /**
  149286. * This class is made for on one-liner static method to help creating particle system set.
  149287. */
  149288. export class ParticleHelper {
  149289. /**
  149290. * Gets or sets base Assets URL
  149291. */
  149292. static BaseAssetsUrl: string;
  149293. /** Define the Url to load snippets */
  149294. static SnippetUrl: string;
  149295. /**
  149296. * Create a default particle system that you can tweak
  149297. * @param emitter defines the emitter to use
  149298. * @param capacity defines the system capacity (default is 500 particles)
  149299. * @param scene defines the hosting scene
  149300. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  149301. * @returns the new Particle system
  149302. */
  149303. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  149304. /**
  149305. * This is the main static method (one-liner) of this helper to create different particle systems
  149306. * @param type This string represents the type to the particle system to create
  149307. * @param scene The scene where the particle system should live
  149308. * @param gpu If the system will use gpu
  149309. * @returns the ParticleSystemSet created
  149310. */
  149311. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  149312. /**
  149313. * Static function used to export a particle system to a ParticleSystemSet variable.
  149314. * Please note that the emitter shape is not exported
  149315. * @param systems defines the particle systems to export
  149316. * @returns the created particle system set
  149317. */
  149318. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  149319. /**
  149320. * Creates a particle system from a snippet saved in a remote file
  149321. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  149322. * @param url defines the url to load from
  149323. * @param scene defines the hosting scene
  149324. * @param gpu If the system will use gpu
  149325. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149326. * @returns a promise that will resolve to the new particle system
  149327. */
  149328. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149329. /**
  149330. * Creates a particle system from a snippet saved by the particle system editor
  149331. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  149332. * @param scene defines the hosting scene
  149333. * @param gpu If the system will use gpu
  149334. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  149335. * @returns a promise that will resolve to the new particle system
  149336. */
  149337. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  149338. }
  149339. }
  149340. declare module BABYLON {
  149341. interface Engine {
  149342. /**
  149343. * Create an effect to use with particle systems.
  149344. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  149345. * the particle system for which you want to create a custom effect in the last parameter
  149346. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  149347. * @param uniformsNames defines a list of attribute names
  149348. * @param samplers defines an array of string used to represent textures
  149349. * @param defines defines the string containing the defines to use to compile the shaders
  149350. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  149351. * @param onCompiled defines a function to call when the effect creation is successful
  149352. * @param onError defines a function to call when the effect creation has failed
  149353. * @param particleSystem the particle system you want to create the effect for
  149354. * @returns the new Effect
  149355. */
  149356. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  149357. }
  149358. interface Mesh {
  149359. /**
  149360. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  149361. * @returns an array of IParticleSystem
  149362. */
  149363. getEmittedParticleSystems(): IParticleSystem[];
  149364. /**
  149365. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  149366. * @returns an array of IParticleSystem
  149367. */
  149368. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  149369. }
  149370. }
  149371. declare module BABYLON {
  149372. /** Defines the 4 color options */
  149373. export enum PointColor {
  149374. /** color value */
  149375. Color = 2,
  149376. /** uv value */
  149377. UV = 1,
  149378. /** random value */
  149379. Random = 0,
  149380. /** stated value */
  149381. Stated = 3
  149382. }
  149383. /**
  149384. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  149385. * 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.
  149386. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  149387. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  149388. *
  149389. * Full documentation here : TO BE ENTERED
  149390. */
  149391. export class PointsCloudSystem implements IDisposable {
  149392. /**
  149393. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  149394. * Example : var p = SPS.particles[i];
  149395. */
  149396. particles: CloudPoint[];
  149397. /**
  149398. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  149399. */
  149400. nbParticles: number;
  149401. /**
  149402. * This a counter for your own usage. It's not set by any SPS functions.
  149403. */
  149404. counter: number;
  149405. /**
  149406. * The PCS name. This name is also given to the underlying mesh.
  149407. */
  149408. name: string;
  149409. /**
  149410. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  149411. */
  149412. mesh: Mesh;
  149413. /**
  149414. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  149415. * Please read :
  149416. */
  149417. vars: any;
  149418. /**
  149419. * @hidden
  149420. */
  149421. _size: number;
  149422. private _scene;
  149423. private _promises;
  149424. private _positions;
  149425. private _indices;
  149426. private _normals;
  149427. private _colors;
  149428. private _uvs;
  149429. private _indices32;
  149430. private _positions32;
  149431. private _colors32;
  149432. private _uvs32;
  149433. private _updatable;
  149434. private _isVisibilityBoxLocked;
  149435. private _alwaysVisible;
  149436. private _groups;
  149437. private _groupCounter;
  149438. private _computeParticleColor;
  149439. private _computeParticleTexture;
  149440. private _computeParticleRotation;
  149441. private _computeBoundingBox;
  149442. private _isReady;
  149443. /**
  149444. * Creates a PCS (Points Cloud System) object
  149445. * @param name (String) is the PCS name, this will be the underlying mesh name
  149446. * @param pointSize (number) is the size for each point
  149447. * @param scene (Scene) is the scene in which the PCS is added
  149448. * @param options defines the options of the PCS e.g.
  149449. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  149450. */
  149451. constructor(name: string, pointSize: number, scene: Scene, options?: {
  149452. updatable?: boolean;
  149453. });
  149454. /**
  149455. * Builds the PCS underlying mesh. Returns a standard Mesh.
  149456. * If no points were added to the PCS, the returned mesh is just a single point.
  149457. * @returns a promise for the created mesh
  149458. */
  149459. buildMeshAsync(): Promise<Mesh>;
  149460. /**
  149461. * @hidden
  149462. */
  149463. private _buildMesh;
  149464. private _addParticle;
  149465. private _randomUnitVector;
  149466. private _getColorIndicesForCoord;
  149467. private _setPointsColorOrUV;
  149468. private _colorFromTexture;
  149469. private _calculateDensity;
  149470. /**
  149471. * Adds points to the PCS in random positions within a unit sphere
  149472. * @param nb (positive integer) the number of particles to be created from this model
  149473. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  149474. * @returns the number of groups in the system
  149475. */
  149476. addPoints(nb: number, pointFunction?: any): number;
  149477. /**
  149478. * Adds points to the PCS from the surface of the model shape
  149479. * @param mesh is any Mesh object that will be used as a surface model for the points
  149480. * @param nb (positive integer) the number of particles to be created from this model
  149481. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149482. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149483. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149484. * @returns the number of groups in the system
  149485. */
  149486. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149487. /**
  149488. * Adds points to the PCS inside the model shape
  149489. * @param mesh is any Mesh object that will be used as a surface model for the points
  149490. * @param nb (positive integer) the number of particles to be created from this model
  149491. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  149492. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  149493. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  149494. * @returns the number of groups in the system
  149495. */
  149496. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  149497. /**
  149498. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  149499. * This method calls `updateParticle()` for each particle of the SPS.
  149500. * For an animated SPS, it is usually called within the render loop.
  149501. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  149502. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  149503. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  149504. * @returns the PCS.
  149505. */
  149506. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  149507. /**
  149508. * Disposes the PCS.
  149509. */
  149510. dispose(): void;
  149511. /**
  149512. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  149513. * doc :
  149514. * @returns the PCS.
  149515. */
  149516. refreshVisibleSize(): PointsCloudSystem;
  149517. /**
  149518. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  149519. * @param size the size (float) of the visibility box
  149520. * note : this doesn't lock the PCS mesh bounding box.
  149521. * doc :
  149522. */
  149523. setVisibilityBox(size: number): void;
  149524. /**
  149525. * Gets whether the PCS is always visible or not
  149526. * doc :
  149527. */
  149528. get isAlwaysVisible(): boolean;
  149529. /**
  149530. * Sets the PCS as always visible or not
  149531. * doc :
  149532. */
  149533. set isAlwaysVisible(val: boolean);
  149534. /**
  149535. * Tells to `setParticles()` to compute the particle rotations or not
  149536. * Default value : false. The PCS is faster when it's set to false
  149537. * Note : particle rotations are only applied to parent particles
  149538. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  149539. */
  149540. set computeParticleRotation(val: boolean);
  149541. /**
  149542. * Tells to `setParticles()` to compute the particle colors or not.
  149543. * Default value : true. The PCS is faster when it's set to false.
  149544. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149545. */
  149546. set computeParticleColor(val: boolean);
  149547. set computeParticleTexture(val: boolean);
  149548. /**
  149549. * Gets if `setParticles()` computes the particle colors or not.
  149550. * Default value : false. The PCS is faster when it's set to false.
  149551. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  149552. */
  149553. get computeParticleColor(): boolean;
  149554. /**
  149555. * Gets if `setParticles()` computes the particle textures or not.
  149556. * Default value : false. The PCS is faster when it's set to false.
  149557. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  149558. */
  149559. get computeParticleTexture(): boolean;
  149560. /**
  149561. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  149562. */
  149563. set computeBoundingBox(val: boolean);
  149564. /**
  149565. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  149566. */
  149567. get computeBoundingBox(): boolean;
  149568. /**
  149569. * This function does nothing. It may be overwritten to set all the particle first values.
  149570. * The PCS doesn't call this function, you may have to call it by your own.
  149571. * doc :
  149572. */
  149573. initParticles(): void;
  149574. /**
  149575. * This function does nothing. It may be overwritten to recycle a particle
  149576. * The PCS doesn't call this function, you can to call it
  149577. * doc :
  149578. * @param particle The particle to recycle
  149579. * @returns the recycled particle
  149580. */
  149581. recycleParticle(particle: CloudPoint): CloudPoint;
  149582. /**
  149583. * Updates a particle : this function should be overwritten by the user.
  149584. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  149585. * doc :
  149586. * @example : just set a particle position or velocity and recycle conditions
  149587. * @param particle The particle to update
  149588. * @returns the updated particle
  149589. */
  149590. updateParticle(particle: CloudPoint): CloudPoint;
  149591. /**
  149592. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  149593. * This does nothing and may be overwritten by the user.
  149594. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149595. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149596. * @param update the boolean update value actually passed to setParticles()
  149597. */
  149598. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149599. /**
  149600. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  149601. * This will be passed three parameters.
  149602. * This does nothing and may be overwritten by the user.
  149603. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149604. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149605. * @param update the boolean update value actually passed to setParticles()
  149606. */
  149607. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149608. }
  149609. }
  149610. declare module BABYLON {
  149611. /**
  149612. * Represents one particle of a points cloud system.
  149613. */
  149614. export class CloudPoint {
  149615. /**
  149616. * particle global index
  149617. */
  149618. idx: number;
  149619. /**
  149620. * The color of the particle
  149621. */
  149622. color: Nullable<Color4>;
  149623. /**
  149624. * The world space position of the particle.
  149625. */
  149626. position: Vector3;
  149627. /**
  149628. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  149629. */
  149630. rotation: Vector3;
  149631. /**
  149632. * The world space rotation quaternion of the particle.
  149633. */
  149634. rotationQuaternion: Nullable<Quaternion>;
  149635. /**
  149636. * The uv of the particle.
  149637. */
  149638. uv: Nullable<Vector2>;
  149639. /**
  149640. * The current speed of the particle.
  149641. */
  149642. velocity: Vector3;
  149643. /**
  149644. * The pivot point in the particle local space.
  149645. */
  149646. pivot: Vector3;
  149647. /**
  149648. * Must the particle be translated from its pivot point in its local space ?
  149649. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  149650. * Default : false
  149651. */
  149652. translateFromPivot: boolean;
  149653. /**
  149654. * Index of this particle in the global "positions" array (Internal use)
  149655. * @hidden
  149656. */
  149657. _pos: number;
  149658. /**
  149659. * @hidden Index of this particle in the global "indices" array (Internal use)
  149660. */
  149661. _ind: number;
  149662. /**
  149663. * Group this particle belongs to
  149664. */
  149665. _group: PointsGroup;
  149666. /**
  149667. * Group id of this particle
  149668. */
  149669. groupId: number;
  149670. /**
  149671. * Index of the particle in its group id (Internal use)
  149672. */
  149673. idxInGroup: number;
  149674. /**
  149675. * @hidden Particle BoundingInfo object (Internal use)
  149676. */
  149677. _boundingInfo: BoundingInfo;
  149678. /**
  149679. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  149680. */
  149681. _pcs: PointsCloudSystem;
  149682. /**
  149683. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  149684. */
  149685. _stillInvisible: boolean;
  149686. /**
  149687. * @hidden Last computed particle rotation matrix
  149688. */
  149689. _rotationMatrix: number[];
  149690. /**
  149691. * Parent particle Id, if any.
  149692. * Default null.
  149693. */
  149694. parentId: Nullable<number>;
  149695. /**
  149696. * @hidden Internal global position in the PCS.
  149697. */
  149698. _globalPosition: Vector3;
  149699. /**
  149700. * Creates a Point Cloud object.
  149701. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  149702. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  149703. * @param group (PointsGroup) is the group the particle belongs to
  149704. * @param groupId (integer) is the group identifier in the PCS.
  149705. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  149706. * @param pcs defines the PCS it is associated to
  149707. */
  149708. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  149709. /**
  149710. * get point size
  149711. */
  149712. get size(): Vector3;
  149713. /**
  149714. * Set point size
  149715. */
  149716. set size(scale: Vector3);
  149717. /**
  149718. * Legacy support, changed quaternion to rotationQuaternion
  149719. */
  149720. get quaternion(): Nullable<Quaternion>;
  149721. /**
  149722. * Legacy support, changed quaternion to rotationQuaternion
  149723. */
  149724. set quaternion(q: Nullable<Quaternion>);
  149725. /**
  149726. * Returns a boolean. True if the particle intersects a mesh, else false
  149727. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  149728. * @param target is the object (point or mesh) what the intersection is computed against
  149729. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  149730. * @returns true if it intersects
  149731. */
  149732. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  149733. /**
  149734. * get the rotation matrix of the particle
  149735. * @hidden
  149736. */
  149737. getRotationMatrix(m: Matrix): void;
  149738. }
  149739. /**
  149740. * Represents a group of points in a points cloud system
  149741. * * PCS internal tool, don't use it manually.
  149742. */
  149743. export class PointsGroup {
  149744. /**
  149745. * The group id
  149746. * @hidden
  149747. */
  149748. groupID: number;
  149749. /**
  149750. * image data for group (internal use)
  149751. * @hidden
  149752. */
  149753. _groupImageData: Nullable<ArrayBufferView>;
  149754. /**
  149755. * Image Width (internal use)
  149756. * @hidden
  149757. */
  149758. _groupImgWidth: number;
  149759. /**
  149760. * Image Height (internal use)
  149761. * @hidden
  149762. */
  149763. _groupImgHeight: number;
  149764. /**
  149765. * Custom position function (internal use)
  149766. * @hidden
  149767. */
  149768. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  149769. /**
  149770. * density per facet for surface points
  149771. * @hidden
  149772. */
  149773. _groupDensity: number[];
  149774. /**
  149775. * Only when points are colored by texture carries pointer to texture list array
  149776. * @hidden
  149777. */
  149778. _textureNb: number;
  149779. /**
  149780. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  149781. * PCS internal tool, don't use it manually.
  149782. * @hidden
  149783. */
  149784. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  149785. }
  149786. }
  149787. declare module BABYLON {
  149788. interface Scene {
  149789. /** @hidden (Backing field) */
  149790. _physicsEngine: Nullable<IPhysicsEngine>;
  149791. /** @hidden */
  149792. _physicsTimeAccumulator: number;
  149793. /**
  149794. * Gets the current physics engine
  149795. * @returns a IPhysicsEngine or null if none attached
  149796. */
  149797. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  149798. /**
  149799. * Enables physics to the current scene
  149800. * @param gravity defines the scene's gravity for the physics engine
  149801. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  149802. * @return a boolean indicating if the physics engine was initialized
  149803. */
  149804. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  149805. /**
  149806. * Disables and disposes the physics engine associated with the scene
  149807. */
  149808. disablePhysicsEngine(): void;
  149809. /**
  149810. * Gets a boolean indicating if there is an active physics engine
  149811. * @returns a boolean indicating if there is an active physics engine
  149812. */
  149813. isPhysicsEnabled(): boolean;
  149814. /**
  149815. * Deletes a physics compound impostor
  149816. * @param compound defines the compound to delete
  149817. */
  149818. deleteCompoundImpostor(compound: any): void;
  149819. /**
  149820. * An event triggered when physic simulation is about to be run
  149821. */
  149822. onBeforePhysicsObservable: Observable<Scene>;
  149823. /**
  149824. * An event triggered when physic simulation has been done
  149825. */
  149826. onAfterPhysicsObservable: Observable<Scene>;
  149827. }
  149828. interface AbstractMesh {
  149829. /** @hidden */
  149830. _physicsImpostor: Nullable<PhysicsImpostor>;
  149831. /**
  149832. * Gets or sets impostor used for physic simulation
  149833. * @see https://doc.babylonjs.com/features/physics_engine
  149834. */
  149835. physicsImpostor: Nullable<PhysicsImpostor>;
  149836. /**
  149837. * Gets the current physics impostor
  149838. * @see https://doc.babylonjs.com/features/physics_engine
  149839. * @returns a physics impostor or null
  149840. */
  149841. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  149842. /** Apply a physic impulse to the mesh
  149843. * @param force defines the force to apply
  149844. * @param contactPoint defines where to apply the force
  149845. * @returns the current mesh
  149846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149847. */
  149848. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  149849. /**
  149850. * Creates a physic joint between two meshes
  149851. * @param otherMesh defines the other mesh to use
  149852. * @param pivot1 defines the pivot to use on this mesh
  149853. * @param pivot2 defines the pivot to use on the other mesh
  149854. * @param options defines additional options (can be plugin dependent)
  149855. * @returns the current mesh
  149856. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  149857. */
  149858. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  149859. /** @hidden */
  149860. _disposePhysicsObserver: Nullable<Observer<Node>>;
  149861. }
  149862. /**
  149863. * Defines the physics engine scene component responsible to manage a physics engine
  149864. */
  149865. export class PhysicsEngineSceneComponent implements ISceneComponent {
  149866. /**
  149867. * The component name helpful to identify the component in the list of scene components.
  149868. */
  149869. readonly name: string;
  149870. /**
  149871. * The scene the component belongs to.
  149872. */
  149873. scene: Scene;
  149874. /**
  149875. * Creates a new instance of the component for the given scene
  149876. * @param scene Defines the scene to register the component in
  149877. */
  149878. constructor(scene: Scene);
  149879. /**
  149880. * Registers the component in a given scene
  149881. */
  149882. register(): void;
  149883. /**
  149884. * Rebuilds the elements related to this component in case of
  149885. * context lost for instance.
  149886. */
  149887. rebuild(): void;
  149888. /**
  149889. * Disposes the component and the associated ressources
  149890. */
  149891. dispose(): void;
  149892. }
  149893. }
  149894. declare module BABYLON {
  149895. /**
  149896. * A helper for physics simulations
  149897. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149898. */
  149899. export class PhysicsHelper {
  149900. private _scene;
  149901. private _physicsEngine;
  149902. /**
  149903. * Initializes the Physics helper
  149904. * @param scene Babylon.js scene
  149905. */
  149906. constructor(scene: Scene);
  149907. /**
  149908. * Applies a radial explosion impulse
  149909. * @param origin the origin of the explosion
  149910. * @param radiusOrEventOptions the radius or the options of radial explosion
  149911. * @param strength the explosion strength
  149912. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149913. * @returns A physics radial explosion event, or null
  149914. */
  149915. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149916. /**
  149917. * Applies a radial explosion force
  149918. * @param origin the origin of the explosion
  149919. * @param radiusOrEventOptions the radius or the options of radial explosion
  149920. * @param strength the explosion strength
  149921. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149922. * @returns A physics radial explosion event, or null
  149923. */
  149924. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149925. /**
  149926. * Creates a gravitational field
  149927. * @param origin the origin of the explosion
  149928. * @param radiusOrEventOptions the radius or the options of radial explosion
  149929. * @param strength the explosion strength
  149930. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149931. * @returns A physics gravitational field event, or null
  149932. */
  149933. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  149934. /**
  149935. * Creates a physics updraft event
  149936. * @param origin the origin of the updraft
  149937. * @param radiusOrEventOptions the radius or the options of the updraft
  149938. * @param strength the strength of the updraft
  149939. * @param height the height of the updraft
  149940. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  149941. * @returns A physics updraft event, or null
  149942. */
  149943. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  149944. /**
  149945. * Creates a physics vortex event
  149946. * @param origin the of the vortex
  149947. * @param radiusOrEventOptions the radius or the options of the vortex
  149948. * @param strength the strength of the vortex
  149949. * @param height the height of the vortex
  149950. * @returns a Physics vortex event, or null
  149951. * A physics vortex event or null
  149952. */
  149953. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149954. }
  149955. /**
  149956. * Represents a physics radial explosion event
  149957. */
  149958. class PhysicsRadialExplosionEvent {
  149959. private _scene;
  149960. private _options;
  149961. private _sphere;
  149962. private _dataFetched;
  149963. /**
  149964. * Initializes a radial explosioin event
  149965. * @param _scene BabylonJS scene
  149966. * @param _options The options for the vortex event
  149967. */
  149968. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149969. /**
  149970. * Returns the data related to the radial explosion event (sphere).
  149971. * @returns The radial explosion event data
  149972. */
  149973. getData(): PhysicsRadialExplosionEventData;
  149974. /**
  149975. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149976. * @param impostor A physics imposter
  149977. * @param origin the origin of the explosion
  149978. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149979. */
  149980. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149981. /**
  149982. * Triggers affecterd impostors callbacks
  149983. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149984. */
  149985. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149986. /**
  149987. * Disposes the sphere.
  149988. * @param force Specifies if the sphere should be disposed by force
  149989. */
  149990. dispose(force?: boolean): void;
  149991. /*** Helpers ***/
  149992. private _prepareSphere;
  149993. private _intersectsWithSphere;
  149994. }
  149995. /**
  149996. * Represents a gravitational field event
  149997. */
  149998. class PhysicsGravitationalFieldEvent {
  149999. private _physicsHelper;
  150000. private _scene;
  150001. private _origin;
  150002. private _options;
  150003. private _tickCallback;
  150004. private _sphere;
  150005. private _dataFetched;
  150006. /**
  150007. * Initializes the physics gravitational field event
  150008. * @param _physicsHelper A physics helper
  150009. * @param _scene BabylonJS scene
  150010. * @param _origin The origin position of the gravitational field event
  150011. * @param _options The options for the vortex event
  150012. */
  150013. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  150014. /**
  150015. * Returns the data related to the gravitational field event (sphere).
  150016. * @returns A gravitational field event
  150017. */
  150018. getData(): PhysicsGravitationalFieldEventData;
  150019. /**
  150020. * Enables the gravitational field.
  150021. */
  150022. enable(): void;
  150023. /**
  150024. * Disables the gravitational field.
  150025. */
  150026. disable(): void;
  150027. /**
  150028. * Disposes the sphere.
  150029. * @param force The force to dispose from the gravitational field event
  150030. */
  150031. dispose(force?: boolean): void;
  150032. private _tick;
  150033. }
  150034. /**
  150035. * Represents a physics updraft event
  150036. */
  150037. class PhysicsUpdraftEvent {
  150038. private _scene;
  150039. private _origin;
  150040. private _options;
  150041. private _physicsEngine;
  150042. private _originTop;
  150043. private _originDirection;
  150044. private _tickCallback;
  150045. private _cylinder;
  150046. private _cylinderPosition;
  150047. private _dataFetched;
  150048. /**
  150049. * Initializes the physics updraft event
  150050. * @param _scene BabylonJS scene
  150051. * @param _origin The origin position of the updraft
  150052. * @param _options The options for the updraft event
  150053. */
  150054. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  150055. /**
  150056. * Returns the data related to the updraft event (cylinder).
  150057. * @returns A physics updraft event
  150058. */
  150059. getData(): PhysicsUpdraftEventData;
  150060. /**
  150061. * Enables the updraft.
  150062. */
  150063. enable(): void;
  150064. /**
  150065. * Disables the updraft.
  150066. */
  150067. disable(): void;
  150068. /**
  150069. * Disposes the cylinder.
  150070. * @param force Specifies if the updraft should be disposed by force
  150071. */
  150072. dispose(force?: boolean): void;
  150073. private getImpostorHitData;
  150074. private _tick;
  150075. /*** Helpers ***/
  150076. private _prepareCylinder;
  150077. private _intersectsWithCylinder;
  150078. }
  150079. /**
  150080. * Represents a physics vortex event
  150081. */
  150082. class PhysicsVortexEvent {
  150083. private _scene;
  150084. private _origin;
  150085. private _options;
  150086. private _physicsEngine;
  150087. private _originTop;
  150088. private _tickCallback;
  150089. private _cylinder;
  150090. private _cylinderPosition;
  150091. private _dataFetched;
  150092. /**
  150093. * Initializes the physics vortex event
  150094. * @param _scene The BabylonJS scene
  150095. * @param _origin The origin position of the vortex
  150096. * @param _options The options for the vortex event
  150097. */
  150098. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  150099. /**
  150100. * Returns the data related to the vortex event (cylinder).
  150101. * @returns The physics vortex event data
  150102. */
  150103. getData(): PhysicsVortexEventData;
  150104. /**
  150105. * Enables the vortex.
  150106. */
  150107. enable(): void;
  150108. /**
  150109. * Disables the cortex.
  150110. */
  150111. disable(): void;
  150112. /**
  150113. * Disposes the sphere.
  150114. * @param force
  150115. */
  150116. dispose(force?: boolean): void;
  150117. private getImpostorHitData;
  150118. private _tick;
  150119. /*** Helpers ***/
  150120. private _prepareCylinder;
  150121. private _intersectsWithCylinder;
  150122. }
  150123. /**
  150124. * Options fot the radial explosion event
  150125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150126. */
  150127. export class PhysicsRadialExplosionEventOptions {
  150128. /**
  150129. * The radius of the sphere for the radial explosion.
  150130. */
  150131. radius: number;
  150132. /**
  150133. * The strenth of the explosion.
  150134. */
  150135. strength: number;
  150136. /**
  150137. * The strenght of the force in correspondence to the distance of the affected object
  150138. */
  150139. falloff: PhysicsRadialImpulseFalloff;
  150140. /**
  150141. * Sphere options for the radial explosion.
  150142. */
  150143. sphere: {
  150144. segments: number;
  150145. diameter: number;
  150146. };
  150147. /**
  150148. * Sphere options for the radial explosion.
  150149. */
  150150. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  150151. }
  150152. /**
  150153. * Options fot the updraft event
  150154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150155. */
  150156. export class PhysicsUpdraftEventOptions {
  150157. /**
  150158. * The radius of the cylinder for the vortex
  150159. */
  150160. radius: number;
  150161. /**
  150162. * The strenth of the updraft.
  150163. */
  150164. strength: number;
  150165. /**
  150166. * The height of the cylinder for the updraft.
  150167. */
  150168. height: number;
  150169. /**
  150170. * The mode for the the updraft.
  150171. */
  150172. updraftMode: PhysicsUpdraftMode;
  150173. }
  150174. /**
  150175. * Options fot the vortex event
  150176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150177. */
  150178. export class PhysicsVortexEventOptions {
  150179. /**
  150180. * The radius of the cylinder for the vortex
  150181. */
  150182. radius: number;
  150183. /**
  150184. * The strenth of the vortex.
  150185. */
  150186. strength: number;
  150187. /**
  150188. * The height of the cylinder for the vortex.
  150189. */
  150190. height: number;
  150191. /**
  150192. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  150193. */
  150194. centripetalForceThreshold: number;
  150195. /**
  150196. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  150197. */
  150198. centripetalForceMultiplier: number;
  150199. /**
  150200. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  150201. */
  150202. centrifugalForceMultiplier: number;
  150203. /**
  150204. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  150205. */
  150206. updraftForceMultiplier: number;
  150207. }
  150208. /**
  150209. * The strenght of the force in correspondence to the distance of the affected object
  150210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150211. */
  150212. export enum PhysicsRadialImpulseFalloff {
  150213. /** Defines that impulse is constant in strength across it's whole radius */
  150214. Constant = 0,
  150215. /** Defines that impulse gets weaker if it's further from the origin */
  150216. Linear = 1
  150217. }
  150218. /**
  150219. * The strength of the force in correspondence to the distance of the affected object
  150220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150221. */
  150222. export enum PhysicsUpdraftMode {
  150223. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  150224. Center = 0,
  150225. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  150226. Perpendicular = 1
  150227. }
  150228. /**
  150229. * Interface for a physics hit data
  150230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150231. */
  150232. export interface PhysicsHitData {
  150233. /**
  150234. * The force applied at the contact point
  150235. */
  150236. force: Vector3;
  150237. /**
  150238. * The contact point
  150239. */
  150240. contactPoint: Vector3;
  150241. /**
  150242. * The distance from the origin to the contact point
  150243. */
  150244. distanceFromOrigin: number;
  150245. }
  150246. /**
  150247. * Interface for radial explosion event data
  150248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150249. */
  150250. export interface PhysicsRadialExplosionEventData {
  150251. /**
  150252. * A sphere used for the radial explosion event
  150253. */
  150254. sphere: Mesh;
  150255. }
  150256. /**
  150257. * Interface for gravitational field event data
  150258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150259. */
  150260. export interface PhysicsGravitationalFieldEventData {
  150261. /**
  150262. * A sphere mesh used for the gravitational field event
  150263. */
  150264. sphere: Mesh;
  150265. }
  150266. /**
  150267. * Interface for updraft event data
  150268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150269. */
  150270. export interface PhysicsUpdraftEventData {
  150271. /**
  150272. * A cylinder used for the updraft event
  150273. */
  150274. cylinder: Mesh;
  150275. }
  150276. /**
  150277. * Interface for vortex event data
  150278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150279. */
  150280. export interface PhysicsVortexEventData {
  150281. /**
  150282. * A cylinder used for the vortex event
  150283. */
  150284. cylinder: Mesh;
  150285. }
  150286. /**
  150287. * Interface for an affected physics impostor
  150288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150289. */
  150290. export interface PhysicsAffectedImpostorWithData {
  150291. /**
  150292. * The impostor affected by the effect
  150293. */
  150294. impostor: PhysicsImpostor;
  150295. /**
  150296. * The data about the hit/horce from the explosion
  150297. */
  150298. hitData: PhysicsHitData;
  150299. }
  150300. }
  150301. declare module BABYLON {
  150302. /** @hidden */
  150303. export var blackAndWhitePixelShader: {
  150304. name: string;
  150305. shader: string;
  150306. };
  150307. }
  150308. declare module BABYLON {
  150309. /**
  150310. * Post process used to render in black and white
  150311. */
  150312. export class BlackAndWhitePostProcess extends PostProcess {
  150313. /**
  150314. * Linear about to convert he result to black and white (default: 1)
  150315. */
  150316. degree: number;
  150317. /**
  150318. * Gets a string identifying the name of the class
  150319. * @returns "BlackAndWhitePostProcess" string
  150320. */
  150321. getClassName(): string;
  150322. /**
  150323. * Creates a black and white post process
  150324. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  150325. * @param name The name of the effect.
  150326. * @param options The required width/height ratio to downsize to before computing the render pass.
  150327. * @param camera The camera to apply the render pass to.
  150328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150329. * @param engine The engine which the post process will be applied. (default: current engine)
  150330. * @param reusable If the post process can be reused on the same frame. (default: false)
  150331. */
  150332. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150333. /** @hidden */
  150334. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  150335. }
  150336. }
  150337. declare module BABYLON {
  150338. /**
  150339. * This represents a set of one or more post processes in Babylon.
  150340. * A post process can be used to apply a shader to a texture after it is rendered.
  150341. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150342. */
  150343. export class PostProcessRenderEffect {
  150344. private _postProcesses;
  150345. private _getPostProcesses;
  150346. private _singleInstance;
  150347. private _cameras;
  150348. private _indicesForCamera;
  150349. /**
  150350. * Name of the effect
  150351. * @hidden
  150352. */
  150353. _name: string;
  150354. /**
  150355. * Instantiates a post process render effect.
  150356. * A post process can be used to apply a shader to a texture after it is rendered.
  150357. * @param engine The engine the effect is tied to
  150358. * @param name The name of the effect
  150359. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  150360. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  150361. */
  150362. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  150363. /**
  150364. * Checks if all the post processes in the effect are supported.
  150365. */
  150366. get isSupported(): boolean;
  150367. /**
  150368. * Updates the current state of the effect
  150369. * @hidden
  150370. */
  150371. _update(): void;
  150372. /**
  150373. * Attaches the effect on cameras
  150374. * @param cameras The camera to attach to.
  150375. * @hidden
  150376. */
  150377. _attachCameras(cameras: Camera): void;
  150378. /**
  150379. * Attaches the effect on cameras
  150380. * @param cameras The camera to attach to.
  150381. * @hidden
  150382. */
  150383. _attachCameras(cameras: Camera[]): void;
  150384. /**
  150385. * Detaches the effect on cameras
  150386. * @param cameras The camera to detatch from.
  150387. * @hidden
  150388. */
  150389. _detachCameras(cameras: Camera): void;
  150390. /**
  150391. * Detatches the effect on cameras
  150392. * @param cameras The camera to detatch from.
  150393. * @hidden
  150394. */
  150395. _detachCameras(cameras: Camera[]): void;
  150396. /**
  150397. * Enables the effect on given cameras
  150398. * @param cameras The camera to enable.
  150399. * @hidden
  150400. */
  150401. _enable(cameras: Camera): void;
  150402. /**
  150403. * Enables the effect on given cameras
  150404. * @param cameras The camera to enable.
  150405. * @hidden
  150406. */
  150407. _enable(cameras: Nullable<Camera[]>): void;
  150408. /**
  150409. * Disables the effect on the given cameras
  150410. * @param cameras The camera to disable.
  150411. * @hidden
  150412. */
  150413. _disable(cameras: Camera): void;
  150414. /**
  150415. * Disables the effect on the given cameras
  150416. * @param cameras The camera to disable.
  150417. * @hidden
  150418. */
  150419. _disable(cameras: Nullable<Camera[]>): void;
  150420. /**
  150421. * Gets a list of the post processes contained in the effect.
  150422. * @param camera The camera to get the post processes on.
  150423. * @returns The list of the post processes in the effect.
  150424. */
  150425. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  150426. }
  150427. }
  150428. declare module BABYLON {
  150429. /** @hidden */
  150430. export var extractHighlightsPixelShader: {
  150431. name: string;
  150432. shader: string;
  150433. };
  150434. }
  150435. declare module BABYLON {
  150436. /**
  150437. * 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.
  150438. */
  150439. export class ExtractHighlightsPostProcess extends PostProcess {
  150440. /**
  150441. * The luminance threshold, pixels below this value will be set to black.
  150442. */
  150443. threshold: number;
  150444. /** @hidden */
  150445. _exposure: number;
  150446. /**
  150447. * Post process which has the input texture to be used when performing highlight extraction
  150448. * @hidden
  150449. */
  150450. _inputPostProcess: Nullable<PostProcess>;
  150451. /**
  150452. * Gets a string identifying the name of the class
  150453. * @returns "ExtractHighlightsPostProcess" string
  150454. */
  150455. getClassName(): string;
  150456. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150457. }
  150458. }
  150459. declare module BABYLON {
  150460. /** @hidden */
  150461. export var bloomMergePixelShader: {
  150462. name: string;
  150463. shader: string;
  150464. };
  150465. }
  150466. declare module BABYLON {
  150467. /**
  150468. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150469. */
  150470. export class BloomMergePostProcess extends PostProcess {
  150471. /** Weight of the bloom to be added to the original input. */
  150472. weight: number;
  150473. /**
  150474. * Gets a string identifying the name of the class
  150475. * @returns "BloomMergePostProcess" string
  150476. */
  150477. getClassName(): string;
  150478. /**
  150479. * Creates a new instance of @see BloomMergePostProcess
  150480. * @param name The name of the effect.
  150481. * @param originalFromInput Post process which's input will be used for the merge.
  150482. * @param blurred Blurred highlights post process which's output will be used.
  150483. * @param weight Weight of the bloom to be added to the original input.
  150484. * @param options The required width/height ratio to downsize to before computing the render pass.
  150485. * @param camera The camera to apply the render pass to.
  150486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150487. * @param engine The engine which the post process will be applied. (default: current engine)
  150488. * @param reusable If the post process can be reused on the same frame. (default: false)
  150489. * @param textureType Type of textures used when performing the post process. (default: 0)
  150490. * @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)
  150491. */
  150492. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  150493. /** Weight of the bloom to be added to the original input. */
  150494. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150495. }
  150496. }
  150497. declare module BABYLON {
  150498. /**
  150499. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  150500. */
  150501. export class BloomEffect extends PostProcessRenderEffect {
  150502. private bloomScale;
  150503. /**
  150504. * @hidden Internal
  150505. */
  150506. _effects: Array<PostProcess>;
  150507. /**
  150508. * @hidden Internal
  150509. */
  150510. _downscale: ExtractHighlightsPostProcess;
  150511. private _blurX;
  150512. private _blurY;
  150513. private _merge;
  150514. /**
  150515. * The luminance threshold to find bright areas of the image to bloom.
  150516. */
  150517. get threshold(): number;
  150518. set threshold(value: number);
  150519. /**
  150520. * The strength of the bloom.
  150521. */
  150522. get weight(): number;
  150523. set weight(value: number);
  150524. /**
  150525. * Specifies the size of the bloom blur kernel, relative to the final output size
  150526. */
  150527. get kernel(): number;
  150528. set kernel(value: number);
  150529. /**
  150530. * Creates a new instance of @see BloomEffect
  150531. * @param scene The scene the effect belongs to.
  150532. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  150533. * @param bloomKernel The size of the kernel to be used when applying the blur.
  150534. * @param bloomWeight The the strength of bloom.
  150535. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150536. * @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)
  150537. */
  150538. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  150539. /**
  150540. * Disposes each of the internal effects for a given camera.
  150541. * @param camera The camera to dispose the effect on.
  150542. */
  150543. disposeEffects(camera: Camera): void;
  150544. /**
  150545. * @hidden Internal
  150546. */
  150547. _updateEffects(): void;
  150548. /**
  150549. * Internal
  150550. * @returns if all the contained post processes are ready.
  150551. * @hidden
  150552. */
  150553. _isReady(): boolean;
  150554. }
  150555. }
  150556. declare module BABYLON {
  150557. /** @hidden */
  150558. export var chromaticAberrationPixelShader: {
  150559. name: string;
  150560. shader: string;
  150561. };
  150562. }
  150563. declare module BABYLON {
  150564. /**
  150565. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  150566. */
  150567. export class ChromaticAberrationPostProcess extends PostProcess {
  150568. /**
  150569. * The amount of seperation of rgb channels (default: 30)
  150570. */
  150571. aberrationAmount: number;
  150572. /**
  150573. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  150574. */
  150575. radialIntensity: number;
  150576. /**
  150577. * 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))
  150578. */
  150579. direction: Vector2;
  150580. /**
  150581. * 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))
  150582. */
  150583. centerPosition: Vector2;
  150584. /** The width of the screen to apply the effect on */
  150585. screenWidth: number;
  150586. /** The height of the screen to apply the effect on */
  150587. screenHeight: number;
  150588. /**
  150589. * Gets a string identifying the name of the class
  150590. * @returns "ChromaticAberrationPostProcess" string
  150591. */
  150592. getClassName(): string;
  150593. /**
  150594. * Creates a new instance ChromaticAberrationPostProcess
  150595. * @param name The name of the effect.
  150596. * @param screenWidth The width of the screen to apply the effect on.
  150597. * @param screenHeight The height of the screen to apply the effect on.
  150598. * @param options The required width/height ratio to downsize to before computing the render pass.
  150599. * @param camera The camera to apply the render pass to.
  150600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150601. * @param engine The engine which the post process will be applied. (default: current engine)
  150602. * @param reusable If the post process can be reused on the same frame. (default: false)
  150603. * @param textureType Type of textures used when performing the post process. (default: 0)
  150604. * @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)
  150605. */
  150606. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150607. /** @hidden */
  150608. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  150609. }
  150610. }
  150611. declare module BABYLON {
  150612. /** @hidden */
  150613. export var circleOfConfusionPixelShader: {
  150614. name: string;
  150615. shader: string;
  150616. };
  150617. }
  150618. declare module BABYLON {
  150619. /**
  150620. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  150621. */
  150622. export class CircleOfConfusionPostProcess extends PostProcess {
  150623. /**
  150624. * 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.
  150625. */
  150626. lensSize: number;
  150627. /**
  150628. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150629. */
  150630. fStop: number;
  150631. /**
  150632. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150633. */
  150634. focusDistance: number;
  150635. /**
  150636. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  150637. */
  150638. focalLength: number;
  150639. /**
  150640. * Gets a string identifying the name of the class
  150641. * @returns "CircleOfConfusionPostProcess" string
  150642. */
  150643. getClassName(): string;
  150644. private _depthTexture;
  150645. /**
  150646. * Creates a new instance CircleOfConfusionPostProcess
  150647. * @param name The name of the effect.
  150648. * @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.
  150649. * @param options The required width/height ratio to downsize to before computing the render pass.
  150650. * @param camera The camera to apply the render pass to.
  150651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150652. * @param engine The engine which the post process will be applied. (default: current engine)
  150653. * @param reusable If the post process can be reused on the same frame. (default: false)
  150654. * @param textureType Type of textures used when performing the post process. (default: 0)
  150655. * @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)
  150656. */
  150657. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150658. /**
  150659. * 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.
  150660. */
  150661. set depthTexture(value: RenderTargetTexture);
  150662. }
  150663. }
  150664. declare module BABYLON {
  150665. /** @hidden */
  150666. export var colorCorrectionPixelShader: {
  150667. name: string;
  150668. shader: string;
  150669. };
  150670. }
  150671. declare module BABYLON {
  150672. /**
  150673. *
  150674. * This post-process allows the modification of rendered colors by using
  150675. * a 'look-up table' (LUT). This effect is also called Color Grading.
  150676. *
  150677. * The object needs to be provided an url to a texture containing the color
  150678. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  150679. * Use an image editing software to tweak the LUT to match your needs.
  150680. *
  150681. * For an example of a color LUT, see here:
  150682. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  150683. * For explanations on color grading, see here:
  150684. * @see http://udn.epicgames.com/Three/ColorGrading.html
  150685. *
  150686. */
  150687. export class ColorCorrectionPostProcess extends PostProcess {
  150688. private _colorTableTexture;
  150689. /**
  150690. * Gets the color table url used to create the LUT texture
  150691. */
  150692. colorTableUrl: string;
  150693. /**
  150694. * Gets a string identifying the name of the class
  150695. * @returns "ColorCorrectionPostProcess" string
  150696. */
  150697. getClassName(): string;
  150698. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150699. /** @hidden */
  150700. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  150701. }
  150702. }
  150703. declare module BABYLON {
  150704. /** @hidden */
  150705. export var convolutionPixelShader: {
  150706. name: string;
  150707. shader: string;
  150708. };
  150709. }
  150710. declare module BABYLON {
  150711. /**
  150712. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  150713. * input texture to perform effects such as edge detection or sharpening
  150714. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150715. */
  150716. export class ConvolutionPostProcess extends PostProcess {
  150717. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  150718. kernel: number[];
  150719. /**
  150720. * Gets a string identifying the name of the class
  150721. * @returns "ConvolutionPostProcess" string
  150722. */
  150723. getClassName(): string;
  150724. /**
  150725. * Creates a new instance ConvolutionPostProcess
  150726. * @param name The name of the effect.
  150727. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  150728. * @param options The required width/height ratio to downsize to before computing the render pass.
  150729. * @param camera The camera to apply the render pass to.
  150730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150731. * @param engine The engine which the post process will be applied. (default: current engine)
  150732. * @param reusable If the post process can be reused on the same frame. (default: false)
  150733. * @param textureType Type of textures used when performing the post process. (default: 0)
  150734. */
  150735. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150736. /** @hidden */
  150737. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  150738. /**
  150739. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150740. */
  150741. static EdgeDetect0Kernel: number[];
  150742. /**
  150743. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150744. */
  150745. static EdgeDetect1Kernel: number[];
  150746. /**
  150747. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150748. */
  150749. static EdgeDetect2Kernel: number[];
  150750. /**
  150751. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150752. */
  150753. static SharpenKernel: number[];
  150754. /**
  150755. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150756. */
  150757. static EmbossKernel: number[];
  150758. /**
  150759. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150760. */
  150761. static GaussianKernel: number[];
  150762. }
  150763. }
  150764. declare module BABYLON {
  150765. /**
  150766. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  150767. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  150768. * based on samples that have a large difference in distance than the center pixel.
  150769. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  150770. */
  150771. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  150772. /**
  150773. * The direction the blur should be applied
  150774. */
  150775. direction: Vector2;
  150776. /**
  150777. * Gets a string identifying the name of the class
  150778. * @returns "DepthOfFieldBlurPostProcess" string
  150779. */
  150780. getClassName(): string;
  150781. /**
  150782. * Creates a new instance CircleOfConfusionPostProcess
  150783. * @param name The name of the effect.
  150784. * @param scene The scene the effect belongs to.
  150785. * @param direction The direction the blur should be applied.
  150786. * @param kernel The size of the kernel used to blur.
  150787. * @param options The required width/height ratio to downsize to before computing the render pass.
  150788. * @param camera The camera to apply the render pass to.
  150789. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  150790. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  150791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150792. * @param engine The engine which the post process will be applied. (default: current engine)
  150793. * @param reusable If the post process can be reused on the same frame. (default: false)
  150794. * @param textureType Type of textures used when performing the post process. (default: 0)
  150795. * @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)
  150796. */
  150797. 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);
  150798. }
  150799. }
  150800. declare module BABYLON {
  150801. /** @hidden */
  150802. export var depthOfFieldMergePixelShader: {
  150803. name: string;
  150804. shader: string;
  150805. };
  150806. }
  150807. declare module BABYLON {
  150808. /**
  150809. * Options to be set when merging outputs from the default pipeline.
  150810. */
  150811. export class DepthOfFieldMergePostProcessOptions {
  150812. /**
  150813. * The original image to merge on top of
  150814. */
  150815. originalFromInput: PostProcess;
  150816. /**
  150817. * Parameters to perform the merge of the depth of field effect
  150818. */
  150819. depthOfField?: {
  150820. circleOfConfusion: PostProcess;
  150821. blurSteps: Array<PostProcess>;
  150822. };
  150823. /**
  150824. * Parameters to perform the merge of bloom effect
  150825. */
  150826. bloom?: {
  150827. blurred: PostProcess;
  150828. weight: number;
  150829. };
  150830. }
  150831. /**
  150832. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150833. */
  150834. export class DepthOfFieldMergePostProcess extends PostProcess {
  150835. private blurSteps;
  150836. /**
  150837. * Gets a string identifying the name of the class
  150838. * @returns "DepthOfFieldMergePostProcess" string
  150839. */
  150840. getClassName(): string;
  150841. /**
  150842. * Creates a new instance of DepthOfFieldMergePostProcess
  150843. * @param name The name of the effect.
  150844. * @param originalFromInput Post process which's input will be used for the merge.
  150845. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  150846. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  150847. * @param options The required width/height ratio to downsize to before computing the render pass.
  150848. * @param camera The camera to apply the render pass to.
  150849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150850. * @param engine The engine which the post process will be applied. (default: current engine)
  150851. * @param reusable If the post process can be reused on the same frame. (default: false)
  150852. * @param textureType Type of textures used when performing the post process. (default: 0)
  150853. * @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)
  150854. */
  150855. 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);
  150856. /**
  150857. * Updates the effect with the current post process compile time values and recompiles the shader.
  150858. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  150859. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  150860. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  150861. * @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
  150862. * @param onCompiled Called when the shader has been compiled.
  150863. * @param onError Called if there is an error when compiling a shader.
  150864. */
  150865. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  150866. }
  150867. }
  150868. declare module BABYLON {
  150869. /**
  150870. * Specifies the level of max blur that should be applied when using the depth of field effect
  150871. */
  150872. export enum DepthOfFieldEffectBlurLevel {
  150873. /**
  150874. * Subtle blur
  150875. */
  150876. Low = 0,
  150877. /**
  150878. * Medium blur
  150879. */
  150880. Medium = 1,
  150881. /**
  150882. * Large blur
  150883. */
  150884. High = 2
  150885. }
  150886. /**
  150887. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  150888. */
  150889. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  150890. private _circleOfConfusion;
  150891. /**
  150892. * @hidden Internal, blurs from high to low
  150893. */
  150894. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  150895. private _depthOfFieldBlurY;
  150896. private _dofMerge;
  150897. /**
  150898. * @hidden Internal post processes in depth of field effect
  150899. */
  150900. _effects: Array<PostProcess>;
  150901. /**
  150902. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  150903. */
  150904. set focalLength(value: number);
  150905. get focalLength(): number;
  150906. /**
  150907. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150908. */
  150909. set fStop(value: number);
  150910. get fStop(): number;
  150911. /**
  150912. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150913. */
  150914. set focusDistance(value: number);
  150915. get focusDistance(): number;
  150916. /**
  150917. * 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.
  150918. */
  150919. set lensSize(value: number);
  150920. get lensSize(): number;
  150921. /**
  150922. * Creates a new instance DepthOfFieldEffect
  150923. * @param scene The scene the effect belongs to.
  150924. * @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.
  150925. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150926. * @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)
  150927. */
  150928. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  150929. /**
  150930. * Get the current class name of the current effet
  150931. * @returns "DepthOfFieldEffect"
  150932. */
  150933. getClassName(): string;
  150934. /**
  150935. * 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.
  150936. */
  150937. set depthTexture(value: RenderTargetTexture);
  150938. /**
  150939. * Disposes each of the internal effects for a given camera.
  150940. * @param camera The camera to dispose the effect on.
  150941. */
  150942. disposeEffects(camera: Camera): void;
  150943. /**
  150944. * @hidden Internal
  150945. */
  150946. _updateEffects(): void;
  150947. /**
  150948. * Internal
  150949. * @returns if all the contained post processes are ready.
  150950. * @hidden
  150951. */
  150952. _isReady(): boolean;
  150953. }
  150954. }
  150955. declare module BABYLON {
  150956. /** @hidden */
  150957. export var displayPassPixelShader: {
  150958. name: string;
  150959. shader: string;
  150960. };
  150961. }
  150962. declare module BABYLON {
  150963. /**
  150964. * DisplayPassPostProcess which produces an output the same as it's input
  150965. */
  150966. export class DisplayPassPostProcess extends PostProcess {
  150967. /**
  150968. * Gets a string identifying the name of the class
  150969. * @returns "DisplayPassPostProcess" string
  150970. */
  150971. getClassName(): string;
  150972. /**
  150973. * Creates the DisplayPassPostProcess
  150974. * @param name The name of the effect.
  150975. * @param options The required width/height ratio to downsize to before computing the render pass.
  150976. * @param camera The camera to apply the render pass to.
  150977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150978. * @param engine The engine which the post process will be applied. (default: current engine)
  150979. * @param reusable If the post process can be reused on the same frame. (default: false)
  150980. */
  150981. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150982. /** @hidden */
  150983. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150984. }
  150985. }
  150986. declare module BABYLON {
  150987. /** @hidden */
  150988. export var filterPixelShader: {
  150989. name: string;
  150990. shader: string;
  150991. };
  150992. }
  150993. declare module BABYLON {
  150994. /**
  150995. * Applies a kernel filter to the image
  150996. */
  150997. export class FilterPostProcess extends PostProcess {
  150998. /** The matrix to be applied to the image */
  150999. kernelMatrix: Matrix;
  151000. /**
  151001. * Gets a string identifying the name of the class
  151002. * @returns "FilterPostProcess" string
  151003. */
  151004. getClassName(): string;
  151005. /**
  151006. *
  151007. * @param name The name of the effect.
  151008. * @param kernelMatrix The matrix to be applied to the image
  151009. * @param options The required width/height ratio to downsize to before computing the render pass.
  151010. * @param camera The camera to apply the render pass to.
  151011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151012. * @param engine The engine which the post process will be applied. (default: current engine)
  151013. * @param reusable If the post process can be reused on the same frame. (default: false)
  151014. */
  151015. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151016. /** @hidden */
  151017. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  151018. }
  151019. }
  151020. declare module BABYLON {
  151021. /** @hidden */
  151022. export var fxaaPixelShader: {
  151023. name: string;
  151024. shader: string;
  151025. };
  151026. }
  151027. declare module BABYLON {
  151028. /** @hidden */
  151029. export var fxaaVertexShader: {
  151030. name: string;
  151031. shader: string;
  151032. };
  151033. }
  151034. declare module BABYLON {
  151035. /**
  151036. * Fxaa post process
  151037. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  151038. */
  151039. export class FxaaPostProcess extends PostProcess {
  151040. /**
  151041. * Gets a string identifying the name of the class
  151042. * @returns "FxaaPostProcess" string
  151043. */
  151044. getClassName(): string;
  151045. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151046. private _getDefines;
  151047. /** @hidden */
  151048. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  151049. }
  151050. }
  151051. declare module BABYLON {
  151052. /** @hidden */
  151053. export var grainPixelShader: {
  151054. name: string;
  151055. shader: string;
  151056. };
  151057. }
  151058. declare module BABYLON {
  151059. /**
  151060. * The GrainPostProcess adds noise to the image at mid luminance levels
  151061. */
  151062. export class GrainPostProcess extends PostProcess {
  151063. /**
  151064. * The intensity of the grain added (default: 30)
  151065. */
  151066. intensity: number;
  151067. /**
  151068. * If the grain should be randomized on every frame
  151069. */
  151070. animated: boolean;
  151071. /**
  151072. * Gets a string identifying the name of the class
  151073. * @returns "GrainPostProcess" string
  151074. */
  151075. getClassName(): string;
  151076. /**
  151077. * Creates a new instance of @see GrainPostProcess
  151078. * @param name The name of the effect.
  151079. * @param options The required width/height ratio to downsize to before computing the render pass.
  151080. * @param camera The camera to apply the render pass to.
  151081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151082. * @param engine The engine which the post process will be applied. (default: current engine)
  151083. * @param reusable If the post process can be reused on the same frame. (default: false)
  151084. * @param textureType Type of textures used when performing the post process. (default: 0)
  151085. * @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)
  151086. */
  151087. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151088. /** @hidden */
  151089. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  151090. }
  151091. }
  151092. declare module BABYLON {
  151093. /** @hidden */
  151094. export var highlightsPixelShader: {
  151095. name: string;
  151096. shader: string;
  151097. };
  151098. }
  151099. declare module BABYLON {
  151100. /**
  151101. * Extracts highlights from the image
  151102. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151103. */
  151104. export class HighlightsPostProcess extends PostProcess {
  151105. /**
  151106. * Gets a string identifying the name of the class
  151107. * @returns "HighlightsPostProcess" string
  151108. */
  151109. getClassName(): string;
  151110. /**
  151111. * Extracts highlights from the image
  151112. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151113. * @param name The name of the effect.
  151114. * @param options The required width/height ratio to downsize to before computing the render pass.
  151115. * @param camera The camera to apply the render pass to.
  151116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151117. * @param engine The engine which the post process will be applied. (default: current engine)
  151118. * @param reusable If the post process can be reused on the same frame. (default: false)
  151119. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  151120. */
  151121. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151122. }
  151123. }
  151124. declare module BABYLON {
  151125. /**
  151126. * Contains all parameters needed for the prepass to perform
  151127. * motion blur
  151128. */
  151129. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  151130. /**
  151131. * Is motion blur enabled
  151132. */
  151133. enabled: boolean;
  151134. /**
  151135. * Name of the configuration
  151136. */
  151137. name: string;
  151138. /**
  151139. * Textures that should be present in the MRT for this effect to work
  151140. */
  151141. readonly texturesRequired: number[];
  151142. }
  151143. }
  151144. declare module BABYLON {
  151145. interface Scene {
  151146. /** @hidden (Backing field) */
  151147. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151148. /**
  151149. * Gets or Sets the current geometry buffer associated to the scene.
  151150. */
  151151. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  151152. /**
  151153. * Enables a GeometryBufferRender and associates it with the scene
  151154. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  151155. * @returns the GeometryBufferRenderer
  151156. */
  151157. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  151158. /**
  151159. * Disables the GeometryBufferRender associated with the scene
  151160. */
  151161. disableGeometryBufferRenderer(): void;
  151162. }
  151163. /**
  151164. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151165. * in several rendering techniques.
  151166. */
  151167. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  151168. /**
  151169. * The component name helpful to identify the component in the list of scene components.
  151170. */
  151171. readonly name: string;
  151172. /**
  151173. * The scene the component belongs to.
  151174. */
  151175. scene: Scene;
  151176. /**
  151177. * Creates a new instance of the component for the given scene
  151178. * @param scene Defines the scene to register the component in
  151179. */
  151180. constructor(scene: Scene);
  151181. /**
  151182. * Registers the component in a given scene
  151183. */
  151184. register(): void;
  151185. /**
  151186. * Rebuilds the elements related to this component in case of
  151187. * context lost for instance.
  151188. */
  151189. rebuild(): void;
  151190. /**
  151191. * Disposes the component and the associated ressources
  151192. */
  151193. dispose(): void;
  151194. private _gatherRenderTargets;
  151195. }
  151196. }
  151197. declare module BABYLON {
  151198. /** @hidden */
  151199. export var motionBlurPixelShader: {
  151200. name: string;
  151201. shader: string;
  151202. };
  151203. }
  151204. declare module BABYLON {
  151205. /**
  151206. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  151207. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  151208. * As an example, all you have to do is to create the post-process:
  151209. * var mb = new BABYLON.MotionBlurPostProcess(
  151210. * 'mb', // The name of the effect.
  151211. * scene, // The scene containing the objects to blur according to their velocity.
  151212. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  151213. * camera // The camera to apply the render pass to.
  151214. * );
  151215. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  151216. */
  151217. export class MotionBlurPostProcess extends PostProcess {
  151218. /**
  151219. * Defines how much the image is blurred by the movement. Default value is equal to 1
  151220. */
  151221. motionStrength: number;
  151222. /**
  151223. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  151224. */
  151225. get motionBlurSamples(): number;
  151226. /**
  151227. * Sets the number of iterations to be used for motion blur quality
  151228. */
  151229. set motionBlurSamples(samples: number);
  151230. private _motionBlurSamples;
  151231. private _forceGeometryBuffer;
  151232. private _geometryBufferRenderer;
  151233. private _prePassRenderer;
  151234. /**
  151235. * Gets a string identifying the name of the class
  151236. * @returns "MotionBlurPostProcess" string
  151237. */
  151238. getClassName(): string;
  151239. /**
  151240. * Creates a new instance MotionBlurPostProcess
  151241. * @param name The name of the effect.
  151242. * @param scene The scene containing the objects to blur according to their velocity.
  151243. * @param options The required width/height ratio to downsize to before computing the render pass.
  151244. * @param camera The camera to apply the render pass to.
  151245. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151246. * @param engine The engine which the post process will be applied. (default: current engine)
  151247. * @param reusable If the post process can be reused on the same frame. (default: false)
  151248. * @param textureType Type of textures used when performing the post process. (default: 0)
  151249. * @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)
  151250. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  151251. */
  151252. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  151253. /**
  151254. * Excludes the given skinned mesh from computing bones velocities.
  151255. * 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.
  151256. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  151257. */
  151258. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151259. /**
  151260. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  151261. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  151262. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  151263. */
  151264. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  151265. /**
  151266. * Disposes the post process.
  151267. * @param camera The camera to dispose the post process on.
  151268. */
  151269. dispose(camera?: Camera): void;
  151270. /** @hidden */
  151271. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  151272. }
  151273. }
  151274. declare module BABYLON {
  151275. /** @hidden */
  151276. export var refractionPixelShader: {
  151277. name: string;
  151278. shader: string;
  151279. };
  151280. }
  151281. declare module BABYLON {
  151282. /**
  151283. * Post process which applies a refractin texture
  151284. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151285. */
  151286. export class RefractionPostProcess extends PostProcess {
  151287. private _refTexture;
  151288. private _ownRefractionTexture;
  151289. /** the base color of the refraction (used to taint the rendering) */
  151290. color: Color3;
  151291. /** simulated refraction depth */
  151292. depth: number;
  151293. /** the coefficient of the base color (0 to remove base color tainting) */
  151294. colorLevel: number;
  151295. /** Gets the url used to load the refraction texture */
  151296. refractionTextureUrl: string;
  151297. /**
  151298. * Gets or sets the refraction texture
  151299. * Please note that you are responsible for disposing the texture if you set it manually
  151300. */
  151301. get refractionTexture(): Texture;
  151302. set refractionTexture(value: Texture);
  151303. /**
  151304. * Gets a string identifying the name of the class
  151305. * @returns "RefractionPostProcess" string
  151306. */
  151307. getClassName(): string;
  151308. /**
  151309. * Initializes the RefractionPostProcess
  151310. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  151311. * @param name The name of the effect.
  151312. * @param refractionTextureUrl Url of the refraction texture to use
  151313. * @param color the base color of the refraction (used to taint the rendering)
  151314. * @param depth simulated refraction depth
  151315. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  151316. * @param camera The camera to apply the render pass to.
  151317. * @param options The required width/height ratio to downsize to before computing the render pass.
  151318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151319. * @param engine The engine which the post process will be applied. (default: current engine)
  151320. * @param reusable If the post process can be reused on the same frame. (default: false)
  151321. */
  151322. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151323. /**
  151324. * Disposes of the post process
  151325. * @param camera Camera to dispose post process on
  151326. */
  151327. dispose(camera: Camera): void;
  151328. /** @hidden */
  151329. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  151330. }
  151331. }
  151332. declare module BABYLON {
  151333. /** @hidden */
  151334. export var sharpenPixelShader: {
  151335. name: string;
  151336. shader: string;
  151337. };
  151338. }
  151339. declare module BABYLON {
  151340. /**
  151341. * The SharpenPostProcess applies a sharpen kernel to every pixel
  151342. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151343. */
  151344. export class SharpenPostProcess extends PostProcess {
  151345. /**
  151346. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  151347. */
  151348. colorAmount: number;
  151349. /**
  151350. * How much sharpness should be applied (default: 0.3)
  151351. */
  151352. edgeAmount: number;
  151353. /**
  151354. * Gets a string identifying the name of the class
  151355. * @returns "SharpenPostProcess" string
  151356. */
  151357. getClassName(): string;
  151358. /**
  151359. * Creates a new instance ConvolutionPostProcess
  151360. * @param name The name of the effect.
  151361. * @param options The required width/height ratio to downsize to before computing the render pass.
  151362. * @param camera The camera to apply the render pass to.
  151363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151364. * @param engine The engine which the post process will be applied. (default: current engine)
  151365. * @param reusable If the post process can be reused on the same frame. (default: false)
  151366. * @param textureType Type of textures used when performing the post process. (default: 0)
  151367. * @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)
  151368. */
  151369. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151370. /** @hidden */
  151371. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  151372. }
  151373. }
  151374. declare module BABYLON {
  151375. /**
  151376. * PostProcessRenderPipeline
  151377. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151378. */
  151379. export class PostProcessRenderPipeline {
  151380. private engine;
  151381. private _renderEffects;
  151382. private _renderEffectsForIsolatedPass;
  151383. /**
  151384. * List of inspectable custom properties (used by the Inspector)
  151385. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  151386. */
  151387. inspectableCustomProperties: IInspectable[];
  151388. /**
  151389. * @hidden
  151390. */
  151391. protected _cameras: Camera[];
  151392. /** @hidden */
  151393. _name: string;
  151394. /**
  151395. * Gets pipeline name
  151396. */
  151397. get name(): string;
  151398. /** Gets the list of attached cameras */
  151399. get cameras(): Camera[];
  151400. /**
  151401. * Initializes a PostProcessRenderPipeline
  151402. * @param engine engine to add the pipeline to
  151403. * @param name name of the pipeline
  151404. */
  151405. constructor(engine: Engine, name: string);
  151406. /**
  151407. * Gets the class name
  151408. * @returns "PostProcessRenderPipeline"
  151409. */
  151410. getClassName(): string;
  151411. /**
  151412. * If all the render effects in the pipeline are supported
  151413. */
  151414. get isSupported(): boolean;
  151415. /**
  151416. * Adds an effect to the pipeline
  151417. * @param renderEffect the effect to add
  151418. */
  151419. addEffect(renderEffect: PostProcessRenderEffect): void;
  151420. /** @hidden */
  151421. _rebuild(): void;
  151422. /** @hidden */
  151423. _enableEffect(renderEffectName: string, cameras: Camera): void;
  151424. /** @hidden */
  151425. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  151426. /** @hidden */
  151427. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151428. /** @hidden */
  151429. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151430. /** @hidden */
  151431. _attachCameras(cameras: Camera, unique: boolean): void;
  151432. /** @hidden */
  151433. _attachCameras(cameras: Camera[], unique: boolean): void;
  151434. /** @hidden */
  151435. _detachCameras(cameras: Camera): void;
  151436. /** @hidden */
  151437. _detachCameras(cameras: Nullable<Camera[]>): void;
  151438. /** @hidden */
  151439. _update(): void;
  151440. /** @hidden */
  151441. _reset(): void;
  151442. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  151443. /**
  151444. * Sets the required values to the prepass renderer.
  151445. * @param prePassRenderer defines the prepass renderer to setup.
  151446. * @returns true if the pre pass is needed.
  151447. */
  151448. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151449. /**
  151450. * Disposes of the pipeline
  151451. */
  151452. dispose(): void;
  151453. }
  151454. }
  151455. declare module BABYLON {
  151456. /**
  151457. * PostProcessRenderPipelineManager class
  151458. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151459. */
  151460. export class PostProcessRenderPipelineManager {
  151461. private _renderPipelines;
  151462. /**
  151463. * Initializes a PostProcessRenderPipelineManager
  151464. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151465. */
  151466. constructor();
  151467. /**
  151468. * Gets the list of supported render pipelines
  151469. */
  151470. get supportedPipelines(): PostProcessRenderPipeline[];
  151471. /**
  151472. * Adds a pipeline to the manager
  151473. * @param renderPipeline The pipeline to add
  151474. */
  151475. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  151476. /**
  151477. * Attaches a camera to the pipeline
  151478. * @param renderPipelineName The name of the pipeline to attach to
  151479. * @param cameras the camera to attach
  151480. * @param unique if the camera can be attached multiple times to the pipeline
  151481. */
  151482. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  151483. /**
  151484. * Detaches a camera from the pipeline
  151485. * @param renderPipelineName The name of the pipeline to detach from
  151486. * @param cameras the camera to detach
  151487. */
  151488. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  151489. /**
  151490. * Enables an effect by name on a pipeline
  151491. * @param renderPipelineName the name of the pipeline to enable the effect in
  151492. * @param renderEffectName the name of the effect to enable
  151493. * @param cameras the cameras that the effect should be enabled on
  151494. */
  151495. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151496. /**
  151497. * Disables an effect by name on a pipeline
  151498. * @param renderPipelineName the name of the pipeline to disable the effect in
  151499. * @param renderEffectName the name of the effect to disable
  151500. * @param cameras the cameras that the effect should be disabled on
  151501. */
  151502. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151503. /**
  151504. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  151505. */
  151506. update(): void;
  151507. /** @hidden */
  151508. _rebuild(): void;
  151509. /**
  151510. * Disposes of the manager and pipelines
  151511. */
  151512. dispose(): void;
  151513. }
  151514. }
  151515. declare module BABYLON {
  151516. interface Scene {
  151517. /** @hidden (Backing field) */
  151518. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151519. /**
  151520. * Gets the postprocess render pipeline manager
  151521. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151522. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151523. */
  151524. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151525. }
  151526. /**
  151527. * Defines the Render Pipeline scene component responsible to rendering pipelines
  151528. */
  151529. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  151530. /**
  151531. * The component name helpfull to identify the component in the list of scene components.
  151532. */
  151533. readonly name: string;
  151534. /**
  151535. * The scene the component belongs to.
  151536. */
  151537. scene: Scene;
  151538. /**
  151539. * Creates a new instance of the component for the given scene
  151540. * @param scene Defines the scene to register the component in
  151541. */
  151542. constructor(scene: Scene);
  151543. /**
  151544. * Registers the component in a given scene
  151545. */
  151546. register(): void;
  151547. /**
  151548. * Rebuilds the elements related to this component in case of
  151549. * context lost for instance.
  151550. */
  151551. rebuild(): void;
  151552. /**
  151553. * Disposes the component and the associated ressources
  151554. */
  151555. dispose(): void;
  151556. private _gatherRenderTargets;
  151557. }
  151558. }
  151559. declare module BABYLON {
  151560. /**
  151561. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  151562. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151563. */
  151564. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151565. private _scene;
  151566. private _camerasToBeAttached;
  151567. /**
  151568. * ID of the sharpen post process,
  151569. */
  151570. private readonly SharpenPostProcessId;
  151571. /**
  151572. * @ignore
  151573. * ID of the image processing post process;
  151574. */
  151575. readonly ImageProcessingPostProcessId: string;
  151576. /**
  151577. * @ignore
  151578. * ID of the Fast Approximate Anti-Aliasing post process;
  151579. */
  151580. readonly FxaaPostProcessId: string;
  151581. /**
  151582. * ID of the chromatic aberration post process,
  151583. */
  151584. private readonly ChromaticAberrationPostProcessId;
  151585. /**
  151586. * ID of the grain post process
  151587. */
  151588. private readonly GrainPostProcessId;
  151589. /**
  151590. * Sharpen post process which will apply a sharpen convolution to enhance edges
  151591. */
  151592. sharpen: SharpenPostProcess;
  151593. private _sharpenEffect;
  151594. private bloom;
  151595. /**
  151596. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  151597. */
  151598. depthOfField: DepthOfFieldEffect;
  151599. /**
  151600. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151601. */
  151602. fxaa: FxaaPostProcess;
  151603. /**
  151604. * Image post processing pass used to perform operations such as tone mapping or color grading.
  151605. */
  151606. imageProcessing: ImageProcessingPostProcess;
  151607. /**
  151608. * Chromatic aberration post process which will shift rgb colors in the image
  151609. */
  151610. chromaticAberration: ChromaticAberrationPostProcess;
  151611. private _chromaticAberrationEffect;
  151612. /**
  151613. * Grain post process which add noise to the image
  151614. */
  151615. grain: GrainPostProcess;
  151616. private _grainEffect;
  151617. /**
  151618. * Glow post process which adds a glow to emissive areas of the image
  151619. */
  151620. private _glowLayer;
  151621. /**
  151622. * Animations which can be used to tweak settings over a period of time
  151623. */
  151624. animations: Animation[];
  151625. private _imageProcessingConfigurationObserver;
  151626. private _sharpenEnabled;
  151627. private _bloomEnabled;
  151628. private _depthOfFieldEnabled;
  151629. private _depthOfFieldBlurLevel;
  151630. private _fxaaEnabled;
  151631. private _imageProcessingEnabled;
  151632. private _defaultPipelineTextureType;
  151633. private _bloomScale;
  151634. private _chromaticAberrationEnabled;
  151635. private _grainEnabled;
  151636. private _buildAllowed;
  151637. /**
  151638. * Gets active scene
  151639. */
  151640. get scene(): Scene;
  151641. /**
  151642. * Enable or disable the sharpen process from the pipeline
  151643. */
  151644. set sharpenEnabled(enabled: boolean);
  151645. get sharpenEnabled(): boolean;
  151646. private _resizeObserver;
  151647. private _hardwareScaleLevel;
  151648. private _bloomKernel;
  151649. /**
  151650. * Specifies the size of the bloom blur kernel, relative to the final output size
  151651. */
  151652. get bloomKernel(): number;
  151653. set bloomKernel(value: number);
  151654. /**
  151655. * Specifies the weight of the bloom in the final rendering
  151656. */
  151657. private _bloomWeight;
  151658. /**
  151659. * Specifies the luma threshold for the area that will be blurred by the bloom
  151660. */
  151661. private _bloomThreshold;
  151662. private _hdr;
  151663. /**
  151664. * The strength of the bloom.
  151665. */
  151666. set bloomWeight(value: number);
  151667. get bloomWeight(): number;
  151668. /**
  151669. * The strength of the bloom.
  151670. */
  151671. set bloomThreshold(value: number);
  151672. get bloomThreshold(): number;
  151673. /**
  151674. * The scale of the bloom, lower value will provide better performance.
  151675. */
  151676. set bloomScale(value: number);
  151677. get bloomScale(): number;
  151678. /**
  151679. * Enable or disable the bloom from the pipeline
  151680. */
  151681. set bloomEnabled(enabled: boolean);
  151682. get bloomEnabled(): boolean;
  151683. private _rebuildBloom;
  151684. /**
  151685. * If the depth of field is enabled.
  151686. */
  151687. get depthOfFieldEnabled(): boolean;
  151688. set depthOfFieldEnabled(enabled: boolean);
  151689. /**
  151690. * Blur level of the depth of field effect. (Higher blur will effect performance)
  151691. */
  151692. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  151693. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  151694. /**
  151695. * If the anti aliasing is enabled.
  151696. */
  151697. set fxaaEnabled(enabled: boolean);
  151698. get fxaaEnabled(): boolean;
  151699. private _samples;
  151700. /**
  151701. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151702. */
  151703. set samples(sampleCount: number);
  151704. get samples(): number;
  151705. /**
  151706. * If image processing is enabled.
  151707. */
  151708. set imageProcessingEnabled(enabled: boolean);
  151709. get imageProcessingEnabled(): boolean;
  151710. /**
  151711. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  151712. */
  151713. set glowLayerEnabled(enabled: boolean);
  151714. get glowLayerEnabled(): boolean;
  151715. /**
  151716. * Gets the glow layer (or null if not defined)
  151717. */
  151718. get glowLayer(): Nullable<GlowLayer>;
  151719. /**
  151720. * Enable or disable the chromaticAberration process from the pipeline
  151721. */
  151722. set chromaticAberrationEnabled(enabled: boolean);
  151723. get chromaticAberrationEnabled(): boolean;
  151724. /**
  151725. * Enable or disable the grain process from the pipeline
  151726. */
  151727. set grainEnabled(enabled: boolean);
  151728. get grainEnabled(): boolean;
  151729. /**
  151730. * @constructor
  151731. * @param name - The rendering pipeline name (default: "")
  151732. * @param hdr - If high dynamic range textures should be used (default: true)
  151733. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151734. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151735. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151736. */
  151737. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151738. /**
  151739. * Get the class name
  151740. * @returns "DefaultRenderingPipeline"
  151741. */
  151742. getClassName(): string;
  151743. /**
  151744. * Force the compilation of the entire pipeline.
  151745. */
  151746. prepare(): void;
  151747. private _hasCleared;
  151748. private _prevPostProcess;
  151749. private _prevPrevPostProcess;
  151750. private _setAutoClearAndTextureSharing;
  151751. private _depthOfFieldSceneObserver;
  151752. private _buildPipeline;
  151753. private _disposePostProcesses;
  151754. /**
  151755. * Adds a camera to the pipeline
  151756. * @param camera the camera to be added
  151757. */
  151758. addCamera(camera: Camera): void;
  151759. /**
  151760. * Removes a camera from the pipeline
  151761. * @param camera the camera to remove
  151762. */
  151763. removeCamera(camera: Camera): void;
  151764. /**
  151765. * Dispose of the pipeline and stop all post processes
  151766. */
  151767. dispose(): void;
  151768. /**
  151769. * Serialize the rendering pipeline (Used when exporting)
  151770. * @returns the serialized object
  151771. */
  151772. serialize(): any;
  151773. /**
  151774. * Parse the serialized pipeline
  151775. * @param source Source pipeline.
  151776. * @param scene The scene to load the pipeline to.
  151777. * @param rootUrl The URL of the serialized pipeline.
  151778. * @returns An instantiated pipeline from the serialized object.
  151779. */
  151780. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  151781. }
  151782. }
  151783. declare module BABYLON {
  151784. /** @hidden */
  151785. export var lensHighlightsPixelShader: {
  151786. name: string;
  151787. shader: string;
  151788. };
  151789. }
  151790. declare module BABYLON {
  151791. /** @hidden */
  151792. export var depthOfFieldPixelShader: {
  151793. name: string;
  151794. shader: string;
  151795. };
  151796. }
  151797. declare module BABYLON {
  151798. /**
  151799. * BABYLON.JS Chromatic Aberration GLSL Shader
  151800. * Author: Olivier Guyot
  151801. * Separates very slightly R, G and B colors on the edges of the screen
  151802. * Inspired by Francois Tarlier & Martins Upitis
  151803. */
  151804. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151805. /**
  151806. * @ignore
  151807. * The chromatic aberration PostProcess id in the pipeline
  151808. */
  151809. LensChromaticAberrationEffect: string;
  151810. /**
  151811. * @ignore
  151812. * The highlights enhancing PostProcess id in the pipeline
  151813. */
  151814. HighlightsEnhancingEffect: string;
  151815. /**
  151816. * @ignore
  151817. * The depth-of-field PostProcess id in the pipeline
  151818. */
  151819. LensDepthOfFieldEffect: string;
  151820. private _scene;
  151821. private _depthTexture;
  151822. private _grainTexture;
  151823. private _chromaticAberrationPostProcess;
  151824. private _highlightsPostProcess;
  151825. private _depthOfFieldPostProcess;
  151826. private _edgeBlur;
  151827. private _grainAmount;
  151828. private _chromaticAberration;
  151829. private _distortion;
  151830. private _highlightsGain;
  151831. private _highlightsThreshold;
  151832. private _dofDistance;
  151833. private _dofAperture;
  151834. private _dofDarken;
  151835. private _dofPentagon;
  151836. private _blurNoise;
  151837. /**
  151838. * @constructor
  151839. *
  151840. * Effect parameters are as follow:
  151841. * {
  151842. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151843. * edge_blur: number; // from 0 to x (1 for realism)
  151844. * distortion: number; // from 0 to x (1 for realism)
  151845. * grain_amount: number; // from 0 to 1
  151846. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151847. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151848. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151849. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151850. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151851. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151852. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151853. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151854. * }
  151855. * Note: if an effect parameter is unset, effect is disabled
  151856. *
  151857. * @param name The rendering pipeline name
  151858. * @param parameters - An object containing all parameters (see above)
  151859. * @param scene The scene linked to this pipeline
  151860. * @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)
  151861. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151862. */
  151863. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151864. /**
  151865. * Get the class name
  151866. * @returns "LensRenderingPipeline"
  151867. */
  151868. getClassName(): string;
  151869. /**
  151870. * Gets associated scene
  151871. */
  151872. get scene(): Scene;
  151873. /**
  151874. * Gets or sets the edge blur
  151875. */
  151876. get edgeBlur(): number;
  151877. set edgeBlur(value: number);
  151878. /**
  151879. * Gets or sets the grain amount
  151880. */
  151881. get grainAmount(): number;
  151882. set grainAmount(value: number);
  151883. /**
  151884. * Gets or sets the chromatic aberration amount
  151885. */
  151886. get chromaticAberration(): number;
  151887. set chromaticAberration(value: number);
  151888. /**
  151889. * Gets or sets the depth of field aperture
  151890. */
  151891. get dofAperture(): number;
  151892. set dofAperture(value: number);
  151893. /**
  151894. * Gets or sets the edge distortion
  151895. */
  151896. get edgeDistortion(): number;
  151897. set edgeDistortion(value: number);
  151898. /**
  151899. * Gets or sets the depth of field distortion
  151900. */
  151901. get dofDistortion(): number;
  151902. set dofDistortion(value: number);
  151903. /**
  151904. * Gets or sets the darken out of focus amount
  151905. */
  151906. get darkenOutOfFocus(): number;
  151907. set darkenOutOfFocus(value: number);
  151908. /**
  151909. * Gets or sets a boolean indicating if blur noise is enabled
  151910. */
  151911. get blurNoise(): boolean;
  151912. set blurNoise(value: boolean);
  151913. /**
  151914. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151915. */
  151916. get pentagonBokeh(): boolean;
  151917. set pentagonBokeh(value: boolean);
  151918. /**
  151919. * Gets or sets the highlight grain amount
  151920. */
  151921. get highlightsGain(): number;
  151922. set highlightsGain(value: number);
  151923. /**
  151924. * Gets or sets the highlight threshold
  151925. */
  151926. get highlightsThreshold(): number;
  151927. set highlightsThreshold(value: number);
  151928. /**
  151929. * Sets the amount of blur at the edges
  151930. * @param amount blur amount
  151931. */
  151932. setEdgeBlur(amount: number): void;
  151933. /**
  151934. * Sets edge blur to 0
  151935. */
  151936. disableEdgeBlur(): void;
  151937. /**
  151938. * Sets the amout of grain
  151939. * @param amount Amount of grain
  151940. */
  151941. setGrainAmount(amount: number): void;
  151942. /**
  151943. * Set grain amount to 0
  151944. */
  151945. disableGrain(): void;
  151946. /**
  151947. * Sets the chromatic aberration amount
  151948. * @param amount amount of chromatic aberration
  151949. */
  151950. setChromaticAberration(amount: number): void;
  151951. /**
  151952. * Sets chromatic aberration amount to 0
  151953. */
  151954. disableChromaticAberration(): void;
  151955. /**
  151956. * Sets the EdgeDistortion amount
  151957. * @param amount amount of EdgeDistortion
  151958. */
  151959. setEdgeDistortion(amount: number): void;
  151960. /**
  151961. * Sets edge distortion to 0
  151962. */
  151963. disableEdgeDistortion(): void;
  151964. /**
  151965. * Sets the FocusDistance amount
  151966. * @param amount amount of FocusDistance
  151967. */
  151968. setFocusDistance(amount: number): void;
  151969. /**
  151970. * Disables depth of field
  151971. */
  151972. disableDepthOfField(): void;
  151973. /**
  151974. * Sets the Aperture amount
  151975. * @param amount amount of Aperture
  151976. */
  151977. setAperture(amount: number): void;
  151978. /**
  151979. * Sets the DarkenOutOfFocus amount
  151980. * @param amount amount of DarkenOutOfFocus
  151981. */
  151982. setDarkenOutOfFocus(amount: number): void;
  151983. private _pentagonBokehIsEnabled;
  151984. /**
  151985. * Creates a pentagon bokeh effect
  151986. */
  151987. enablePentagonBokeh(): void;
  151988. /**
  151989. * Disables the pentagon bokeh effect
  151990. */
  151991. disablePentagonBokeh(): void;
  151992. /**
  151993. * Enables noise blur
  151994. */
  151995. enableNoiseBlur(): void;
  151996. /**
  151997. * Disables noise blur
  151998. */
  151999. disableNoiseBlur(): void;
  152000. /**
  152001. * Sets the HighlightsGain amount
  152002. * @param amount amount of HighlightsGain
  152003. */
  152004. setHighlightsGain(amount: number): void;
  152005. /**
  152006. * Sets the HighlightsThreshold amount
  152007. * @param amount amount of HighlightsThreshold
  152008. */
  152009. setHighlightsThreshold(amount: number): void;
  152010. /**
  152011. * Disables highlights
  152012. */
  152013. disableHighlights(): void;
  152014. /**
  152015. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  152016. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  152017. */
  152018. dispose(disableDepthRender?: boolean): void;
  152019. private _createChromaticAberrationPostProcess;
  152020. private _createHighlightsPostProcess;
  152021. private _createDepthOfFieldPostProcess;
  152022. private _createGrainTexture;
  152023. }
  152024. }
  152025. declare module BABYLON {
  152026. /**
  152027. * Contains all parameters needed for the prepass to perform
  152028. * screen space subsurface scattering
  152029. */
  152030. export class SSAO2Configuration implements PrePassEffectConfiguration {
  152031. /**
  152032. * Is subsurface enabled
  152033. */
  152034. enabled: boolean;
  152035. /**
  152036. * Name of the configuration
  152037. */
  152038. name: string;
  152039. /**
  152040. * Textures that should be present in the MRT for this effect to work
  152041. */
  152042. readonly texturesRequired: number[];
  152043. }
  152044. }
  152045. declare module BABYLON {
  152046. /** @hidden */
  152047. export var ssao2PixelShader: {
  152048. name: string;
  152049. shader: string;
  152050. };
  152051. }
  152052. declare module BABYLON {
  152053. /** @hidden */
  152054. export var ssaoCombinePixelShader: {
  152055. name: string;
  152056. shader: string;
  152057. };
  152058. }
  152059. declare module BABYLON {
  152060. /**
  152061. * Render pipeline to produce ssao effect
  152062. */
  152063. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  152064. /**
  152065. * @ignore
  152066. * The PassPostProcess id in the pipeline that contains the original scene color
  152067. */
  152068. SSAOOriginalSceneColorEffect: string;
  152069. /**
  152070. * @ignore
  152071. * The SSAO PostProcess id in the pipeline
  152072. */
  152073. SSAORenderEffect: string;
  152074. /**
  152075. * @ignore
  152076. * The horizontal blur PostProcess id in the pipeline
  152077. */
  152078. SSAOBlurHRenderEffect: string;
  152079. /**
  152080. * @ignore
  152081. * The vertical blur PostProcess id in the pipeline
  152082. */
  152083. SSAOBlurVRenderEffect: string;
  152084. /**
  152085. * @ignore
  152086. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152087. */
  152088. SSAOCombineRenderEffect: string;
  152089. /**
  152090. * The output strength of the SSAO post-process. Default value is 1.0.
  152091. */
  152092. totalStrength: number;
  152093. /**
  152094. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  152095. */
  152096. maxZ: number;
  152097. /**
  152098. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  152099. */
  152100. minZAspect: number;
  152101. private _samples;
  152102. /**
  152103. * Number of samples used for the SSAO calculations. Default value is 8
  152104. */
  152105. set samples(n: number);
  152106. get samples(): number;
  152107. private _textureSamples;
  152108. /**
  152109. * Number of samples to use for antialiasing
  152110. */
  152111. set textureSamples(n: number);
  152112. get textureSamples(): number;
  152113. /**
  152114. * Force rendering the geometry through geometry buffer
  152115. */
  152116. private _forceGeometryBuffer;
  152117. /**
  152118. * Ratio object used for SSAO ratio and blur ratio
  152119. */
  152120. private _ratio;
  152121. /**
  152122. * Dynamically generated sphere sampler.
  152123. */
  152124. private _sampleSphere;
  152125. /**
  152126. * Blur filter offsets
  152127. */
  152128. private _samplerOffsets;
  152129. private _expensiveBlur;
  152130. /**
  152131. * If bilateral blur should be used
  152132. */
  152133. set expensiveBlur(b: boolean);
  152134. get expensiveBlur(): boolean;
  152135. /**
  152136. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  152137. */
  152138. radius: number;
  152139. /**
  152140. * The base color of the SSAO post-process
  152141. * The final result is "base + ssao" between [0, 1]
  152142. */
  152143. base: number;
  152144. /**
  152145. * Support test.
  152146. */
  152147. static get IsSupported(): boolean;
  152148. private _scene;
  152149. private _randomTexture;
  152150. private _originalColorPostProcess;
  152151. private _ssaoPostProcess;
  152152. private _blurHPostProcess;
  152153. private _blurVPostProcess;
  152154. private _ssaoCombinePostProcess;
  152155. private _prePassRenderer;
  152156. /**
  152157. * Gets active scene
  152158. */
  152159. get scene(): Scene;
  152160. /**
  152161. * @constructor
  152162. * @param name The rendering pipeline name
  152163. * @param scene The scene linked to this pipeline
  152164. * @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 }
  152165. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152166. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  152167. */
  152168. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  152169. /**
  152170. * Get the class name
  152171. * @returns "SSAO2RenderingPipeline"
  152172. */
  152173. getClassName(): string;
  152174. /**
  152175. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152176. */
  152177. dispose(disableGeometryBufferRenderer?: boolean): void;
  152178. private _createBlurPostProcess;
  152179. /** @hidden */
  152180. _rebuild(): void;
  152181. private _bits;
  152182. private _radicalInverse_VdC;
  152183. private _hammersley;
  152184. private _hemisphereSample_uniform;
  152185. private _generateHemisphere;
  152186. private _getDefinesForSSAO;
  152187. private _createSSAOPostProcess;
  152188. private _createSSAOCombinePostProcess;
  152189. private _createRandomTexture;
  152190. /**
  152191. * Serialize the rendering pipeline (Used when exporting)
  152192. * @returns the serialized object
  152193. */
  152194. serialize(): any;
  152195. /**
  152196. * Parse the serialized pipeline
  152197. * @param source Source pipeline.
  152198. * @param scene The scene to load the pipeline to.
  152199. * @param rootUrl The URL of the serialized pipeline.
  152200. * @returns An instantiated pipeline from the serialized object.
  152201. */
  152202. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  152203. }
  152204. }
  152205. declare module BABYLON {
  152206. /** @hidden */
  152207. export var ssaoPixelShader: {
  152208. name: string;
  152209. shader: string;
  152210. };
  152211. }
  152212. declare module BABYLON {
  152213. /**
  152214. * Render pipeline to produce ssao effect
  152215. */
  152216. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  152217. /**
  152218. * @ignore
  152219. * The PassPostProcess id in the pipeline that contains the original scene color
  152220. */
  152221. SSAOOriginalSceneColorEffect: string;
  152222. /**
  152223. * @ignore
  152224. * The SSAO PostProcess id in the pipeline
  152225. */
  152226. SSAORenderEffect: string;
  152227. /**
  152228. * @ignore
  152229. * The horizontal blur PostProcess id in the pipeline
  152230. */
  152231. SSAOBlurHRenderEffect: string;
  152232. /**
  152233. * @ignore
  152234. * The vertical blur PostProcess id in the pipeline
  152235. */
  152236. SSAOBlurVRenderEffect: string;
  152237. /**
  152238. * @ignore
  152239. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152240. */
  152241. SSAOCombineRenderEffect: string;
  152242. /**
  152243. * The output strength of the SSAO post-process. Default value is 1.0.
  152244. */
  152245. totalStrength: number;
  152246. /**
  152247. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  152248. */
  152249. radius: number;
  152250. /**
  152251. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  152252. * Must not be equal to fallOff and superior to fallOff.
  152253. * Default value is 0.0075
  152254. */
  152255. area: number;
  152256. /**
  152257. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  152258. * Must not be equal to area and inferior to area.
  152259. * Default value is 0.000001
  152260. */
  152261. fallOff: number;
  152262. /**
  152263. * The base color of the SSAO post-process
  152264. * The final result is "base + ssao" between [0, 1]
  152265. */
  152266. base: number;
  152267. private _scene;
  152268. private _depthTexture;
  152269. private _randomTexture;
  152270. private _originalColorPostProcess;
  152271. private _ssaoPostProcess;
  152272. private _blurHPostProcess;
  152273. private _blurVPostProcess;
  152274. private _ssaoCombinePostProcess;
  152275. private _firstUpdate;
  152276. /**
  152277. * Gets active scene
  152278. */
  152279. get scene(): Scene;
  152280. /**
  152281. * @constructor
  152282. * @param name - The rendering pipeline name
  152283. * @param scene - The scene linked to this pipeline
  152284. * @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 }
  152285. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  152286. */
  152287. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  152288. /**
  152289. * Get the class name
  152290. * @returns "SSAORenderingPipeline"
  152291. */
  152292. getClassName(): string;
  152293. /**
  152294. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  152295. */
  152296. dispose(disableDepthRender?: boolean): void;
  152297. private _createBlurPostProcess;
  152298. /** @hidden */
  152299. _rebuild(): void;
  152300. private _createSSAOPostProcess;
  152301. private _createSSAOCombinePostProcess;
  152302. private _createRandomTexture;
  152303. }
  152304. }
  152305. declare module BABYLON {
  152306. /**
  152307. * Contains all parameters needed for the prepass to perform
  152308. * screen space reflections
  152309. */
  152310. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  152311. /**
  152312. * Is ssr enabled
  152313. */
  152314. enabled: boolean;
  152315. /**
  152316. * Name of the configuration
  152317. */
  152318. name: string;
  152319. /**
  152320. * Textures that should be present in the MRT for this effect to work
  152321. */
  152322. readonly texturesRequired: number[];
  152323. }
  152324. }
  152325. declare module BABYLON {
  152326. /** @hidden */
  152327. export var screenSpaceReflectionPixelShader: {
  152328. name: string;
  152329. shader: string;
  152330. };
  152331. }
  152332. declare module BABYLON {
  152333. /**
  152334. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  152335. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  152336. */
  152337. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  152338. /**
  152339. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  152340. */
  152341. threshold: number;
  152342. /**
  152343. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  152344. */
  152345. strength: number;
  152346. /**
  152347. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  152348. */
  152349. reflectionSpecularFalloffExponent: number;
  152350. /**
  152351. * 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]
  152352. */
  152353. step: number;
  152354. /**
  152355. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  152356. */
  152357. roughnessFactor: number;
  152358. private _forceGeometryBuffer;
  152359. private _geometryBufferRenderer;
  152360. private _prePassRenderer;
  152361. private _enableSmoothReflections;
  152362. private _reflectionSamples;
  152363. private _smoothSteps;
  152364. /**
  152365. * Gets a string identifying the name of the class
  152366. * @returns "ScreenSpaceReflectionPostProcess" string
  152367. */
  152368. getClassName(): string;
  152369. /**
  152370. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  152371. * @param name The name of the effect.
  152372. * @param scene The scene containing the objects to calculate reflections.
  152373. * @param options The required width/height ratio to downsize to before computing the render pass.
  152374. * @param camera The camera to apply the render pass to.
  152375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152376. * @param engine The engine which the post process will be applied. (default: current engine)
  152377. * @param reusable If the post process can be reused on the same frame. (default: false)
  152378. * @param textureType Type of textures used when performing the post process. (default: 0)
  152379. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  152380. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152381. */
  152382. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152383. /**
  152384. * Gets wether or not smoothing reflections is enabled.
  152385. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152386. */
  152387. get enableSmoothReflections(): boolean;
  152388. /**
  152389. * Sets wether or not smoothing reflections is enabled.
  152390. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  152391. */
  152392. set enableSmoothReflections(enabled: boolean);
  152393. /**
  152394. * Gets the number of samples taken while computing reflections. More samples count is high,
  152395. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152396. */
  152397. get reflectionSamples(): number;
  152398. /**
  152399. * Sets the number of samples taken while computing reflections. More samples count is high,
  152400. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  152401. */
  152402. set reflectionSamples(samples: number);
  152403. /**
  152404. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  152405. * more the post-process will require GPU power and can generate a drop in FPS.
  152406. * Default value (5.0) work pretty well in all cases but can be adjusted.
  152407. */
  152408. get smoothSteps(): number;
  152409. set smoothSteps(steps: number);
  152410. private _updateEffectDefines;
  152411. /** @hidden */
  152412. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  152413. }
  152414. }
  152415. declare module BABYLON {
  152416. /** @hidden */
  152417. export var standardPixelShader: {
  152418. name: string;
  152419. shader: string;
  152420. };
  152421. }
  152422. declare module BABYLON {
  152423. /**
  152424. * Standard rendering pipeline
  152425. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152426. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  152427. */
  152428. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152429. /**
  152430. * Public members
  152431. */
  152432. /**
  152433. * Post-process which contains the original scene color before the pipeline applies all the effects
  152434. */
  152435. originalPostProcess: Nullable<PostProcess>;
  152436. /**
  152437. * Post-process used to down scale an image x4
  152438. */
  152439. downSampleX4PostProcess: Nullable<PostProcess>;
  152440. /**
  152441. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  152442. */
  152443. brightPassPostProcess: Nullable<PostProcess>;
  152444. /**
  152445. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  152446. */
  152447. blurHPostProcesses: PostProcess[];
  152448. /**
  152449. * Post-process array storing all the vertical blur post-processes used by the pipeline
  152450. */
  152451. blurVPostProcesses: PostProcess[];
  152452. /**
  152453. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  152454. */
  152455. textureAdderPostProcess: Nullable<PostProcess>;
  152456. /**
  152457. * Post-process used to create volumetric lighting effect
  152458. */
  152459. volumetricLightPostProcess: Nullable<PostProcess>;
  152460. /**
  152461. * Post-process used to smooth the previous volumetric light post-process on the X axis
  152462. */
  152463. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  152464. /**
  152465. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  152466. */
  152467. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  152468. /**
  152469. * Post-process used to merge the volumetric light effect and the real scene color
  152470. */
  152471. volumetricLightMergePostProces: Nullable<PostProcess>;
  152472. /**
  152473. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  152474. */
  152475. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  152476. /**
  152477. * Base post-process used to calculate the average luminance of the final image for HDR
  152478. */
  152479. luminancePostProcess: Nullable<PostProcess>;
  152480. /**
  152481. * Post-processes used to create down sample post-processes in order to get
  152482. * the average luminance of the final image for HDR
  152483. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  152484. */
  152485. luminanceDownSamplePostProcesses: PostProcess[];
  152486. /**
  152487. * Post-process used to create a HDR effect (light adaptation)
  152488. */
  152489. hdrPostProcess: Nullable<PostProcess>;
  152490. /**
  152491. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  152492. */
  152493. textureAdderFinalPostProcess: Nullable<PostProcess>;
  152494. /**
  152495. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  152496. */
  152497. lensFlareFinalPostProcess: Nullable<PostProcess>;
  152498. /**
  152499. * Post-process used to merge the final HDR post-process and the real scene color
  152500. */
  152501. hdrFinalPostProcess: Nullable<PostProcess>;
  152502. /**
  152503. * Post-process used to create a lens flare effect
  152504. */
  152505. lensFlarePostProcess: Nullable<PostProcess>;
  152506. /**
  152507. * Post-process that merges the result of the lens flare post-process and the real scene color
  152508. */
  152509. lensFlareComposePostProcess: Nullable<PostProcess>;
  152510. /**
  152511. * Post-process used to create a motion blur effect
  152512. */
  152513. motionBlurPostProcess: Nullable<PostProcess>;
  152514. /**
  152515. * Post-process used to create a depth of field effect
  152516. */
  152517. depthOfFieldPostProcess: Nullable<PostProcess>;
  152518. /**
  152519. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152520. */
  152521. fxaaPostProcess: Nullable<FxaaPostProcess>;
  152522. /**
  152523. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  152524. */
  152525. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  152526. /**
  152527. * Represents the brightness threshold in order to configure the illuminated surfaces
  152528. */
  152529. brightThreshold: number;
  152530. /**
  152531. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  152532. */
  152533. blurWidth: number;
  152534. /**
  152535. * Sets if the blur for highlighted surfaces must be only horizontal
  152536. */
  152537. horizontalBlur: boolean;
  152538. /**
  152539. * Gets the overall exposure used by the pipeline
  152540. */
  152541. get exposure(): number;
  152542. /**
  152543. * Sets the overall exposure used by the pipeline
  152544. */
  152545. set exposure(value: number);
  152546. /**
  152547. * Texture used typically to simulate "dirty" on camera lens
  152548. */
  152549. lensTexture: Nullable<Texture>;
  152550. /**
  152551. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  152552. */
  152553. volumetricLightCoefficient: number;
  152554. /**
  152555. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  152556. */
  152557. volumetricLightPower: number;
  152558. /**
  152559. * Used the set the blur intensity to smooth the volumetric lights
  152560. */
  152561. volumetricLightBlurScale: number;
  152562. /**
  152563. * Light (spot or directional) used to generate the volumetric lights rays
  152564. * The source light must have a shadow generate so the pipeline can get its
  152565. * depth map
  152566. */
  152567. sourceLight: Nullable<SpotLight | DirectionalLight>;
  152568. /**
  152569. * For eye adaptation, represents the minimum luminance the eye can see
  152570. */
  152571. hdrMinimumLuminance: number;
  152572. /**
  152573. * For eye adaptation, represents the decrease luminance speed
  152574. */
  152575. hdrDecreaseRate: number;
  152576. /**
  152577. * For eye adaptation, represents the increase luminance speed
  152578. */
  152579. hdrIncreaseRate: number;
  152580. /**
  152581. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152582. */
  152583. get hdrAutoExposure(): boolean;
  152584. /**
  152585. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152586. */
  152587. set hdrAutoExposure(value: boolean);
  152588. /**
  152589. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  152590. */
  152591. lensColorTexture: Nullable<Texture>;
  152592. /**
  152593. * The overall strengh for the lens flare effect
  152594. */
  152595. lensFlareStrength: number;
  152596. /**
  152597. * Dispersion coefficient for lens flare ghosts
  152598. */
  152599. lensFlareGhostDispersal: number;
  152600. /**
  152601. * Main lens flare halo width
  152602. */
  152603. lensFlareHaloWidth: number;
  152604. /**
  152605. * Based on the lens distortion effect, defines how much the lens flare result
  152606. * is distorted
  152607. */
  152608. lensFlareDistortionStrength: number;
  152609. /**
  152610. * Configures the blur intensity used for for lens flare (halo)
  152611. */
  152612. lensFlareBlurWidth: number;
  152613. /**
  152614. * Lens star texture must be used to simulate rays on the flares and is available
  152615. * in the documentation
  152616. */
  152617. lensStarTexture: Nullable<Texture>;
  152618. /**
  152619. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  152620. * flare effect by taking account of the dirt texture
  152621. */
  152622. lensFlareDirtTexture: Nullable<Texture>;
  152623. /**
  152624. * Represents the focal length for the depth of field effect
  152625. */
  152626. depthOfFieldDistance: number;
  152627. /**
  152628. * Represents the blur intensity for the blurred part of the depth of field effect
  152629. */
  152630. depthOfFieldBlurWidth: number;
  152631. /**
  152632. * Gets how much the image is blurred by the movement while using the motion blur post-process
  152633. */
  152634. get motionStrength(): number;
  152635. /**
  152636. * Sets how much the image is blurred by the movement while using the motion blur post-process
  152637. */
  152638. set motionStrength(strength: number);
  152639. /**
  152640. * Gets wether or not the motion blur post-process is object based or screen based.
  152641. */
  152642. get objectBasedMotionBlur(): boolean;
  152643. /**
  152644. * Sets wether or not the motion blur post-process should be object based or screen based
  152645. */
  152646. set objectBasedMotionBlur(value: boolean);
  152647. /**
  152648. * List of animations for the pipeline (IAnimatable implementation)
  152649. */
  152650. animations: Animation[];
  152651. /**
  152652. * Private members
  152653. */
  152654. private _scene;
  152655. private _currentDepthOfFieldSource;
  152656. private _basePostProcess;
  152657. private _fixedExposure;
  152658. private _currentExposure;
  152659. private _hdrAutoExposure;
  152660. private _hdrCurrentLuminance;
  152661. private _motionStrength;
  152662. private _isObjectBasedMotionBlur;
  152663. private _floatTextureType;
  152664. private _camerasToBeAttached;
  152665. private _ratio;
  152666. private _bloomEnabled;
  152667. private _depthOfFieldEnabled;
  152668. private _vlsEnabled;
  152669. private _lensFlareEnabled;
  152670. private _hdrEnabled;
  152671. private _motionBlurEnabled;
  152672. private _fxaaEnabled;
  152673. private _screenSpaceReflectionsEnabled;
  152674. private _motionBlurSamples;
  152675. private _volumetricLightStepsCount;
  152676. private _samples;
  152677. /**
  152678. * @ignore
  152679. * Specifies if the bloom pipeline is enabled
  152680. */
  152681. get BloomEnabled(): boolean;
  152682. set BloomEnabled(enabled: boolean);
  152683. /**
  152684. * @ignore
  152685. * Specifies if the depth of field pipeline is enabed
  152686. */
  152687. get DepthOfFieldEnabled(): boolean;
  152688. set DepthOfFieldEnabled(enabled: boolean);
  152689. /**
  152690. * @ignore
  152691. * Specifies if the lens flare pipeline is enabed
  152692. */
  152693. get LensFlareEnabled(): boolean;
  152694. set LensFlareEnabled(enabled: boolean);
  152695. /**
  152696. * @ignore
  152697. * Specifies if the HDR pipeline is enabled
  152698. */
  152699. get HDREnabled(): boolean;
  152700. set HDREnabled(enabled: boolean);
  152701. /**
  152702. * @ignore
  152703. * Specifies if the volumetric lights scattering effect is enabled
  152704. */
  152705. get VLSEnabled(): boolean;
  152706. set VLSEnabled(enabled: boolean);
  152707. /**
  152708. * @ignore
  152709. * Specifies if the motion blur effect is enabled
  152710. */
  152711. get MotionBlurEnabled(): boolean;
  152712. set MotionBlurEnabled(enabled: boolean);
  152713. /**
  152714. * Specifies if anti-aliasing is enabled
  152715. */
  152716. get fxaaEnabled(): boolean;
  152717. set fxaaEnabled(enabled: boolean);
  152718. /**
  152719. * Specifies if screen space reflections are enabled.
  152720. */
  152721. get screenSpaceReflectionsEnabled(): boolean;
  152722. set screenSpaceReflectionsEnabled(enabled: boolean);
  152723. /**
  152724. * Specifies the number of steps used to calculate the volumetric lights
  152725. * Typically in interval [50, 200]
  152726. */
  152727. get volumetricLightStepsCount(): number;
  152728. set volumetricLightStepsCount(count: number);
  152729. /**
  152730. * Specifies the number of samples used for the motion blur effect
  152731. * Typically in interval [16, 64]
  152732. */
  152733. get motionBlurSamples(): number;
  152734. set motionBlurSamples(samples: number);
  152735. /**
  152736. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152737. */
  152738. get samples(): number;
  152739. set samples(sampleCount: number);
  152740. /**
  152741. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152742. * @constructor
  152743. * @param name The rendering pipeline name
  152744. * @param scene The scene linked to this pipeline
  152745. * @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)
  152746. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  152747. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152748. */
  152749. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  152750. private _buildPipeline;
  152751. private _createDownSampleX4PostProcess;
  152752. private _createBrightPassPostProcess;
  152753. private _createBlurPostProcesses;
  152754. private _createTextureAdderPostProcess;
  152755. private _createVolumetricLightPostProcess;
  152756. private _createLuminancePostProcesses;
  152757. private _createHdrPostProcess;
  152758. private _createLensFlarePostProcess;
  152759. private _createDepthOfFieldPostProcess;
  152760. private _createMotionBlurPostProcess;
  152761. private _getDepthTexture;
  152762. private _disposePostProcesses;
  152763. /**
  152764. * Dispose of the pipeline and stop all post processes
  152765. */
  152766. dispose(): void;
  152767. /**
  152768. * Serialize the rendering pipeline (Used when exporting)
  152769. * @returns the serialized object
  152770. */
  152771. serialize(): any;
  152772. /**
  152773. * Parse the serialized pipeline
  152774. * @param source Source pipeline.
  152775. * @param scene The scene to load the pipeline to.
  152776. * @param rootUrl The URL of the serialized pipeline.
  152777. * @returns An instantiated pipeline from the serialized object.
  152778. */
  152779. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  152780. /**
  152781. * Luminance steps
  152782. */
  152783. static LuminanceSteps: number;
  152784. }
  152785. }
  152786. declare module BABYLON {
  152787. /** @hidden */
  152788. export var stereoscopicInterlacePixelShader: {
  152789. name: string;
  152790. shader: string;
  152791. };
  152792. }
  152793. declare module BABYLON {
  152794. /**
  152795. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  152796. */
  152797. export class StereoscopicInterlacePostProcessI extends PostProcess {
  152798. private _stepSize;
  152799. private _passedProcess;
  152800. /**
  152801. * Gets a string identifying the name of the class
  152802. * @returns "StereoscopicInterlacePostProcessI" string
  152803. */
  152804. getClassName(): string;
  152805. /**
  152806. * Initializes a StereoscopicInterlacePostProcessI
  152807. * @param name The name of the effect.
  152808. * @param rigCameras The rig cameras to be appled to the post process
  152809. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152810. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152812. * @param engine The engine which the post process will be applied. (default: current engine)
  152813. * @param reusable If the post process can be reused on the same frame. (default: false)
  152814. */
  152815. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152816. }
  152817. /**
  152818. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152819. */
  152820. export class StereoscopicInterlacePostProcess extends PostProcess {
  152821. private _stepSize;
  152822. private _passedProcess;
  152823. /**
  152824. * Gets a string identifying the name of the class
  152825. * @returns "StereoscopicInterlacePostProcess" string
  152826. */
  152827. getClassName(): string;
  152828. /**
  152829. * Initializes a StereoscopicInterlacePostProcess
  152830. * @param name The name of the effect.
  152831. * @param rigCameras The rig cameras to be appled to the post process
  152832. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152834. * @param engine The engine which the post process will be applied. (default: current engine)
  152835. * @param reusable If the post process can be reused on the same frame. (default: false)
  152836. */
  152837. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152838. }
  152839. }
  152840. declare module BABYLON {
  152841. /** @hidden */
  152842. export var tonemapPixelShader: {
  152843. name: string;
  152844. shader: string;
  152845. };
  152846. }
  152847. declare module BABYLON {
  152848. /** Defines operator used for tonemapping */
  152849. export enum TonemappingOperator {
  152850. /** Hable */
  152851. Hable = 0,
  152852. /** Reinhard */
  152853. Reinhard = 1,
  152854. /** HejiDawson */
  152855. HejiDawson = 2,
  152856. /** Photographic */
  152857. Photographic = 3
  152858. }
  152859. /**
  152860. * Defines a post process to apply tone mapping
  152861. */
  152862. export class TonemapPostProcess extends PostProcess {
  152863. private _operator;
  152864. /** Defines the required exposure adjustement */
  152865. exposureAdjustment: number;
  152866. /**
  152867. * Gets a string identifying the name of the class
  152868. * @returns "TonemapPostProcess" string
  152869. */
  152870. getClassName(): string;
  152871. /**
  152872. * Creates a new TonemapPostProcess
  152873. * @param name defines the name of the postprocess
  152874. * @param _operator defines the operator to use
  152875. * @param exposureAdjustment defines the required exposure adjustement
  152876. * @param camera defines the camera to use (can be null)
  152877. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152878. * @param engine defines the hosting engine (can be ignore if camera is set)
  152879. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152880. */
  152881. constructor(name: string, _operator: TonemappingOperator,
  152882. /** Defines the required exposure adjustement */
  152883. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152884. }
  152885. }
  152886. declare module BABYLON {
  152887. /** @hidden */
  152888. export var volumetricLightScatteringPixelShader: {
  152889. name: string;
  152890. shader: string;
  152891. };
  152892. }
  152893. declare module BABYLON {
  152894. /** @hidden */
  152895. export var volumetricLightScatteringPassVertexShader: {
  152896. name: string;
  152897. shader: string;
  152898. };
  152899. }
  152900. declare module BABYLON {
  152901. /** @hidden */
  152902. export var volumetricLightScatteringPassPixelShader: {
  152903. name: string;
  152904. shader: string;
  152905. };
  152906. }
  152907. declare module BABYLON {
  152908. /**
  152909. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152910. */
  152911. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152912. private _volumetricLightScatteringPass;
  152913. private _volumetricLightScatteringRTT;
  152914. private _viewPort;
  152915. private _screenCoordinates;
  152916. private _cachedDefines;
  152917. /**
  152918. * If not undefined, the mesh position is computed from the attached node position
  152919. */
  152920. attachedNode: {
  152921. position: Vector3;
  152922. };
  152923. /**
  152924. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152925. */
  152926. customMeshPosition: Vector3;
  152927. /**
  152928. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152929. */
  152930. useCustomMeshPosition: boolean;
  152931. /**
  152932. * If the post-process should inverse the light scattering direction
  152933. */
  152934. invert: boolean;
  152935. /**
  152936. * The internal mesh used by the post-process
  152937. */
  152938. mesh: Mesh;
  152939. /**
  152940. * @hidden
  152941. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152942. */
  152943. get useDiffuseColor(): boolean;
  152944. set useDiffuseColor(useDiffuseColor: boolean);
  152945. /**
  152946. * Array containing the excluded meshes not rendered in the internal pass
  152947. */
  152948. excludedMeshes: AbstractMesh[];
  152949. /**
  152950. * Controls the overall intensity of the post-process
  152951. */
  152952. exposure: number;
  152953. /**
  152954. * Dissipates each sample's contribution in range [0, 1]
  152955. */
  152956. decay: number;
  152957. /**
  152958. * Controls the overall intensity of each sample
  152959. */
  152960. weight: number;
  152961. /**
  152962. * Controls the density of each sample
  152963. */
  152964. density: number;
  152965. /**
  152966. * @constructor
  152967. * @param name The post-process name
  152968. * @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)
  152969. * @param camera The camera that the post-process will be attached to
  152970. * @param mesh The mesh used to create the light scattering
  152971. * @param samples The post-process quality, default 100
  152972. * @param samplingModeThe post-process filtering mode
  152973. * @param engine The babylon engine
  152974. * @param reusable If the post-process is reusable
  152975. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152976. */
  152977. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152978. /**
  152979. * Returns the string "VolumetricLightScatteringPostProcess"
  152980. * @returns "VolumetricLightScatteringPostProcess"
  152981. */
  152982. getClassName(): string;
  152983. private _isReady;
  152984. /**
  152985. * Sets the new light position for light scattering effect
  152986. * @param position The new custom light position
  152987. */
  152988. setCustomMeshPosition(position: Vector3): void;
  152989. /**
  152990. * Returns the light position for light scattering effect
  152991. * @return Vector3 The custom light position
  152992. */
  152993. getCustomMeshPosition(): Vector3;
  152994. /**
  152995. * Disposes the internal assets and detaches the post-process from the camera
  152996. */
  152997. dispose(camera: Camera): void;
  152998. /**
  152999. * Returns the render target texture used by the post-process
  153000. * @return the render target texture used by the post-process
  153001. */
  153002. getPass(): RenderTargetTexture;
  153003. private _meshExcluded;
  153004. private _createPass;
  153005. private _updateMeshScreenCoordinates;
  153006. /**
  153007. * Creates a default mesh for the Volumeric Light Scattering post-process
  153008. * @param name The mesh name
  153009. * @param scene The scene where to create the mesh
  153010. * @return the default mesh
  153011. */
  153012. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  153013. }
  153014. }
  153015. declare module BABYLON {
  153016. /** @hidden */
  153017. export var screenSpaceCurvaturePixelShader: {
  153018. name: string;
  153019. shader: string;
  153020. };
  153021. }
  153022. declare module BABYLON {
  153023. /**
  153024. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  153025. */
  153026. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  153027. /**
  153028. * Defines how much ridge the curvature effect displays.
  153029. */
  153030. ridge: number;
  153031. /**
  153032. * Defines how much valley the curvature effect displays.
  153033. */
  153034. valley: number;
  153035. private _geometryBufferRenderer;
  153036. /**
  153037. * Gets a string identifying the name of the class
  153038. * @returns "ScreenSpaceCurvaturePostProcess" string
  153039. */
  153040. getClassName(): string;
  153041. /**
  153042. * Creates a new instance ScreenSpaceCurvaturePostProcess
  153043. * @param name The name of the effect.
  153044. * @param scene The scene containing the objects to blur according to their velocity.
  153045. * @param options The required width/height ratio to downsize to before computing the render pass.
  153046. * @param camera The camera to apply the render pass to.
  153047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153048. * @param engine The engine which the post process will be applied. (default: current engine)
  153049. * @param reusable If the post process can be reused on the same frame. (default: false)
  153050. * @param textureType Type of textures used when performing the post process. (default: 0)
  153051. * @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)
  153052. */
  153053. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  153054. /**
  153055. * Support test.
  153056. */
  153057. static get IsSupported(): boolean;
  153058. /** @hidden */
  153059. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  153060. }
  153061. }
  153062. declare module BABYLON {
  153063. interface Scene {
  153064. /** @hidden (Backing field) */
  153065. _boundingBoxRenderer: BoundingBoxRenderer;
  153066. /** @hidden (Backing field) */
  153067. _forceShowBoundingBoxes: boolean;
  153068. /**
  153069. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  153070. */
  153071. forceShowBoundingBoxes: boolean;
  153072. /**
  153073. * Gets the bounding box renderer associated with the scene
  153074. * @returns a BoundingBoxRenderer
  153075. */
  153076. getBoundingBoxRenderer(): BoundingBoxRenderer;
  153077. }
  153078. interface AbstractMesh {
  153079. /** @hidden (Backing field) */
  153080. _showBoundingBox: boolean;
  153081. /**
  153082. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  153083. */
  153084. showBoundingBox: boolean;
  153085. }
  153086. /**
  153087. * Component responsible of rendering the bounding box of the meshes in a scene.
  153088. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  153089. */
  153090. export class BoundingBoxRenderer implements ISceneComponent {
  153091. /**
  153092. * The component name helpfull to identify the component in the list of scene components.
  153093. */
  153094. readonly name: string;
  153095. /**
  153096. * The scene the component belongs to.
  153097. */
  153098. scene: Scene;
  153099. /**
  153100. * Color of the bounding box lines placed in front of an object
  153101. */
  153102. frontColor: Color3;
  153103. /**
  153104. * Color of the bounding box lines placed behind an object
  153105. */
  153106. backColor: Color3;
  153107. /**
  153108. * Defines if the renderer should show the back lines or not
  153109. */
  153110. showBackLines: boolean;
  153111. /**
  153112. * Observable raised before rendering a bounding box
  153113. */
  153114. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  153115. /**
  153116. * Observable raised after rendering a bounding box
  153117. */
  153118. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  153119. /**
  153120. * @hidden
  153121. */
  153122. renderList: SmartArray<BoundingBox>;
  153123. private _colorShader;
  153124. private _vertexBuffers;
  153125. private _indexBuffer;
  153126. private _fillIndexBuffer;
  153127. private _fillIndexData;
  153128. /**
  153129. * Instantiates a new bounding box renderer in a scene.
  153130. * @param scene the scene the renderer renders in
  153131. */
  153132. constructor(scene: Scene);
  153133. /**
  153134. * Registers the component in a given scene
  153135. */
  153136. register(): void;
  153137. private _evaluateSubMesh;
  153138. private _activeMesh;
  153139. private _prepareRessources;
  153140. private _createIndexBuffer;
  153141. /**
  153142. * Rebuilds the elements related to this component in case of
  153143. * context lost for instance.
  153144. */
  153145. rebuild(): void;
  153146. /**
  153147. * @hidden
  153148. */
  153149. reset(): void;
  153150. /**
  153151. * Render the bounding boxes of a specific rendering group
  153152. * @param renderingGroupId defines the rendering group to render
  153153. */
  153154. render(renderingGroupId: number): void;
  153155. /**
  153156. * In case of occlusion queries, we can render the occlusion bounding box through this method
  153157. * @param mesh Define the mesh to render the occlusion bounding box for
  153158. */
  153159. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  153160. /**
  153161. * Dispose and release the resources attached to this renderer.
  153162. */
  153163. dispose(): void;
  153164. }
  153165. }
  153166. declare module BABYLON {
  153167. interface Scene {
  153168. /** @hidden (Backing field) */
  153169. _depthRenderer: {
  153170. [id: string]: DepthRenderer;
  153171. };
  153172. /**
  153173. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  153174. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  153175. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  153176. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  153177. * @returns the created depth renderer
  153178. */
  153179. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  153180. /**
  153181. * Disables a depth renderer for a given camera
  153182. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  153183. */
  153184. disableDepthRenderer(camera?: Nullable<Camera>): void;
  153185. }
  153186. /**
  153187. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  153188. * in several rendering techniques.
  153189. */
  153190. export class DepthRendererSceneComponent implements ISceneComponent {
  153191. /**
  153192. * The component name helpfull to identify the component in the list of scene components.
  153193. */
  153194. readonly name: string;
  153195. /**
  153196. * The scene the component belongs to.
  153197. */
  153198. scene: Scene;
  153199. /**
  153200. * Creates a new instance of the component for the given scene
  153201. * @param scene Defines the scene to register the component in
  153202. */
  153203. constructor(scene: Scene);
  153204. /**
  153205. * Registers the component in a given scene
  153206. */
  153207. register(): void;
  153208. /**
  153209. * Rebuilds the elements related to this component in case of
  153210. * context lost for instance.
  153211. */
  153212. rebuild(): void;
  153213. /**
  153214. * Disposes the component and the associated ressources
  153215. */
  153216. dispose(): void;
  153217. private _gatherRenderTargets;
  153218. private _gatherActiveCameraRenderTargets;
  153219. }
  153220. }
  153221. declare module BABYLON {
  153222. interface AbstractScene {
  153223. /** @hidden (Backing field) */
  153224. _prePassRenderer: Nullable<PrePassRenderer>;
  153225. /**
  153226. * Gets or Sets the current prepass renderer associated to the scene.
  153227. */
  153228. prePassRenderer: Nullable<PrePassRenderer>;
  153229. /**
  153230. * Enables the prepass and associates it with the scene
  153231. * @returns the PrePassRenderer
  153232. */
  153233. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  153234. /**
  153235. * Disables the prepass associated with the scene
  153236. */
  153237. disablePrePassRenderer(): void;
  153238. }
  153239. /**
  153240. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153241. * in several rendering techniques.
  153242. */
  153243. export class PrePassRendererSceneComponent implements ISceneComponent {
  153244. /**
  153245. * The component name helpful to identify the component in the list of scene components.
  153246. */
  153247. readonly name: string;
  153248. /**
  153249. * The scene the component belongs to.
  153250. */
  153251. scene: Scene;
  153252. /**
  153253. * Creates a new instance of the component for the given scene
  153254. * @param scene Defines the scene to register the component in
  153255. */
  153256. constructor(scene: Scene);
  153257. /**
  153258. * Registers the component in a given scene
  153259. */
  153260. register(): void;
  153261. private _beforeCameraDraw;
  153262. private _afterCameraDraw;
  153263. private _beforeClearStage;
  153264. /**
  153265. * Rebuilds the elements related to this component in case of
  153266. * context lost for instance.
  153267. */
  153268. rebuild(): void;
  153269. /**
  153270. * Disposes the component and the associated ressources
  153271. */
  153272. dispose(): void;
  153273. }
  153274. }
  153275. declare module BABYLON {
  153276. /** @hidden */
  153277. export var fibonacci: {
  153278. name: string;
  153279. shader: string;
  153280. };
  153281. }
  153282. declare module BABYLON {
  153283. /** @hidden */
  153284. export var diffusionProfile: {
  153285. name: string;
  153286. shader: string;
  153287. };
  153288. }
  153289. declare module BABYLON {
  153290. /** @hidden */
  153291. export var subSurfaceScatteringPixelShader: {
  153292. name: string;
  153293. shader: string;
  153294. };
  153295. }
  153296. declare module BABYLON {
  153297. /**
  153298. * Sub surface scattering post process
  153299. */
  153300. export class SubSurfaceScatteringPostProcess extends PostProcess {
  153301. /**
  153302. * Gets a string identifying the name of the class
  153303. * @returns "SubSurfaceScatteringPostProcess" string
  153304. */
  153305. getClassName(): string;
  153306. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  153307. }
  153308. }
  153309. declare module BABYLON {
  153310. /**
  153311. * Contains all parameters needed for the prepass to perform
  153312. * screen space subsurface scattering
  153313. */
  153314. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  153315. /** @hidden */
  153316. static _SceneComponentInitialization: (scene: Scene) => void;
  153317. private _ssDiffusionS;
  153318. private _ssFilterRadii;
  153319. private _ssDiffusionD;
  153320. /**
  153321. * Post process to attach for screen space subsurface scattering
  153322. */
  153323. postProcess: SubSurfaceScatteringPostProcess;
  153324. /**
  153325. * Diffusion profile color for subsurface scattering
  153326. */
  153327. get ssDiffusionS(): number[];
  153328. /**
  153329. * Diffusion profile max color channel value for subsurface scattering
  153330. */
  153331. get ssDiffusionD(): number[];
  153332. /**
  153333. * Diffusion profile filter radius for subsurface scattering
  153334. */
  153335. get ssFilterRadii(): number[];
  153336. /**
  153337. * Is subsurface enabled
  153338. */
  153339. enabled: boolean;
  153340. /**
  153341. * Name of the configuration
  153342. */
  153343. name: string;
  153344. /**
  153345. * Diffusion profile colors for subsurface scattering
  153346. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  153347. * See ...
  153348. * Note that you can only store up to 5 of them
  153349. */
  153350. ssDiffusionProfileColors: Color3[];
  153351. /**
  153352. * Defines the ratio real world => scene units.
  153353. * Used for subsurface scattering
  153354. */
  153355. metersPerUnit: number;
  153356. /**
  153357. * Textures that should be present in the MRT for this effect to work
  153358. */
  153359. readonly texturesRequired: number[];
  153360. private _scene;
  153361. /**
  153362. * Builds a subsurface configuration object
  153363. * @param scene The scene
  153364. */
  153365. constructor(scene: Scene);
  153366. /**
  153367. * Adds a new diffusion profile.
  153368. * Useful for more realistic subsurface scattering on diverse materials.
  153369. * @param color The color of the diffusion profile. Should be the average color of the material.
  153370. * @return The index of the diffusion profile for the material subsurface configuration
  153371. */
  153372. addDiffusionProfile(color: Color3): number;
  153373. /**
  153374. * Creates the sss post process
  153375. * @return The created post process
  153376. */
  153377. createPostProcess(): SubSurfaceScatteringPostProcess;
  153378. /**
  153379. * Deletes all diffusion profiles.
  153380. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  153381. */
  153382. clearAllDiffusionProfiles(): void;
  153383. /**
  153384. * Disposes this object
  153385. */
  153386. dispose(): void;
  153387. /**
  153388. * @hidden
  153389. * https://zero-radiance.github.io/post/sampling-diffusion/
  153390. *
  153391. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  153392. * ------------------------------------------------------------------------------------
  153393. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  153394. * PDF[r, phi, s] = r * R[r, phi, s]
  153395. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  153396. * ------------------------------------------------------------------------------------
  153397. * We importance sample the color channel with the widest scattering distance.
  153398. */
  153399. getDiffusionProfileParameters(color: Color3): number;
  153400. /**
  153401. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  153402. * 'u' is the random number (the value of the CDF): [0, 1).
  153403. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  153404. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  153405. */
  153406. private _sampleBurleyDiffusionProfile;
  153407. }
  153408. }
  153409. declare module BABYLON {
  153410. interface AbstractScene {
  153411. /** @hidden (Backing field) */
  153412. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153413. /**
  153414. * Gets or Sets the current prepass renderer associated to the scene.
  153415. */
  153416. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  153417. /**
  153418. * Enables the subsurface effect for prepass
  153419. * @returns the SubSurfaceConfiguration
  153420. */
  153421. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  153422. /**
  153423. * Disables the subsurface effect for prepass
  153424. */
  153425. disableSubSurfaceForPrePass(): void;
  153426. }
  153427. /**
  153428. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153429. * in several rendering techniques.
  153430. */
  153431. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  153432. /**
  153433. * The component name helpful to identify the component in the list of scene components.
  153434. */
  153435. readonly name: string;
  153436. /**
  153437. * The scene the component belongs to.
  153438. */
  153439. scene: Scene;
  153440. /**
  153441. * Creates a new instance of the component for the given scene
  153442. * @param scene Defines the scene to register the component in
  153443. */
  153444. constructor(scene: Scene);
  153445. /**
  153446. * Registers the component in a given scene
  153447. */
  153448. register(): void;
  153449. /**
  153450. * Serializes the component data to the specified json object
  153451. * @param serializationObject The object to serialize to
  153452. */
  153453. serialize(serializationObject: any): void;
  153454. /**
  153455. * Adds all the elements from the container to the scene
  153456. * @param container the container holding the elements
  153457. */
  153458. addFromContainer(container: AbstractScene): void;
  153459. /**
  153460. * Removes all the elements in the container from the scene
  153461. * @param container contains the elements to remove
  153462. * @param dispose if the removed element should be disposed (default: false)
  153463. */
  153464. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  153465. /**
  153466. * Rebuilds the elements related to this component in case of
  153467. * context lost for instance.
  153468. */
  153469. rebuild(): void;
  153470. /**
  153471. * Disposes the component and the associated ressources
  153472. */
  153473. dispose(): void;
  153474. }
  153475. }
  153476. declare module BABYLON {
  153477. /** @hidden */
  153478. export var outlinePixelShader: {
  153479. name: string;
  153480. shader: string;
  153481. };
  153482. }
  153483. declare module BABYLON {
  153484. /** @hidden */
  153485. export var outlineVertexShader: {
  153486. name: string;
  153487. shader: string;
  153488. };
  153489. }
  153490. declare module BABYLON {
  153491. interface Scene {
  153492. /** @hidden */
  153493. _outlineRenderer: OutlineRenderer;
  153494. /**
  153495. * Gets the outline renderer associated with the scene
  153496. * @returns a OutlineRenderer
  153497. */
  153498. getOutlineRenderer(): OutlineRenderer;
  153499. }
  153500. interface AbstractMesh {
  153501. /** @hidden (Backing field) */
  153502. _renderOutline: boolean;
  153503. /**
  153504. * Gets or sets a boolean indicating if the outline must be rendered as well
  153505. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  153506. */
  153507. renderOutline: boolean;
  153508. /** @hidden (Backing field) */
  153509. _renderOverlay: boolean;
  153510. /**
  153511. * Gets or sets a boolean indicating if the overlay must be rendered as well
  153512. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  153513. */
  153514. renderOverlay: boolean;
  153515. }
  153516. /**
  153517. * This class is responsible to draw bothe outline/overlay of meshes.
  153518. * It should not be used directly but through the available method on mesh.
  153519. */
  153520. export class OutlineRenderer implements ISceneComponent {
  153521. /**
  153522. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  153523. */
  153524. private static _StencilReference;
  153525. /**
  153526. * The name of the component. Each component must have a unique name.
  153527. */
  153528. name: string;
  153529. /**
  153530. * The scene the component belongs to.
  153531. */
  153532. scene: Scene;
  153533. /**
  153534. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  153535. */
  153536. zOffset: number;
  153537. private _engine;
  153538. private _effect;
  153539. private _cachedDefines;
  153540. private _savedDepthWrite;
  153541. /**
  153542. * Instantiates a new outline renderer. (There could be only one per scene).
  153543. * @param scene Defines the scene it belongs to
  153544. */
  153545. constructor(scene: Scene);
  153546. /**
  153547. * Register the component to one instance of a scene.
  153548. */
  153549. register(): void;
  153550. /**
  153551. * Rebuilds the elements related to this component in case of
  153552. * context lost for instance.
  153553. */
  153554. rebuild(): void;
  153555. /**
  153556. * Disposes the component and the associated ressources.
  153557. */
  153558. dispose(): void;
  153559. /**
  153560. * Renders the outline in the canvas.
  153561. * @param subMesh Defines the sumesh to render
  153562. * @param batch Defines the batch of meshes in case of instances
  153563. * @param useOverlay Defines if the rendering is for the overlay or the outline
  153564. */
  153565. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  153566. /**
  153567. * Returns whether or not the outline renderer is ready for a given submesh.
  153568. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  153569. * @param subMesh Defines the submesh to check readyness for
  153570. * @param useInstances Defines wheter wee are trying to render instances or not
  153571. * @returns true if ready otherwise false
  153572. */
  153573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  153574. private _beforeRenderingMesh;
  153575. private _afterRenderingMesh;
  153576. }
  153577. }
  153578. declare module BABYLON {
  153579. /**
  153580. * Defines the basic options interface of a Sprite Frame Source Size.
  153581. */
  153582. export interface ISpriteJSONSpriteSourceSize {
  153583. /**
  153584. * number of the original width of the Frame
  153585. */
  153586. w: number;
  153587. /**
  153588. * number of the original height of the Frame
  153589. */
  153590. h: number;
  153591. }
  153592. /**
  153593. * Defines the basic options interface of a Sprite Frame Data.
  153594. */
  153595. export interface ISpriteJSONSpriteFrameData {
  153596. /**
  153597. * number of the x offset of the Frame
  153598. */
  153599. x: number;
  153600. /**
  153601. * number of the y offset of the Frame
  153602. */
  153603. y: number;
  153604. /**
  153605. * number of the width of the Frame
  153606. */
  153607. w: number;
  153608. /**
  153609. * number of the height of the Frame
  153610. */
  153611. h: number;
  153612. }
  153613. /**
  153614. * Defines the basic options interface of a JSON Sprite.
  153615. */
  153616. export interface ISpriteJSONSprite {
  153617. /**
  153618. * string name of the Frame
  153619. */
  153620. filename: string;
  153621. /**
  153622. * ISpriteJSONSpriteFrame basic object of the frame data
  153623. */
  153624. frame: ISpriteJSONSpriteFrameData;
  153625. /**
  153626. * boolean to flag is the frame was rotated.
  153627. */
  153628. rotated: boolean;
  153629. /**
  153630. * boolean to flag is the frame was trimmed.
  153631. */
  153632. trimmed: boolean;
  153633. /**
  153634. * ISpriteJSONSpriteFrame basic object of the source data
  153635. */
  153636. spriteSourceSize: ISpriteJSONSpriteFrameData;
  153637. /**
  153638. * ISpriteJSONSpriteFrame basic object of the source data
  153639. */
  153640. sourceSize: ISpriteJSONSpriteSourceSize;
  153641. }
  153642. /**
  153643. * Defines the basic options interface of a JSON atlas.
  153644. */
  153645. export interface ISpriteJSONAtlas {
  153646. /**
  153647. * Array of objects that contain the frame data.
  153648. */
  153649. frames: Array<ISpriteJSONSprite>;
  153650. /**
  153651. * object basic object containing the sprite meta data.
  153652. */
  153653. meta?: object;
  153654. }
  153655. }
  153656. declare module BABYLON {
  153657. /** @hidden */
  153658. export var spriteMapPixelShader: {
  153659. name: string;
  153660. shader: string;
  153661. };
  153662. }
  153663. declare module BABYLON {
  153664. /** @hidden */
  153665. export var spriteMapVertexShader: {
  153666. name: string;
  153667. shader: string;
  153668. };
  153669. }
  153670. declare module BABYLON {
  153671. /**
  153672. * Defines the basic options interface of a SpriteMap
  153673. */
  153674. export interface ISpriteMapOptions {
  153675. /**
  153676. * Vector2 of the number of cells in the grid.
  153677. */
  153678. stageSize?: Vector2;
  153679. /**
  153680. * Vector2 of the size of the output plane in World Units.
  153681. */
  153682. outputSize?: Vector2;
  153683. /**
  153684. * Vector3 of the position of the output plane in World Units.
  153685. */
  153686. outputPosition?: Vector3;
  153687. /**
  153688. * Vector3 of the rotation of the output plane.
  153689. */
  153690. outputRotation?: Vector3;
  153691. /**
  153692. * number of layers that the system will reserve in resources.
  153693. */
  153694. layerCount?: number;
  153695. /**
  153696. * number of max animation frames a single cell will reserve in resources.
  153697. */
  153698. maxAnimationFrames?: number;
  153699. /**
  153700. * number cell index of the base tile when the system compiles.
  153701. */
  153702. baseTile?: number;
  153703. /**
  153704. * boolean flip the sprite after its been repositioned by the framing data.
  153705. */
  153706. flipU?: boolean;
  153707. /**
  153708. * Vector3 scalar of the global RGB values of the SpriteMap.
  153709. */
  153710. colorMultiply?: Vector3;
  153711. }
  153712. /**
  153713. * Defines the IDisposable interface in order to be cleanable from resources.
  153714. */
  153715. export interface ISpriteMap extends IDisposable {
  153716. /**
  153717. * String name of the SpriteMap.
  153718. */
  153719. name: string;
  153720. /**
  153721. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153722. */
  153723. atlasJSON: ISpriteJSONAtlas;
  153724. /**
  153725. * Texture of the SpriteMap.
  153726. */
  153727. spriteSheet: Texture;
  153728. /**
  153729. * The parameters to initialize the SpriteMap with.
  153730. */
  153731. options: ISpriteMapOptions;
  153732. }
  153733. /**
  153734. * Class used to manage a grid restricted sprite deployment on an Output plane.
  153735. */
  153736. export class SpriteMap implements ISpriteMap {
  153737. /** The Name of the spriteMap */
  153738. name: string;
  153739. /** The JSON file with the frame and meta data */
  153740. atlasJSON: ISpriteJSONAtlas;
  153741. /** The systems Sprite Sheet Texture */
  153742. spriteSheet: Texture;
  153743. /** Arguments passed with the Constructor */
  153744. options: ISpriteMapOptions;
  153745. /** Public Sprite Storage array, parsed from atlasJSON */
  153746. sprites: Array<ISpriteJSONSprite>;
  153747. /** Returns the Number of Sprites in the System */
  153748. get spriteCount(): number;
  153749. /** Returns the Position of Output Plane*/
  153750. get position(): Vector3;
  153751. /** Returns the Position of Output Plane*/
  153752. set position(v: Vector3);
  153753. /** Returns the Rotation of Output Plane*/
  153754. get rotation(): Vector3;
  153755. /** Returns the Rotation of Output Plane*/
  153756. set rotation(v: Vector3);
  153757. /** Sets the AnimationMap*/
  153758. get animationMap(): RawTexture;
  153759. /** Sets the AnimationMap*/
  153760. set animationMap(v: RawTexture);
  153761. /** Scene that the SpriteMap was created in */
  153762. private _scene;
  153763. /** Texture Buffer of Float32 that holds tile frame data*/
  153764. private _frameMap;
  153765. /** Texture Buffers of Float32 that holds tileMap data*/
  153766. private _tileMaps;
  153767. /** Texture Buffer of Float32 that holds Animation Data*/
  153768. private _animationMap;
  153769. /** Custom ShaderMaterial Central to the System*/
  153770. private _material;
  153771. /** Custom ShaderMaterial Central to the System*/
  153772. private _output;
  153773. /** Systems Time Ticker*/
  153774. private _time;
  153775. /**
  153776. * Creates a new SpriteMap
  153777. * @param name defines the SpriteMaps Name
  153778. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  153779. * @param spriteSheet is the Texture that the Sprites are on.
  153780. * @param options a basic deployment configuration
  153781. * @param scene The Scene that the map is deployed on
  153782. */
  153783. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  153784. /**
  153785. * Returns tileID location
  153786. * @returns Vector2 the cell position ID
  153787. */
  153788. getTileID(): Vector2;
  153789. /**
  153790. * Gets the UV location of the mouse over the SpriteMap.
  153791. * @returns Vector2 the UV position of the mouse interaction
  153792. */
  153793. getMousePosition(): Vector2;
  153794. /**
  153795. * Creates the "frame" texture Buffer
  153796. * -------------------------------------
  153797. * Structure of frames
  153798. * "filename": "Falling-Water-2.png",
  153799. * "frame": {"x":69,"y":103,"w":24,"h":32},
  153800. * "rotated": true,
  153801. * "trimmed": true,
  153802. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  153803. * "sourceSize": {"w":32,"h":32}
  153804. * @returns RawTexture of the frameMap
  153805. */
  153806. private _createFrameBuffer;
  153807. /**
  153808. * Creates the tileMap texture Buffer
  153809. * @param buffer normally and array of numbers, or a false to generate from scratch
  153810. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153811. * @returns RawTexture of the tileMap
  153812. */
  153813. private _createTileBuffer;
  153814. /**
  153815. * Modifies the data of the tileMaps
  153816. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153817. * @param pos is the iVector2 Coordinates of the Tile
  153818. * @param tile The SpriteIndex of the new Tile
  153819. */
  153820. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153821. /**
  153822. * Creates the animationMap texture Buffer
  153823. * @param buffer normally and array of numbers, or a false to generate from scratch
  153824. * @returns RawTexture of the animationMap
  153825. */
  153826. private _createTileAnimationBuffer;
  153827. /**
  153828. * Modifies the data of the animationMap
  153829. * @param cellID is the Index of the Sprite
  153830. * @param _frame is the target Animation frame
  153831. * @param toCell is the Target Index of the next frame of the animation
  153832. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153833. * @param speed is a global scalar of the time variable on the map.
  153834. */
  153835. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153836. /**
  153837. * Exports the .tilemaps file
  153838. */
  153839. saveTileMaps(): void;
  153840. /**
  153841. * Imports the .tilemaps file
  153842. * @param url of the .tilemaps file
  153843. */
  153844. loadTileMaps(url: string): void;
  153845. /**
  153846. * Release associated resources
  153847. */
  153848. dispose(): void;
  153849. }
  153850. }
  153851. declare module BABYLON {
  153852. /**
  153853. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153854. * @see https://doc.babylonjs.com/babylon101/sprites
  153855. */
  153856. export class SpritePackedManager extends SpriteManager {
  153857. /** defines the packed manager's name */
  153858. name: string;
  153859. /**
  153860. * Creates a new sprite manager from a packed sprite sheet
  153861. * @param name defines the manager's name
  153862. * @param imgUrl defines the sprite sheet url
  153863. * @param capacity defines the maximum allowed number of sprites
  153864. * @param scene defines the hosting scene
  153865. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153866. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153867. * @param samplingMode defines the smapling mode to use with spritesheet
  153868. * @param fromPacked set to true; do not alter
  153869. */
  153870. constructor(
  153871. /** defines the packed manager's name */
  153872. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153873. }
  153874. }
  153875. declare module BABYLON {
  153876. /**
  153877. * Defines the list of states available for a task inside a AssetsManager
  153878. */
  153879. export enum AssetTaskState {
  153880. /**
  153881. * Initialization
  153882. */
  153883. INIT = 0,
  153884. /**
  153885. * Running
  153886. */
  153887. RUNNING = 1,
  153888. /**
  153889. * Done
  153890. */
  153891. DONE = 2,
  153892. /**
  153893. * Error
  153894. */
  153895. ERROR = 3
  153896. }
  153897. /**
  153898. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153899. */
  153900. export abstract class AbstractAssetTask {
  153901. /**
  153902. * Task name
  153903. */ name: string;
  153904. /**
  153905. * Callback called when the task is successful
  153906. */
  153907. onSuccess: (task: any) => void;
  153908. /**
  153909. * Callback called when the task is not successful
  153910. */
  153911. onError: (task: any, message?: string, exception?: any) => void;
  153912. /**
  153913. * Creates a new AssetsManager
  153914. * @param name defines the name of the task
  153915. */
  153916. constructor(
  153917. /**
  153918. * Task name
  153919. */ name: string);
  153920. private _isCompleted;
  153921. private _taskState;
  153922. private _errorObject;
  153923. /**
  153924. * Get if the task is completed
  153925. */
  153926. get isCompleted(): boolean;
  153927. /**
  153928. * Gets the current state of the task
  153929. */
  153930. get taskState(): AssetTaskState;
  153931. /**
  153932. * Gets the current error object (if task is in error)
  153933. */
  153934. get errorObject(): {
  153935. message?: string;
  153936. exception?: any;
  153937. };
  153938. /**
  153939. * Internal only
  153940. * @hidden
  153941. */
  153942. _setErrorObject(message?: string, exception?: any): void;
  153943. /**
  153944. * Execute the current task
  153945. * @param scene defines the scene where you want your assets to be loaded
  153946. * @param onSuccess is a callback called when the task is successfully executed
  153947. * @param onError is a callback called if an error occurs
  153948. */
  153949. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153950. /**
  153951. * Execute the current task
  153952. * @param scene defines the scene where you want your assets to be loaded
  153953. * @param onSuccess is a callback called when the task is successfully executed
  153954. * @param onError is a callback called if an error occurs
  153955. */
  153956. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153957. /**
  153958. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153959. * This can be used with failed tasks that have the reason for failure fixed.
  153960. */
  153961. reset(): void;
  153962. private onErrorCallback;
  153963. private onDoneCallback;
  153964. }
  153965. /**
  153966. * Define the interface used by progress events raised during assets loading
  153967. */
  153968. export interface IAssetsProgressEvent {
  153969. /**
  153970. * Defines the number of remaining tasks to process
  153971. */
  153972. remainingCount: number;
  153973. /**
  153974. * Defines the total number of tasks
  153975. */
  153976. totalCount: number;
  153977. /**
  153978. * Defines the task that was just processed
  153979. */
  153980. task: AbstractAssetTask;
  153981. }
  153982. /**
  153983. * Class used to share progress information about assets loading
  153984. */
  153985. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153986. /**
  153987. * Defines the number of remaining tasks to process
  153988. */
  153989. remainingCount: number;
  153990. /**
  153991. * Defines the total number of tasks
  153992. */
  153993. totalCount: number;
  153994. /**
  153995. * Defines the task that was just processed
  153996. */
  153997. task: AbstractAssetTask;
  153998. /**
  153999. * Creates a AssetsProgressEvent
  154000. * @param remainingCount defines the number of remaining tasks to process
  154001. * @param totalCount defines the total number of tasks
  154002. * @param task defines the task that was just processed
  154003. */
  154004. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  154005. }
  154006. /**
  154007. * Define a task used by AssetsManager to load assets into a container
  154008. */
  154009. export class ContainerAssetTask extends AbstractAssetTask {
  154010. /**
  154011. * Defines the name of the task
  154012. */
  154013. name: string;
  154014. /**
  154015. * Defines the list of mesh's names you want to load
  154016. */
  154017. meshesNames: any;
  154018. /**
  154019. * Defines the root url to use as a base to load your meshes and associated resources
  154020. */
  154021. rootUrl: string;
  154022. /**
  154023. * Defines the filename or File of the scene to load from
  154024. */
  154025. sceneFilename: string | File;
  154026. /**
  154027. * Get the loaded asset container
  154028. */
  154029. loadedContainer: AssetContainer;
  154030. /**
  154031. * Gets the list of loaded meshes
  154032. */
  154033. loadedMeshes: Array<AbstractMesh>;
  154034. /**
  154035. * Gets the list of loaded particle systems
  154036. */
  154037. loadedParticleSystems: Array<IParticleSystem>;
  154038. /**
  154039. * Gets the list of loaded skeletons
  154040. */
  154041. loadedSkeletons: Array<Skeleton>;
  154042. /**
  154043. * Gets the list of loaded animation groups
  154044. */
  154045. loadedAnimationGroups: Array<AnimationGroup>;
  154046. /**
  154047. * Callback called when the task is successful
  154048. */
  154049. onSuccess: (task: ContainerAssetTask) => void;
  154050. /**
  154051. * Callback called when the task is successful
  154052. */
  154053. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  154054. /**
  154055. * Creates a new ContainerAssetTask
  154056. * @param name defines the name of the task
  154057. * @param meshesNames defines the list of mesh's names you want to load
  154058. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154059. * @param sceneFilename defines the filename or File of the scene to load from
  154060. */
  154061. constructor(
  154062. /**
  154063. * Defines the name of the task
  154064. */
  154065. name: string,
  154066. /**
  154067. * Defines the list of mesh's names you want to load
  154068. */
  154069. meshesNames: any,
  154070. /**
  154071. * Defines the root url to use as a base to load your meshes and associated resources
  154072. */
  154073. rootUrl: string,
  154074. /**
  154075. * Defines the filename or File of the scene to load from
  154076. */
  154077. sceneFilename: string | File);
  154078. /**
  154079. * Execute the current task
  154080. * @param scene defines the scene where you want your assets to be loaded
  154081. * @param onSuccess is a callback called when the task is successfully executed
  154082. * @param onError is a callback called if an error occurs
  154083. */
  154084. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154085. }
  154086. /**
  154087. * Define a task used by AssetsManager to load meshes
  154088. */
  154089. export class MeshAssetTask extends AbstractAssetTask {
  154090. /**
  154091. * Defines the name of the task
  154092. */
  154093. name: string;
  154094. /**
  154095. * Defines the list of mesh's names you want to load
  154096. */
  154097. meshesNames: any;
  154098. /**
  154099. * Defines the root url to use as a base to load your meshes and associated resources
  154100. */
  154101. rootUrl: string;
  154102. /**
  154103. * Defines the filename or File of the scene to load from
  154104. */
  154105. sceneFilename: string | File;
  154106. /**
  154107. * Gets the list of loaded meshes
  154108. */
  154109. loadedMeshes: Array<AbstractMesh>;
  154110. /**
  154111. * Gets the list of loaded particle systems
  154112. */
  154113. loadedParticleSystems: Array<IParticleSystem>;
  154114. /**
  154115. * Gets the list of loaded skeletons
  154116. */
  154117. loadedSkeletons: Array<Skeleton>;
  154118. /**
  154119. * Gets the list of loaded animation groups
  154120. */
  154121. loadedAnimationGroups: Array<AnimationGroup>;
  154122. /**
  154123. * Callback called when the task is successful
  154124. */
  154125. onSuccess: (task: MeshAssetTask) => void;
  154126. /**
  154127. * Callback called when the task is successful
  154128. */
  154129. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  154130. /**
  154131. * Creates a new MeshAssetTask
  154132. * @param name defines the name of the task
  154133. * @param meshesNames defines the list of mesh's names you want to load
  154134. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154135. * @param sceneFilename defines the filename or File of the scene to load from
  154136. */
  154137. constructor(
  154138. /**
  154139. * Defines the name of the task
  154140. */
  154141. name: string,
  154142. /**
  154143. * Defines the list of mesh's names you want to load
  154144. */
  154145. meshesNames: any,
  154146. /**
  154147. * Defines the root url to use as a base to load your meshes and associated resources
  154148. */
  154149. rootUrl: string,
  154150. /**
  154151. * Defines the filename or File of the scene to load from
  154152. */
  154153. sceneFilename: string | File);
  154154. /**
  154155. * Execute the current task
  154156. * @param scene defines the scene where you want your assets to be loaded
  154157. * @param onSuccess is a callback called when the task is successfully executed
  154158. * @param onError is a callback called if an error occurs
  154159. */
  154160. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154161. }
  154162. /**
  154163. * Define a task used by AssetsManager to load text content
  154164. */
  154165. export class TextFileAssetTask extends AbstractAssetTask {
  154166. /**
  154167. * Defines the name of the task
  154168. */
  154169. name: string;
  154170. /**
  154171. * Defines the location of the file to load
  154172. */
  154173. url: string;
  154174. /**
  154175. * Gets the loaded text string
  154176. */
  154177. text: string;
  154178. /**
  154179. * Callback called when the task is successful
  154180. */
  154181. onSuccess: (task: TextFileAssetTask) => void;
  154182. /**
  154183. * Callback called when the task is successful
  154184. */
  154185. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  154186. /**
  154187. * Creates a new TextFileAssetTask object
  154188. * @param name defines the name of the task
  154189. * @param url defines the location of the file to load
  154190. */
  154191. constructor(
  154192. /**
  154193. * Defines the name of the task
  154194. */
  154195. name: string,
  154196. /**
  154197. * Defines the location of the file to load
  154198. */
  154199. url: string);
  154200. /**
  154201. * Execute the current task
  154202. * @param scene defines the scene where you want your assets to be loaded
  154203. * @param onSuccess is a callback called when the task is successfully executed
  154204. * @param onError is a callback called if an error occurs
  154205. */
  154206. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154207. }
  154208. /**
  154209. * Define a task used by AssetsManager to load binary data
  154210. */
  154211. export class BinaryFileAssetTask extends AbstractAssetTask {
  154212. /**
  154213. * Defines the name of the task
  154214. */
  154215. name: string;
  154216. /**
  154217. * Defines the location of the file to load
  154218. */
  154219. url: string;
  154220. /**
  154221. * Gets the lodaded data (as an array buffer)
  154222. */
  154223. data: ArrayBuffer;
  154224. /**
  154225. * Callback called when the task is successful
  154226. */
  154227. onSuccess: (task: BinaryFileAssetTask) => void;
  154228. /**
  154229. * Callback called when the task is successful
  154230. */
  154231. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  154232. /**
  154233. * Creates a new BinaryFileAssetTask object
  154234. * @param name defines the name of the new task
  154235. * @param url defines the location of the file to load
  154236. */
  154237. constructor(
  154238. /**
  154239. * Defines the name of the task
  154240. */
  154241. name: string,
  154242. /**
  154243. * Defines the location of the file to load
  154244. */
  154245. url: string);
  154246. /**
  154247. * Execute the current task
  154248. * @param scene defines the scene where you want your assets to be loaded
  154249. * @param onSuccess is a callback called when the task is successfully executed
  154250. * @param onError is a callback called if an error occurs
  154251. */
  154252. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154253. }
  154254. /**
  154255. * Define a task used by AssetsManager to load images
  154256. */
  154257. export class ImageAssetTask extends AbstractAssetTask {
  154258. /**
  154259. * Defines the name of the task
  154260. */
  154261. name: string;
  154262. /**
  154263. * Defines the location of the image to load
  154264. */
  154265. url: string;
  154266. /**
  154267. * Gets the loaded images
  154268. */
  154269. image: HTMLImageElement;
  154270. /**
  154271. * Callback called when the task is successful
  154272. */
  154273. onSuccess: (task: ImageAssetTask) => void;
  154274. /**
  154275. * Callback called when the task is successful
  154276. */
  154277. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  154278. /**
  154279. * Creates a new ImageAssetTask
  154280. * @param name defines the name of the task
  154281. * @param url defines the location of the image to load
  154282. */
  154283. constructor(
  154284. /**
  154285. * Defines the name of the task
  154286. */
  154287. name: string,
  154288. /**
  154289. * Defines the location of the image to load
  154290. */
  154291. url: string);
  154292. /**
  154293. * Execute the current task
  154294. * @param scene defines the scene where you want your assets to be loaded
  154295. * @param onSuccess is a callback called when the task is successfully executed
  154296. * @param onError is a callback called if an error occurs
  154297. */
  154298. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154299. }
  154300. /**
  154301. * Defines the interface used by texture loading tasks
  154302. */
  154303. export interface ITextureAssetTask<TEX extends BaseTexture> {
  154304. /**
  154305. * Gets the loaded texture
  154306. */
  154307. texture: TEX;
  154308. }
  154309. /**
  154310. * Define a task used by AssetsManager to load 2D textures
  154311. */
  154312. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  154313. /**
  154314. * Defines the name of the task
  154315. */
  154316. name: string;
  154317. /**
  154318. * Defines the location of the file to load
  154319. */
  154320. url: string;
  154321. /**
  154322. * Defines if mipmap should not be generated (default is false)
  154323. */
  154324. noMipmap?: boolean | undefined;
  154325. /**
  154326. * Defines if texture must be inverted on Y axis (default is true)
  154327. */
  154328. invertY: boolean;
  154329. /**
  154330. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154331. */
  154332. samplingMode: number;
  154333. /**
  154334. * Gets the loaded texture
  154335. */
  154336. texture: Texture;
  154337. /**
  154338. * Callback called when the task is successful
  154339. */
  154340. onSuccess: (task: TextureAssetTask) => void;
  154341. /**
  154342. * Callback called when the task is successful
  154343. */
  154344. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  154345. /**
  154346. * Creates a new TextureAssetTask object
  154347. * @param name defines the name of the task
  154348. * @param url defines the location of the file to load
  154349. * @param noMipmap defines if mipmap should not be generated (default is false)
  154350. * @param invertY defines if texture must be inverted on Y axis (default is true)
  154351. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154352. */
  154353. constructor(
  154354. /**
  154355. * Defines the name of the task
  154356. */
  154357. name: string,
  154358. /**
  154359. * Defines the location of the file to load
  154360. */
  154361. url: string,
  154362. /**
  154363. * Defines if mipmap should not be generated (default is false)
  154364. */
  154365. noMipmap?: boolean | undefined,
  154366. /**
  154367. * Defines if texture must be inverted on Y axis (default is true)
  154368. */
  154369. invertY?: boolean,
  154370. /**
  154371. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  154372. */
  154373. samplingMode?: number);
  154374. /**
  154375. * Execute the current task
  154376. * @param scene defines the scene where you want your assets to be loaded
  154377. * @param onSuccess is a callback called when the task is successfully executed
  154378. * @param onError is a callback called if an error occurs
  154379. */
  154380. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154381. }
  154382. /**
  154383. * Define a task used by AssetsManager to load cube textures
  154384. */
  154385. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  154386. /**
  154387. * Defines the name of the task
  154388. */
  154389. name: string;
  154390. /**
  154391. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154392. */
  154393. url: string;
  154394. /**
  154395. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154396. */
  154397. extensions?: string[] | undefined;
  154398. /**
  154399. * Defines if mipmaps should not be generated (default is false)
  154400. */
  154401. noMipmap?: boolean | undefined;
  154402. /**
  154403. * Defines the explicit list of files (undefined by default)
  154404. */
  154405. files?: string[] | undefined;
  154406. /**
  154407. * Gets the loaded texture
  154408. */
  154409. texture: CubeTexture;
  154410. /**
  154411. * Callback called when the task is successful
  154412. */
  154413. onSuccess: (task: CubeTextureAssetTask) => void;
  154414. /**
  154415. * Callback called when the task is successful
  154416. */
  154417. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  154418. /**
  154419. * Creates a new CubeTextureAssetTask
  154420. * @param name defines the name of the task
  154421. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154422. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154423. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154424. * @param files defines the explicit list of files (undefined by default)
  154425. */
  154426. constructor(
  154427. /**
  154428. * Defines the name of the task
  154429. */
  154430. name: string,
  154431. /**
  154432. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154433. */
  154434. url: string,
  154435. /**
  154436. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154437. */
  154438. extensions?: string[] | undefined,
  154439. /**
  154440. * Defines if mipmaps should not be generated (default is false)
  154441. */
  154442. noMipmap?: boolean | undefined,
  154443. /**
  154444. * Defines the explicit list of files (undefined by default)
  154445. */
  154446. files?: string[] | undefined);
  154447. /**
  154448. * Execute the current task
  154449. * @param scene defines the scene where you want your assets to be loaded
  154450. * @param onSuccess is a callback called when the task is successfully executed
  154451. * @param onError is a callback called if an error occurs
  154452. */
  154453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154454. }
  154455. /**
  154456. * Define a task used by AssetsManager to load HDR cube textures
  154457. */
  154458. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  154459. /**
  154460. * Defines the name of the task
  154461. */
  154462. name: string;
  154463. /**
  154464. * Defines the location of the file to load
  154465. */
  154466. url: string;
  154467. /**
  154468. * Defines the desired size (the more it increases the longer the generation will be)
  154469. */
  154470. size: number;
  154471. /**
  154472. * Defines if mipmaps should not be generated (default is false)
  154473. */
  154474. noMipmap: boolean;
  154475. /**
  154476. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154477. */
  154478. generateHarmonics: boolean;
  154479. /**
  154480. * 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)
  154481. */
  154482. gammaSpace: boolean;
  154483. /**
  154484. * Internal Use Only
  154485. */
  154486. reserved: boolean;
  154487. /**
  154488. * Gets the loaded texture
  154489. */
  154490. texture: HDRCubeTexture;
  154491. /**
  154492. * Callback called when the task is successful
  154493. */
  154494. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  154495. /**
  154496. * Callback called when the task is successful
  154497. */
  154498. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  154499. /**
  154500. * Creates a new HDRCubeTextureAssetTask object
  154501. * @param name defines the name of the task
  154502. * @param url defines the location of the file to load
  154503. * @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.
  154504. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154505. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154506. * @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)
  154507. * @param reserved Internal use only
  154508. */
  154509. constructor(
  154510. /**
  154511. * Defines the name of the task
  154512. */
  154513. name: string,
  154514. /**
  154515. * Defines the location of the file to load
  154516. */
  154517. url: string,
  154518. /**
  154519. * Defines the desired size (the more it increases the longer the generation will be)
  154520. */
  154521. size: number,
  154522. /**
  154523. * Defines if mipmaps should not be generated (default is false)
  154524. */
  154525. noMipmap?: boolean,
  154526. /**
  154527. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154528. */
  154529. generateHarmonics?: boolean,
  154530. /**
  154531. * 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)
  154532. */
  154533. gammaSpace?: boolean,
  154534. /**
  154535. * Internal Use Only
  154536. */
  154537. reserved?: boolean);
  154538. /**
  154539. * Execute the current task
  154540. * @param scene defines the scene where you want your assets to be loaded
  154541. * @param onSuccess is a callback called when the task is successfully executed
  154542. * @param onError is a callback called if an error occurs
  154543. */
  154544. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154545. }
  154546. /**
  154547. * Define a task used by AssetsManager to load Equirectangular cube textures
  154548. */
  154549. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  154550. /**
  154551. * Defines the name of the task
  154552. */
  154553. name: string;
  154554. /**
  154555. * Defines the location of the file to load
  154556. */
  154557. url: string;
  154558. /**
  154559. * Defines the desired size (the more it increases the longer the generation will be)
  154560. */
  154561. size: number;
  154562. /**
  154563. * Defines if mipmaps should not be generated (default is false)
  154564. */
  154565. noMipmap: boolean;
  154566. /**
  154567. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154568. * but the standard material would require them in Gamma space) (default is true)
  154569. */
  154570. gammaSpace: boolean;
  154571. /**
  154572. * Gets the loaded texture
  154573. */
  154574. texture: EquiRectangularCubeTexture;
  154575. /**
  154576. * Callback called when the task is successful
  154577. */
  154578. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  154579. /**
  154580. * Callback called when the task is successful
  154581. */
  154582. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  154583. /**
  154584. * Creates a new EquiRectangularCubeTextureAssetTask object
  154585. * @param name defines the name of the task
  154586. * @param url defines the location of the file to load
  154587. * @param size defines the desired size (the more it increases the longer the generation will be)
  154588. * If the size is omitted this implies you are using a preprocessed cubemap.
  154589. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154590. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  154591. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  154592. * (default is true)
  154593. */
  154594. constructor(
  154595. /**
  154596. * Defines the name of the task
  154597. */
  154598. name: string,
  154599. /**
  154600. * Defines the location of the file to load
  154601. */
  154602. url: string,
  154603. /**
  154604. * Defines the desired size (the more it increases the longer the generation will be)
  154605. */
  154606. size: number,
  154607. /**
  154608. * Defines if mipmaps should not be generated (default is false)
  154609. */
  154610. noMipmap?: boolean,
  154611. /**
  154612. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154613. * but the standard material would require them in Gamma space) (default is true)
  154614. */
  154615. gammaSpace?: boolean);
  154616. /**
  154617. * Execute the current task
  154618. * @param scene defines the scene where you want your assets to be loaded
  154619. * @param onSuccess is a callback called when the task is successfully executed
  154620. * @param onError is a callback called if an error occurs
  154621. */
  154622. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154623. }
  154624. /**
  154625. * This class can be used to easily import assets into a scene
  154626. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  154627. */
  154628. export class AssetsManager {
  154629. private _scene;
  154630. private _isLoading;
  154631. protected _tasks: AbstractAssetTask[];
  154632. protected _waitingTasksCount: number;
  154633. protected _totalTasksCount: number;
  154634. /**
  154635. * Callback called when all tasks are processed
  154636. */
  154637. onFinish: (tasks: AbstractAssetTask[]) => void;
  154638. /**
  154639. * Callback called when a task is successful
  154640. */
  154641. onTaskSuccess: (task: AbstractAssetTask) => void;
  154642. /**
  154643. * Callback called when a task had an error
  154644. */
  154645. onTaskError: (task: AbstractAssetTask) => void;
  154646. /**
  154647. * Callback called when a task is done (whatever the result is)
  154648. */
  154649. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  154650. /**
  154651. * Observable called when all tasks are processed
  154652. */
  154653. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  154654. /**
  154655. * Observable called when a task had an error
  154656. */
  154657. onTaskErrorObservable: Observable<AbstractAssetTask>;
  154658. /**
  154659. * Observable called when all tasks were executed
  154660. */
  154661. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  154662. /**
  154663. * Observable called when a task is done (whatever the result is)
  154664. */
  154665. onProgressObservable: Observable<IAssetsProgressEvent>;
  154666. /**
  154667. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  154668. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  154669. */
  154670. useDefaultLoadingScreen: boolean;
  154671. /**
  154672. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  154673. * when all assets have been downloaded.
  154674. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  154675. */
  154676. autoHideLoadingUI: boolean;
  154677. /**
  154678. * Creates a new AssetsManager
  154679. * @param scene defines the scene to work on
  154680. */
  154681. constructor(scene: Scene);
  154682. /**
  154683. * Add a ContainerAssetTask to the list of active tasks
  154684. * @param taskName defines the name of the new task
  154685. * @param meshesNames defines the name of meshes to load
  154686. * @param rootUrl defines the root url to use to locate files
  154687. * @param sceneFilename defines the filename of the scene file
  154688. * @returns a new ContainerAssetTask object
  154689. */
  154690. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  154691. /**
  154692. * Add a MeshAssetTask to the list of active tasks
  154693. * @param taskName defines the name of the new task
  154694. * @param meshesNames defines the name of meshes to load
  154695. * @param rootUrl defines the root url to use to locate files
  154696. * @param sceneFilename defines the filename of the scene file
  154697. * @returns a new MeshAssetTask object
  154698. */
  154699. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  154700. /**
  154701. * Add a TextFileAssetTask to the list of active tasks
  154702. * @param taskName defines the name of the new task
  154703. * @param url defines the url of the file to load
  154704. * @returns a new TextFileAssetTask object
  154705. */
  154706. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  154707. /**
  154708. * Add a BinaryFileAssetTask to the list of active tasks
  154709. * @param taskName defines the name of the new task
  154710. * @param url defines the url of the file to load
  154711. * @returns a new BinaryFileAssetTask object
  154712. */
  154713. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  154714. /**
  154715. * Add a ImageAssetTask to the list of active tasks
  154716. * @param taskName defines the name of the new task
  154717. * @param url defines the url of the file to load
  154718. * @returns a new ImageAssetTask object
  154719. */
  154720. addImageTask(taskName: string, url: string): ImageAssetTask;
  154721. /**
  154722. * Add a TextureAssetTask to the list of active tasks
  154723. * @param taskName defines the name of the new task
  154724. * @param url defines the url of the file to load
  154725. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154726. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154727. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154728. * @returns a new TextureAssetTask object
  154729. */
  154730. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154731. /**
  154732. * Add a CubeTextureAssetTask to the list of active tasks
  154733. * @param taskName defines the name of the new task
  154734. * @param url defines the url of the file to load
  154735. * @param extensions defines the extension to use to load the cube map (can be null)
  154736. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154737. * @param files defines the list of files to load (can be null)
  154738. * @returns a new CubeTextureAssetTask object
  154739. */
  154740. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  154741. /**
  154742. *
  154743. * Add a HDRCubeTextureAssetTask to the list of active tasks
  154744. * @param taskName defines the name of the new task
  154745. * @param url defines the url of the file to load
  154746. * @param size defines the size you want for the cubemap (can be null)
  154747. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154748. * @param generateHarmonics defines if you want to automatically generate (true by default)
  154749. * @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)
  154750. * @param reserved Internal use only
  154751. * @returns a new HDRCubeTextureAssetTask object
  154752. */
  154753. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  154754. /**
  154755. *
  154756. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  154757. * @param taskName defines the name of the new task
  154758. * @param url defines the url of the file to load
  154759. * @param size defines the size you want for the cubemap (can be null)
  154760. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154761. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  154762. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  154763. * @returns a new EquiRectangularCubeTextureAssetTask object
  154764. */
  154765. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  154766. /**
  154767. * Remove a task from the assets manager.
  154768. * @param task the task to remove
  154769. */
  154770. removeTask(task: AbstractAssetTask): void;
  154771. private _decreaseWaitingTasksCount;
  154772. private _runTask;
  154773. /**
  154774. * Reset the AssetsManager and remove all tasks
  154775. * @return the current instance of the AssetsManager
  154776. */
  154777. reset(): AssetsManager;
  154778. /**
  154779. * Start the loading process
  154780. * @return the current instance of the AssetsManager
  154781. */
  154782. load(): AssetsManager;
  154783. /**
  154784. * Start the loading process as an async operation
  154785. * @return a promise returning the list of failed tasks
  154786. */
  154787. loadAsync(): Promise<void>;
  154788. }
  154789. }
  154790. declare module BABYLON {
  154791. /**
  154792. * Wrapper class for promise with external resolve and reject.
  154793. */
  154794. export class Deferred<T> {
  154795. /**
  154796. * The promise associated with this deferred object.
  154797. */
  154798. readonly promise: Promise<T>;
  154799. private _resolve;
  154800. private _reject;
  154801. /**
  154802. * The resolve method of the promise associated with this deferred object.
  154803. */
  154804. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  154805. /**
  154806. * The reject method of the promise associated with this deferred object.
  154807. */
  154808. get reject(): (reason?: any) => void;
  154809. /**
  154810. * Constructor for this deferred object.
  154811. */
  154812. constructor();
  154813. }
  154814. }
  154815. declare module BABYLON {
  154816. /**
  154817. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154818. */
  154819. export class MeshExploder {
  154820. private _centerMesh;
  154821. private _meshes;
  154822. private _meshesOrigins;
  154823. private _toCenterVectors;
  154824. private _scaledDirection;
  154825. private _newPosition;
  154826. private _centerPosition;
  154827. /**
  154828. * Explodes meshes from a center mesh.
  154829. * @param meshes The meshes to explode.
  154830. * @param centerMesh The mesh to be center of explosion.
  154831. */
  154832. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154833. private _setCenterMesh;
  154834. /**
  154835. * Get class name
  154836. * @returns "MeshExploder"
  154837. */
  154838. getClassName(): string;
  154839. /**
  154840. * "Exploded meshes"
  154841. * @returns Array of meshes with the centerMesh at index 0.
  154842. */
  154843. getMeshes(): Array<Mesh>;
  154844. /**
  154845. * Explodes meshes giving a specific direction
  154846. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154847. */
  154848. explode(direction?: number): void;
  154849. }
  154850. }
  154851. declare module BABYLON {
  154852. /**
  154853. * Class used to help managing file picking and drag'n'drop
  154854. */
  154855. export class FilesInput {
  154856. /**
  154857. * List of files ready to be loaded
  154858. */
  154859. static get FilesToLoad(): {
  154860. [key: string]: File;
  154861. };
  154862. /**
  154863. * Callback called when a file is processed
  154864. */
  154865. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154866. private _engine;
  154867. private _currentScene;
  154868. private _sceneLoadedCallback;
  154869. private _progressCallback;
  154870. private _additionalRenderLoopLogicCallback;
  154871. private _textureLoadingCallback;
  154872. private _startingProcessingFilesCallback;
  154873. private _onReloadCallback;
  154874. private _errorCallback;
  154875. private _elementToMonitor;
  154876. private _sceneFileToLoad;
  154877. private _filesToLoad;
  154878. /**
  154879. * Creates a new FilesInput
  154880. * @param engine defines the rendering engine
  154881. * @param scene defines the hosting scene
  154882. * @param sceneLoadedCallback callback called when scene is loaded
  154883. * @param progressCallback callback called to track progress
  154884. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154885. * @param textureLoadingCallback callback called when a texture is loading
  154886. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154887. * @param onReloadCallback callback called when a reload is requested
  154888. * @param errorCallback callback call if an error occurs
  154889. */
  154890. 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>);
  154891. private _dragEnterHandler;
  154892. private _dragOverHandler;
  154893. private _dropHandler;
  154894. /**
  154895. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154896. * @param elementToMonitor defines the DOM element to track
  154897. */
  154898. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154899. /** Gets the current list of files to load */
  154900. get filesToLoad(): File[];
  154901. /**
  154902. * Release all associated resources
  154903. */
  154904. dispose(): void;
  154905. private renderFunction;
  154906. private drag;
  154907. private drop;
  154908. private _traverseFolder;
  154909. private _processFiles;
  154910. /**
  154911. * Load files from a drop event
  154912. * @param event defines the drop event to use as source
  154913. */
  154914. loadFiles(event: any): void;
  154915. private _processReload;
  154916. /**
  154917. * Reload the current scene from the loaded files
  154918. */
  154919. reload(): void;
  154920. }
  154921. }
  154922. declare module BABYLON {
  154923. /**
  154924. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154925. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154926. */
  154927. export class SceneOptimization {
  154928. /**
  154929. * Defines the priority of this optimization (0 by default which means first in the list)
  154930. */
  154931. priority: number;
  154932. /**
  154933. * Gets a string describing the action executed by the current optimization
  154934. * @returns description string
  154935. */
  154936. getDescription(): string;
  154937. /**
  154938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154939. * @param scene defines the current scene where to apply this optimization
  154940. * @param optimizer defines the current optimizer
  154941. * @returns true if everything that can be done was applied
  154942. */
  154943. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154944. /**
  154945. * Creates the SceneOptimization object
  154946. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154947. * @param desc defines the description associated with the optimization
  154948. */
  154949. constructor(
  154950. /**
  154951. * Defines the priority of this optimization (0 by default which means first in the list)
  154952. */
  154953. priority?: number);
  154954. }
  154955. /**
  154956. * Defines an optimization used to reduce the size of render target textures
  154957. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154958. */
  154959. export class TextureOptimization extends SceneOptimization {
  154960. /**
  154961. * Defines the priority of this optimization (0 by default which means first in the list)
  154962. */
  154963. priority: number;
  154964. /**
  154965. * 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
  154966. */
  154967. maximumSize: number;
  154968. /**
  154969. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154970. */
  154971. step: number;
  154972. /**
  154973. * Gets a string describing the action executed by the current optimization
  154974. * @returns description string
  154975. */
  154976. getDescription(): string;
  154977. /**
  154978. * Creates the TextureOptimization object
  154979. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154980. * @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
  154981. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154982. */
  154983. constructor(
  154984. /**
  154985. * Defines the priority of this optimization (0 by default which means first in the list)
  154986. */
  154987. priority?: number,
  154988. /**
  154989. * 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
  154990. */
  154991. maximumSize?: number,
  154992. /**
  154993. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154994. */
  154995. step?: number);
  154996. /**
  154997. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154998. * @param scene defines the current scene where to apply this optimization
  154999. * @param optimizer defines the current optimizer
  155000. * @returns true if everything that can be done was applied
  155001. */
  155002. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155003. }
  155004. /**
  155005. * Defines an optimization used to increase or decrease the rendering resolution
  155006. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155007. */
  155008. export class HardwareScalingOptimization extends SceneOptimization {
  155009. /**
  155010. * Defines the priority of this optimization (0 by default which means first in the list)
  155011. */
  155012. priority: number;
  155013. /**
  155014. * Defines the maximum scale to use (2 by default)
  155015. */
  155016. maximumScale: number;
  155017. /**
  155018. * Defines the step to use between two passes (0.5 by default)
  155019. */
  155020. step: number;
  155021. private _currentScale;
  155022. private _directionOffset;
  155023. /**
  155024. * Gets a string describing the action executed by the current optimization
  155025. * @return description string
  155026. */
  155027. getDescription(): string;
  155028. /**
  155029. * Creates the HardwareScalingOptimization object
  155030. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155031. * @param maximumScale defines the maximum scale to use (2 by default)
  155032. * @param step defines the step to use between two passes (0.5 by default)
  155033. */
  155034. constructor(
  155035. /**
  155036. * Defines the priority of this optimization (0 by default which means first in the list)
  155037. */
  155038. priority?: number,
  155039. /**
  155040. * Defines the maximum scale to use (2 by default)
  155041. */
  155042. maximumScale?: number,
  155043. /**
  155044. * Defines the step to use between two passes (0.5 by default)
  155045. */
  155046. step?: number);
  155047. /**
  155048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155049. * @param scene defines the current scene where to apply this optimization
  155050. * @param optimizer defines the current optimizer
  155051. * @returns true if everything that can be done was applied
  155052. */
  155053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155054. }
  155055. /**
  155056. * Defines an optimization used to remove shadows
  155057. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155058. */
  155059. export class ShadowsOptimization extends SceneOptimization {
  155060. /**
  155061. * Gets a string describing the action executed by the current optimization
  155062. * @return description string
  155063. */
  155064. getDescription(): string;
  155065. /**
  155066. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155067. * @param scene defines the current scene where to apply this optimization
  155068. * @param optimizer defines the current optimizer
  155069. * @returns true if everything that can be done was applied
  155070. */
  155071. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155072. }
  155073. /**
  155074. * Defines an optimization used to turn post-processes off
  155075. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155076. */
  155077. export class PostProcessesOptimization extends SceneOptimization {
  155078. /**
  155079. * Gets a string describing the action executed by the current optimization
  155080. * @return description string
  155081. */
  155082. getDescription(): string;
  155083. /**
  155084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155085. * @param scene defines the current scene where to apply this optimization
  155086. * @param optimizer defines the current optimizer
  155087. * @returns true if everything that can be done was applied
  155088. */
  155089. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155090. }
  155091. /**
  155092. * Defines an optimization used to turn lens flares off
  155093. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155094. */
  155095. export class LensFlaresOptimization extends SceneOptimization {
  155096. /**
  155097. * Gets a string describing the action executed by the current optimization
  155098. * @return description string
  155099. */
  155100. getDescription(): string;
  155101. /**
  155102. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155103. * @param scene defines the current scene where to apply this optimization
  155104. * @param optimizer defines the current optimizer
  155105. * @returns true if everything that can be done was applied
  155106. */
  155107. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155108. }
  155109. /**
  155110. * Defines an optimization based on user defined callback.
  155111. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155112. */
  155113. export class CustomOptimization extends SceneOptimization {
  155114. /**
  155115. * Callback called to apply the custom optimization.
  155116. */
  155117. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  155118. /**
  155119. * Callback called to get custom description
  155120. */
  155121. onGetDescription: () => string;
  155122. /**
  155123. * Gets a string describing the action executed by the current optimization
  155124. * @returns description string
  155125. */
  155126. getDescription(): string;
  155127. /**
  155128. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155129. * @param scene defines the current scene where to apply this optimization
  155130. * @param optimizer defines the current optimizer
  155131. * @returns true if everything that can be done was applied
  155132. */
  155133. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155134. }
  155135. /**
  155136. * Defines an optimization used to turn particles off
  155137. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155138. */
  155139. export class ParticlesOptimization extends SceneOptimization {
  155140. /**
  155141. * Gets a string describing the action executed by the current optimization
  155142. * @return description string
  155143. */
  155144. getDescription(): string;
  155145. /**
  155146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155147. * @param scene defines the current scene where to apply this optimization
  155148. * @param optimizer defines the current optimizer
  155149. * @returns true if everything that can be done was applied
  155150. */
  155151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155152. }
  155153. /**
  155154. * Defines an optimization used to turn render targets off
  155155. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155156. */
  155157. export class RenderTargetsOptimization extends SceneOptimization {
  155158. /**
  155159. * Gets a string describing the action executed by the current optimization
  155160. * @return description string
  155161. */
  155162. getDescription(): string;
  155163. /**
  155164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155165. * @param scene defines the current scene where to apply this optimization
  155166. * @param optimizer defines the current optimizer
  155167. * @returns true if everything that can be done was applied
  155168. */
  155169. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155170. }
  155171. /**
  155172. * Defines an optimization used to merge meshes with compatible materials
  155173. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155174. */
  155175. export class MergeMeshesOptimization extends SceneOptimization {
  155176. private static _UpdateSelectionTree;
  155177. /**
  155178. * Gets or sets a boolean which defines if optimization octree has to be updated
  155179. */
  155180. static get UpdateSelectionTree(): boolean;
  155181. /**
  155182. * Gets or sets a boolean which defines if optimization octree has to be updated
  155183. */
  155184. static set UpdateSelectionTree(value: boolean);
  155185. /**
  155186. * Gets a string describing the action executed by the current optimization
  155187. * @return description string
  155188. */
  155189. getDescription(): string;
  155190. private _canBeMerged;
  155191. /**
  155192. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155193. * @param scene defines the current scene where to apply this optimization
  155194. * @param optimizer defines the current optimizer
  155195. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  155196. * @returns true if everything that can be done was applied
  155197. */
  155198. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  155199. }
  155200. /**
  155201. * Defines a list of options used by SceneOptimizer
  155202. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155203. */
  155204. export class SceneOptimizerOptions {
  155205. /**
  155206. * Defines the target frame rate to reach (60 by default)
  155207. */
  155208. targetFrameRate: number;
  155209. /**
  155210. * Defines the interval between two checkes (2000ms by default)
  155211. */
  155212. trackerDuration: number;
  155213. /**
  155214. * Gets the list of optimizations to apply
  155215. */
  155216. optimizations: SceneOptimization[];
  155217. /**
  155218. * Creates a new list of options used by SceneOptimizer
  155219. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  155220. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  155221. */
  155222. constructor(
  155223. /**
  155224. * Defines the target frame rate to reach (60 by default)
  155225. */
  155226. targetFrameRate?: number,
  155227. /**
  155228. * Defines the interval between two checkes (2000ms by default)
  155229. */
  155230. trackerDuration?: number);
  155231. /**
  155232. * Add a new optimization
  155233. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  155234. * @returns the current SceneOptimizerOptions
  155235. */
  155236. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  155237. /**
  155238. * Add a new custom optimization
  155239. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  155240. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  155241. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155242. * @returns the current SceneOptimizerOptions
  155243. */
  155244. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  155245. /**
  155246. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  155247. * @param targetFrameRate defines the target frame rate (60 by default)
  155248. * @returns a SceneOptimizerOptions object
  155249. */
  155250. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155251. /**
  155252. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  155253. * @param targetFrameRate defines the target frame rate (60 by default)
  155254. * @returns a SceneOptimizerOptions object
  155255. */
  155256. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155257. /**
  155258. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  155259. * @param targetFrameRate defines the target frame rate (60 by default)
  155260. * @returns a SceneOptimizerOptions object
  155261. */
  155262. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  155263. }
  155264. /**
  155265. * Class used to run optimizations in order to reach a target frame rate
  155266. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155267. */
  155268. export class SceneOptimizer implements IDisposable {
  155269. private _isRunning;
  155270. private _options;
  155271. private _scene;
  155272. private _currentPriorityLevel;
  155273. private _targetFrameRate;
  155274. private _trackerDuration;
  155275. private _currentFrameRate;
  155276. private _sceneDisposeObserver;
  155277. private _improvementMode;
  155278. /**
  155279. * Defines an observable called when the optimizer reaches the target frame rate
  155280. */
  155281. onSuccessObservable: Observable<SceneOptimizer>;
  155282. /**
  155283. * Defines an observable called when the optimizer enables an optimization
  155284. */
  155285. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  155286. /**
  155287. * Defines an observable called when the optimizer is not able to reach the target frame rate
  155288. */
  155289. onFailureObservable: Observable<SceneOptimizer>;
  155290. /**
  155291. * Gets a boolean indicating if the optimizer is in improvement mode
  155292. */
  155293. get isInImprovementMode(): boolean;
  155294. /**
  155295. * Gets the current priority level (0 at start)
  155296. */
  155297. get currentPriorityLevel(): number;
  155298. /**
  155299. * Gets the current frame rate checked by the SceneOptimizer
  155300. */
  155301. get currentFrameRate(): number;
  155302. /**
  155303. * Gets or sets the current target frame rate (60 by default)
  155304. */
  155305. get targetFrameRate(): number;
  155306. /**
  155307. * Gets or sets the current target frame rate (60 by default)
  155308. */
  155309. set targetFrameRate(value: number);
  155310. /**
  155311. * Gets or sets the current interval between two checks (every 2000ms by default)
  155312. */
  155313. get trackerDuration(): number;
  155314. /**
  155315. * Gets or sets the current interval between two checks (every 2000ms by default)
  155316. */
  155317. set trackerDuration(value: number);
  155318. /**
  155319. * Gets the list of active optimizations
  155320. */
  155321. get optimizations(): SceneOptimization[];
  155322. /**
  155323. * Creates a new SceneOptimizer
  155324. * @param scene defines the scene to work on
  155325. * @param options defines the options to use with the SceneOptimizer
  155326. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  155327. * @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)
  155328. */
  155329. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  155330. /**
  155331. * Stops the current optimizer
  155332. */
  155333. stop(): void;
  155334. /**
  155335. * Reset the optimizer to initial step (current priority level = 0)
  155336. */
  155337. reset(): void;
  155338. /**
  155339. * Start the optimizer. By default it will try to reach a specific framerate
  155340. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  155341. */
  155342. start(): void;
  155343. private _checkCurrentState;
  155344. /**
  155345. * Release all resources
  155346. */
  155347. dispose(): void;
  155348. /**
  155349. * Helper function to create a SceneOptimizer with one single line of code
  155350. * @param scene defines the scene to work on
  155351. * @param options defines the options to use with the SceneOptimizer
  155352. * @param onSuccess defines a callback to call on success
  155353. * @param onFailure defines a callback to call on failure
  155354. * @returns the new SceneOptimizer object
  155355. */
  155356. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  155357. }
  155358. }
  155359. declare module BABYLON {
  155360. /**
  155361. * Class used to serialize a scene into a string
  155362. */
  155363. export class SceneSerializer {
  155364. /**
  155365. * Clear cache used by a previous serialization
  155366. */
  155367. static ClearCache(): void;
  155368. /**
  155369. * Serialize a scene into a JSON compatible object
  155370. * @param scene defines the scene to serialize
  155371. * @returns a JSON compatible object
  155372. */
  155373. static Serialize(scene: Scene): any;
  155374. /**
  155375. * Serialize a mesh into a JSON compatible object
  155376. * @param toSerialize defines the mesh to serialize
  155377. * @param withParents defines if parents must be serialized as well
  155378. * @param withChildren defines if children must be serialized as well
  155379. * @returns a JSON compatible object
  155380. */
  155381. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  155382. }
  155383. }
  155384. declare module BABYLON {
  155385. /**
  155386. * Class used to host texture specific utilities
  155387. */
  155388. export class TextureTools {
  155389. /**
  155390. * Uses the GPU to create a copy texture rescaled at a given size
  155391. * @param texture Texture to copy from
  155392. * @param width defines the desired width
  155393. * @param height defines the desired height
  155394. * @param useBilinearMode defines if bilinear mode has to be used
  155395. * @return the generated texture
  155396. */
  155397. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  155398. }
  155399. }
  155400. declare module BABYLON {
  155401. /**
  155402. * This represents the different options available for the video capture.
  155403. */
  155404. export interface VideoRecorderOptions {
  155405. /** Defines the mime type of the video. */
  155406. mimeType: string;
  155407. /** Defines the FPS the video should be recorded at. */
  155408. fps: number;
  155409. /** Defines the chunk size for the recording data. */
  155410. recordChunckSize: number;
  155411. /** The audio tracks to attach to the recording. */
  155412. audioTracks?: MediaStreamTrack[];
  155413. }
  155414. /**
  155415. * This can help with recording videos from BabylonJS.
  155416. * This is based on the available WebRTC functionalities of the browser.
  155417. *
  155418. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  155419. */
  155420. export class VideoRecorder {
  155421. private static readonly _defaultOptions;
  155422. /**
  155423. * Returns whether or not the VideoRecorder is available in your browser.
  155424. * @param engine Defines the Babylon Engine.
  155425. * @returns true if supported otherwise false.
  155426. */
  155427. static IsSupported(engine: Engine): boolean;
  155428. private readonly _options;
  155429. private _canvas;
  155430. private _mediaRecorder;
  155431. private _recordedChunks;
  155432. private _fileName;
  155433. private _resolve;
  155434. private _reject;
  155435. /**
  155436. * True when a recording is already in progress.
  155437. */
  155438. get isRecording(): boolean;
  155439. /**
  155440. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  155441. * @param engine Defines the BabylonJS Engine you wish to record.
  155442. * @param options Defines options that can be used to customize the capture.
  155443. */
  155444. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  155445. /**
  155446. * Stops the current recording before the default capture timeout passed in the startRecording function.
  155447. */
  155448. stopRecording(): void;
  155449. /**
  155450. * Starts recording the canvas for a max duration specified in parameters.
  155451. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  155452. * If null no automatic download will start and you can rely on the promise to get the data back.
  155453. * @param maxDuration Defines the maximum recording time in seconds.
  155454. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  155455. * @return A promise callback at the end of the recording with the video data in Blob.
  155456. */
  155457. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  155458. /**
  155459. * Releases internal resources used during the recording.
  155460. */
  155461. dispose(): void;
  155462. private _handleDataAvailable;
  155463. private _handleError;
  155464. private _handleStop;
  155465. }
  155466. }
  155467. declare module BABYLON {
  155468. /**
  155469. * Class containing a set of static utilities functions for screenshots
  155470. */
  155471. export class ScreenshotTools {
  155472. /**
  155473. * Captures a screenshot of the current rendering
  155474. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155475. * @param engine defines the rendering engine
  155476. * @param camera defines the source camera
  155477. * @param size This parameter can be set to a single number or to an object with the
  155478. * following (optional) properties: precision, width, height. If a single number is passed,
  155479. * it will be used for both width and height. If an object is passed, the screenshot size
  155480. * will be derived from the parameters. The precision property is a multiplier allowing
  155481. * rendering at a higher or lower resolution
  155482. * @param successCallback defines the callback receives a single parameter which contains the
  155483. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155484. * src parameter of an <img> to display it
  155485. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155486. * Check your browser for supported MIME types
  155487. */
  155488. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  155489. /**
  155490. * Captures a screenshot of the current rendering
  155491. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155492. * @param engine defines the rendering engine
  155493. * @param camera defines the source camera
  155494. * @param size This parameter can be set to a single number or to an object with the
  155495. * following (optional) properties: precision, width, height. If a single number is passed,
  155496. * it will be used for both width and height. If an object is passed, the screenshot size
  155497. * will be derived from the parameters. The precision property is a multiplier allowing
  155498. * rendering at a higher or lower resolution
  155499. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155500. * Check your browser for supported MIME types
  155501. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155502. * to the src parameter of an <img> to display it
  155503. */
  155504. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  155505. /**
  155506. * Generates an image screenshot from the specified camera.
  155507. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155508. * @param engine The engine to use for rendering
  155509. * @param camera The camera to use for rendering
  155510. * @param size This parameter can be set to a single number or to an object with the
  155511. * following (optional) properties: precision, width, height. If a single number is passed,
  155512. * it will be used for both width and height. If an object is passed, the screenshot size
  155513. * will be derived from the parameters. The precision property is a multiplier allowing
  155514. * rendering at a higher or lower resolution
  155515. * @param successCallback The callback receives a single parameter which contains the
  155516. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155517. * src parameter of an <img> to display it
  155518. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155519. * Check your browser for supported MIME types
  155520. * @param samples Texture samples (default: 1)
  155521. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155522. * @param fileName A name for for the downloaded file.
  155523. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155524. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  155525. */
  155526. 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;
  155527. /**
  155528. * Generates an image screenshot from the specified camera.
  155529. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155530. * @param engine The engine to use for rendering
  155531. * @param camera The camera to use for rendering
  155532. * @param size This parameter can be set to a single number or to an object with the
  155533. * following (optional) properties: precision, width, height. If a single number is passed,
  155534. * it will be used for both width and height. If an object is passed, the screenshot size
  155535. * will be derived from the parameters. The precision property is a multiplier allowing
  155536. * rendering at a higher or lower resolution
  155537. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155538. * Check your browser for supported MIME types
  155539. * @param samples Texture samples (default: 1)
  155540. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155541. * @param fileName A name for for the downloaded file.
  155542. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155543. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155544. * to the src parameter of an <img> to display it
  155545. */
  155546. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  155547. /**
  155548. * Gets height and width for screenshot size
  155549. * @private
  155550. */
  155551. private static _getScreenshotSize;
  155552. }
  155553. }
  155554. declare module BABYLON {
  155555. /**
  155556. * Interface for a data buffer
  155557. */
  155558. export interface IDataBuffer {
  155559. /**
  155560. * Reads bytes from the data buffer.
  155561. * @param byteOffset The byte offset to read
  155562. * @param byteLength The byte length to read
  155563. * @returns A promise that resolves when the bytes are read
  155564. */
  155565. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  155566. /**
  155567. * The byte length of the buffer.
  155568. */
  155569. readonly byteLength: number;
  155570. }
  155571. /**
  155572. * Utility class for reading from a data buffer
  155573. */
  155574. export class DataReader {
  155575. /**
  155576. * The data buffer associated with this data reader.
  155577. */
  155578. readonly buffer: IDataBuffer;
  155579. /**
  155580. * The current byte offset from the beginning of the data buffer.
  155581. */
  155582. byteOffset: number;
  155583. private _dataView;
  155584. private _dataByteOffset;
  155585. /**
  155586. * Constructor
  155587. * @param buffer The buffer to read
  155588. */
  155589. constructor(buffer: IDataBuffer);
  155590. /**
  155591. * Loads the given byte length.
  155592. * @param byteLength The byte length to load
  155593. * @returns A promise that resolves when the load is complete
  155594. */
  155595. loadAsync(byteLength: number): Promise<void>;
  155596. /**
  155597. * Read a unsigned 32-bit integer from the currently loaded data range.
  155598. * @returns The 32-bit integer read
  155599. */
  155600. readUint32(): number;
  155601. /**
  155602. * Read a byte array from the currently loaded data range.
  155603. * @param byteLength The byte length to read
  155604. * @returns The byte array read
  155605. */
  155606. readUint8Array(byteLength: number): Uint8Array;
  155607. /**
  155608. * Read a string from the currently loaded data range.
  155609. * @param byteLength The byte length to read
  155610. * @returns The string read
  155611. */
  155612. readString(byteLength: number): string;
  155613. /**
  155614. * Skips the given byte length the currently loaded data range.
  155615. * @param byteLength The byte length to skip
  155616. */
  155617. skipBytes(byteLength: number): void;
  155618. }
  155619. }
  155620. declare module BABYLON {
  155621. /**
  155622. * Class for storing data to local storage if available or in-memory storage otherwise
  155623. */
  155624. export class DataStorage {
  155625. private static _Storage;
  155626. private static _GetStorage;
  155627. /**
  155628. * Reads a string from the data storage
  155629. * @param key The key to read
  155630. * @param defaultValue The value if the key doesn't exist
  155631. * @returns The string value
  155632. */
  155633. static ReadString(key: string, defaultValue: string): string;
  155634. /**
  155635. * Writes a string to the data storage
  155636. * @param key The key to write
  155637. * @param value The value to write
  155638. */
  155639. static WriteString(key: string, value: string): void;
  155640. /**
  155641. * Reads a boolean from the data storage
  155642. * @param key The key to read
  155643. * @param defaultValue The value if the key doesn't exist
  155644. * @returns The boolean value
  155645. */
  155646. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  155647. /**
  155648. * Writes a boolean to the data storage
  155649. * @param key The key to write
  155650. * @param value The value to write
  155651. */
  155652. static WriteBoolean(key: string, value: boolean): void;
  155653. /**
  155654. * Reads a number from the data storage
  155655. * @param key The key to read
  155656. * @param defaultValue The value if the key doesn't exist
  155657. * @returns The number value
  155658. */
  155659. static ReadNumber(key: string, defaultValue: number): number;
  155660. /**
  155661. * Writes a number to the data storage
  155662. * @param key The key to write
  155663. * @param value The value to write
  155664. */
  155665. static WriteNumber(key: string, value: number): void;
  155666. }
  155667. }
  155668. declare module BABYLON {
  155669. /**
  155670. * Class used to record delta files between 2 scene states
  155671. */
  155672. export class SceneRecorder {
  155673. private _trackedScene;
  155674. private _savedJSON;
  155675. /**
  155676. * Track a given scene. This means the current scene state will be considered the original state
  155677. * @param scene defines the scene to track
  155678. */
  155679. track(scene: Scene): void;
  155680. /**
  155681. * Get the delta between current state and original state
  155682. * @returns a string containing the delta
  155683. */
  155684. getDelta(): any;
  155685. private _compareArray;
  155686. private _compareObjects;
  155687. private _compareCollections;
  155688. private static GetShadowGeneratorById;
  155689. /**
  155690. * Apply a given delta to a given scene
  155691. * @param deltaJSON defines the JSON containing the delta
  155692. * @param scene defines the scene to apply the delta to
  155693. */
  155694. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  155695. private static _ApplyPropertiesToEntity;
  155696. private static _ApplyDeltaForEntity;
  155697. }
  155698. }
  155699. declare module BABYLON {
  155700. /**
  155701. * A 3D trajectory consisting of an order list of vectors describing a
  155702. * path of motion through 3D space.
  155703. */
  155704. export class Trajectory {
  155705. private _points;
  155706. private readonly _segmentLength;
  155707. /**
  155708. * Serialize to JSON.
  155709. * @returns serialized JSON string
  155710. */
  155711. serialize(): string;
  155712. /**
  155713. * Deserialize from JSON.
  155714. * @param json serialized JSON string
  155715. * @returns deserialized Trajectory
  155716. */
  155717. static Deserialize(json: string): Trajectory;
  155718. /**
  155719. * Create a new empty Trajectory.
  155720. * @param segmentLength radius of discretization for Trajectory points
  155721. */
  155722. constructor(segmentLength?: number);
  155723. /**
  155724. * Get the length of the Trajectory.
  155725. * @returns length of the Trajectory
  155726. */
  155727. getLength(): number;
  155728. /**
  155729. * Append a new point to the Trajectory.
  155730. * NOTE: This implementation has many allocations.
  155731. * @param point point to append to the Trajectory
  155732. */
  155733. add(point: DeepImmutable<Vector3>): void;
  155734. /**
  155735. * Create a new Trajectory with a segment length chosen to make it
  155736. * probable that the new Trajectory will have a specified number of
  155737. * segments. This operation is imprecise.
  155738. * @param targetResolution number of segments desired
  155739. * @returns new Trajectory with approximately the requested number of segments
  155740. */
  155741. resampleAtTargetResolution(targetResolution: number): Trajectory;
  155742. /**
  155743. * Convert Trajectory segments into tokenized representation. This
  155744. * representation is an array of numbers where each nth number is the
  155745. * index of the token which is most similar to the nth segment of the
  155746. * Trajectory.
  155747. * @param tokens list of vectors which serve as discrete tokens
  155748. * @returns list of indices of most similar token per segment
  155749. */
  155750. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  155751. private static _forwardDir;
  155752. private static _inverseFromVec;
  155753. private static _upDir;
  155754. private static _fromToVec;
  155755. private static _lookMatrix;
  155756. /**
  155757. * Transform the rotation (i.e., direction) of a segment to isolate
  155758. * the relative transformation represented by the segment. This operation
  155759. * may or may not succeed due to singularities in the equations that define
  155760. * motion relativity in this context.
  155761. * @param priorVec the origin of the prior segment
  155762. * @param fromVec the origin of the current segment
  155763. * @param toVec the destination of the current segment
  155764. * @param result reference to output variable
  155765. * @returns whether or not transformation was successful
  155766. */
  155767. private static _transformSegmentDirToRef;
  155768. private static _bestMatch;
  155769. private static _score;
  155770. private static _bestScore;
  155771. /**
  155772. * Determine which token vector is most similar to the
  155773. * segment vector.
  155774. * @param segment segment vector
  155775. * @param tokens token vector list
  155776. * @returns index of the most similar token to the segment
  155777. */
  155778. private static _tokenizeSegment;
  155779. }
  155780. /**
  155781. * Class representing a set of known, named trajectories to which Trajectories can be
  155782. * added and using which Trajectories can be recognized.
  155783. */
  155784. export class TrajectoryClassifier {
  155785. private _maximumAllowableMatchCost;
  155786. private _vector3Alphabet;
  155787. private _levenshteinAlphabet;
  155788. private _nameToDescribedTrajectory;
  155789. /**
  155790. * Serialize to JSON.
  155791. * @returns JSON serialization
  155792. */
  155793. serialize(): string;
  155794. /**
  155795. * Deserialize from JSON.
  155796. * @param json JSON serialization
  155797. * @returns deserialized TrajectorySet
  155798. */
  155799. static Deserialize(json: string): TrajectoryClassifier;
  155800. /**
  155801. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  155802. * VERY naive, need to be generating these things from known
  155803. * sets. Better version later, probably eliminating this one.
  155804. * @returns auto-generated TrajectorySet
  155805. */
  155806. static Generate(): TrajectoryClassifier;
  155807. private constructor();
  155808. /**
  155809. * Add a new Trajectory to the set with a given name.
  155810. * @param trajectory new Trajectory to be added
  155811. * @param classification name to which to add the Trajectory
  155812. */
  155813. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155814. /**
  155815. * Remove a known named trajectory and all Trajectories associated with it.
  155816. * @param classification name to remove
  155817. * @returns whether anything was removed
  155818. */
  155819. deleteClassification(classification: string): boolean;
  155820. /**
  155821. * Attempt to recognize a Trajectory from among all the classifications
  155822. * already known to the classifier.
  155823. * @param trajectory Trajectory to be recognized
  155824. * @returns classification of Trajectory if recognized, null otherwise
  155825. */
  155826. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155827. }
  155828. }
  155829. declare module BABYLON {
  155830. /**
  155831. * An interface for all Hit test features
  155832. */
  155833. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155834. /**
  155835. * Triggered when new babylon (transformed) hit test results are available
  155836. */
  155837. onHitTestResultObservable: Observable<T[]>;
  155838. }
  155839. /**
  155840. * Options used for hit testing
  155841. */
  155842. export interface IWebXRLegacyHitTestOptions {
  155843. /**
  155844. * Only test when user interacted with the scene. Default - hit test every frame
  155845. */
  155846. testOnPointerDownOnly?: boolean;
  155847. /**
  155848. * The node to use to transform the local results to world coordinates
  155849. */
  155850. worldParentNode?: TransformNode;
  155851. }
  155852. /**
  155853. * Interface defining the babylon result of raycasting/hit-test
  155854. */
  155855. export interface IWebXRLegacyHitResult {
  155856. /**
  155857. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155858. */
  155859. transformationMatrix: Matrix;
  155860. /**
  155861. * The native hit test result
  155862. */
  155863. xrHitResult: XRHitResult | XRHitTestResult;
  155864. }
  155865. /**
  155866. * The currently-working hit-test module.
  155867. * Hit test (or Ray-casting) is used to interact with the real world.
  155868. * For further information read here - https://github.com/immersive-web/hit-test
  155869. */
  155870. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155871. /**
  155872. * options to use when constructing this feature
  155873. */
  155874. readonly options: IWebXRLegacyHitTestOptions;
  155875. private _direction;
  155876. private _mat;
  155877. private _onSelectEnabled;
  155878. private _origin;
  155879. /**
  155880. * The module's name
  155881. */
  155882. static readonly Name: string;
  155883. /**
  155884. * The (Babylon) version of this module.
  155885. * This is an integer representing the implementation version.
  155886. * This number does not correspond to the WebXR specs version
  155887. */
  155888. static readonly Version: number;
  155889. /**
  155890. * Populated with the last native XR Hit Results
  155891. */
  155892. lastNativeXRHitResults: XRHitResult[];
  155893. /**
  155894. * Triggered when new babylon (transformed) hit test results are available
  155895. */
  155896. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155897. /**
  155898. * Creates a new instance of the (legacy version) hit test feature
  155899. * @param _xrSessionManager an instance of WebXRSessionManager
  155900. * @param options options to use when constructing this feature
  155901. */
  155902. constructor(_xrSessionManager: WebXRSessionManager,
  155903. /**
  155904. * options to use when constructing this feature
  155905. */
  155906. options?: IWebXRLegacyHitTestOptions);
  155907. /**
  155908. * execute a hit test with an XR Ray
  155909. *
  155910. * @param xrSession a native xrSession that will execute this hit test
  155911. * @param xrRay the ray (position and direction) to use for ray-casting
  155912. * @param referenceSpace native XR reference space to use for the hit-test
  155913. * @param filter filter function that will filter the results
  155914. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155915. */
  155916. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155917. /**
  155918. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155919. * @param event the (select) event to use to select with
  155920. * @param referenceSpace the reference space to use for this hit test
  155921. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155922. */
  155923. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155924. /**
  155925. * attach this feature
  155926. * Will usually be called by the features manager
  155927. *
  155928. * @returns true if successful.
  155929. */
  155930. attach(): boolean;
  155931. /**
  155932. * detach this feature.
  155933. * Will usually be called by the features manager
  155934. *
  155935. * @returns true if successful.
  155936. */
  155937. detach(): boolean;
  155938. /**
  155939. * Dispose this feature and all of the resources attached
  155940. */
  155941. dispose(): void;
  155942. protected _onXRFrame(frame: XRFrame): void;
  155943. private _onHitTestResults;
  155944. private _onSelect;
  155945. }
  155946. }
  155947. declare module BABYLON {
  155948. /**
  155949. * Options used for hit testing (version 2)
  155950. */
  155951. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155952. /**
  155953. * Do not create a permanent hit test. Will usually be used when only
  155954. * transient inputs are needed.
  155955. */
  155956. disablePermanentHitTest?: boolean;
  155957. /**
  155958. * Enable transient (for example touch-based) hit test inspections
  155959. */
  155960. enableTransientHitTest?: boolean;
  155961. /**
  155962. * Offset ray for the permanent hit test
  155963. */
  155964. offsetRay?: Vector3;
  155965. /**
  155966. * Offset ray for the transient hit test
  155967. */
  155968. transientOffsetRay?: Vector3;
  155969. /**
  155970. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155971. */
  155972. useReferenceSpace?: boolean;
  155973. /**
  155974. * Override the default entity type(s) of the hit-test result
  155975. */
  155976. entityTypes?: XRHitTestTrackableType[];
  155977. }
  155978. /**
  155979. * Interface defining the babylon result of hit-test
  155980. */
  155981. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155982. /**
  155983. * The input source that generated this hit test (if transient)
  155984. */
  155985. inputSource?: XRInputSource;
  155986. /**
  155987. * Is this a transient hit test
  155988. */
  155989. isTransient?: boolean;
  155990. /**
  155991. * Position of the hit test result
  155992. */
  155993. position: Vector3;
  155994. /**
  155995. * Rotation of the hit test result
  155996. */
  155997. rotationQuaternion: Quaternion;
  155998. /**
  155999. * The native hit test result
  156000. */
  156001. xrHitResult: XRHitTestResult;
  156002. }
  156003. /**
  156004. * The currently-working hit-test module.
  156005. * Hit test (or Ray-casting) is used to interact with the real world.
  156006. * For further information read here - https://github.com/immersive-web/hit-test
  156007. *
  156008. * Tested on chrome (mobile) 80.
  156009. */
  156010. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  156011. /**
  156012. * options to use when constructing this feature
  156013. */
  156014. readonly options: IWebXRHitTestOptions;
  156015. private _tmpMat;
  156016. private _tmpPos;
  156017. private _tmpQuat;
  156018. private _transientXrHitTestSource;
  156019. private _xrHitTestSource;
  156020. private initHitTestSource;
  156021. /**
  156022. * The module's name
  156023. */
  156024. static readonly Name: string;
  156025. /**
  156026. * The (Babylon) version of this module.
  156027. * This is an integer representing the implementation version.
  156028. * This number does not correspond to the WebXR specs version
  156029. */
  156030. static readonly Version: number;
  156031. /**
  156032. * When set to true, each hit test will have its own position/rotation objects
  156033. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  156034. * the developers will clone them or copy them as they see fit.
  156035. */
  156036. autoCloneTransformation: boolean;
  156037. /**
  156038. * Triggered when new babylon (transformed) hit test results are available
  156039. * Note - this will be called when results come back from the device. It can be an empty array!!
  156040. */
  156041. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  156042. /**
  156043. * Use this to temporarily pause hit test checks.
  156044. */
  156045. paused: boolean;
  156046. /**
  156047. * Creates a new instance of the hit test feature
  156048. * @param _xrSessionManager an instance of WebXRSessionManager
  156049. * @param options options to use when constructing this feature
  156050. */
  156051. constructor(_xrSessionManager: WebXRSessionManager,
  156052. /**
  156053. * options to use when constructing this feature
  156054. */
  156055. options?: IWebXRHitTestOptions);
  156056. /**
  156057. * attach this feature
  156058. * Will usually be called by the features manager
  156059. *
  156060. * @returns true if successful.
  156061. */
  156062. attach(): boolean;
  156063. /**
  156064. * detach this feature.
  156065. * Will usually be called by the features manager
  156066. *
  156067. * @returns true if successful.
  156068. */
  156069. detach(): boolean;
  156070. /**
  156071. * Dispose this feature and all of the resources attached
  156072. */
  156073. dispose(): void;
  156074. protected _onXRFrame(frame: XRFrame): void;
  156075. private _processWebXRHitTestResult;
  156076. }
  156077. }
  156078. declare module BABYLON {
  156079. /**
  156080. * Configuration options of the anchor system
  156081. */
  156082. export interface IWebXRAnchorSystemOptions {
  156083. /**
  156084. * a node that will be used to convert local to world coordinates
  156085. */
  156086. worldParentNode?: TransformNode;
  156087. /**
  156088. * If set to true a reference of the created anchors will be kept until the next session starts
  156089. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  156090. */
  156091. doNotRemoveAnchorsOnSessionEnded?: boolean;
  156092. }
  156093. /**
  156094. * A babylon container for an XR Anchor
  156095. */
  156096. export interface IWebXRAnchor {
  156097. /**
  156098. * A babylon-assigned ID for this anchor
  156099. */
  156100. id: number;
  156101. /**
  156102. * Transformation matrix to apply to an object attached to this anchor
  156103. */
  156104. transformationMatrix: Matrix;
  156105. /**
  156106. * The native anchor object
  156107. */
  156108. xrAnchor: XRAnchor;
  156109. /**
  156110. * if defined, this object will be constantly updated by the anchor's position and rotation
  156111. */
  156112. attachedNode?: TransformNode;
  156113. }
  156114. /**
  156115. * An implementation of the anchor system for WebXR.
  156116. * For further information see https://github.com/immersive-web/anchors/
  156117. */
  156118. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  156119. private _options;
  156120. private _lastFrameDetected;
  156121. private _trackedAnchors;
  156122. private _referenceSpaceForFrameAnchors;
  156123. private _futureAnchors;
  156124. /**
  156125. * The module's name
  156126. */
  156127. static readonly Name: string;
  156128. /**
  156129. * The (Babylon) version of this module.
  156130. * This is an integer representing the implementation version.
  156131. * This number does not correspond to the WebXR specs version
  156132. */
  156133. static readonly Version: number;
  156134. /**
  156135. * Observers registered here will be executed when a new anchor was added to the session
  156136. */
  156137. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  156138. /**
  156139. * Observers registered here will be executed when an anchor was removed from the session
  156140. */
  156141. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  156142. /**
  156143. * Observers registered here will be executed when an existing anchor updates
  156144. * This can execute N times every frame
  156145. */
  156146. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  156147. /**
  156148. * Set the reference space to use for anchor creation, when not using a hit test.
  156149. * Will default to the session's reference space if not defined
  156150. */
  156151. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  156152. /**
  156153. * constructs a new anchor system
  156154. * @param _xrSessionManager an instance of WebXRSessionManager
  156155. * @param _options configuration object for this feature
  156156. */
  156157. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  156158. private _tmpVector;
  156159. private _tmpQuaternion;
  156160. private _populateTmpTransformation;
  156161. /**
  156162. * Create a new anchor point using a hit test result at a specific point in the scene
  156163. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156164. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156165. *
  156166. * @param hitTestResult The hit test result to use for this anchor creation
  156167. * @param position an optional position offset for this anchor
  156168. * @param rotationQuaternion an optional rotation offset for this anchor
  156169. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156170. */
  156171. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  156172. /**
  156173. * Add a new anchor at a specific position and rotation
  156174. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  156175. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  156176. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  156177. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  156178. *
  156179. * @param position the position in which to add an anchor
  156180. * @param rotationQuaternion an optional rotation for the anchor transformation
  156181. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  156182. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  156183. */
  156184. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  156185. /**
  156186. * detach this feature.
  156187. * Will usually be called by the features manager
  156188. *
  156189. * @returns true if successful.
  156190. */
  156191. detach(): boolean;
  156192. /**
  156193. * Dispose this feature and all of the resources attached
  156194. */
  156195. dispose(): void;
  156196. protected _onXRFrame(frame: XRFrame): void;
  156197. /**
  156198. * avoiding using Array.find for global support.
  156199. * @param xrAnchor the plane to find in the array
  156200. */
  156201. private _findIndexInAnchorArray;
  156202. private _updateAnchorWithXRFrame;
  156203. private _createAnchorAtTransformation;
  156204. }
  156205. }
  156206. declare module BABYLON {
  156207. /**
  156208. * Options used in the plane detector module
  156209. */
  156210. export interface IWebXRPlaneDetectorOptions {
  156211. /**
  156212. * The node to use to transform the local results to world coordinates
  156213. */
  156214. worldParentNode?: TransformNode;
  156215. /**
  156216. * If set to true a reference of the created planes will be kept until the next session starts
  156217. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  156218. */
  156219. doNotRemovePlanesOnSessionEnded?: boolean;
  156220. }
  156221. /**
  156222. * A babylon interface for a WebXR plane.
  156223. * A Plane is actually a polygon, built from N points in space
  156224. *
  156225. * Supported in chrome 79, not supported in canary 81 ATM
  156226. */
  156227. export interface IWebXRPlane {
  156228. /**
  156229. * a babylon-assigned ID for this polygon
  156230. */
  156231. id: number;
  156232. /**
  156233. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  156234. */
  156235. polygonDefinition: Array<Vector3>;
  156236. /**
  156237. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  156238. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  156239. */
  156240. transformationMatrix: Matrix;
  156241. /**
  156242. * the native xr-plane object
  156243. */
  156244. xrPlane: XRPlane;
  156245. }
  156246. /**
  156247. * The plane detector is used to detect planes in the real world when in AR
  156248. * For more information see https://github.com/immersive-web/real-world-geometry/
  156249. */
  156250. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  156251. private _options;
  156252. private _detectedPlanes;
  156253. private _enabled;
  156254. private _lastFrameDetected;
  156255. /**
  156256. * The module's name
  156257. */
  156258. static readonly Name: string;
  156259. /**
  156260. * The (Babylon) version of this module.
  156261. * This is an integer representing the implementation version.
  156262. * This number does not correspond to the WebXR specs version
  156263. */
  156264. static readonly Version: number;
  156265. /**
  156266. * Observers registered here will be executed when a new plane was added to the session
  156267. */
  156268. onPlaneAddedObservable: Observable<IWebXRPlane>;
  156269. /**
  156270. * Observers registered here will be executed when a plane is no longer detected in the session
  156271. */
  156272. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  156273. /**
  156274. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  156275. * This can execute N times every frame
  156276. */
  156277. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  156278. /**
  156279. * construct a new Plane Detector
  156280. * @param _xrSessionManager an instance of xr Session manager
  156281. * @param _options configuration to use when constructing this feature
  156282. */
  156283. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  156284. /**
  156285. * detach this feature.
  156286. * Will usually be called by the features manager
  156287. *
  156288. * @returns true if successful.
  156289. */
  156290. detach(): boolean;
  156291. /**
  156292. * Dispose this feature and all of the resources attached
  156293. */
  156294. dispose(): void;
  156295. protected _onXRFrame(frame: XRFrame): void;
  156296. private _init;
  156297. private _updatePlaneWithXRPlane;
  156298. /**
  156299. * avoiding using Array.find for global support.
  156300. * @param xrPlane the plane to find in the array
  156301. */
  156302. private findIndexInPlaneArray;
  156303. }
  156304. }
  156305. declare module BABYLON {
  156306. /**
  156307. * Options interface for the background remover plugin
  156308. */
  156309. export interface IWebXRBackgroundRemoverOptions {
  156310. /**
  156311. * Further background meshes to disable when entering AR
  156312. */
  156313. backgroundMeshes?: AbstractMesh[];
  156314. /**
  156315. * flags to configure the removal of the environment helper.
  156316. * If not set, the entire background will be removed. If set, flags should be set as well.
  156317. */
  156318. environmentHelperRemovalFlags?: {
  156319. /**
  156320. * Should the skybox be removed (default false)
  156321. */
  156322. skyBox?: boolean;
  156323. /**
  156324. * Should the ground be removed (default false)
  156325. */
  156326. ground?: boolean;
  156327. };
  156328. /**
  156329. * don't disable the environment helper
  156330. */
  156331. ignoreEnvironmentHelper?: boolean;
  156332. }
  156333. /**
  156334. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  156335. */
  156336. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  156337. /**
  156338. * read-only options to be used in this module
  156339. */
  156340. readonly options: IWebXRBackgroundRemoverOptions;
  156341. /**
  156342. * The module's name
  156343. */
  156344. static readonly Name: string;
  156345. /**
  156346. * The (Babylon) version of this module.
  156347. * This is an integer representing the implementation version.
  156348. * This number does not correspond to the WebXR specs version
  156349. */
  156350. static readonly Version: number;
  156351. /**
  156352. * registered observers will be triggered when the background state changes
  156353. */
  156354. onBackgroundStateChangedObservable: Observable<boolean>;
  156355. /**
  156356. * constructs a new background remover module
  156357. * @param _xrSessionManager the session manager for this module
  156358. * @param options read-only options to be used in this module
  156359. */
  156360. constructor(_xrSessionManager: WebXRSessionManager,
  156361. /**
  156362. * read-only options to be used in this module
  156363. */
  156364. options?: IWebXRBackgroundRemoverOptions);
  156365. /**
  156366. * attach this feature
  156367. * Will usually be called by the features manager
  156368. *
  156369. * @returns true if successful.
  156370. */
  156371. attach(): boolean;
  156372. /**
  156373. * detach this feature.
  156374. * Will usually be called by the features manager
  156375. *
  156376. * @returns true if successful.
  156377. */
  156378. detach(): boolean;
  156379. /**
  156380. * Dispose this feature and all of the resources attached
  156381. */
  156382. dispose(): void;
  156383. protected _onXRFrame(_xrFrame: XRFrame): void;
  156384. private _setBackgroundState;
  156385. }
  156386. }
  156387. declare module BABYLON {
  156388. /**
  156389. * Options for the controller physics feature
  156390. */
  156391. export class IWebXRControllerPhysicsOptions {
  156392. /**
  156393. * Should the headset get its own impostor
  156394. */
  156395. enableHeadsetImpostor?: boolean;
  156396. /**
  156397. * Optional parameters for the headset impostor
  156398. */
  156399. headsetImpostorParams?: {
  156400. /**
  156401. * The type of impostor to create. Default is sphere
  156402. */
  156403. impostorType: number;
  156404. /**
  156405. * the size of the impostor. Defaults to 10cm
  156406. */
  156407. impostorSize?: number | {
  156408. width: number;
  156409. height: number;
  156410. depth: number;
  156411. };
  156412. /**
  156413. * Friction definitions
  156414. */
  156415. friction?: number;
  156416. /**
  156417. * Restitution
  156418. */
  156419. restitution?: number;
  156420. };
  156421. /**
  156422. * The physics properties of the future impostors
  156423. */
  156424. physicsProperties?: {
  156425. /**
  156426. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  156427. * Note that this requires a physics engine that supports mesh impostors!
  156428. */
  156429. useControllerMesh?: boolean;
  156430. /**
  156431. * The type of impostor to create. Default is sphere
  156432. */
  156433. impostorType?: number;
  156434. /**
  156435. * the size of the impostor. Defaults to 10cm
  156436. */
  156437. impostorSize?: number | {
  156438. width: number;
  156439. height: number;
  156440. depth: number;
  156441. };
  156442. /**
  156443. * Friction definitions
  156444. */
  156445. friction?: number;
  156446. /**
  156447. * Restitution
  156448. */
  156449. restitution?: number;
  156450. };
  156451. /**
  156452. * the xr input to use with this pointer selection
  156453. */
  156454. xrInput: WebXRInput;
  156455. }
  156456. /**
  156457. * Add physics impostor to your webxr controllers,
  156458. * including naive calculation of their linear and angular velocity
  156459. */
  156460. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  156461. private readonly _options;
  156462. private _attachController;
  156463. private _controllers;
  156464. private _debugMode;
  156465. private _delta;
  156466. private _headsetImpostor?;
  156467. private _headsetMesh?;
  156468. private _lastTimestamp;
  156469. private _tmpQuaternion;
  156470. private _tmpVector;
  156471. /**
  156472. * The module's name
  156473. */
  156474. static readonly Name: string;
  156475. /**
  156476. * The (Babylon) version of this module.
  156477. * This is an integer representing the implementation version.
  156478. * This number does not correspond to the webxr specs version
  156479. */
  156480. static readonly Version: number;
  156481. /**
  156482. * Construct a new Controller Physics Feature
  156483. * @param _xrSessionManager the corresponding xr session manager
  156484. * @param _options options to create this feature with
  156485. */
  156486. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  156487. /**
  156488. * @hidden
  156489. * enable debugging - will show console outputs and the impostor mesh
  156490. */
  156491. _enablePhysicsDebug(): void;
  156492. /**
  156493. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  156494. * @param xrController the controller to add
  156495. */
  156496. addController(xrController: WebXRInputSource): void;
  156497. /**
  156498. * attach this feature
  156499. * Will usually be called by the features manager
  156500. *
  156501. * @returns true if successful.
  156502. */
  156503. attach(): boolean;
  156504. /**
  156505. * detach this feature.
  156506. * Will usually be called by the features manager
  156507. *
  156508. * @returns true if successful.
  156509. */
  156510. detach(): boolean;
  156511. /**
  156512. * Get the headset impostor, if enabled
  156513. * @returns the impostor
  156514. */
  156515. getHeadsetImpostor(): PhysicsImpostor | undefined;
  156516. /**
  156517. * Get the physics impostor of a specific controller.
  156518. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  156519. * @param controller the controller or the controller id of which to get the impostor
  156520. * @returns the impostor or null
  156521. */
  156522. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  156523. /**
  156524. * Update the physics properties provided in the constructor
  156525. * @param newProperties the new properties object
  156526. */
  156527. setPhysicsProperties(newProperties: {
  156528. impostorType?: number;
  156529. impostorSize?: number | {
  156530. width: number;
  156531. height: number;
  156532. depth: number;
  156533. };
  156534. friction?: number;
  156535. restitution?: number;
  156536. }): void;
  156537. protected _onXRFrame(_xrFrame: any): void;
  156538. private _detachController;
  156539. }
  156540. }
  156541. declare module BABYLON {
  156542. /**
  156543. * A babylon interface for a "WebXR" feature point.
  156544. * Represents the position and confidence value of a given feature point.
  156545. */
  156546. export interface IWebXRFeaturePoint {
  156547. /**
  156548. * Represents the position of the feature point in world space.
  156549. */
  156550. position: Vector3;
  156551. /**
  156552. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  156553. */
  156554. confidenceValue: number;
  156555. }
  156556. /**
  156557. * The feature point system is used to detect feature points from real world geometry.
  156558. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  156559. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  156560. */
  156561. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  156562. private _enabled;
  156563. private _featurePointCloud;
  156564. /**
  156565. * The module's name
  156566. */
  156567. static readonly Name: string;
  156568. /**
  156569. * The (Babylon) version of this module.
  156570. * This is an integer representing the implementation version.
  156571. * This number does not correspond to the WebXR specs version
  156572. */
  156573. static readonly Version: number;
  156574. /**
  156575. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  156576. * Will notify the observers about which feature points have been added.
  156577. */
  156578. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  156579. /**
  156580. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  156581. * Will notify the observers about which feature points have been updated.
  156582. */
  156583. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  156584. /**
  156585. * The current feature point cloud maintained across frames.
  156586. */
  156587. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  156588. /**
  156589. * construct the feature point system
  156590. * @param _xrSessionManager an instance of xr Session manager
  156591. */
  156592. constructor(_xrSessionManager: WebXRSessionManager);
  156593. /**
  156594. * Detach this feature.
  156595. * Will usually be called by the features manager
  156596. *
  156597. * @returns true if successful.
  156598. */
  156599. detach(): boolean;
  156600. /**
  156601. * Dispose this feature and all of the resources attached
  156602. */
  156603. dispose(): void;
  156604. /**
  156605. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  156606. */
  156607. protected _onXRFrame(frame: XRFrame): void;
  156608. /**
  156609. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  156610. */
  156611. private _init;
  156612. }
  156613. }
  156614. declare module BABYLON {
  156615. /**
  156616. * Configuration interface for the hand tracking feature
  156617. */
  156618. export interface IWebXRHandTrackingOptions {
  156619. /**
  156620. * The xrInput that will be used as source for new hands
  156621. */
  156622. xrInput: WebXRInput;
  156623. /**
  156624. * Configuration object for the joint meshes
  156625. */
  156626. jointMeshes?: {
  156627. /**
  156628. * Should the meshes created be invisible (defaults to false)
  156629. */
  156630. invisible?: boolean;
  156631. /**
  156632. * A source mesh to be used to create instances. Defaults to a sphere.
  156633. * This mesh will be the source for all other (25) meshes.
  156634. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  156635. */
  156636. sourceMesh?: Mesh;
  156637. /**
  156638. * This function will be called after a mesh was created for a specific joint.
  156639. * Using this function you can either manipulate the instance or return a new mesh.
  156640. * When returning a new mesh the instance created before will be disposed
  156641. */
  156642. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  156643. /**
  156644. * Should the source mesh stay visible. Defaults to false
  156645. */
  156646. keepOriginalVisible?: boolean;
  156647. /**
  156648. * Scale factor for all instances (defaults to 2)
  156649. */
  156650. scaleFactor?: number;
  156651. /**
  156652. * Should each instance have its own physics impostor
  156653. */
  156654. enablePhysics?: boolean;
  156655. /**
  156656. * If enabled, override default physics properties
  156657. */
  156658. physicsProps?: {
  156659. friction?: number;
  156660. restitution?: number;
  156661. impostorType?: number;
  156662. };
  156663. /**
  156664. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  156665. */
  156666. handMesh?: AbstractMesh;
  156667. };
  156668. }
  156669. /**
  156670. * Parts of the hands divided to writs and finger names
  156671. */
  156672. export const enum HandPart {
  156673. /**
  156674. * HandPart - Wrist
  156675. */
  156676. WRIST = "wrist",
  156677. /**
  156678. * HandPart - The THumb
  156679. */
  156680. THUMB = "thumb",
  156681. /**
  156682. * HandPart - Index finger
  156683. */
  156684. INDEX = "index",
  156685. /**
  156686. * HandPart - Middle finger
  156687. */
  156688. MIDDLE = "middle",
  156689. /**
  156690. * HandPart - Ring finger
  156691. */
  156692. RING = "ring",
  156693. /**
  156694. * HandPart - Little finger
  156695. */
  156696. LITTLE = "little"
  156697. }
  156698. /**
  156699. * Representing a single hand (with its corresponding native XRHand object)
  156700. */
  156701. export class WebXRHand implements IDisposable {
  156702. /** the controller to which the hand correlates */
  156703. readonly xrController: WebXRInputSource;
  156704. /** the meshes to be used to track the hand joints */
  156705. readonly trackedMeshes: AbstractMesh[];
  156706. /**
  156707. * Hand-parts definition (key is HandPart)
  156708. */
  156709. handPartsDefinition: {
  156710. [key: string]: number[];
  156711. };
  156712. /**
  156713. * Populate the HandPartsDefinition object.
  156714. * This is called as a side effect since certain browsers don't have XRHand defined.
  156715. */
  156716. private generateHandPartsDefinition;
  156717. /**
  156718. * Construct a new hand object
  156719. * @param xrController the controller to which the hand correlates
  156720. * @param trackedMeshes the meshes to be used to track the hand joints
  156721. */
  156722. constructor(
  156723. /** the controller to which the hand correlates */
  156724. xrController: WebXRInputSource,
  156725. /** the meshes to be used to track the hand joints */
  156726. trackedMeshes: AbstractMesh[]);
  156727. /**
  156728. * Update this hand from the latest xr frame
  156729. * @param xrFrame xrFrame to update from
  156730. * @param referenceSpace The current viewer reference space
  156731. * @param scaleFactor optional scale factor for the meshes
  156732. */
  156733. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156734. /**
  156735. * Get meshes of part of the hand
  156736. * @param part the part of hand to get
  156737. * @returns An array of meshes that correlate to the hand part requested
  156738. */
  156739. getHandPartMeshes(part: HandPart): AbstractMesh[];
  156740. /**
  156741. * Dispose this Hand object
  156742. */
  156743. dispose(): void;
  156744. }
  156745. /**
  156746. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  156747. */
  156748. export class WebXRHandTracking extends WebXRAbstractFeature {
  156749. /**
  156750. * options to use when constructing this feature
  156751. */
  156752. readonly options: IWebXRHandTrackingOptions;
  156753. private static _idCounter;
  156754. /**
  156755. * The module's name
  156756. */
  156757. static readonly Name: string;
  156758. /**
  156759. * The (Babylon) version of this module.
  156760. * This is an integer representing the implementation version.
  156761. * This number does not correspond to the WebXR specs version
  156762. */
  156763. static readonly Version: number;
  156764. /**
  156765. * This observable will notify registered observers when a new hand object was added and initialized
  156766. */
  156767. onHandAddedObservable: Observable<WebXRHand>;
  156768. /**
  156769. * This observable will notify its observers right before the hand object is disposed
  156770. */
  156771. onHandRemovedObservable: Observable<WebXRHand>;
  156772. private _hands;
  156773. /**
  156774. * Creates a new instance of the hit test feature
  156775. * @param _xrSessionManager an instance of WebXRSessionManager
  156776. * @param options options to use when constructing this feature
  156777. */
  156778. constructor(_xrSessionManager: WebXRSessionManager,
  156779. /**
  156780. * options to use when constructing this feature
  156781. */
  156782. options: IWebXRHandTrackingOptions);
  156783. /**
  156784. * Check if the needed objects are defined.
  156785. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  156786. */
  156787. isCompatible(): boolean;
  156788. /**
  156789. * attach this feature
  156790. * Will usually be called by the features manager
  156791. *
  156792. * @returns true if successful.
  156793. */
  156794. attach(): boolean;
  156795. /**
  156796. * detach this feature.
  156797. * Will usually be called by the features manager
  156798. *
  156799. * @returns true if successful.
  156800. */
  156801. detach(): boolean;
  156802. /**
  156803. * Dispose this feature and all of the resources attached
  156804. */
  156805. dispose(): void;
  156806. /**
  156807. * Get the hand object according to the controller id
  156808. * @param controllerId the controller id to which we want to get the hand
  156809. * @returns null if not found or the WebXRHand object if found
  156810. */
  156811. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  156812. /**
  156813. * Get a hand object according to the requested handedness
  156814. * @param handedness the handedness to request
  156815. * @returns null if not found or the WebXRHand object if found
  156816. */
  156817. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156818. protected _onXRFrame(_xrFrame: XRFrame): void;
  156819. private _attachHand;
  156820. private _detachHand;
  156821. }
  156822. }
  156823. declare module BABYLON {
  156824. /**
  156825. * The motion controller class for all microsoft mixed reality controllers
  156826. */
  156827. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156828. protected readonly _mapping: {
  156829. defaultButton: {
  156830. valueNodeName: string;
  156831. unpressedNodeName: string;
  156832. pressedNodeName: string;
  156833. };
  156834. defaultAxis: {
  156835. valueNodeName: string;
  156836. minNodeName: string;
  156837. maxNodeName: string;
  156838. };
  156839. buttons: {
  156840. "xr-standard-trigger": {
  156841. rootNodeName: string;
  156842. componentProperty: string;
  156843. states: string[];
  156844. };
  156845. "xr-standard-squeeze": {
  156846. rootNodeName: string;
  156847. componentProperty: string;
  156848. states: string[];
  156849. };
  156850. "xr-standard-touchpad": {
  156851. rootNodeName: string;
  156852. labelAnchorNodeName: string;
  156853. touchPointNodeName: string;
  156854. };
  156855. "xr-standard-thumbstick": {
  156856. rootNodeName: string;
  156857. componentProperty: string;
  156858. states: string[];
  156859. };
  156860. };
  156861. axes: {
  156862. "xr-standard-touchpad": {
  156863. "x-axis": {
  156864. rootNodeName: string;
  156865. };
  156866. "y-axis": {
  156867. rootNodeName: string;
  156868. };
  156869. };
  156870. "xr-standard-thumbstick": {
  156871. "x-axis": {
  156872. rootNodeName: string;
  156873. };
  156874. "y-axis": {
  156875. rootNodeName: string;
  156876. };
  156877. };
  156878. };
  156879. };
  156880. /**
  156881. * The base url used to load the left and right controller models
  156882. */
  156883. static MODEL_BASE_URL: string;
  156884. /**
  156885. * The name of the left controller model file
  156886. */
  156887. static MODEL_LEFT_FILENAME: string;
  156888. /**
  156889. * The name of the right controller model file
  156890. */
  156891. static MODEL_RIGHT_FILENAME: string;
  156892. profileId: string;
  156893. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156894. protected _getFilenameAndPath(): {
  156895. filename: string;
  156896. path: string;
  156897. };
  156898. protected _getModelLoadingConstraints(): boolean;
  156899. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156900. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156901. protected _updateModel(): void;
  156902. }
  156903. }
  156904. declare module BABYLON {
  156905. /**
  156906. * The motion controller class for oculus touch (quest, rift).
  156907. * This class supports legacy mapping as well the standard xr mapping
  156908. */
  156909. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156910. private _forceLegacyControllers;
  156911. private _modelRootNode;
  156912. /**
  156913. * The base url used to load the left and right controller models
  156914. */
  156915. static MODEL_BASE_URL: string;
  156916. /**
  156917. * The name of the left controller model file
  156918. */
  156919. static MODEL_LEFT_FILENAME: string;
  156920. /**
  156921. * The name of the right controller model file
  156922. */
  156923. static MODEL_RIGHT_FILENAME: string;
  156924. /**
  156925. * Base Url for the Quest controller model.
  156926. */
  156927. static QUEST_MODEL_BASE_URL: string;
  156928. profileId: string;
  156929. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156930. protected _getFilenameAndPath(): {
  156931. filename: string;
  156932. path: string;
  156933. };
  156934. protected _getModelLoadingConstraints(): boolean;
  156935. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156936. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156937. protected _updateModel(): void;
  156938. /**
  156939. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156940. * between the touch and touch 2.
  156941. */
  156942. private _isQuest;
  156943. }
  156944. }
  156945. declare module BABYLON {
  156946. /**
  156947. * The motion controller class for the standard HTC-Vive controllers
  156948. */
  156949. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156950. private _modelRootNode;
  156951. /**
  156952. * The base url used to load the left and right controller models
  156953. */
  156954. static MODEL_BASE_URL: string;
  156955. /**
  156956. * File name for the controller model.
  156957. */
  156958. static MODEL_FILENAME: string;
  156959. profileId: string;
  156960. /**
  156961. * Create a new Vive motion controller object
  156962. * @param scene the scene to use to create this controller
  156963. * @param gamepadObject the corresponding gamepad object
  156964. * @param handedness the handedness of the controller
  156965. */
  156966. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156967. protected _getFilenameAndPath(): {
  156968. filename: string;
  156969. path: string;
  156970. };
  156971. protected _getModelLoadingConstraints(): boolean;
  156972. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156973. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156974. protected _updateModel(): void;
  156975. }
  156976. }
  156977. declare module BABYLON {
  156978. /**
  156979. * A cursor which tracks a point on a path
  156980. */
  156981. export class PathCursor {
  156982. private path;
  156983. /**
  156984. * Stores path cursor callbacks for when an onchange event is triggered
  156985. */
  156986. private _onchange;
  156987. /**
  156988. * The value of the path cursor
  156989. */
  156990. value: number;
  156991. /**
  156992. * The animation array of the path cursor
  156993. */
  156994. animations: Animation[];
  156995. /**
  156996. * Initializes the path cursor
  156997. * @param path The path to track
  156998. */
  156999. constructor(path: Path2);
  157000. /**
  157001. * Gets the cursor point on the path
  157002. * @returns A point on the path cursor at the cursor location
  157003. */
  157004. getPoint(): Vector3;
  157005. /**
  157006. * Moves the cursor ahead by the step amount
  157007. * @param step The amount to move the cursor forward
  157008. * @returns This path cursor
  157009. */
  157010. moveAhead(step?: number): PathCursor;
  157011. /**
  157012. * Moves the cursor behind by the step amount
  157013. * @param step The amount to move the cursor back
  157014. * @returns This path cursor
  157015. */
  157016. moveBack(step?: number): PathCursor;
  157017. /**
  157018. * Moves the cursor by the step amount
  157019. * If the step amount is greater than one, an exception is thrown
  157020. * @param step The amount to move the cursor
  157021. * @returns This path cursor
  157022. */
  157023. move(step: number): PathCursor;
  157024. /**
  157025. * Ensures that the value is limited between zero and one
  157026. * @returns This path cursor
  157027. */
  157028. private ensureLimits;
  157029. /**
  157030. * Runs onchange callbacks on change (used by the animation engine)
  157031. * @returns This path cursor
  157032. */
  157033. private raiseOnChange;
  157034. /**
  157035. * Executes a function on change
  157036. * @param f A path cursor onchange callback
  157037. * @returns This path cursor
  157038. */
  157039. onchange(f: (cursor: PathCursor) => void): PathCursor;
  157040. }
  157041. }
  157042. declare module BABYLON {
  157043. /** @hidden */
  157044. export var blurPixelShader: {
  157045. name: string;
  157046. shader: string;
  157047. };
  157048. }
  157049. declare module BABYLON {
  157050. /** @hidden */
  157051. export var pointCloudVertexDeclaration: {
  157052. name: string;
  157053. shader: string;
  157054. };
  157055. }
  157056. // Mixins
  157057. interface Window {
  157058. mozIndexedDB: IDBFactory;
  157059. webkitIndexedDB: IDBFactory;
  157060. msIndexedDB: IDBFactory;
  157061. webkitURL: typeof URL;
  157062. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  157063. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  157064. WebGLRenderingContext: WebGLRenderingContext;
  157065. MSGesture: MSGesture;
  157066. CANNON: any;
  157067. AudioContext: AudioContext;
  157068. webkitAudioContext: AudioContext;
  157069. PointerEvent: any;
  157070. Math: Math;
  157071. Uint8Array: Uint8ArrayConstructor;
  157072. Float32Array: Float32ArrayConstructor;
  157073. mozURL: typeof URL;
  157074. msURL: typeof URL;
  157075. VRFrameData: any; // WebVR, from specs 1.1
  157076. DracoDecoderModule: any;
  157077. setImmediate(handler: (...args: any[]) => void): number;
  157078. }
  157079. interface HTMLCanvasElement {
  157080. requestPointerLock(): void;
  157081. msRequestPointerLock?(): void;
  157082. mozRequestPointerLock?(): void;
  157083. webkitRequestPointerLock?(): void;
  157084. /** Track wether a record is in progress */
  157085. isRecording: boolean;
  157086. /** Capture Stream method defined by some browsers */
  157087. captureStream(fps?: number): MediaStream;
  157088. }
  157089. interface CanvasRenderingContext2D {
  157090. msImageSmoothingEnabled: boolean;
  157091. }
  157092. interface MouseEvent {
  157093. mozMovementX: number;
  157094. mozMovementY: number;
  157095. webkitMovementX: number;
  157096. webkitMovementY: number;
  157097. msMovementX: number;
  157098. msMovementY: number;
  157099. }
  157100. interface Navigator {
  157101. mozGetVRDevices: (any: any) => any;
  157102. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157103. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157104. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157105. webkitGetGamepads(): Gamepad[];
  157106. msGetGamepads(): Gamepad[];
  157107. webkitGamepads(): Gamepad[];
  157108. }
  157109. interface HTMLVideoElement {
  157110. mozSrcObject: any;
  157111. }
  157112. interface Math {
  157113. fround(x: number): number;
  157114. imul(a: number, b: number): number;
  157115. }
  157116. interface WebGLRenderingContext {
  157117. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  157118. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  157119. vertexAttribDivisor(index: number, divisor: number): void;
  157120. createVertexArray(): any;
  157121. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  157122. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  157123. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  157124. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  157125. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  157126. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  157127. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  157128. // Queries
  157129. createQuery(): WebGLQuery;
  157130. deleteQuery(query: WebGLQuery): void;
  157131. beginQuery(target: number, query: WebGLQuery): void;
  157132. endQuery(target: number): void;
  157133. getQueryParameter(query: WebGLQuery, pname: number): any;
  157134. getQuery(target: number, pname: number): any;
  157135. MAX_SAMPLES: number;
  157136. RGBA8: number;
  157137. READ_FRAMEBUFFER: number;
  157138. DRAW_FRAMEBUFFER: number;
  157139. UNIFORM_BUFFER: number;
  157140. HALF_FLOAT_OES: number;
  157141. RGBA16F: number;
  157142. RGBA32F: number;
  157143. R32F: number;
  157144. RG32F: number;
  157145. RGB32F: number;
  157146. R16F: number;
  157147. RG16F: number;
  157148. RGB16F: number;
  157149. RED: number;
  157150. RG: number;
  157151. R8: number;
  157152. RG8: number;
  157153. UNSIGNED_INT_24_8: number;
  157154. DEPTH24_STENCIL8: number;
  157155. MIN: number;
  157156. MAX: number;
  157157. /* Multiple Render Targets */
  157158. drawBuffers(buffers: number[]): void;
  157159. readBuffer(src: number): void;
  157160. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  157161. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  157162. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  157163. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  157164. // Occlusion Query
  157165. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  157166. ANY_SAMPLES_PASSED: number;
  157167. QUERY_RESULT_AVAILABLE: number;
  157168. QUERY_RESULT: number;
  157169. }
  157170. interface WebGLProgram {
  157171. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  157172. }
  157173. interface EXT_disjoint_timer_query {
  157174. QUERY_COUNTER_BITS_EXT: number;
  157175. TIME_ELAPSED_EXT: number;
  157176. TIMESTAMP_EXT: number;
  157177. GPU_DISJOINT_EXT: number;
  157178. QUERY_RESULT_EXT: number;
  157179. QUERY_RESULT_AVAILABLE_EXT: number;
  157180. queryCounterEXT(query: WebGLQuery, target: number): void;
  157181. createQueryEXT(): WebGLQuery;
  157182. beginQueryEXT(target: number, query: WebGLQuery): void;
  157183. endQueryEXT(target: number): void;
  157184. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  157185. deleteQueryEXT(query: WebGLQuery): void;
  157186. }
  157187. interface WebGLUniformLocation {
  157188. _currentState: any;
  157189. }
  157190. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  157191. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  157192. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  157193. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157194. interface WebGLRenderingContext {
  157195. readonly RASTERIZER_DISCARD: number;
  157196. readonly DEPTH_COMPONENT24: number;
  157197. readonly TEXTURE_3D: number;
  157198. readonly TEXTURE_2D_ARRAY: number;
  157199. readonly TEXTURE_COMPARE_FUNC: number;
  157200. readonly TEXTURE_COMPARE_MODE: number;
  157201. readonly COMPARE_REF_TO_TEXTURE: number;
  157202. readonly TEXTURE_WRAP_R: number;
  157203. readonly HALF_FLOAT: number;
  157204. readonly RGB8: number;
  157205. readonly RED_INTEGER: number;
  157206. readonly RG_INTEGER: number;
  157207. readonly RGB_INTEGER: number;
  157208. readonly RGBA_INTEGER: number;
  157209. readonly R8_SNORM: number;
  157210. readonly RG8_SNORM: number;
  157211. readonly RGB8_SNORM: number;
  157212. readonly RGBA8_SNORM: number;
  157213. readonly R8I: number;
  157214. readonly RG8I: number;
  157215. readonly RGB8I: number;
  157216. readonly RGBA8I: number;
  157217. readonly R8UI: number;
  157218. readonly RG8UI: number;
  157219. readonly RGB8UI: number;
  157220. readonly RGBA8UI: number;
  157221. readonly R16I: number;
  157222. readonly RG16I: number;
  157223. readonly RGB16I: number;
  157224. readonly RGBA16I: number;
  157225. readonly R16UI: number;
  157226. readonly RG16UI: number;
  157227. readonly RGB16UI: number;
  157228. readonly RGBA16UI: number;
  157229. readonly R32I: number;
  157230. readonly RG32I: number;
  157231. readonly RGB32I: number;
  157232. readonly RGBA32I: number;
  157233. readonly R32UI: number;
  157234. readonly RG32UI: number;
  157235. readonly RGB32UI: number;
  157236. readonly RGBA32UI: number;
  157237. readonly RGB10_A2UI: number;
  157238. readonly R11F_G11F_B10F: number;
  157239. readonly RGB9_E5: number;
  157240. readonly RGB10_A2: number;
  157241. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  157242. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  157243. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  157244. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  157245. readonly DEPTH_COMPONENT32F: number;
  157246. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  157247. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  157248. 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;
  157249. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  157250. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  157251. readonly TRANSFORM_FEEDBACK: number;
  157252. readonly INTERLEAVED_ATTRIBS: number;
  157253. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  157254. createTransformFeedback(): WebGLTransformFeedback;
  157255. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  157256. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  157257. beginTransformFeedback(primitiveMode: number): void;
  157258. endTransformFeedback(): void;
  157259. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  157260. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157261. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157262. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  157263. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  157264. }
  157265. interface ImageBitmap {
  157266. readonly width: number;
  157267. readonly height: number;
  157268. close(): void;
  157269. }
  157270. interface WebGLQuery extends WebGLObject {
  157271. }
  157272. declare var WebGLQuery: {
  157273. prototype: WebGLQuery;
  157274. new(): WebGLQuery;
  157275. };
  157276. interface WebGLSampler extends WebGLObject {
  157277. }
  157278. declare var WebGLSampler: {
  157279. prototype: WebGLSampler;
  157280. new(): WebGLSampler;
  157281. };
  157282. interface WebGLSync extends WebGLObject {
  157283. }
  157284. declare var WebGLSync: {
  157285. prototype: WebGLSync;
  157286. new(): WebGLSync;
  157287. };
  157288. interface WebGLTransformFeedback extends WebGLObject {
  157289. }
  157290. declare var WebGLTransformFeedback: {
  157291. prototype: WebGLTransformFeedback;
  157292. new(): WebGLTransformFeedback;
  157293. };
  157294. interface WebGLVertexArrayObject extends WebGLObject {
  157295. }
  157296. declare var WebGLVertexArrayObject: {
  157297. prototype: WebGLVertexArrayObject;
  157298. new(): WebGLVertexArrayObject;
  157299. };
  157300. // Type definitions for WebVR API
  157301. // Project: https://w3c.github.io/webvr/
  157302. // Definitions by: six a <https://github.com/lostfictions>
  157303. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  157304. interface VRDisplay extends EventTarget {
  157305. /**
  157306. * Dictionary of capabilities describing the VRDisplay.
  157307. */
  157308. readonly capabilities: VRDisplayCapabilities;
  157309. /**
  157310. * z-depth defining the far plane of the eye view frustum
  157311. * enables mapping of values in the render target depth
  157312. * attachment to scene coordinates. Initially set to 10000.0.
  157313. */
  157314. depthFar: number;
  157315. /**
  157316. * z-depth defining the near plane of the eye view frustum
  157317. * enables mapping of values in the render target depth
  157318. * attachment to scene coordinates. Initially set to 0.01.
  157319. */
  157320. depthNear: number;
  157321. /**
  157322. * An identifier for this distinct VRDisplay. Used as an
  157323. * association point in the Gamepad API.
  157324. */
  157325. readonly displayId: number;
  157326. /**
  157327. * A display name, a user-readable name identifying it.
  157328. */
  157329. readonly displayName: string;
  157330. readonly isConnected: boolean;
  157331. readonly isPresenting: boolean;
  157332. /**
  157333. * If this VRDisplay supports room-scale experiences, the optional
  157334. * stage attribute contains details on the room-scale parameters.
  157335. */
  157336. readonly stageParameters: VRStageParameters | null;
  157337. /**
  157338. * Passing the value returned by `requestAnimationFrame` to
  157339. * `cancelAnimationFrame` will unregister the callback.
  157340. * @param handle Define the hanle of the request to cancel
  157341. */
  157342. cancelAnimationFrame(handle: number): void;
  157343. /**
  157344. * Stops presenting to the VRDisplay.
  157345. * @returns a promise to know when it stopped
  157346. */
  157347. exitPresent(): Promise<void>;
  157348. /**
  157349. * Return the current VREyeParameters for the given eye.
  157350. * @param whichEye Define the eye we want the parameter for
  157351. * @returns the eye parameters
  157352. */
  157353. getEyeParameters(whichEye: string): VREyeParameters;
  157354. /**
  157355. * Populates the passed VRFrameData with the information required to render
  157356. * the current frame.
  157357. * @param frameData Define the data structure to populate
  157358. * @returns true if ok otherwise false
  157359. */
  157360. getFrameData(frameData: VRFrameData): boolean;
  157361. /**
  157362. * Get the layers currently being presented.
  157363. * @returns the list of VR layers
  157364. */
  157365. getLayers(): VRLayer[];
  157366. /**
  157367. * Return a VRPose containing the future predicted pose of the VRDisplay
  157368. * when the current frame will be presented. The value returned will not
  157369. * change until JavaScript has returned control to the browser.
  157370. *
  157371. * The VRPose will contain the position, orientation, velocity,
  157372. * and acceleration of each of these properties.
  157373. * @returns the pose object
  157374. */
  157375. getPose(): VRPose;
  157376. /**
  157377. * Return the current instantaneous pose of the VRDisplay, with no
  157378. * prediction applied.
  157379. * @returns the current instantaneous pose
  157380. */
  157381. getImmediatePose(): VRPose;
  157382. /**
  157383. * The callback passed to `requestAnimationFrame` will be called
  157384. * any time a new frame should be rendered. When the VRDisplay is
  157385. * presenting the callback will be called at the native refresh
  157386. * rate of the HMD. When not presenting this function acts
  157387. * identically to how window.requestAnimationFrame acts. Content should
  157388. * make no assumptions of frame rate or vsync behavior as the HMD runs
  157389. * asynchronously from other displays and at differing refresh rates.
  157390. * @param callback Define the eaction to run next frame
  157391. * @returns the request handle it
  157392. */
  157393. requestAnimationFrame(callback: FrameRequestCallback): number;
  157394. /**
  157395. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  157396. * Repeat calls while already presenting will update the VRLayers being displayed.
  157397. * @param layers Define the list of layer to present
  157398. * @returns a promise to know when the request has been fulfilled
  157399. */
  157400. requestPresent(layers: VRLayer[]): Promise<void>;
  157401. /**
  157402. * Reset the pose for this display, treating its current position and
  157403. * orientation as the "origin/zero" values. VRPose.position,
  157404. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  157405. * updated when calling resetPose(). This should be called in only
  157406. * sitting-space experiences.
  157407. */
  157408. resetPose(): void;
  157409. /**
  157410. * The VRLayer provided to the VRDisplay will be captured and presented
  157411. * in the HMD. Calling this function has the same effect on the source
  157412. * canvas as any other operation that uses its source image, and canvases
  157413. * created without preserveDrawingBuffer set to true will be cleared.
  157414. * @param pose Define the pose to submit
  157415. */
  157416. submitFrame(pose?: VRPose): void;
  157417. }
  157418. declare var VRDisplay: {
  157419. prototype: VRDisplay;
  157420. new(): VRDisplay;
  157421. };
  157422. interface VRLayer {
  157423. leftBounds?: number[] | Float32Array | null;
  157424. rightBounds?: number[] | Float32Array | null;
  157425. source?: HTMLCanvasElement | null;
  157426. }
  157427. interface VRDisplayCapabilities {
  157428. readonly canPresent: boolean;
  157429. readonly hasExternalDisplay: boolean;
  157430. readonly hasOrientation: boolean;
  157431. readonly hasPosition: boolean;
  157432. readonly maxLayers: number;
  157433. }
  157434. interface VREyeParameters {
  157435. /** @deprecated */
  157436. readonly fieldOfView: VRFieldOfView;
  157437. readonly offset: Float32Array;
  157438. readonly renderHeight: number;
  157439. readonly renderWidth: number;
  157440. }
  157441. interface VRFieldOfView {
  157442. readonly downDegrees: number;
  157443. readonly leftDegrees: number;
  157444. readonly rightDegrees: number;
  157445. readonly upDegrees: number;
  157446. }
  157447. interface VRFrameData {
  157448. readonly leftProjectionMatrix: Float32Array;
  157449. readonly leftViewMatrix: Float32Array;
  157450. readonly pose: VRPose;
  157451. readonly rightProjectionMatrix: Float32Array;
  157452. readonly rightViewMatrix: Float32Array;
  157453. readonly timestamp: number;
  157454. }
  157455. interface VRPose {
  157456. readonly angularAcceleration: Float32Array | null;
  157457. readonly angularVelocity: Float32Array | null;
  157458. readonly linearAcceleration: Float32Array | null;
  157459. readonly linearVelocity: Float32Array | null;
  157460. readonly orientation: Float32Array | null;
  157461. readonly position: Float32Array | null;
  157462. readonly timestamp: number;
  157463. }
  157464. interface VRStageParameters {
  157465. sittingToStandingTransform?: Float32Array;
  157466. sizeX?: number;
  157467. sizeY?: number;
  157468. }
  157469. interface Navigator {
  157470. getVRDisplays(): Promise<VRDisplay[]>;
  157471. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  157472. }
  157473. interface Window {
  157474. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  157475. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  157476. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  157477. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157478. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157479. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  157480. }
  157481. interface Gamepad {
  157482. readonly displayId: number;
  157483. }
  157484. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  157485. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  157486. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  157487. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  157488. type XRHandedness = "none" | "left" | "right";
  157489. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  157490. type XREye = "none" | "left" | "right";
  157491. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  157492. interface XRSpace extends EventTarget {}
  157493. interface XRRenderState {
  157494. depthNear?: number;
  157495. depthFar?: number;
  157496. inlineVerticalFieldOfView?: number;
  157497. baseLayer?: XRWebGLLayer;
  157498. }
  157499. interface XRInputSource {
  157500. handedness: XRHandedness;
  157501. targetRayMode: XRTargetRayMode;
  157502. targetRaySpace: XRSpace;
  157503. gripSpace: XRSpace | undefined;
  157504. gamepad: Gamepad | undefined;
  157505. profiles: Array<string>;
  157506. hand: XRHand | undefined;
  157507. }
  157508. interface XRSessionInit {
  157509. optionalFeatures?: string[];
  157510. requiredFeatures?: string[];
  157511. }
  157512. interface XRSession {
  157513. addEventListener: Function;
  157514. removeEventListener: Function;
  157515. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  157516. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  157517. requestAnimationFrame: Function;
  157518. end(): Promise<void>;
  157519. renderState: XRRenderState;
  157520. inputSources: Array<XRInputSource>;
  157521. // hit test
  157522. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  157523. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  157524. // legacy AR hit test
  157525. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157526. // legacy plane detection
  157527. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  157528. }
  157529. interface XRReferenceSpace extends XRSpace {
  157530. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  157531. onreset: any;
  157532. }
  157533. type XRPlaneSet = Set<XRPlane>;
  157534. type XRAnchorSet = Set<XRAnchor>;
  157535. interface XRFrame {
  157536. session: XRSession;
  157537. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  157538. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  157539. // AR
  157540. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  157541. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  157542. // Anchors
  157543. trackedAnchors?: XRAnchorSet;
  157544. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  157545. // Planes
  157546. worldInformation: {
  157547. detectedPlanes?: XRPlaneSet;
  157548. };
  157549. // Hand tracking
  157550. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  157551. }
  157552. interface XRViewerPose extends XRPose {
  157553. views: Array<XRView>;
  157554. }
  157555. interface XRPose {
  157556. transform: XRRigidTransform;
  157557. emulatedPosition: boolean;
  157558. }
  157559. interface XRWebGLLayerOptions {
  157560. antialias?: boolean;
  157561. depth?: boolean;
  157562. stencil?: boolean;
  157563. alpha?: boolean;
  157564. multiview?: boolean;
  157565. framebufferScaleFactor?: number;
  157566. }
  157567. declare var XRWebGLLayer: {
  157568. prototype: XRWebGLLayer;
  157569. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  157570. };
  157571. interface XRWebGLLayer {
  157572. framebuffer: WebGLFramebuffer;
  157573. framebufferWidth: number;
  157574. framebufferHeight: number;
  157575. getViewport: Function;
  157576. }
  157577. declare class XRRigidTransform {
  157578. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  157579. position: DOMPointReadOnly;
  157580. orientation: DOMPointReadOnly;
  157581. matrix: Float32Array;
  157582. inverse: XRRigidTransform;
  157583. }
  157584. interface XRView {
  157585. eye: XREye;
  157586. projectionMatrix: Float32Array;
  157587. transform: XRRigidTransform;
  157588. }
  157589. interface XRInputSourceChangeEvent {
  157590. session: XRSession;
  157591. removed: Array<XRInputSource>;
  157592. added: Array<XRInputSource>;
  157593. }
  157594. interface XRInputSourceEvent extends Event {
  157595. readonly frame: XRFrame;
  157596. readonly inputSource: XRInputSource;
  157597. }
  157598. // Experimental(er) features
  157599. declare class XRRay {
  157600. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  157601. origin: DOMPointReadOnly;
  157602. direction: DOMPointReadOnly;
  157603. matrix: Float32Array;
  157604. }
  157605. declare enum XRHitTestTrackableType {
  157606. "point",
  157607. "plane",
  157608. "mesh",
  157609. }
  157610. interface XRHitResult {
  157611. hitMatrix: Float32Array;
  157612. }
  157613. interface XRTransientInputHitTestResult {
  157614. readonly inputSource: XRInputSource;
  157615. readonly results: Array<XRHitTestResult>;
  157616. }
  157617. interface XRHitTestResult {
  157618. getPose(baseSpace: XRSpace): XRPose | undefined;
  157619. // When anchor system is enabled
  157620. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  157621. }
  157622. interface XRHitTestSource {
  157623. cancel(): void;
  157624. }
  157625. interface XRTransientInputHitTestSource {
  157626. cancel(): void;
  157627. }
  157628. interface XRHitTestOptionsInit {
  157629. space: XRSpace;
  157630. entityTypes?: Array<XRHitTestTrackableType>;
  157631. offsetRay?: XRRay;
  157632. }
  157633. interface XRTransientInputHitTestOptionsInit {
  157634. profile: string;
  157635. entityTypes?: Array<XRHitTestTrackableType>;
  157636. offsetRay?: XRRay;
  157637. }
  157638. interface XRAnchor {
  157639. anchorSpace: XRSpace;
  157640. delete(): void;
  157641. }
  157642. interface XRPlane {
  157643. orientation: "Horizontal" | "Vertical";
  157644. planeSpace: XRSpace;
  157645. polygon: Array<DOMPointReadOnly>;
  157646. lastChangedTime: number;
  157647. }
  157648. interface XRJointSpace extends XRSpace {}
  157649. interface XRJointPose extends XRPose {
  157650. radius: number | undefined;
  157651. }
  157652. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  157653. readonly length: number;
  157654. [index: number]: XRJointSpace;
  157655. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  157656. readonly WRIST: number;
  157657. readonly THUMB_METACARPAL: number;
  157658. readonly THUMB_PHALANX_PROXIMAL: number;
  157659. readonly THUMB_PHALANX_DISTAL: number;
  157660. readonly THUMB_PHALANX_TIP: number;
  157661. readonly INDEX_METACARPAL: number;
  157662. readonly INDEX_PHALANX_PROXIMAL: number;
  157663. readonly INDEX_PHALANX_INTERMEDIATE: number;
  157664. readonly INDEX_PHALANX_DISTAL: number;
  157665. readonly INDEX_PHALANX_TIP: number;
  157666. readonly MIDDLE_METACARPAL: number;
  157667. readonly MIDDLE_PHALANX_PROXIMAL: number;
  157668. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  157669. readonly MIDDLE_PHALANX_DISTAL: number;
  157670. readonly MIDDLE_PHALANX_TIP: number;
  157671. readonly RING_METACARPAL: number;
  157672. readonly RING_PHALANX_PROXIMAL: number;
  157673. readonly RING_PHALANX_INTERMEDIATE: number;
  157674. readonly RING_PHALANX_DISTAL: number;
  157675. readonly RING_PHALANX_TIP: number;
  157676. readonly LITTLE_METACARPAL: number;
  157677. readonly LITTLE_PHALANX_PROXIMAL: number;
  157678. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  157679. readonly LITTLE_PHALANX_DISTAL: number;
  157680. readonly LITTLE_PHALANX_TIP: number;
  157681. }
  157682. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  157683. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  157684. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  157685. interface XRSession {
  157686. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  157687. }
  157688. interface XRFrame {
  157689. featurePointCloud? : Array<number>;
  157690. }